mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-17 21:31:14 +00:00
chore: update freqai to modern typing syntax
This commit is contained in:
@@ -4,7 +4,7 @@ import logging
|
||||
from abc import abstractmethod
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Dict, Optional, Tuple, Type, Union
|
||||
from typing import Any, Callable, Optional, Union
|
||||
|
||||
import gymnasium as gym
|
||||
import numpy as np
|
||||
@@ -114,7 +114,7 @@ class BaseReinforcementLearningModel(IFreqaiModel):
|
||||
training_filter=True,
|
||||
)
|
||||
|
||||
dd: Dict[str, Any] = dk.make_train_test_datasets(features_filtered, labels_filtered)
|
||||
dd: dict[str, Any] = dk.make_train_test_datasets(features_filtered, labels_filtered)
|
||||
self.df_raw = copy.deepcopy(dd["train_features"])
|
||||
dk.fit_labels() # FIXME useless for now, but just satiating append methods
|
||||
|
||||
@@ -151,7 +151,7 @@ class BaseReinforcementLearningModel(IFreqaiModel):
|
||||
|
||||
def set_train_and_eval_environments(
|
||||
self,
|
||||
data_dictionary: Dict[str, DataFrame],
|
||||
data_dictionary: dict[str, DataFrame],
|
||||
prices_train: DataFrame,
|
||||
prices_test: DataFrame,
|
||||
dk: FreqaiDataKitchen,
|
||||
@@ -183,7 +183,7 @@ class BaseReinforcementLearningModel(IFreqaiModel):
|
||||
actions = self.train_env.get_actions()
|
||||
self.tensorboard_callback = TensorboardCallback(verbose=1, actions=actions)
|
||||
|
||||
def pack_env_dict(self, pair: str) -> Dict[str, Any]:
|
||||
def pack_env_dict(self, pair: str) -> dict[str, Any]:
|
||||
"""
|
||||
Create dictionary of environment arguments
|
||||
"""
|
||||
@@ -204,7 +204,7 @@ class BaseReinforcementLearningModel(IFreqaiModel):
|
||||
return env_info
|
||||
|
||||
@abstractmethod
|
||||
def fit(self, data_dictionary: Dict[str, Any], dk: FreqaiDataKitchen, **kwargs):
|
||||
def fit(self, data_dictionary: dict[str, Any], dk: FreqaiDataKitchen, **kwargs):
|
||||
"""
|
||||
Agent customizations and abstract Reinforcement Learning customizations
|
||||
go in here. Abstract method, so this function must be overridden by
|
||||
@@ -212,7 +212,7 @@ class BaseReinforcementLearningModel(IFreqaiModel):
|
||||
"""
|
||||
return
|
||||
|
||||
def get_state_info(self, pair: str) -> Tuple[float, float, int]:
|
||||
def get_state_info(self, pair: str) -> tuple[float, float, int]:
|
||||
"""
|
||||
State info during dry/live (not backtesting) which is fed back
|
||||
into the model.
|
||||
@@ -250,7 +250,7 @@ class BaseReinforcementLearningModel(IFreqaiModel):
|
||||
|
||||
def predict(
|
||||
self, unfiltered_df: DataFrame, dk: FreqaiDataKitchen, **kwargs
|
||||
) -> Tuple[DataFrame, npt.NDArray[np.int_]]:
|
||||
) -> tuple[DataFrame, npt.NDArray[np.int_]]:
|
||||
"""
|
||||
Filter the prediction features data and predict with it.
|
||||
:param unfiltered_dataframe: Full dataframe for the current backtest period.
|
||||
@@ -303,7 +303,7 @@ class BaseReinforcementLearningModel(IFreqaiModel):
|
||||
|
||||
def build_ohlc_price_dataframes(
|
||||
self, data_dictionary: dict, pair: str, dk: FreqaiDataKitchen
|
||||
) -> Tuple[DataFrame, DataFrame]:
|
||||
) -> tuple[DataFrame, DataFrame]:
|
||||
"""
|
||||
Builds the train prices and test prices for the environment.
|
||||
"""
|
||||
@@ -482,13 +482,13 @@ class BaseReinforcementLearningModel(IFreqaiModel):
|
||||
|
||||
|
||||
def make_env(
|
||||
MyRLEnv: Type[BaseEnvironment],
|
||||
MyRLEnv: type[BaseEnvironment],
|
||||
env_id: str,
|
||||
rank: int,
|
||||
seed: int,
|
||||
train_df: DataFrame,
|
||||
price: DataFrame,
|
||||
env_info: Dict[str, Any] = {},
|
||||
env_info: dict[str, Any] = {},
|
||||
) -> Callable:
|
||||
"""
|
||||
Utility function for multiprocessed env.
|
||||
|
||||
Reference in New Issue
Block a user