From 64d4a52a5615ff9d5ddc2be693d8a79c002d0c9f Mon Sep 17 00:00:00 2001 From: richardjozsa Date: Sun, 27 Nov 2022 20:43:50 +0100 Subject: [PATCH] Improve the RL learning process Improve the RL learning process by selecting random start point for the agent, it can help to block the agent to only learn on the selected period of time, while improving the quality of the model. --- freqtrade/freqai/RL/BaseEnvironment.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/freqtrade/freqai/RL/BaseEnvironment.py b/freqtrade/freqai/RL/BaseEnvironment.py index 3332e5a18..5d881ba32 100644 --- a/freqtrade/freqai/RL/BaseEnvironment.py +++ b/freqtrade/freqai/RL/BaseEnvironment.py @@ -9,6 +9,7 @@ import pandas as pd from gym import spaces from gym.utils import seeding from pandas import DataFrame +import random from freqtrade.data.dataprovider import DataProvider @@ -121,6 +122,9 @@ class BaseEnvironment(gym.Env): self._done = False if self.starting_point is True: + length_of_data = int(self._end_tick/4) + start_tick = random.randint(self.window_size+1, length_of_data) + self._start_tick = start_tick self._position_history = (self._start_tick * [None]) + [self._position] else: self._position_history = (self.window_size * [None]) + [self._position]