Fixed big, added ability to bring data to forecast menu (#2823)

This commit is contained in:
Colin Delahunty
2022-10-13 16:46:47 +01:00
committed by GitHub
parent fcb58ca910
commit 33955fa591
3 changed files with 26 additions and 19 deletions

1
i18n/en.yml vendored
View File

@@ -873,6 +873,7 @@ en:
funds/equity: equity holdings
funds/al_swe: display fund allocation (sector, country, holdings)
funds/info_swe: get fund information
funds/forecast: forecasting techniques
alternative/covid: COVID menu, cases, deaths, rates
alternative/oss: Open Source menu, star history, repos information
alternative/covid/slopes: get countries with highest slope in cases

View File

@@ -181,28 +181,19 @@ def get_fund_historical(
logger.exception(str(e))
return pd.DataFrame(), "", name, country
# Note that dates for investpy need to be in the format dd/mm/yyyy
from_date = start_date.strftime("%d/%m/%Y")
to_date = end_date.strftime("%d/%m/%Y")
# Note that dates for investpy need to be in the format mm/dd/yyyy
from_date = start_date.strftime("%m/%d/%Y")
to_date = end_date.strftime("%m/%d/%Y")
search_country = matching_country if matching_country else country
# Using investiny to get around the 403 error with investment.com api
# We need to get an ID number
id_number = int(investiny.search_assets(name, limit=1)[0]["ticker"])
try:
# return (
# investpy.funds.get_fund_historical_data(
# fund_name, search_country, from_date=from_date, to_date=to_date
# ),
# fund_name,
# fund_symbol,
# matching_country,
# )
df = pd.DataFrame.from_dict(
investiny.historical_data(id_number, from_date=from_date, to_date=to_date)
).set_index("date")
# Using investiny to get around the 403 error with investment.com api
# We need to get an ID number
id_number = int(investiny.search_assets(name, limit=1)[0]["ticker"])
data = investiny.historical_data(
id_number, from_date=from_date, to_date=to_date
)
df = pd.DataFrame.from_dict(data).set_index("date")
df.columns = [col.title() for col in df.columns]
df.index = pd.to_datetime(df.index)
return (df, fund_name, fund_symbol, matching_country)

View File

@@ -50,6 +50,7 @@ class FundController(BaseController):
"equity",
"al_swe",
"info_swe",
"forecast",
]
fund_countries = investpy.funds.get_fund_countries()
@@ -146,6 +147,7 @@ class FundController(BaseController):
if self.country == "sweden":
mt.add_cmd("al_swe", self.fund_symbol)
mt.add_cmd("info_swe", self.fund_symbol)
mt.add_cmd("forecast", self.fund_symbol)
console.print(text=mt.menu_text, menu="Mutual Funds")
def custom_reset(self):
@@ -537,3 +539,16 @@ Potential errors
avanza_view.display_info(self.fund_name)
return self.queue
@log_start_end(log=logger)
def call_forecast(self, _):
"""Process forecast command"""
# pylint: disable=import-outside-toplevel
from openbb_terminal.forecast import forecast_controller
self.queue = self.load_class(
forecast_controller.ForecastController,
self.fund_name,
self.data,
self.queue,
)