make env keep current position when low profit
This commit is contained in:
parent
45218faeb0
commit
81b5aa66e8
@ -127,17 +127,25 @@ class Base3ActionRLEnv(gym.Env):
|
|||||||
Action: Short, position: Long -> Close Long and Open Short
|
Action: Short, position: Long -> Close Long and Open Short
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if action == Actions.Neutral.value:
|
u_pnl = self.get_unrealized_profit()
|
||||||
self._position = Positions.Neutral
|
# keep current position if upnl from -0.4% to 0.4%
|
||||||
trade_type = "neutral"
|
if u_pnl <= 0.004 and u_pnl >= -0.004 and self._position != Positions.Neutral:
|
||||||
elif action == Actions.Long.value:
|
if action == Actions.Long.value and self._position == Positions.Short:
|
||||||
self._position = Positions.Long
|
self._position = Positions.Short
|
||||||
trade_type = "long"
|
elif action == Actions.Short.value and self._position == Positions.Long:
|
||||||
elif action == Actions.Short.value:
|
self._position = Positions.Long
|
||||||
self._position = Positions.Short
|
|
||||||
trade_type = "short"
|
|
||||||
else:
|
else:
|
||||||
print("case not defined")
|
if action == Actions.Neutral.value:
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user