fix: Update stop loss check to use open_price instead of price
This commit is contained in:
parent
04e2cf1d02
commit
03e454cb09
@ -103,7 +103,7 @@ class DynamicStrategy(Strategy):
|
|||||||
if self.position and self.position.size > 0: # Make sure we have an active position
|
if self.position and self.position.size > 0: # Make sure we have an active position
|
||||||
try:
|
try:
|
||||||
# Calculate the percentage loss from entry
|
# Calculate the percentage loss from entry
|
||||||
entry_price = self.position.price # Changed from entry to price
|
entry_price = self.position.open_price # Changed from price to open_price
|
||||||
current_loss = ((price - entry_price) / entry_price) * 100
|
current_loss = ((price - entry_price) / entry_price) * 100
|
||||||
|
|
||||||
# If loss exceeds 7%, close the position
|
# If loss exceeds 7%, close the position
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user