PHASE 2 ENHANCED: Manual trades now wait for next 1-minute datapoint instead of using cached/stale data. Guarantees fresh ATR (<60s old). User requirement: 'when i send a telegram message to enter the market, the bot will simply wait for the next 1 minute datapoint' Implementation: - Add wait_for_fresh_market_data() async helper function - Polls market data cache every 5 seconds (max 60s) - Detects fresh data by timestamp change - Extracts real ATR/ADX/RSI from 1-minute TradingView data - User sees waiting message + confirmation when fresh data arrives - Falls back to preset ATR 0.43 on timeout (fail-safe) Benefits: - Adaptive targets match CURRENT volatility (not historical) - No stale data risk (guaranteed <60s old) - Better than Phase 2 v1 (5-minute tolerance) - Consistent with automated trades (same 1-min data source) User Experience: 1. User: /long sol 2. Bot: ⏳ Waiting for next 1-minute datapoint... 3. [Wait 15-45 seconds typically] 4. Bot: ✅ Fresh ATR: 0.4523 | ADX: 34.2 | RSI: 56.8 5. Bot: ✅ Position opened with adaptive targets Changes: - Add asyncio import for async sleep - Add wait_for_fresh_market_data() before manual_trade_handler - Replace Phase 2 v1 (5min tolerance) with polling logic - Add 3 user messages (waiting, confirmation, timeout) - Extract ATR/ADX/RSI from fresh data or fallback Files: - telegram_command_bot.py: +70 lines polling logic
35 KiB
35 KiB