reduce number of pair_dict lookups, remove coin_first
This commit is contained in:
@@ -166,7 +166,7 @@ class FreqaiDataDrawer:
|
||||
if isinstance(object, np.generic):
|
||||
return object.item()
|
||||
|
||||
def get_pair_dict_info(self, pair: str) -> Tuple[str, int, bool, bool]:
|
||||
def get_pair_dict_info(self, pair: str) -> Tuple[str, int, bool]:
|
||||
"""
|
||||
Locate and load existing model metadata from persistent storage. If not located,
|
||||
create a new one and append the current pair to it and prepare it for its first
|
||||
@@ -175,23 +175,20 @@ class FreqaiDataDrawer:
|
||||
:return:
|
||||
model_filename: str = unique filename used for loading persistent objects from disk
|
||||
trained_timestamp: int = the last time the coin was trained
|
||||
coin_first: bool = If the coin is fresh without metadata
|
||||
return_null_array: bool = Follower could not find pair metadata
|
||||
"""
|
||||
pair_in_dict = self.pair_dict.get(pair)
|
||||
pair_dict = self.pair_dict.get(pair)
|
||||
data_path_set = self.pair_dict.get(pair, {}).get("data_path", None)
|
||||
return_null_array = False
|
||||
|
||||
if pair_in_dict:
|
||||
model_filename = self.pair_dict[pair]["model_filename"]
|
||||
trained_timestamp = self.pair_dict[pair]["trained_timestamp"]
|
||||
coin_first = self.pair_dict[pair]["first"]
|
||||
if pair_dict:
|
||||
model_filename = pair_dict["model_filename"]
|
||||
trained_timestamp = pair_dict["trained_timestamp"]
|
||||
elif not self.follow_mode:
|
||||
self.pair_dict[pair] = {}
|
||||
model_filename = self.pair_dict[pair]["model_filename"] = ""
|
||||
coin_first = self.pair_dict[pair]["first"] = True
|
||||
trained_timestamp = self.pair_dict[pair]["trained_timestamp"] = 0
|
||||
self.pair_dict[pair]["priority"] = len(self.pair_dict)
|
||||
pair_dict = self.pair_dict[pair] = {}
|
||||
model_filename = pair_dict["model_filename"] = ""
|
||||
trained_timestamp = pair_dict["trained_timestamp"] = 0
|
||||
pair_dict["priority"] = len(self.pair_dict)
|
||||
|
||||
if not data_path_set and self.follow_mode:
|
||||
logger.warning(
|
||||
@@ -199,9 +196,11 @@ class FreqaiDataDrawer:
|
||||
f"pair_dictionary at path {self.full_path}, sending null values "
|
||||
"back to strategy."
|
||||
)
|
||||
trained_timestamp = 0
|
||||
model_filename = ''
|
||||
return_null_array = True
|
||||
|
||||
return model_filename, trained_timestamp, coin_first, return_null_array
|
||||
return model_filename, trained_timestamp, return_null_array
|
||||
|
||||
def set_pair_dict_info(self, metadata: dict) -> None:
|
||||
pair_in_dict = self.pair_dict.get(metadata["pair"])
|
||||
|
Reference in New Issue
Block a user