mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 13:01:38 +00:00
Add --export to load functions (#2811)
Co-authored-by: martinb-bb <105685594+martinb-bb@users.noreply.github.com>
This commit is contained in:
@@ -18,6 +18,7 @@ from openbb_terminal.forex.forex_helper import FOREX_SOURCES, SOURCES_INTERVALS
|
||||
from openbb_terminal.helper_funcs import (
|
||||
valid_date,
|
||||
EXPORT_ONLY_RAW_DATA_ALLOWED,
|
||||
export_data,
|
||||
)
|
||||
from openbb_terminal.menu import session
|
||||
from openbb_terminal.parent_classes import BaseController
|
||||
@@ -159,8 +160,7 @@ class ForexController(BaseController):
|
||||
other_args.insert(0, "-t")
|
||||
|
||||
ns_parser = self.parse_known_args_and_warn(
|
||||
parser,
|
||||
other_args,
|
||||
parser, other_args, export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED
|
||||
)
|
||||
|
||||
if ns_parser:
|
||||
@@ -193,6 +193,13 @@ class ForexController(BaseController):
|
||||
else:
|
||||
self.data.index.name = "date"
|
||||
|
||||
export_data(
|
||||
ns_parser.export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"load",
|
||||
self.data.copy(),
|
||||
)
|
||||
|
||||
self.source = ns_parser.source
|
||||
|
||||
console.print(f"{self.from_symbol}-{self.to_symbol} loaded.\n")
|
||||
|
||||
@@ -43,6 +43,7 @@ from openbb_terminal.helper_funcs import (
|
||||
parse_and_split_input,
|
||||
search_wikipedia,
|
||||
screenshot,
|
||||
export_data,
|
||||
)
|
||||
from openbb_terminal.config_terminal import theme
|
||||
from openbb_terminal.rich_config import console, get_ordered_list_sources
|
||||
@@ -979,7 +980,9 @@ class StockBaseController(BaseController, metaclass=ABCMeta):
|
||||
if other_args and "-" not in other_args[0][0]:
|
||||
other_args.insert(0, "-t")
|
||||
|
||||
ns_parser = self.parse_known_args_and_warn(parser, other_args)
|
||||
ns_parser = self.parse_known_args_and_warn(
|
||||
parser, other_args, export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED
|
||||
)
|
||||
|
||||
if ns_parser:
|
||||
if ns_parser.weekly and ns_parser.monthly:
|
||||
@@ -1059,7 +1062,13 @@ class StockBaseController(BaseController, metaclass=ABCMeta):
|
||||
self.stock = self.stock.rename(columns={"Adj Close": "AdjClose"})
|
||||
self.stock = self.stock.dropna()
|
||||
self.stock.columns = [x.lower() for x in self.stock.columns]
|
||||
console.print("")
|
||||
console.print()
|
||||
export_data(
|
||||
ns_parser.export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"load",
|
||||
self.stock.copy(),
|
||||
)
|
||||
|
||||
|
||||
class CryptoBaseController(BaseController, metaclass=ABCMeta):
|
||||
@@ -1151,7 +1160,9 @@ class CryptoBaseController(BaseController, metaclass=ABCMeta):
|
||||
if other_args and "-" not in other_args[0][0]:
|
||||
other_args.insert(0, "-c")
|
||||
|
||||
ns_parser = self.parse_known_args_and_warn(parser, other_args)
|
||||
ns_parser = self.parse_known_args_and_warn(
|
||||
parser, other_args, export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED
|
||||
)
|
||||
|
||||
if ns_parser:
|
||||
if ns_parser.source in ("YahooFinance", "CoinGecko"):
|
||||
@@ -1181,3 +1192,9 @@ class CryptoBaseController(BaseController, metaclass=ABCMeta):
|
||||
ns_parser.exchange,
|
||||
self.current_interval,
|
||||
)
|
||||
export_data(
|
||||
ns_parser.export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"load",
|
||||
self.current_df.copy(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user