mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 04:52:07 +00:00
@@ -17,6 +17,7 @@ from openbb_terminal.decorators import log_start_end
|
||||
from openbb_terminal.etf import (
|
||||
financedatabase_view,
|
||||
fmp_view,
|
||||
stockanalysis_model,
|
||||
stockanalysis_view,
|
||||
)
|
||||
from openbb_terminal.etf.discovery import disc_controller
|
||||
@@ -261,6 +262,15 @@ class ETFController(BaseController):
|
||||
f"Loading Daily data for {self.etf_name} with starting period {ns_parser.start.strftime('%Y-%m-%d')}.",
|
||||
)
|
||||
|
||||
try:
|
||||
self.etf_holdings = list(
|
||||
stockanalysis_model.get_etf_holdings(self.etf_name)[
|
||||
: ns_parser.limit
|
||||
].index
|
||||
)
|
||||
except Exception as e:
|
||||
console.print(f"Error: {e}")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_overview(self, other_args: List[str]):
|
||||
"""Process overview command"""
|
||||
@@ -557,16 +567,31 @@ class ETFController(BaseController):
|
||||
console.print("Use 'load <ticker>' prior to this command!")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_ca(self, _):
|
||||
def call_ca(self, other_args: List[str]):
|
||||
"""Process ca command"""
|
||||
if len(self.etf_holdings) > 0:
|
||||
self.queue = ca_controller.ComparisonAnalysisController(
|
||||
self.etf_holdings, self.queue
|
||||
).menu(custom_path_menu_above="/stocks/")
|
||||
else:
|
||||
console.print(
|
||||
"Load a ticker with major holdings to compare them on this menu\n"
|
||||
)
|
||||
parser = argparse.ArgumentParser(
|
||||
add_help=False,
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
prog="ca",
|
||||
description="Compare ETF's holdings with each other",
|
||||
)
|
||||
|
||||
ns_parser = self.parse_known_args_and_warn(
|
||||
parser,
|
||||
other_args,
|
||||
export_allowed=EXPORT_BOTH_RAW_DATA_AND_FIGURES,
|
||||
raw=True,
|
||||
)
|
||||
|
||||
if ns_parser:
|
||||
if len(self.etf_holdings) == 0:
|
||||
console.print(
|
||||
"Load a ticker with major holdings to compare them on this menu\n"
|
||||
)
|
||||
elif len(self.etf_holdings) > 0:
|
||||
self.queue = ca_controller.ComparisonAnalysisController(
|
||||
self.etf_holdings, self.queue
|
||||
).menu(custom_path_menu_above="/stocks/")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_disc(self, _):
|
||||
|
||||
Reference in New Issue
Block a user