0

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?

prashanth manohar
  • 531
  • 1
  • 13
  • 30

1 Answers1

1

try using the ticker with the index specified first SGX:C52

get_last_trade_price('SGX:C52')
prashanth manohar
  • 531
  • 1
  • 13
  • 30
Solaxun
  • 2,732
  • 1
  • 22
  • 41