fix: Correct entry price attribute in stop loss check

This commit is contained in:
Bobby (aider) 2025-02-13 23:47:38 -08:00
parent a755e12ca0
commit 531d356bf0

View File

@ -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.entry_price # Changed from entry to entry_price entry_price = self.position.entry # Changed from entry_price to entry
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