mop-tracker / mop

Stock market tracker for hackers.
MIT License
1.94k stars 298 forks source link

New source for ticker data needed #42

Closed cjc343 closed 4 years ago

cjc343 commented 6 years ago

http://download.finance.yahoo.com/d/quotes.csv?s=%s&f=sl1c1p2oghjkva2r2rdyj3j1 is no longer serving quote data. The following message is displayed:

It has come to our attention that this service is being used in violation of the Yahoo Terms of Service. As such, the service is being discontinued. For all future markets and equities data research, please refer to finance.yahoo.com.

In short, a new source for ticker data is needed to replace yahoo. There will likely be additional changes required to support any new data source.

alexaisok commented 6 years ago

Alpha Vantage looks promising. It offers a proper API instead of the common web scraping options.

arvin-foroutan commented 6 years ago

Here's another Yahoo source that still works but in a different format:

Single quote: https://query1.finance.yahoo.com/v7/finance/quote?symbols=AAPL Multiple quotes: https://query1.finance.yahoo.com/v7/finance/quote?symbols=AAPL,NFLX

Both return json and I can't seem to get them to return csv via query parameters. Let us know if you guys have better luck.

arinbjornk commented 6 years ago

There exists a python library for downloading quotes in the new format c0redumb/yahoo_quote_download

Not sure if it actually returns CSV but it says:

The CSV file downloaded through the new API has a few data and format differences from the CSV file from the original iChart source. If you plan to use the downloaded data with code that used to process the data from old API, please check your code to make sure that these differences are taken care of.

hp4k1h5 commented 6 years ago

there is also the google api: npm has a package which might simplify the process of moving this over https://www.npmjs.com/package/google-finance

metiscus commented 6 years ago

I've written some code in c++ that can get and parse the google api and retrieve almost all of the data needed here. I don't really know Go but in case someone who does has the time and inclination, you can find the code https://github.com/metiscus/cquote/blob/master/main.cpp

The general idea is as follows: Do an HTTP GET for std::string query = "https://finance.google.com/finance?q="; query += stock.ticker; query += "&output=json";

Chop off the first 5 characters of the returned string as well as the last character to make it valid JSON. Then all you need to do is to remap the json keys. stock.is_valid = true; stock.name = d["name"].GetString(); stock.exchange = d["exchange"].GetString(); stock.last = parse_float(d["l"].GetString()); stock.change = parse_float(d["c"].GetString()); stock.change_pct = parse_float(d["cp"].GetString()); stock.open = parse_float(d["op"].GetString()); stock.high = parse_float(d["hi"].GetString()); stock.low = parse_float(d["lo"].GetString()); stock.stat_52_low = parse_float(d["hi52"].GetString()); stock.stat_52_high = parse_float(d["lo52"].GetString()); stock.stat_eps = parse_float(d["eps"].GetString()); stock.stat_pe = parse_float(d["pe"].GetString()); stock.stat_dividend = parse_float(d["ldiv"].GetString()); stock.stat_yield = parse_float(d["dy"].GetString()); stock.stat_shares = d["shares"].GetString(); stock.stat_volume = d["vo"].GetString(); stock.stat_avg_volume = d["avvo"].GetString();

NewbieReader commented 5 years ago

Capture12

Guys sorry for being a totally noob. Im getting the same comment as this guys post. Error fetching stock quotes. Can you please give me the noob explanation why I cant get the quotes? I have read that its has something to do with yahoo finance that now its giving its data availability. So how can I fix it? Please explain it in a matter that a total noob like me could understand please.

Anyway, I found that the upper codes of my cnn.market.go works just fine coz as I browse the context of the code where such values were found I have data for the STOCKS like:

market.Dow[change] = matches[1] market.Dow[latest] = matches[2] market.Dow[percent] = matches[3] market.Nasdaq[change] = matches[4] market.Nasdaq[latest] = matches[5] market.Nasdaq[percent] = matches[6] market.Sp500[change] = matches[7] market.Sp500[latest] = matches[8] market.Sp500[percent] = matches[9]

I read that the Error in quotes has something to do with the market.regex, im not sure if im quite following this right but as my analysis to the script, this seems where I am getting the error can add new stock in the main.go program. Anyway im running this at termux. I found out that theres a script that runs stocks in Linux so I search and ended up in this Mob in GitHub. Im totally a noob so please do help me guys! thanks my Seniors :). Im just running around this thread about Mob but I cant really get what im missing so I decided to ask for help. Says this Issue #42 has the answer but I cant really get to understand how to change my ticker from yahoo-finance to something that works. Hope you understand Thanks

brandleesee commented 5 years ago

Leave this here as this is part of the research: https://blog.api.rakuten.net/api-tutorial-yahoo-finance/

laoshaw commented 5 years ago

https://github.com/RxJSInAction/rxjs-in-action/issues/13

"Ran into the same issue. Found that this Yahoo API call will work, https://query1.finance.yahoo.com/v7/finance/quote?lang=en-US&region=US&corsDomain=finance.yahoo.com&symbols=FB&fields=regularMarketPrice but it returns JSON not csv."

brandleesee commented 5 years ago

Should be fixed as per https://github.com/mop-tracker/mop/commit/e619620384738595fe4ec59f598b4fa161512eac https://github.com/mop-tracker/mop/commit/a4b86c4d15fa4d3b4480a827d9aabed3290a4c88 https://github.com/mop-tracker/mop/commit/f1908ce3c6a88e380865b2a4338540efb888088d https://github.com/brandleesee/TerminalStocks/commit/34a348528bb09cd55b019ac192613812f74f4695 https://github.com/brandleesee/TerminalStocks/commit/308a29d80942d5101a3bcaf45a684ebccd2eed26. Feedback appreciated. If successful will close.

ghost commented 4 years ago

Works for me!

brandleesee commented 4 years ago

Great, noted! Closing then :D