mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-09 02:42:36 +00:00
* Fix exports missing on Eclect.US and Finviz * Fix formatting * Fix formatting * Fix lamda not using 'def' * Fix pylint issues Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>
62 lines
1.4 KiB
Python
62 lines
1.4 KiB
Python
"""Eclect.us model"""
|
|
__docformat__ = "numpy"
|
|
|
|
import logging
|
|
|
|
import requests
|
|
import pandas as pd
|
|
|
|
from openbb_terminal.decorators import log_start_end
|
|
|
|
# pylint: disable=R1718
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@log_start_end(log=logger)
|
|
def get_filings_analysis(symbol: str) -> pd.DataFrame:
|
|
"""Save time reading SEC filings with the help of machine learning. [Source: https://eclect.us]
|
|
|
|
Parameters
|
|
----------
|
|
symbol: str
|
|
Ticker symbol to see analysis of filings
|
|
|
|
Returns
|
|
-------
|
|
str
|
|
Analysis of filings text
|
|
"""
|
|
|
|
response = requests.get(f"https://api.eclect.us/symbol/{symbol.lower()}?page=1")
|
|
|
|
if response.status_code != 200:
|
|
return pd.DataFrame()
|
|
|
|
response_dict = response.json()
|
|
|
|
def resultGroupMapper(g):
|
|
def resultMapper(a):
|
|
return {
|
|
"Good": a["good_or_bad"] == "good",
|
|
"Sentence": a["sentence"],
|
|
"Group": g,
|
|
}
|
|
|
|
return resultMapper
|
|
|
|
risk = pd.DataFrame(
|
|
map(resultGroupMapper("Risk factors"), response_dict[0]["rf_highlights"]),
|
|
columns=["Group", "Good", "Sentence"],
|
|
)
|
|
analysis = pd.DataFrame(
|
|
map(
|
|
resultGroupMapper("Discussion and Analysis"),
|
|
response_dict[0]["daa_highlights"],
|
|
),
|
|
columns=["Group", "Good", "Sentence"],
|
|
)
|
|
|
|
return pd.concat([risk, analysis], ignore_index=True)
|