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:
alexferrari88
2022-05-03 18:21:28 +02:00
committed by GitHub
parent 7d55b6fe76
commit 6b4987f3da
3 changed files with 6 additions and 0 deletions

View File

@@ -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")

View File

@@ -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("")

View File

@@ -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="",
),
),
(