remove keep low profit

This commit is contained in:
sonnhfit 2022-08-18 17:53:52 +07:00 committed by robcaulk
parent 81b5aa66e8
commit 7962a1439b

View File

@ -127,25 +127,17 @@ class Base3ActionRLEnv(gym.Env):
Action: Short, position: Long -> Close Long and Open Short Action: Short, position: Long -> Close Long and Open Short
""" """
u_pnl = self.get_unrealized_profit() if action == Actions.Neutral.value:
# keep current position if upnl from -0.4% to 0.4% self._position = Positions.Neutral
if u_pnl <= 0.004 and u_pnl >= -0.004 and self._position != Positions.Neutral: trade_type = "neutral"
if action == Actions.Long.value and self._position == Positions.Short: elif action == Actions.Long.value:
self._position = Positions.Short self._position = Positions.Long
elif action == Actions.Short.value and self._position == Positions.Long: trade_type = "long"
self._position = Positions.Long elif action == Actions.Short.value:
self._position = Positions.Short
trade_type = "short"
else: else:
if action == Actions.Neutral.value: print("case not defined")
self._position = Positions.Neutral
trade_type = "neutral"
elif action == Actions.Long.value:
self._position = Positions.Long
trade_type = "long"
elif action == Actions.Short.value:
self._position = Positions.Short
trade_type = "short"
else:
print("case not defined")
# Update last trade tick # Update last trade tick
self._last_trade_tick = self._current_tick self._last_trade_tick = self._current_tick