mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-27 19:53:17 +00:00
improve export (#3176)
This commit is contained in:
@@ -528,19 +528,10 @@ class ETFController(BaseController):
|
||||
)
|
||||
|
||||
ns_parser = self.parse_known_args_and_warn(
|
||||
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
|
||||
parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES
|
||||
)
|
||||
if ns_parser:
|
||||
if self.etf_name:
|
||||
export_data(
|
||||
ns_parser.export,
|
||||
os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "raw_data"
|
||||
),
|
||||
f"{self.etf_name}",
|
||||
self.etf_data,
|
||||
)
|
||||
|
||||
if ns_parser.raw:
|
||||
qa_view.display_raw(
|
||||
data=self.etf_data,
|
||||
@@ -579,6 +570,13 @@ class ETFController(BaseController):
|
||||
ma=mov_avgs,
|
||||
asset_type="ETF",
|
||||
)
|
||||
|
||||
export_data(
|
||||
ns_parser.export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
f"{self.etf_name}",
|
||||
self.etf_data,
|
||||
)
|
||||
else:
|
||||
console.print("No ticker loaded. First use `load {ticker}`\n")
|
||||
|
||||
|
||||
@@ -1278,11 +1278,11 @@ def compose_export_path(func_name: str, dir_path: str) -> Path:
|
||||
if resolve_path.parts[-2] == "openbb_terminal":
|
||||
path_cmd = f"{resolve_path.parts[-1]}"
|
||||
else:
|
||||
path_cmd = f"{resolve_path.parts[-2]}//{resolve_path.parts[-1]}"
|
||||
path_cmd = f"{resolve_path.parts[-2]}_{resolve_path.parts[-1]}"
|
||||
|
||||
default_filename = f"{now.strftime('%Y%m%d_%H%M%S')}_{func_name}"
|
||||
default_filename = f"{now.strftime('%Y%m%d_%H%M%S')}_{path_cmd}_{func_name}"
|
||||
|
||||
full_path = USER_EXPORTS_DIRECTORY / path_cmd / default_filename
|
||||
full_path = USER_EXPORTS_DIRECTORY / default_filename
|
||||
|
||||
return full_path
|
||||
|
||||
@@ -1333,9 +1333,9 @@ def export_data(
|
||||
elif exp_type.endswith("svg"):
|
||||
plt.savefig(saved_path)
|
||||
else:
|
||||
console.print("Wrong export file specified.\n")
|
||||
console.print("Wrong export file specified.")
|
||||
|
||||
console.print(f"Saved file: {saved_path}\n")
|
||||
console.print(f"Saved file: {saved_path}")
|
||||
|
||||
|
||||
def get_rf() -> float:
|
||||
|
||||
@@ -453,15 +453,6 @@ class StocksController(StockBaseController):
|
||||
)
|
||||
if ns_parser:
|
||||
if self.ticker:
|
||||
export_data(
|
||||
ns_parser.export,
|
||||
os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "raw_data"
|
||||
),
|
||||
f"{self.ticker}",
|
||||
self.stock,
|
||||
)
|
||||
|
||||
if ns_parser.sort and not self.stock.empty:
|
||||
sort = (
|
||||
ns_parser.sort if ns_parser.sort != "AdjClose" else "Adj Close"
|
||||
@@ -514,8 +505,16 @@ class StocksController(StockBaseController):
|
||||
ma=mov_avgs,
|
||||
yscale="log" if ns_parser.logy else "linear",
|
||||
)
|
||||
|
||||
export_data(
|
||||
ns_parser.export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
f"{self.ticker}",
|
||||
self.stock,
|
||||
)
|
||||
|
||||
else:
|
||||
console.print("No ticker loaded. First use `load {ticker}`\n")
|
||||
console.print("No ticker loaded. First use 'load <ticker>'")
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_news(self, other_args: List[str]):
|
||||
|
||||
Reference in New Issue
Block a user