Update some areas to use default docstring formatting

This commit is contained in:
Matthias 2022-07-24 16:51:48 +02:00
parent 61c41fd919
commit 70b7a254af
5 changed files with 59 additions and 71 deletions

View File

@ -183,12 +183,11 @@ various configuration parameters which multiply the feature set such as `include
(see convention below). I.e. user should not prepend any supporting metrics (see convention below). I.e. user should not prepend any supporting metrics
(e.g. bb_lowerband below) with % unless they explicitly want to pass that metric to the (e.g. bb_lowerband below) with % unless they explicitly want to pass that metric to the
model. model.
:params: :param pair: pair to be used as informative
:pair: pair to be used as informative :param df: strategy dataframe which will receive merges from informatives
:df: strategy dataframe which will receive merges from informatives :param tf: timeframe of the dataframe which will modify the feature names
:tf: timeframe of the dataframe which will modify the feature names :param informative: the dataframe associated with the informative pair
:informative: the dataframe associated with the informative pair :param coin: the name of the coin which will modify the feature names.
:coin: the name of the coin which will modify the feature names.
""" """
with self.freqai.lock: with self.freqai.lock:

View File

@ -163,13 +163,12 @@ class FreqaiDataDrawer:
Locate and load existing model metadata from persistent storage. If not located, 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 create a new one and append the current pair to it and prepare it for its first
training training
:params: :param pair: str: pair to lookup
metadata: dict = strategy furnished pair metadata :return:
:returns: model_filename: str = unique filename used for loading persistent objects from disk
model_filename: str = unique filename used for loading persistent objects from disk trained_timestamp: int = the last time the coin was trained
trained_timestamp: int = the last time the coin was trained coin_first: bool = If the coin is fresh without metadata
coin_first: bool = If the coin is fresh without metadata return_null_array: bool = Follower could not find pair metadata
return_null_array: bool = Follower could not find pair metadata
""" """
pair_in_dict = self.pair_dict.get(pair) pair_in_dict = self.pair_dict.get(pair)
data_path_set = self.pair_dict.get(pair, {}).get("data_path", None) data_path_set = self.pair_dict.get(pair, {}).get("data_path", None)
@ -277,13 +276,12 @@ class FreqaiDataDrawer:
) )
df = pd.concat([prepend_df, df], axis=0) df = pd.concat([prepend_df, df], axis=0)
def attach_return_values_to_return_dataframe(self, pair: str, dataframe) -> DataFrame: def attach_return_values_to_return_dataframe(
self, pair: str, dataframe: DataFrame) -> DataFrame:
""" """
Attach the return values to the strat dataframe Attach the return values to the strat dataframe
:params: :param dataframe: DataFrame = strategy dataframe
dataframe: DataFrame = strat dataframe :return: DataFrame = strat dataframe with return values attached
:returns:
dataframe: DataFrame = strat dataframe with return values attached
""" """
df = self.model_return_values[pair] df = self.model_return_values[pair]
to_keep = [col for col in dataframe.columns if not col.startswith("&")] to_keep = [col for col in dataframe.columns if not col.startswith("&")]

View File

@ -129,8 +129,7 @@ class IFreqaiModel(ABC):
Function designed to constantly scan pairs for retraining on a separate thread (intracandle) Function designed to constantly scan pairs for retraining on a separate thread (intracandle)
to improve model youth. This function is agnostic to data preparation/collection/storage, to improve model youth. This function is agnostic to data preparation/collection/storage,
it simply trains on what ever data is available in the self.dd. it simply trains on what ever data is available in the self.dd.
:params: :param strategy: IStrategy = The user defined strategy class
strategy: IStrategy = The user defined strategy class
""" """
while 1: while 1:
time.sleep(1) time.sleep(1)
@ -164,12 +163,11 @@ class IFreqaiModel(ABC):
following the training window). FreqAI slides the window and sequentially builds following the training window). FreqAI slides the window and sequentially builds
the backtesting results before returning the concatenated results for the full the backtesting results before returning the concatenated results for the full
backtesting period back to the strategy. backtesting period back to the strategy.
:params: :param dataframe: DataFrame = strategy passed dataframe
dataframe: DataFrame = strategy passed dataframe :param metadata: Dict = pair metadata
metadata: Dict = pair metadata :param dk: FreqaiDataKitchen = Data management/analysis tool associated to present pair only
dk: FreqaiDataKitchen = Data management/analysis tool assoicated to present pair only :return:
:returns: FreqaiDataKitchen = Data management/analysis tool associated to present pair only
dk: FreqaiDataKitchen = Data management/analysis tool assoicated to present pair only
""" """
self.pair_it += 1 self.pair_it += 1
@ -239,13 +237,12 @@ class IFreqaiModel(ABC):
""" """
The main broad execution for dry/live. This function will check if a retraining should be The main broad execution for dry/live. This function will check if a retraining should be
performed, and if so, retrain and reset the model. performed, and if so, retrain and reset the model.
:params: :param dataframe: DataFrame = strategy passed dataframe
dataframe: DataFrame = strategy passed dataframe :param metadata: Dict = pair metadata
metadata: Dict = pair metadata :param strategy: IStrategy = currently employed strategy
strategy: IStrategy = currently employed strategy dk: FreqaiDataKitchen = Data management/analysis tool associated to present pair only
dk: FreqaiDataKitchen = Data management/analysis tool assoicated to present pair only
:returns: :returns:
dk: FreqaiDataKitchen = Data management/analysis tool assoicated to present pair only dk: FreqaiDataKitchen = Data management/analysis tool associated to present pair only
""" """
# update follower # update follower
@ -353,9 +350,9 @@ class IFreqaiModel(ABC):
""" """
Ensure user is passing the proper feature set if they are reusing an `identifier` pointing Ensure user is passing the proper feature set if they are reusing an `identifier` pointing
to a folder holding existing models. to a folder holding existing models.
:params: :param dataframe: DataFrame = strategy provided dataframe
dataframe: DataFrame = strategy provided dataframe :param dk: FreqaiDataKitchen = non-persistent data container/analyzer for
dk: FreqaiDataKitchen = non-persistent data container/analyzer for current coin/bot loop current coin/bot loop
""" """
dk.find_features(dataframe) dk.find_features(dataframe)
if "training_features_list_raw" in dk.data: if "training_features_list_raw" in dk.data:
@ -461,13 +458,14 @@ class IFreqaiModel(ABC):
""" """
Retreive data and train model in single threaded mode (only used if model directory is empty Retreive data and train model in single threaded mode (only used if model directory is empty
upon startup for dry/live ) upon startup for dry/live )
:params: :param new_trained_timerange: TimeRange = the timerange to train the model on
new_trained_timerange: TimeRange = the timerange to train the model on :param metadata: dict = strategy provided metadata
metadata: dict = strategy provided metadata :param strategy: IStrategy = user defined strategy object
strategy: IStrategy = user defined strategy object :param dk: FreqaiDataKitchen = non-persistent data container for current coin/loop
dk: FreqaiDataKitchen = non-persistent data container for current coin/loop :param data_load_timerange: TimeRange = the amount of data to be loaded
data_load_timerange: TimeRange = the amount of data to be loaded for populate_any_indicators for populate_any_indicators
(larger than new_trained_timerange so that new_trained_timerange does not contain any NaNs) (larger than new_trained_timerange so that
new_trained_timerange does not contain any NaNs)
""" """
corr_dataframes, base_dataframes = dk.get_base_and_corr_dataframes( corr_dataframes, base_dataframes = dk.get_base_and_corr_dataframes(
@ -515,11 +513,9 @@ class IFreqaiModel(ABC):
""" """
Filter the training data and train a model to it. Train makes heavy use of the datahandler Filter the training data and train a model to it. Train makes heavy use of the datahandler
for storing, saving, loading, and analyzing the data. for storing, saving, loading, and analyzing the data.
:params: :param unfiltered_dataframe: Full dataframe for the current training period
:unfiltered_dataframe: Full dataframe for the current training period :param metadata: pair metadata from strategy.
:metadata: pair metadata from strategy. :return: Trained model which can be used to inference (self.predict)
:returns:
:model: Trained model which can be used to inference (self.predict)
""" """
@abstractmethod @abstractmethod
@ -528,9 +524,8 @@ class IFreqaiModel(ABC):
Most regressors use the same function names and arguments e.g. user Most regressors use the same function names and arguments e.g. user
can drop in LGBMRegressor in place of CatBoostRegressor and all data can drop in LGBMRegressor in place of CatBoostRegressor and all data
management will be properly handled by Freqai. management will be properly handled by Freqai.
:params: :param data_dictionary: Dict = the dictionary constructed by DataHandler to hold
data_dictionary: Dict = the dictionary constructed by DataHandler to hold all the training and test data/labels.
all the training and test data/labels.
""" """
return return
@ -541,9 +536,9 @@ class IFreqaiModel(ABC):
) -> Tuple[DataFrame, npt.ArrayLike]: ) -> Tuple[DataFrame, npt.ArrayLike]:
""" """
Filter the prediction features data and predict with it. Filter the prediction features data and predict with it.
:param: :param unfiltered_dataframe: Full dataframe for the current backtest period.
unfiltered_dataframe: Full dataframe for the current backtest period. :param dk: FreqaiDataKitchen = Data management/analysis tool associated to present pair only
dk: FreqaiDataKitchen = Data management/analysis tool assoicated to present pair only :param first: boolean = whether this is the first prediction or not.
:return: :return:
:predictions: np.array of predictions :predictions: np.array of predictions
:do_predict: np.array of 1s and 0s to indicate places where freqai needed to remove :do_predict: np.array of 1s and 0s to indicate places where freqai needed to remove
@ -554,12 +549,10 @@ class IFreqaiModel(ABC):
def return_values(self, dataframe: DataFrame, dk: FreqaiDataKitchen) -> DataFrame: def return_values(self, dataframe: DataFrame, dk: FreqaiDataKitchen) -> DataFrame:
""" """
User defines the dataframe to be returned to strategy here. User defines the dataframe to be returned to strategy here.
:params: :param dataframe: DataFrame = the full dataframe for the current prediction (live)
dataframe: DataFrame = the full dataframe for the current prediction (live) or --timerange (backtesting)
or --timerange (backtesting) :param dk: FreqaiDataKitchen = Data management/analysis tool associated to present pair only
dk: FreqaiDataKitchen = Data management/analysis tool assoicated to present pair only :return: dataframe: DataFrame = dataframe filled with user defined data
:returns:
dataframe: DataFrame = dataframe filled with user defined data
""" """
return return

View File

@ -566,12 +566,11 @@ class IStrategy(ABC, HyperStrategyMixin):
additional features here, but must follow the naming convention. additional features here, but must follow the naming convention.
This method is *only* used in FreqaiDataKitchen class and therefore This method is *only* used in FreqaiDataKitchen class and therefore
it is only called if FreqAI is active. it is only called if FreqAI is active.
:params: :param pair: pair to be used as informative
:pair: pair to be used as informative :param df: strategy dataframe which will receive merges from informatives
:df: strategy dataframe which will receive merges from informatives :param tf: timeframe of the dataframe which will modify the feature names
:tf: timeframe of the dataframe which will modify the feature names :param informative: the dataframe associated with the informative pair
:informative: the dataframe associated with the informative pair :param coin: the name of the coin which will modify the feature names.
:coin: the name of the coin which will modify the feature names.
""" """
return df return df

View File

@ -74,12 +74,11 @@ class FreqaiExampleStrategy(IStrategy):
(see convention below). I.e. user should not prepend any supporting metrics (see convention below). I.e. user should not prepend any supporting metrics
(e.g. bb_lowerband below) with % unless they explicitly want to pass that metric to the (e.g. bb_lowerband below) with % unless they explicitly want to pass that metric to the
model. model.
:params: :param pair: pair to be used as informative
:pair: pair to be used as informative :param df: strategy dataframe which will receive merges from informatives
:df: strategy dataframe which will receive merges from informatives :param tf: timeframe of the dataframe which will modify the feature names
:tf: timeframe of the dataframe which will modify the feature names :param informative: the dataframe associated with the informative pair
:informative: the dataframe associated with the informative pair :param coin: the name of the coin which will modify the feature names.
:coin: the name of the coin which will modify the feature names.
""" """
with self.freqai.lock: with self.freqai.lock: