Files
OpenBB/gamestonk_terminal/common/behavioural_analysis/finnhub_model.py
LBolte29 6426b76771 decorated functions (#1282)
* decorated functions and removed assertion tests that are now caught by decorator logs
* modified functions with @property
* fixed bc of coingecko
* fixed outedated tests
2022-01-31 20:37:16 +01:00

36 lines
739 B
Python

"""Finnhub Model"""
__docformat__ = "numpy"
import logging
from typing import Dict
import requests
from gamestonk_terminal import config_terminal as cfg
from gamestonk_terminal.decorators import log_start_end
logger = logging.getLogger(__name__)
@log_start_end(log=logger)
def get_sentiment_stats(ticker: str) -> Dict:
"""Get sentiment stats [Source: finnhub]
Parameters
----------
ticker : str
Ticker to get sentiment stats
Returns
-------
Dict
Get sentiment stats
"""
response = requests.get(
f"https://finnhub.io/api/v1/news-sentiment?symbol={ticker}&token={cfg.API_FINNHUB_KEY}"
)
if response.status_code == 200:
return response.json()
return {}