Skip to content
Advertisement

python stock price real time data feed (script debug)

i’m just beginning to learn to code and i want to apologize in advance if this question is trivial.

ive been trying to find a way to feed stock market data into python real time and came across this blog http://www.quantatrisk.com/2015/05/07/hacking-google-finance-in-pre-market-trading-python/

Below is the script i copied and pasted.

JavaScript

it seems to be a great code except when i run it, i get the following error message

JavaScript

I tried modifying fetchPreMarket such that it just outputs info = data[0] but when i tried ‘print info’, nothing came of it.

Thanks in advance

Advertisement

Answer

So… The Google Finance API has been discontinued. I am surprised that link works, but there is no "etl" (or "el") key in the data.

And so, you’ll get KeyError: 'elt' at info["elt"]

For reference,

JavaScript

You may have better luck with the googlefinance or yahoo-finance python modules rather than directly calling the API address.

It is worth noting that the Yahoo API is not “realtime”, though. It is about a 15 minute delayed quote.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement