Finnhub-Stock-API / finnhub-python

Finnhub Python API Client. Finnhub API provides institutional-grade financial data to investors, fintech startups and investment firms. We support real-time stock price, global fundamentals, global ETFs holdings and alternative data. https://finnhub.io/docs/api
https://finnhub.io/
Apache License 2.0
585 stars 101 forks source link

technical_indicator: indicator_specific_fields #1

Closed vladvoinescu closed 4 years ago

vladvoinescu commented 4 years ago

Hey,

It seems to me that the indicator_specific_fields param doesn't work for the technical_indicator method. The only way I could make it compile and have the request sent was calling it like this: rsiResult = finn.technical_indicator( symbol=STOCK, resolution=CANDLE_SIZE, _from=UNTIL - TIME_FRAME, to=UNTIL, indicator='rsi', indicator_specific_fields={'timeperiod': 14})

However, this ends up by sending a request to the url which looks like this: 'https://finnhub.io/api/v1/indicator?symbol=AAPL&resolution=15&from=1592163900&to=1592595900&indicator=rsi&Indicator+specific+fields=%7B%27timeperiod%27%3A+14%7D&token=brmfkpvrh5re15om42ag'

Which is different than the one that the back-end expects: r = requests.get('https://finnhub.io/api/v1/indicator?symbol=AAPL&resolution=D&from=1583098857&to=1584308457&indicator=sma&timeperiod=3&token=brmfkpvrh5re15om42ag')

Full disclosure: my Python skills are close to none, however I spent almost a day on this and could not make it work 😁

Any sort of help would be appreciated.

Kind regards, Vlad

TonyPlayer commented 4 years ago

I've had similar issues. In my case results are unchanged still getting RSI value with timeperiod = 3.

nongdenchet commented 4 years ago

Hi guys, thank you for reporting let us have a look on this

nongdenchet commented 4 years ago

Hi guys @TonyPlayer @vladcvoinescu we have released 1.1.7 to address this issue. Let us know if you guys are still facing it

TonyPlayer commented 4 years ago

Hi @nongdenchet, can you please give me example how to use RSI for timeperiod = 14. I'm still getting error when i use argument like below: print(finnhub_client.technical_indicator(symbol=symbol, resolution=5, _from=_from, to=to, indicator='rsi', timeperiod=14))

~\anaconda3\lib\site-packages\finnhub\api\default_api.py in technical_indicator_with_http_info(self, symbol, resolution, _from, to, indicator, **kwargs) 5184 raise ApiTypeError( 5185 "Got an unexpected keyword argument '%s'" -> 5186 " to method technical_indicator" % key 5187 ) 5188 local_var_params[key] = val

ApiTypeError: Got an unexpected keyword argument 'timeperiod' to method technical_indicator

finnhubio commented 4 years ago

Hi @nongdenchet, can you please give me example how to use RSI for timeperiod = 14. I'm still getting error when i use argument like below: print(finnhub_client.technical_indicator(symbol=symbol, resolution=5, _from=_from, to=to, indicator='rsi', timeperiod=14))

~\anaconda3\lib\site-packages\finnhub\api\default_api.py in technical_indicator_with_http_info(self, symbol, resolution, _from, to, indicator, **kwargs) 5184 raise ApiTypeError( 5185 "Got an unexpected keyword argument '%s'" -> 5186 " to method technical_indicator" % key 5187 ) 5188 local_var_params[key] = val

ApiTypeError: Got an unexpected keyword argument 'timeperiod' to method technical_indicator

Plz try the example shown in the original post: rsiResult = finn.technical_indicator( symbol=STOCK, resolution=CANDLE_SIZE, _from=UNTIL - TIME_FRAME, to=UNTIL, indicator='rsi', indicator_specific_fields={'timeperiod': 14})

TonyPlayer commented 4 years ago

Yeah, i've tried that, and got the following error: ApiTypeError: Got an unexpected keyword argument 'indicator_specific_fields' to method technical_indicator

nongdenchet commented 4 years ago

hi team sorry for late response, please try this one

print(finnhub_client.technical_indicator(symbol="AAPL", resolution='D', _from=1583098857, to=1584308457, indicator='rsi', indicator_fields={"timeperiod": 3}))
nongdenchet commented 4 years ago

@TonyPlayer I forget to update README, I have updated it accordingly