Ensure that talib never gets called in parallel

This commit is contained in:
Robert Caulk 2022-09-02 18:05:41 +02:00 committed by GitHub
parent b53791fef2
commit c4ab6c0d8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -174,30 +174,28 @@ class FreqaiExampleHybridStrategy(IStrategy):
# flake8: noqa: C901 # flake8: noqa: C901
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# User creates their own custom strat here. Present example is a supertrend
# based strategy.
dataframe = self.freqai.start(dataframe, metadata, self) dataframe = self.freqai.start(dataframe, metadata, self)
# TA indicators to combine with the Freqai targets with self.freqai.analysis_lock:
# RSI # TA indicators to combine with the Freqai targets
dataframe['rsi'] = ta.RSI(dataframe) # RSI
dataframe['rsi'] = ta.RSI(dataframe)
# Bollinger Bands # Bollinger Bands
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2) bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
dataframe['bb_lowerband'] = bollinger['lower'] dataframe['bb_lowerband'] = bollinger['lower']
dataframe['bb_middleband'] = bollinger['mid'] dataframe['bb_middleband'] = bollinger['mid']
dataframe['bb_upperband'] = bollinger['upper'] dataframe['bb_upperband'] = bollinger['upper']
dataframe["bb_percent"] = ( dataframe["bb_percent"] = (
(dataframe["close"] - dataframe["bb_lowerband"]) / (dataframe["close"] - dataframe["bb_lowerband"]) /
(dataframe["bb_upperband"] - dataframe["bb_lowerband"]) (dataframe["bb_upperband"] - dataframe["bb_lowerband"])
) )
dataframe["bb_width"] = ( dataframe["bb_width"] = (
(dataframe["bb_upperband"] - dataframe["bb_lowerband"]) / dataframe["bb_middleband"] (dataframe["bb_upperband"] - dataframe["bb_lowerband"]) / dataframe["bb_middleband"]
) )
# TEMA - Triple Exponential Moving Average # TEMA - Triple Exponential Moving Average
dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9) dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9)
return dataframe return dataframe