From e7de812948c87be1a5b5ccc82301d5e227c6bd97 Mon Sep 17 00:00:00 2001 From: robcaulk Date: Tue, 9 Aug 2022 16:03:10 +0200 Subject: [PATCH] Allow user to user pair_dict for persistent storage of custom data --- freqtrade/freqai/data_drawer.py | 3 ++- freqtrade/templates/FreqaiExampleStrategy.py | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/freqtrade/freqai/data_drawer.py b/freqtrade/freqai/data_drawer.py index f8002a45f..ec49c7050 100644 --- a/freqtrade/freqai/data_drawer.py +++ b/freqtrade/freqai/data_drawer.py @@ -31,6 +31,7 @@ class pair_info(TypedDict): trained_timestamp: int priority: int data_path: str + extras: dict class FreqaiDataDrawer: @@ -87,7 +88,7 @@ class FreqaiDataDrawer: self.old_DBSCAN_eps: Dict[str, float] = {} self.empty_pair_dict: pair_info = { "model_filename": "", "trained_timestamp": 0, - "priority": 1, "first": True, "data_path": ""} + "priority": 1, "first": True, "data_path": "", "extras": {}} def load_drawer_from_disk(self): """ diff --git a/freqtrade/templates/FreqaiExampleStrategy.py b/freqtrade/templates/FreqaiExampleStrategy.py index ee1602725..01f947a6a 100644 --- a/freqtrade/templates/FreqaiExampleStrategy.py +++ b/freqtrade/templates/FreqaiExampleStrategy.py @@ -252,16 +252,16 @@ class FreqaiExampleStrategy(IStrategy): if ( "prediction" + entry_tag not in pair_dict[pair] - or pair_dict[pair]["prediction" + entry_tag] == 0 + or pair_dict[pair]['extras']["prediction" + entry_tag] == 0 ): with self.freqai.lock: - pair_dict[pair]["prediction" + entry_tag] = abs(trade_candle["&-s_close"]) + pair_dict[pair]['extras']["prediction" + entry_tag] = abs(trade_candle["&-s_close"]) if not follow_mode: self.freqai.dd.save_drawer_to_disk() else: self.freqai.dd.save_follower_dict_to_disk() - roi_price = pair_dict[pair]["prediction" + entry_tag] + roi_price = pair_dict[pair]['extras']["prediction" + entry_tag] roi_time = self.max_roi_time_long.value roi_decay = roi_price * ( @@ -299,7 +299,7 @@ class FreqaiExampleStrategy(IStrategy): pair_dict = self.freqai.dd.follower_dict with self.freqai.lock: - pair_dict[pair]["prediction" + entry_tag] = 0 + pair_dict[pair]['extras']["prediction" + entry_tag] = 0 if not follow_mode: self.freqai.dd.save_drawer_to_disk() else: