package com.goldenchart.entity;

import jakarta.persistence.*;
import lombok.*;

import java.time.LocalDateTime;

/**
 * 실시간 전략 체크에서 발생한 매매 시그널 이력.
 */
@Entity
@Table(name = "gc_trade_signal")
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class GcTradeSignal {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "device_id", length = 100)
    private String deviceId;

    @Column(name = "user_id")
    private Long userId;

    @Column(name = "market", nullable = false, length = 30)
    private String market;

    @Column(name = "strategy_id")
    private Long strategyId;

    @Column(name = "strategy_name", length = 200)
    private String strategyName;

    /** BUY | SELL */
    @Column(name = "signal_type", nullable = false, length = 10)
    private String signalType;

    @Column(name = "price", nullable = false)
    private Double price;

    /** 캔들 시작 Unix 초 */
    @Column(name = "candle_time", nullable = false)
    private Long candleTime;

    @Column(name = "candle_type", nullable = false, length = 10)
    @Builder.Default
    private String candleType = "1m";

    /** CANDLE_CLOSE | REALTIME_TICK */
    @Column(name = "execution_type", nullable = false, length = 30)
    private String executionType;

    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;

    @PrePersist
    protected void onCreate() { createdAt = LocalDateTime.now(); }
}
