package com.goldenchart.trading.pipeline;

import com.goldenchart.service.LiveRiskMonitorService;
import com.goldenchart.websocket.BarBuilder;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * Core Engine — 단일 틱에 대한 캔들 조립 + 실시간 리스크 감시.
 */
@Component
@RequiredArgsConstructor
public class MarketTickProcessor {

    private final BarBuilder barBuilder;
    private final RealtimePositionMonitor positionMonitor;
    private final LiveRiskMonitorService liveRiskMonitor;
    private final TickActivityTracker activityTracker;

    public void process(TradeTickEvent event) {
        activityTracker.record(event.market());
        barBuilder.onTick(event.market(), event.tradePrice(), event.tradeVolume(), event.tradeTimeMs());
        positionMonitor.onTick(event.market(), event.tradePrice());
        liveRiskMonitor.onTick(event.market(), event.tradePrice());
    }
}
