make env keep current position when low profit
This commit is contained in:
parent
45218faeb0
commit
81b5aa66e8
@ -127,6 +127,14 @@ 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()
|
||||||
|
# keep current position if upnl from -0.4% to 0.4%
|
||||||
|
if u_pnl <= 0.004 and u_pnl >= -0.004 and self._position != Positions.Neutral:
|
||||||
|
if action == Actions.Long.value and self._position == Positions.Short:
|
||||||
|
self._position = Positions.Short
|
||||||
|
elif action == Actions.Short.value and self._position == Positions.Long:
|
||||||
|
self._position = Positions.Long
|
||||||
|
else:
|
||||||
if action == Actions.Neutral.value:
|
if action == Actions.Neutral.value:
|
||||||
self._position = Positions.Neutral
|
self._position = Positions.Neutral
|
||||||
trade_type = "neutral"
|
trade_type = "neutral"
|
||||||
|
Loading…
Reference in New Issue
Block a user