mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-02 07:23:25 +00:00
* add mutual funds to sdk * add docstring returns * mypy * remove avanza * add historical chart * split funcs * revert po controller * revert forecast sdk controller * revert forecsat * revert changes to forecast * redo po * remove .md files * pylint * why these md gone? * pagesize to limit * missed this one * country default US * default on load not on search --------- Co-authored-by: James Maslek <jmaslek11@gmail.com>
40 lines
834 B
Python
40 lines
834 B
Python
"""Avanza Model"""
|
|
__docformat__ = "numpy"
|
|
|
|
# pylint: disable=E1101
|
|
|
|
import logging
|
|
import os
|
|
|
|
import pandas as pd
|
|
|
|
from openbb_terminal.decorators import log_start_end
|
|
from openbb_terminal.helper_funcs import request
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@log_start_end(log=logger)
|
|
def get_data(isin: str) -> dict:
|
|
"""Gets the data from Avanza
|
|
|
|
Parameters
|
|
----------
|
|
isin: str
|
|
ISIN of the fund
|
|
|
|
Returns
|
|
-------
|
|
dict
|
|
Fund data
|
|
"""
|
|
ava_fund = pd.read_csv(
|
|
os.path.join("openbb_terminal", "mutual_funds", "avanza_fund_ID.csv"),
|
|
index_col=0,
|
|
)
|
|
fund_id = ava_fund.loc[ava_fund["ISIN"] == isin]["ID"].tolist()[0]
|
|
url = f"https://www.avanza.se/_api/fund-guide/guide/{fund_id}"
|
|
response = request(url)
|
|
fund_data = response.json()
|
|
return fund_data
|