finnhubio / Finnhub-API

Finnhub API provides institutional-grade financial data to investors, fintech startups and investment firms. We support real-time stock price, global fundamentals and alternative data. https://finnhub.io/docs/api
98 stars 6 forks source link

add trade=true to quote() method #476

Open luckman212 opened 2 years ago

luckman212 commented 2 years ago

Hello,

I'm using the Finnhub py module v2.4.9

I found through trial and error that the finnhub.Client().quote() does not return realtime quotes pre- and post-market, unless you also pass an undocumented &trade=true param.

I edited my client.py like this to allow the quotes to update after hours:

  def quote(self, symbol):
    return self._get("/quote", params={
      "symbol": symbol,
      "trade": 'true' <==
    })

I wonder if it would be possible to make this an offical optional parameter so it will work without hacking the module.

Also, I note that the t: value that is returned by the API (epoch time) does not accurately reflect the quote retreived when trade=true is used. So I instead am using a timestamp from datetime (ugh)

luckman212 commented 2 years ago

Further testing, seems sometimes the API gets "stuck" when using trade=true and returns old quotes e.g. FSLY this morning (2/17 8:30am) returning 19.70 even though the market is at 20.76 now premarket.

Also CMBM last trade 24.79 but API returns 0.00

So it seems this API is very unreliable when using this parameter.