Skip to content

Commit

Permalink
Merge pull request #30 from nexon33/main
Browse files Browse the repository at this point in the history
Fix action and space bounds
  • Loading branch information
AminHP authored Mar 17, 2023
2 parents 96ae011 + 917ef62 commit d4baed8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions gym_mtsim/envs/mt_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,18 @@ def __init__(

# spaces
self.action_space = spaces.Box(
low=-1e10, high=1e10, dtype=np.float64,
low=-1e2, high=1e2, dtype=np.float64,
shape=(len(self.trading_symbols) * (self.symbol_max_orders + 2),)
) # symbol -> [close_order_i(logit), hold(logit), volume]

INF = 1e10
self.observation_space = spaces.Dict({
'balance': spaces.Box(low=-np.inf, high=np.inf, shape=(1,), dtype=np.float64),
'equity': spaces.Box(low=-np.inf, high=np.inf, shape=(1,), dtype=np.float64),
'margin': spaces.Box(low=-np.inf, high=np.inf, shape=(1,), dtype=np.float64),
'features': spaces.Box(low=-np.inf, high=np.inf, shape=self.features_shape, dtype=np.float64),
'balance': spaces.Box(low=-INF, high=INF, shape=(1,), dtype=np.float64),
'equity': spaces.Box(low=-INF, high=INF, shape=(1,), dtype=np.float64),
'margin': spaces.Box(low=-INF, high=INF, shape=(1,), dtype=np.float64),
'features': spaces.Box(low=-INF, high=INF, shape=self.features_shape, dtype=np.float64),
'orders': spaces.Box(
low=-np.inf, high=np.inf, dtype=np.float64,
low=-INF, high=INF, dtype=np.float64,
shape=(len(self.trading_symbols), self.symbol_max_orders, 3)
) # symbol, order_i -> [entry_price, volume, profit]
})
Expand Down
2 changes: 1 addition & 1 deletion gym_mtsim/simulator/mt_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def free_margin(self) -> float:
def margin_level(self) -> float:
margin = round(self.margin, 6)
if margin == 0.:
return np.inf
return float('inf')
return self.equity / margin


Expand Down

0 comments on commit d4baed8

Please sign in to comment.