Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2f2a7665e7 | |||
| 7eaff3ae58 | |||
| f99fc7fdc1 |
@@ -946,6 +946,27 @@ class TradingEngine:
|
|||||||
if pos_match is None:
|
if pos_match is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Suppress take-profit when a strong buy signal is active
|
||||||
|
if trigger.trigger_type == "take_profit" and self.pool is not None:
|
||||||
|
try:
|
||||||
|
active_buy = await self.pool.fetchrow(
|
||||||
|
"SELECT confidence FROM recommendations "
|
||||||
|
"WHERE ticker = $1 AND action = 'buy' "
|
||||||
|
"AND mode IN ('paper_eligible', 'live_eligible') "
|
||||||
|
"AND generated_at > NOW() - INTERVAL '2 hours' "
|
||||||
|
"ORDER BY confidence DESC LIMIT 1",
|
||||||
|
trigger.ticker,
|
||||||
|
)
|
||||||
|
if active_buy and float(active_buy["confidence"]) >= 0.80:
|
||||||
|
logger.info(
|
||||||
|
"Suppressing take-profit for %s — active buy signal (confidence=%.3f)",
|
||||||
|
trigger.ticker,
|
||||||
|
float(active_buy["confidence"]),
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
except Exception:
|
||||||
|
pass # On error, proceed with the take-profit
|
||||||
|
|
||||||
await self._submit_sell_order(
|
await self._submit_sell_order(
|
||||||
trigger.ticker,
|
trigger.ticker,
|
||||||
pos_match.quantity,
|
pos_match.quantity,
|
||||||
|
|||||||
Reference in New Issue
Block a user