package com.goldenchart.trading.pipeline;

/**
 * 주문 실행 큐에 적재되는 모의투자 주문 요청.
 */
public record OrderRequest(
        OrderKind kind,
        String deviceId,
        Long userId,
        String market,
        Long strategyId,
        String side,
        double price,
        String reason
) {
    public enum OrderKind {
        STRATEGY_SIGNAL,
        STOP_LOSS,
        TAKE_PROFIT
    }

    public static OrderRequest strategySignal(String deviceId, Long userId, String market,
                                              Long strategyId, String side, double price) {
        return new OrderRequest(OrderKind.STRATEGY_SIGNAL, deviceId, userId, market,
                strategyId, side, price, "STRATEGY");
    }

    public static OrderRequest stopLoss(String deviceId, Long userId, String market,
                                        double price, double lossPct) {
        return new OrderRequest(OrderKind.STOP_LOSS, deviceId, userId, market,
                null, "SELL", price, "STOP_LOSS_" + lossPct + "%");
    }

    public static OrderRequest takeProfit(String deviceId, Long userId, String market,
                                          double price, double profitPct) {
        return new OrderRequest(OrderKind.TAKE_PROFIT, deviceId, userId, market,
                null, "SELL", price, "TAKE_PROFIT_" + profitPct + "%");
    }
}
