Move "freqai.lock" to backend to simplify user interface

This commit is contained in:
Matthias 2022-08-14 17:19:50 +02:00
parent a5e96881f4
commit 3a9ec76c91
6 changed files with 323 additions and 331 deletions

View File

@ -177,8 +177,6 @@ The user interface is isolated to the typical config file. A typical FreqAI conf
Features are added by the user inside the `populate_any_indicators()` method of the strategy
by prepending indicators with `%` and labels are added by prepending `&`.
There are some important components/structures that the user *must* include when building their feature set.
As shown below, `with self.freqai.lock:` must be used to ensure thread safety - especially when using third
party libraries for indicator construction such as TA-lib.
Another structure to consider is the location of the labels at the bottom of the example function (below `if set_generalized_indicators:`).
This is where the user will add single features and labels to their feature set to avoid duplication from
various configuration parameters which multiply the feature set such as `include_timeframes`.
@ -203,7 +201,6 @@ various configuration parameters which multiply the feature set such as `include
coint = pair.split('/')[0]
with self.freqai.lock:
if informative is None:
informative = self.dp.get_pair_dataframe(pair, tf)
@ -430,7 +427,6 @@ The FreqAI strategy requires the user to include the following lines of code in
coin = pair.split('/')[0]
with self.freqai.lock:
if informative is None:
informative = self.dp.get_pair_dataframe(pair, tf)

View File

@ -961,6 +961,7 @@ class FreqaiDataKitchen:
for tf in tfs:
if tf == tfs[-1]:
sgi = True # doing this last allows user to use all tf raw prices in labels
with strategy.freqai.lock:
dataframe = strategy.populate_any_indicators(
pair,
dataframe.copy(),
@ -968,6 +969,7 @@ class FreqaiDataKitchen:
informative=base_dataframes[tf],
set_generalized_indicators=sgi
)
with strategy.freqai.lock:
if pairs:
for i in pairs:
if pair in i:

View File

@ -82,7 +82,6 @@ class FreqaiExampleStrategy(IStrategy):
coin = pair.split('/')[0]
with self.freqai.lock:
if informative is None:
informative = self.dp.get_pair_dataframe(pair, tf)
@ -252,7 +251,6 @@ class FreqaiExampleStrategy(IStrategy):
"prediction" + entry_tag not in pair_dict[pair]
or pair_dict[pair]['extras']["prediction" + entry_tag] == 0
):
with self.freqai.lock:
pair_dict[pair]['extras']["prediction" + entry_tag] = abs(trade_candle["&-s_close"])
if not follow_mode:
self.freqai.dd.save_drawer_to_disk()
@ -296,7 +294,6 @@ class FreqaiExampleStrategy(IStrategy):
else:
pair_dict = self.freqai.dd.follower_dict
with self.freqai.lock:
pair_dict[pair]['extras']["prediction" + entry_tag] = 0
if not follow_mode:
self.freqai.dd.save_drawer_to_disk()

View File

@ -63,7 +63,6 @@ class freqai_test_classifier(IStrategy):
coin = pair.split('/')[0]
with self.freqai.lock:
if informative is None:
informative = self.dp.get_pair_dataframe(pair, tf)

View File

@ -62,7 +62,6 @@ class freqai_test_multimodel_strat(IStrategy):
coin = pair.split('/')[0]
with self.freqai.lock:
if informative is None:
informative = self.dp.get_pair_dataframe(pair, tf)

View File

@ -62,7 +62,6 @@ class freqai_test_strat(IStrategy):
coin = pair.split('/')[0]
with self.freqai.lock:
if informative is None:
informative = self.dp.get_pair_dataframe(pair, tf)