mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 21:12:16 +00:00
* fix darkpool api * fix typo * add default params on RSI ta * fix ta models for stocks api * fix ta models for stocks api * improve API * improve API * test_finbrain updated * fix finbrain model api * ba controller * improve API * minor improvs to API * a newly fantastic equity report * fixed image issue * add help to tier in finra command * make export to default to False for API use * remove ipynb_checkpoints * remove extra file Co-authored-by: jose-donato <zmcdonato@gmail.com> Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
"""FinBrain Model"""
|
|
__docformat__ = "numpy"
|
|
|
|
import logging
|
|
|
|
import pandas as pd
|
|
import requests
|
|
|
|
from openbb_terminal.decorators import log_start_end
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@log_start_end(log=logger)
|
|
def get_sentiment(ticker: str) -> pd.DataFrame:
|
|
"""Gets Sentiment analysis provided by FinBrain's API [Source: finbrain]
|
|
|
|
Parameters
|
|
----------
|
|
ticker : str
|
|
Ticker to get the sentiment analysis from
|
|
|
|
Returns
|
|
-------
|
|
DataFrame()
|
|
Empty if there was an issue with data retrieval
|
|
"""
|
|
result = requests.get(f"https://api.finbrain.tech/v0/sentiments/{ticker}")
|
|
sentiment = pd.DataFrame()
|
|
if result.status_code == 200:
|
|
result_json = result.json()
|
|
if "sentimentAnalysis" in result_json:
|
|
sentiment = pd.DataFrame.from_dict(
|
|
result_json["sentimentAnalysis"], orient="index"
|
|
)
|
|
sentiment.index = pd.to_datetime(sentiment.index).to_pydatetime()
|
|
sentiment.index.name = "date"
|
|
sentiment.columns = ["Sentiment Analysis"]
|
|
sentiment.sort_index(ascending=True, inplace=True)
|
|
|
|
return sentiment
|