Skip to content

Commit

Permalink
polish(cy): polish anytrading (#731)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloud-Pku authored Sep 20, 2023
1 parent 5d59c81 commit 6a26e98
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dizoo/gym_anytrading/envs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ If profit or loss occurs, it means that one of the following two cycles in state

According to the above definition, we can easily know that the formula of accumulative profit is:

$\prod_{buying\ long}(r_{curr}/r_{pre}\ *\ cost) + \prod_{short\ selling}((2-r_{curr}/r_{pre})\ *\ cost)$
$\prod_{buying\ long}(r_{curr}/r_{pre}\ *\ cost) * \prod_{short\ selling}((2-r_{curr}/r_{pre})\ *\ cost)$


### Reward Function
Expand Down
Binary file modified dizoo/gym_anytrading/envs/statemachine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dizoo/gym_anytrading/envs/stocks_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def _process_data(self, start_idx: int = None) -> Any:
# validate index
if start_idx is None:
if self.train_range == None or self.test_range == None:
self.start_idx = np.random.randint(self.window_size, len(self.df) - self._cfg.eps_length)
self.start_idx = np.random.randint(self.window_size - 1, len(self.df) - self._cfg.eps_length)
elif self._env_id[-1] == 'e':
boundary = int(len(self.df) * (1 + self.test_range))
assert len(self.df) - self._cfg.eps_length > boundary + self.window_size,\
Expand Down

0 comments on commit 6a26e98

Please sign in to comment.