Update function signatures in all templates

add typehints to help the user's editor suggest the right things.
This commit is contained in:
Matthias
2023-02-04 20:04:16 +01:00
parent 0dd2472385
commit 801714a588
8 changed files with 67 additions and 45 deletions

View File

@@ -1,5 +1,6 @@
import logging
from functools import reduce
from typing import Dict
import talib.abstract as ta
from pandas import DataFrame
@@ -24,20 +25,21 @@ class freqai_rl_test_strat(IStrategy):
startup_candle_count: int = 300
can_short = False
def feature_engineering_expand_all(self, dataframe, period, **kwargs):
def feature_engineering_expand_all(self, dataframe: DataFrame, period: int,
metadata: Dict, **kwargs):
dataframe["%-rsi-period"] = ta.RSI(dataframe, timeperiod=period)
return dataframe
def feature_engineering_expand_basic(self, dataframe: DataFrame, **kwargs):
def feature_engineering_expand_basic(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["%-pct-change"] = dataframe["close"].pct_change()
dataframe["%-raw_volume"] = dataframe["volume"]
return dataframe
def feature_engineering_standard(self, dataframe, **kwargs):
def feature_engineering_standard(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["%-day_of_week"] = dataframe["date"].dt.dayofweek
dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
@@ -49,7 +51,7 @@ class freqai_rl_test_strat(IStrategy):
return dataframe
def set_freqai_targets(self, dataframe, **kwargs):
def set_freqai_targets(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["&-action"] = 0

View File

@@ -1,5 +1,6 @@
import logging
from functools import reduce
from typing import Dict
import numpy as np
import talib.abstract as ta
@@ -56,7 +57,8 @@ class freqai_test_classifier(IStrategy):
informative_pairs.append((pair, tf))
return informative_pairs
def feature_engineering_expand_all(self, dataframe, period, **kwargs):
def feature_engineering_expand_all(self, dataframe: DataFrame, period: int,
metadata: Dict, **kwargs):
dataframe["%-rsi-period"] = ta.RSI(dataframe, timeperiod=period)
dataframe["%-mfi-period"] = ta.MFI(dataframe, timeperiod=period)
@@ -64,7 +66,7 @@ class freqai_test_classifier(IStrategy):
return dataframe
def feature_engineering_expand_basic(self, dataframe: DataFrame, **kwargs):
def feature_engineering_expand_basic(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["%-pct-change"] = dataframe["close"].pct_change()
dataframe["%-raw_volume"] = dataframe["volume"]
@@ -72,14 +74,14 @@ class freqai_test_classifier(IStrategy):
return dataframe
def feature_engineering_standard(self, dataframe, **kwargs):
def feature_engineering_standard(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["%-day_of_week"] = dataframe["date"].dt.dayofweek
dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
return dataframe
def set_freqai_targets(self, dataframe, **kwargs):
def set_freqai_targets(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe['&s-up_or_down'] = np.where(dataframe["close"].shift(-100) >
dataframe["close"], 'up', 'down')

View File

@@ -1,5 +1,6 @@
import logging
from functools import reduce
from typing import Dict
import numpy as np
import talib.abstract as ta
@@ -43,7 +44,8 @@ class freqai_test_multimodel_classifier_strat(IStrategy):
)
max_roi_time_long = IntParameter(0, 800, default=400, space="sell", optimize=False, load=True)
def feature_engineering_expand_all(self, dataframe, period, **kwargs):
def feature_engineering_expand_all(self, dataframe: DataFrame, period: int,
metadata: Dict, **kwargs):
dataframe["%-rsi-period"] = ta.RSI(dataframe, timeperiod=period)
dataframe["%-mfi-period"] = ta.MFI(dataframe, timeperiod=period)
@@ -51,7 +53,7 @@ class freqai_test_multimodel_classifier_strat(IStrategy):
return dataframe
def feature_engineering_expand_basic(self, dataframe: DataFrame, **kwargs):
def feature_engineering_expand_basic(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["%-pct-change"] = dataframe["close"].pct_change()
dataframe["%-raw_volume"] = dataframe["volume"]
@@ -59,14 +61,14 @@ class freqai_test_multimodel_classifier_strat(IStrategy):
return dataframe
def feature_engineering_standard(self, dataframe, **kwargs):
def feature_engineering_standard(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["%-day_of_week"] = dataframe["date"].dt.dayofweek
dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
return dataframe
def set_freqai_targets(self, dataframe, **kwargs):
def set_freqai_targets(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe['&s-up_or_down'] = np.where(dataframe["close"].shift(-50) >
dataframe["close"], 'up', 'down')

View File

@@ -1,5 +1,6 @@
import logging
from functools import reduce
from typing import Dict
import talib.abstract as ta
from pandas import DataFrame
@@ -42,7 +43,8 @@ class freqai_test_multimodel_strat(IStrategy):
)
max_roi_time_long = IntParameter(0, 800, default=400, space="sell", optimize=False, load=True)
def feature_engineering_expand_all(self, dataframe, period, **kwargs):
def feature_engineering_expand_all(self, dataframe: DataFrame, period: int,
metadata: Dict, **kwargs):
dataframe["%-rsi-period"] = ta.RSI(dataframe, timeperiod=period)
dataframe["%-mfi-period"] = ta.MFI(dataframe, timeperiod=period)
@@ -50,7 +52,7 @@ class freqai_test_multimodel_strat(IStrategy):
return dataframe
def feature_engineering_expand_basic(self, dataframe: DataFrame, **kwargs):
def feature_engineering_expand_basic(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["%-pct-change"] = dataframe["close"].pct_change()
dataframe["%-raw_volume"] = dataframe["volume"]
@@ -58,14 +60,14 @@ class freqai_test_multimodel_strat(IStrategy):
return dataframe
def feature_engineering_standard(self, dataframe, **kwargs):
def feature_engineering_standard(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["%-day_of_week"] = dataframe["date"].dt.dayofweek
dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
return dataframe
def set_freqai_targets(self, dataframe, **kwargs):
def set_freqai_targets(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["&-s_close"] = (
dataframe["close"]

View File

@@ -1,5 +1,6 @@
import logging
from functools import reduce
from typing import Dict
import talib.abstract as ta
from pandas import DataFrame
@@ -42,7 +43,8 @@ class freqai_test_strat(IStrategy):
)
max_roi_time_long = IntParameter(0, 800, default=400, space="sell", optimize=False, load=True)
def feature_engineering_expand_all(self, dataframe, period, **kwargs):
def feature_engineering_expand_all(self, dataframe: DataFrame, period: int,
metadata: Dict, **kwargs):
dataframe["%-rsi-period"] = ta.RSI(dataframe, timeperiod=period)
dataframe["%-mfi-period"] = ta.MFI(dataframe, timeperiod=period)
@@ -50,7 +52,7 @@ class freqai_test_strat(IStrategy):
return dataframe
def feature_engineering_expand_basic(self, dataframe: DataFrame, **kwargs):
def feature_engineering_expand_basic(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["%-pct-change"] = dataframe["close"].pct_change()
dataframe["%-raw_volume"] = dataframe["volume"]
@@ -58,14 +60,14 @@ class freqai_test_strat(IStrategy):
return dataframe
def feature_engineering_standard(self, dataframe, **kwargs):
def feature_engineering_standard(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["%-day_of_week"] = dataframe["date"].dt.dayofweek
dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
return dataframe
def set_freqai_targets(self, dataframe, **kwargs):
def set_freqai_targets(self, dataframe: DataFrame, metadata: Dict, **kwargs):
dataframe["&-s_close"] = (
dataframe["close"]