Files
OpenBB/gamestonk_terminal/stocks/comparison_analysis/finnhub_model.py
jmaslek ffcaa19e79 Refactor ca menu (#726)
* First wave of refactoring.  yfinance and marketwatch menus

* Finbrain commands refactored

* Refactor finviz commands

* Add custom ML model for running get

* Bug fixes + dim ca commands when no similar selected

* Add pylint disable

* move ml command into yfinance stuff.  fix typos

* Change historical/corr to have interested ticker first

* Pylint error

* Comment out fa test
2021-09-02 20:30:33 -04:00

23 lines
559 B
Python

"""Finnhub model"""
__docformat__ = "numpy"
from typing import List, Tuple
import requests
from gamestonk_terminal import config_terminal as cfg
def get_similar_companies(ticker: str) -> Tuple[List[str], str]:
result = requests.get(
f"https://finnhub.io/api/v1/stock/peers?symbol={ticker}&token={cfg.API_FINNHUB_KEY}"
)
if result.status_code == 200:
similar = result.json()
user = "Finnhub"
else:
print("Similar companies not found.")
similar = [""]
user = "Error"
return similar, user