fix: simulation conditions now check properly from first iteration
The first price check was always skipped because last_price was None. Now first iteration primes last_price, subsequent iterations check conditions.
This commit is contained in:
@@ -69,12 +69,14 @@ class SimulateEngine:
|
|||||||
current_volume = float(price_data.get("volume", 0))
|
current_volume = float(price_data.get("volume", 0))
|
||||||
|
|
||||||
if current_price > 0:
|
if current_price > 0:
|
||||||
await self._check_conditions(
|
# Only check conditions if we have a previous price to compare
|
||||||
current_price, current_volume, price_data
|
if self.last_price is not None:
|
||||||
)
|
await self._check_conditions(
|
||||||
|
current_price, current_volume, price_data
|
||||||
self.last_price = current_price
|
)
|
||||||
self.last_volume = current_volume
|
# Update last price AFTER checking (so next iteration has comparison data)
|
||||||
|
self.last_price = current_price
|
||||||
|
self.last_volume = current_volume
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to get price for {token_id}: {e}")
|
logger.warning(f"Failed to get price for {token_id}: {e}")
|
||||||
|
|||||||
Reference in New Issue
Block a user