feat: add position monitor logging with real-time price tracking

Log current price and unrealized PnL every 5 minutes while holding a position,
using the existing kline WebSocket's unclosed candle data for real-time price updates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
21in7
2026-03-03 20:36:46 +09:00
parent 292ecc3e33
commit a33283ecb3
4 changed files with 119 additions and 0 deletions

View File

@@ -116,6 +116,8 @@ class MultiSymbolStream:
}
# 첫 번째 심볼이 주 심볼 (XRP)
self.primary_symbol = self.symbols[0]
# 미종료 캔들 포함 최신 가격 (포지션 모니터링용)
self.latest_price: float | None = None
def parse_kline(self, msg: dict) -> dict:
k = msg["k"]
@@ -142,6 +144,9 @@ class MultiSymbolStream:
symbol = data["s"].lower()
candle = self.parse_kline(data)
if symbol == self.primary_symbol:
self.latest_price = candle["close"]
if candle["is_closed"] and symbol in self.buffers:
self.buffers[symbol].append(candle)
if symbol == self.primary_symbol and self.on_candle: