diff --git a/gym_mtsim/envs/mt_env.py b/gym_mtsim/envs/mt_env.py index f452c48..ea15445 100644 --- a/gym_mtsim/envs/mt_env.py +++ b/gym_mtsim/envs/mt_env.py @@ -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] }) diff --git a/gym_mtsim/simulator/mt_simulator.py b/gym_mtsim/simulator/mt_simulator.py index 2df7747..0b4c86a 100644 --- a/gym_mtsim/simulator/mt_simulator.py +++ b/gym_mtsim/simulator/mt_simulator.py @@ -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