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.
This commit is contained in:
richardjozsa 2022-11-27 20:43:50 +01:00
parent 320535a227
commit 64d4a52a56
1 changed files with 4 additions and 0 deletions

View File

@ -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]