Reputation: 680
This is functional code for retrieving stock prices.
from googlefinance import getQuotes
import json
import re
def get_last_trade_price(TICKER):
Asset = json.dumps(getQuotes(TICKER))
raw = (json.loads(Asset)[0]["LastTradePrice"])
raw = re.sub(',','',raw)
return float(raw)
This function retrieves the last traded price of the stock.
get_last_trade_price('AAPL')
But it does not work for some of the stocks listed in other exchanges outside the US.
get_last_trade_price('C52')
This link shows the details of the company. How can I get this code to work?
Upvotes: 0
Views: 502
Reputation: 2792
try using the ticker with the index specified first SGX:C52
get_last_trade_price('SGX:C52')
Upvotes: 1