Display online NSE (National Stock Exchange) data in php web application - php

I want to display online NSE (National Stock Exchange) data in my php web application. Please help me how to do this.

You can use google api .. they provide real time data for NSE.
but the catch is google finance api is available for java only it was not available for c# last time i checked.
Not sure about whether finance api are there for PHP.

Find out if NSX has a web service that exposes the stock charts. If so, this will likely be a REST or a SOAP endpoint that can be queried for specific stocks.
Create a PHP component that makes a request to that endpoint, and caches the results for a certain period of time (so that your site visitors don't have to wait for the roundtrip every time a page is loaded).

NSE don't have any web service AFAIK, the only thing they export is previous day data. You might have to do some sort of data parsing on the NSE webpages.

If you want to take historical data from NSE website, you can always do that.
for example, following is the url to retrieve nifty index data.
[http://www.nseindia.com/content/indices/histdata/S&P%20CNX%20NIFTY01-02-2010-04-02-2010.csv]
observe date pattern in the url, it is from 01 FEB 2010 to 04 FEB 2010.
change dates as you need, call the url from your server. It is csv format, so any language can process it.
Regards.
http://www.kakup.com

Related

Setting an analytics custom metric server side

I'm using the GTM data layer to populate data through the enhanced ecommerce interface of Analytics. The goal is to provide detailed cost data so I can build a dashboard that shows profitability for my business. It's working great on a transaction basis and I am uploading shipping costs, product costs, discounts, and a host of other transaction data. However, my business also has fixed overhead costs. I want to upload that to analytics once per day so I can see the true profitability on a day by day basis. This requires it to be a server-side request from my PHP server. I am unfamiliar with how to set a custom metric from the server side. Does anyone know how I can send this once-per-day data to analytics from the server side? Would I send it as a pageview event? The variable name would be "fixed overhead". I'm not really sure where to start. Thanks in advance!
Sending data server-side to Google Analytics is entirely possible (and admittedly it is pretty daunting if you've not done it before).
The two best resources to use are the Google Analytics Measurement Protocol documentation and the Google Analytics Hit Builder. Use the parameter guide to prep the custom metric data specifically.
Here is my actual snippet that I use for all of my PHP projects (first ~150 lines or so). I'm certain there are better ways to do it, but at the very least it might help you figure out some of the complexities.
It's a lot of info to soak in, but I hope that gets you headed in the right direction!

PHP/Python Requests to Google Webmaster Tools API

I'm trying to download the 'Top Queries' CSV and am having a few issues. I started off doing this via Python and I was getting GWMT to send me a CSV with all the results (and also made a script to automatically place it into an SQL database) but stopped using Python for this problem when I realized that I could not set the date range. That would be the first question (as it would make the next question irrelevant):
Does anyone know a way to query specific date ranges using Python to access the Google API? Like I said, I can download everything else but cannot set the date range (automatically gives you a month's worth).
Secondly, in term of the PHP solution, I setup XAMPP on my computer and got that working swimmingly but as soon as I started trying to download CSV's (using code from this link) but every time I load it in the Browser, no CSV is downloaded. There are few reasons why I think this might be:
API authentication not working
Something on my computer not allowing csv to be downloaded
Credentials problem in WMT
Weirdly enough, when I did the OAuth2 yesterday for Python, it worked but then when I started working this morning, the credential had been deleted? Should I just create and go through the same authentication process for Python (which gave authorization for the web property) again to allow the csv to be downloaded?
Anyways, any help on this would be greatly appreciated as the alternative is manual pulling and loading into SQL!!!! :S
The script you linked to is not supported by Google, never was, and it relies on Oauth1 which is deprecated.
Currently the only official way to download Search Queries data is via the Search Queries API, although it's in limited mode, meaning we're (Google) testing it with people who showed interest and subscribed when we announced we'll launch it in limited beta. Once testing is done, we'll very likely launch it for the general public, but I don't have a timeframe for that.
You can find the currently supported methods and more information about them in the API Explorer for Search Console (former Webmaster Tools)
For webmasters.searchanalytics.query it currently says:
[LIMITED ACCESS] Query your data with filters and parameters that you define. Returns zero or more rows grouped by the row keys that you define. You must define a date range of one or more days. When date is one of the group by values, any days without data are omitted from the result list. If you need to know which days have data, issue a broad date range query grouped by date for any metric, and see which day rows are returned.

Developing an application that creates financial chart from web services

I'm trying to create an application that will create a chart that will get the data by calling a financial web service. Users will interact with the chart by clicking on it. There could be millions of views on the application, so millions of requests on the web service. What's the best way to do this? Will I need to call the web service each time, a million times?
The way I see it you would be better off reading the data from the web service at fixed interval (every X seconds/minutes/hours depending if your data is real-time or not) and displaying the graph with that information. That way your number of requests to the web service will not vary and you can change one part of the equation without affecting the other.
Edit after first comment: my answer stands. You would be better off getting the data at a fixed interval and inform users that the data is supplied with a delay (the usual delay with financial activity data is 15 minutes). That way you know in advance the number of requests you will run and you greatly speed up the service to your users.
A word of warning: Yahoo Finance changed its API licensing in 2012 or 2011 and it is now forbidden to use data from the API for public applications without a commercial license.

PHP Using Exchange 2007 to Display Calendar on Website with Real Time Updates

I'm trying to use PHP to grab calendar information from Exchange 2007 to display the calendar on a webpage. I've figure out how to do all of this with EWS but I was wondering if there is a way to get updates to the calendar in real time so that they are changed on the website instantly. Can Exchange trigger my script whenever a change is made or do I need to poll Exchange at regular intervals? If the latter, is that going to tie up resources?
No, you need to poll exchange server using built-in sync function. Since sync is incremental it doesn't produce all that much overhead. You just poll the server at whatever intervals you require (within reason of course). Please refer to this answer for some more info:
PHP - Syncing MySQL Contacts with Exchange

Is there easy way to retrieve Google Finance data?

Once in a day we want to download google finance data for 6100+ stock symbols.
Right now we are going to this url and getting the data for all stock symbols.
http://www.google.com/finance?q=NYSE:AA&fstype=ii
Getting the data like this use lots of bandwidth and slowness on the server.
Is there better way to get the data from Google.
There is Google Finance API, but it is not available in PHP
The Google Finance API is available for use by all web scripting languages. All the API is is a description of and instructions on how to utilize their REST service. You use something like cURL in PHP to call to their REST service and retrieve the results output by it in XML format, and then parse the XML to display, store, whatever the information retreived.
Note that even though they don't have an example for PHP like they do for many of their APIs, their APIs still all use the same sort of system, so the examples provided for something like the Google Spreadsheets Data API or the Google Documents List API would be valid for getting a starting point on the Google Finance API. The difference between them would be the parameters passed, the data returned, and the url which you would be calling with the parameters to get the data.
If you can live without the data coming from Google, have you looked at the Yahoo Finance API? It's pretty flexible and allows the downloading of multiple symbols at once (though you may not necessarily want to do all 6100 at once).
For example, you can do:
http://finance.yahoo.com/d/quotes.csv?s=XOM+BBDb.TO+JNJ+MSFT&f=snd1l1yr
More detail on how to use the API is nicely written up at:
http://www.gummy-stuff.org/Yahoo-data.htm

Categories