Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve export to be all in same folder #3176

Merged
merged 1 commit into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions openbb_terminal/etf/etf_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,19 +529,10 @@ def call_candle(self, other_args: List[str]):
)

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,
Expand Down Expand Up @@ -580,6 +571,13 @@ def call_candle(self, other_args: List[str]):
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")

Expand Down
10 changes: 5 additions & 5 deletions openbb_terminal/helper_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
19 changes: 9 additions & 10 deletions openbb_terminal/stocks/stocks_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,15 +453,6 @@ def call_candle(self, other_args: List[str]):
)
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"
Expand Down Expand Up @@ -514,8 +505,16 @@ def call_candle(self, other_args: List[str]):
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]):
Expand Down