Skip to content

Commit

Permalink
Updated remaining_trades to fractional_remaining_trades and added sup…
Browse files Browse the repository at this point in the history
…port for more supplementary information to be output by the environment in the future
  • Loading branch information
samre12 committed Jun 1, 2018
1 parent 14850a0 commit 96cf28b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ env = gym.make('RealizedPnLEnv-v0')

- Use `env.reset()` to start a new random episode.

- returns history of observations prior to the starting point of the episode. Look [Parameters](#params) for more information.
- returns history of observations prior to the starting point of the episode, fractional remaining trades that is `[1.0]` at the start of the episode. Look [Parameters](#params) for more information.

```python
state = env.reset() # use state to make initial prediction
Expand All @@ -66,7 +66,7 @@ env = gym.make('RealizedPnLEnv-v0')

- Use `env.step(action)` to take one step in the environment.

- returns `(observation, reward, is_terminal, remaining_trades)` in respective order
- returns `(observation, reward, is_terminal, fractional_remaining_trades)` in respective order

```python
observation, reward, is_terminal, remaining_trades = env.step(action)
Expand Down Expand Up @@ -215,4 +215,6 @@ Listing changes from [**`b9af98db728230569a18d54dcfa87f7337930314`**](https://gi

### Breaking Changes

- Environment with **Unrealized PnL** reward function is now built using `env = gym.make('UnrealizedPnLEnv-v0')` rather than `env = gym.make('CryptoTrading-v0')`
- Environment with **Unrealized PnL** reward function is now built using `env = gym.make('UnrealizedPnLEnv-v0')` rather than `env = gym.make('CryptoTrading-v0')`

- Instead of `remaining_trades`, `env.step(action)` now outputs `np.array([fractional_remaining_trades])`. This is to take into account more supplementary information (like **technical indicators**) in the future
2 changes: 1 addition & 1 deletion gym_cryptotrading/envs/cryptoenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _new_random_episode(self):

map(self.logger.debug, message_list)

return self.historical_prices[self.current - self.history_length:self.current]
return self.historical_prices[self.current - self.history_length:self.current], np.array([1.0])


def _reset_params(self):
Expand Down
4 changes: 2 additions & 2 deletions gym_cryptotrading/envs/realizedPnL.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ def step(self, action):
self.timesteps = self.timesteps + 1
if self.timesteps is not self.horizon:
self.current = self.current + 1
return state, reward, False, float(self.horizon - self.timesteps)
return state, reward, False, np.array([float(self.horizon - self.timesteps) / self.horizon])
else:
return state, reward, True, 0.0
return state, reward, True, np.array([0.0])
4 changes: 2 additions & 2 deletions gym_cryptotrading/envs/unrealizedPnL.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def step(self, action):
self.timesteps = self.timesteps + 1
if self.timesteps is not self.horizon:
self.current = self.current + 1
return state, reward, False, float(self.horizon - self.timesteps)
return state, reward, False, np.array([float(self.horizon - self.timesteps) / self.horizon])
else:
return state, reward, True, 0.0
return state, reward, True, np.array([0.0])

4 changes: 2 additions & 2 deletions gym_cryptotrading/envs/weightedPnL.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ def step(self, action):
self.timesteps = self.timesteps + 1
if self.timesteps is not self.horizon:
self.current = self.current + 1
return state, reward, False, float(self.horizon - self.timesteps)
return state, reward, False, np.array([float(self.horizon - self.timesteps) / self.horizon])
else:
return state, reward, True, 0.0
return state, reward, True, np.array([0.0])

0 comments on commit 96cf28b

Please sign in to comment.