Improves the forex menu to include the forecast command (#2818)

* Added forecast to forex menu

* Fixed tests

* fix test print

Co-authored-by: martinb-bb <105685594+martinb-bb@users.noreply.github.com>
This commit is contained in:
Colin Delahunty
2022-10-13 17:46:52 +01:00
committed by GitHub
parent 33955fa591
commit 0254d78741
4 changed files with 18 additions and 21 deletions

1
i18n/en.yml vendored
View File

@@ -796,6 +796,7 @@ en:
forex/ta: technical analysis, ema, macd, rsi, adx, bbands, obv
forex/qa: quantitative analysis, decompose, cusum, residuals analysis
forex/forex: Forex brokerages
forex/forecast: forecast techniques
forex/oanda: Oanda menu
forex/ta/_currency: Currency pair loaded
forex/ta/_source: Source

View File

@@ -45,7 +45,7 @@ FX_TICKERS = pd.read_csv(forex_data_path).iloc[:, 0].to_list()
class ForexController(BaseController):
"""Forex Controller class."""
CHOICES_COMMANDS = ["load", "quote", "candle", "resources", "fwd"]
CHOICES_COMMANDS = ["load", "quote", "candle", "resources", "fwd", "forecast"]
CHOICES_MENUS = ["ta", "qa", "Oanda"]
RESOLUTION = ["i", "d", "w", "m"]
@@ -102,6 +102,7 @@ class ForexController(BaseController):
mt.add_raw("\n")
mt.add_info("forex")
mt.add_menu("oanda")
mt.add_menu("forecast")
console.print(text=mt.menu_text, menu="Forex")
def custom_reset(self):
@@ -315,14 +316,7 @@ class ForexController(BaseController):
"""Enter Oanda menu."""
from openbb_terminal.forex.oanda.oanda_controller import OandaController
# if self.to_symbol and self.from_symbol:
self.queue = self.load_class(
OandaController,
queue=self.queue,
)
# else:
# console.print("No currency pair data is loaded. Use 'load' to load data.\n")
self.queue = self.load_class(OandaController, queue=self.queue)
@log_start_end(log=logger)
def call_ta(self, _):
@@ -367,10 +361,14 @@ class ForexController(BaseController):
else:
console.print("No pair selected.\n")
# HELP WANTED!
# TODO: Add news and reddit commands back
# behavioural analysis and exploratory data analysis would be useful in the
# forex menu. The examples of integration of the common ba and eda components
# into the stocks context can provide an insight on how this can be done.
# The earlier implementation did not work and was deleted in commit
# d0e51033f7d5d4da6386b9e0b787892979924dce
@log_start_end(log=logger)
def call_forecast(self, _):
"""Process forecast command"""
from openbb_terminal.forecast import forecast_controller
self.queue = self.load_class(
forecast_controller.ForecastController,
self.fx_pair,
self.data,
self.queue,
)

View File

@@ -167,10 +167,9 @@ class StocksController(StockBaseController):
s_intraday = (f"Intraday {self.interval}", "Daily")[
self.interval == "1440min"
]
stock_text += f"{s_intraday} {self.ticker}"
if self.start:
stock_text = f"{s_intraday} {self.ticker} (from {self.start.strftime('%Y-%m-%d')})"
else:
stock_text = f"{s_intraday} {self.ticker}"
stock_text += f" (from {self.start.strftime('%Y-%m-%d')})"
mt = MenuText("stocks/", 100)
mt.add_cmd("search")
@@ -743,8 +742,6 @@ class StocksController(StockBaseController):
self.stock,
self.queue,
)
# TODO: This menu should work regardless of data being daily or not!
# James: 5/27 I think it does now
else:
console.print("Use 'load <ticker>' prior to this command!", "\n")

View File

@@ -12,4 +12,5 @@ Source: YahooFinance
Forex brokerages:
> oanda Oanda menu
> forecast forecast techniques