mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 21:42:22 +00:00
Allow exporting from stocks/ca/hcorr (#1759)
* Add export to call_hcorr * Add export_data to display_correlation * Fix linting * Fix test for yahoo_finance_view.display_correlation Co-authored-by: Alex Ferrari <a.ferrari88@gmail.com> Co-authored-by: didierlopes.eth <dro.lopes@campus.fct.unl.pt>
This commit is contained in:
@@ -598,6 +598,7 @@ class ComparisonAnalysisController(BaseController):
|
||||
similar_tickers=self.similar,
|
||||
start=ns_parser.start.strftime("%Y-%m-%d"),
|
||||
candle_type=ns_parser.type_candle,
|
||||
export=ns_parser.export,
|
||||
)
|
||||
else:
|
||||
console.print("Please make sure there are similar tickers selected. \n")
|
||||
|
||||
@@ -168,6 +168,7 @@ def display_correlation(
|
||||
start: str = (datetime.now() - timedelta(days=366)).strftime("%Y-%m-%d"),
|
||||
candle_type: str = "a",
|
||||
external_axes: Optional[List[plt.Axes]] = None,
|
||||
export: str = "",
|
||||
):
|
||||
"""
|
||||
Correlation heatmap based on historical price comparison
|
||||
@@ -183,6 +184,8 @@ def display_correlation(
|
||||
OHLCA column to use, by default "a" for Adjusted Close
|
||||
external_axes : Optional[List[plt.Axes]], optional
|
||||
External axes (1 axis is expected in the list), by default None
|
||||
export : str, optional
|
||||
Format to export correlation prices, by default ""
|
||||
|
||||
"""
|
||||
df_similar = yahoo_finance_model.get_historical(similar_tickers, start, candle_type)
|
||||
@@ -227,4 +230,5 @@ def display_correlation(
|
||||
if not external_axes:
|
||||
theme.visualize_output()
|
||||
|
||||
export_data(export, os.path.dirname(os.path.abspath(__file__)), "hcorr", df_similar)
|
||||
console.print("")
|
||||
|
||||
@@ -256,6 +256,7 @@ def test_call_func_expect_queue(expected_queue, queue, func):
|
||||
similar_tickers=["MOCK_SIMILAR_1", "MOCK_SIMILAR_2"],
|
||||
start="2020-12-01",
|
||||
candle_type="h",
|
||||
export="",
|
||||
),
|
||||
),
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user