views:

6533

answers:

7

hello all, I am building a web based trading system where buy and sell signals would be generated by reading quotes from either Yahoo finance, google finance or the exchange(NSE of India) itself.My first preference would be to fetch data from this url:

http://www.nseindia.com/content/equities/niftywatch.htm

the page on the site uses tables and i want to fetch data for a particular stock by using class/id of a particular row. Now the problem is I can't figure out how to fetch data from a diffrent domain on my server. I use jquery at the client side, on server-side I use ASP.Net in VB. So please help me out and suggest how do i fetch stock quotes from the above source. Even if i can get access to the table on the above url, my work will be done. Please help. Thanks a lot in advance.

P.S.: Just noticed on google finance that they stream real time quote for this particular exchange, so if it is easy to fetch data from google(I understand that they have apis for virtually their every service) then please explain the same.

+3  A: 

Google does indeed offer an API for Google Finance, documented here: http://code.google.com/apis/finance/

It looks like it's designed around the idea of a portfolio, and I don't offhand see a way to request a quote for a specific stock. The closest fit seems to be "Retrieving specific positions."

In any case, this is not something you want to tackle with jQuery. For one thing, you will not be able to read any data from another site (e.g., that nseindia.com site), unless there's a JSONP script setup on the site you could exploit.

VoteyDisciple
hey thanks a lot for directing to the api, going through it right now.. but if i can't fetch data from another site then how do i use this api.
Amit Kumar Jha
You can't read from another site *using JavaScript* but you certainly can from ASP.NET. Google should have some examples of precisely how to do that.
VoteyDisciple
+5  A: 

Here's how to grab historical daily stock prices (up through today) from Yahoo Finance in CSV format:

http://ichart.finance.yahoo.com/table.csv?s=STOCK

where STOCK is the ticker symbol.

You can limit what that returns with some additional parameters:

  • s - Ticker symbol. This is the only parameter that isn't optional.

    Start date for historical prices:

  • a - Month number, starting with 0 for January.

  • b - Day number, eg, 1 for the first of the month.

  • c - Year.

    End date for historical prices (default is the most current available closing price):

  • d - Month number, starting with 0 for January.

  • e - Day number, eg, 1 for the first of the month.

  • f - Year.

    And finally, the frequency of historical prices:

  • g - Possible values are 'd' for daily (the default), 'w' for weekly, and 'm' for monthly.

dreeves
thanks for guiding... but as voteydisciple says i can't read data from other sites, so how do I go about retrieving the quotes....
Amit Kumar Jha
By the way, does anyone know where the above is officially documented? I pieced that together from some unofficial place but Yahoo presumably maintains better documentation for this.
dreeves
A: 

I'm confused from your comments when you say you can't fetch data from another site.

Are you saying that you can't make HTTP calls from your server because it's prohibited by a firewall policy or some other constraint? Or, are you saying you simply don't know how to make HTTP calls from your server?

If it's the latter, you should be able to very easily find a .NET library for making HTTP GET calls (I don't use .NET so I can't say exactly what library to use).

Once you've figured that out, then you need to figure out how you're going to parse the response. Is it data from a HTML table, is it a CSV file, is it an XML feed, or...? They are all going to have different parsing needs, so it's hard to explain how to do it without more specificity. There are likely to be libraries available that you can use for that too, but it certainly depends on what your data source looks like.

If this is truly the case, it sounds to me like maybe you have only a shallow understanding of how HTTP works and could perhaps benefit from learning how HTTP 1.1 works before going any further. You don't have to understand the whole specification, but enough to distinguish the role of the user agent, server, content types, etc.

Otherwise, if you are saying that you can't get around firewall policies and the like, then you will have to give more information about your server environment before we can help.

Joe Holloway
A: 

Can you tell the link which will provide the stock codes for filling the same in given URL.Regards

NSE
A: 

R u looking for end of day data. If that is the case, you can compose url for bhavcopy or historical data between two dates (there is a limit for duration. I think 3 years or so).

Interesting thing is, while you download historical data from nseindia, pay attention to the link they have provided while downloading zip data, copy it, modify it to fit your date range, hit it.

this way you can automate the download of historical data from nseindia. In fact we are using the same for http://kakup.com

ofcourse, we convert it to metastock format also. its working fine.

Narendra
A: 

You can download the page containing all the information about a particular stock by using wget. After the page is saved to your local hard drive, you can parse and retrieve the real-time price (,p:"stock_price").

For example: wget http://www.google.ca/finance?q=some_particular_stock

Program this to retrieve information at a regular interval and you have yourself a real-time quote tracker.

Jake88
A: 

I have been using a simple REST service for getting stock quote from yahoo and i have just posted in my site for my reference. People can just go through it.

http://vikku.info/codetrash/Yahoo_Finance_Stock_Quote_API

Jayapal Chandran