Files
OpenBB/gamestonk_terminal/stocks/technical_analysis/finbrain_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

39 lines
975 B
Python

"""Finbrain model"""
__docformat__ = "numpy"
import logging
import requests
from gamestonk_terminal.decorators import log_start_end
from gamestonk_terminal.rich_config import console
logger = logging.getLogger(__name__)
@log_start_end(log=logger)
def get_technical_summary_report(ticker: str) -> str:
"""Get technical summary report provided by FinBrain's API
Parameters
----------
ticker : str
Ticker to get the technical summary
Returns
-------
report:str
technical summary report
"""
result = requests.get(f"https://api.finbrain.tech/v0/technicalSummary/{ticker}")
report = ""
if result.status_code == 200:
if "technicalSummary" in result.json():
report = result.json()["technicalSummary"]
else:
console.print("Unexpected data format from FinBrain API")
else:
console.print("Request error in retrieving sentiment from FinBrain API")
return report