Files
stocksearch/models/autotrade.go
2026-03-31 19:32:59 +09:00

70 lines
2.6 KiB
Go

package models
import "time"
// AutoTradeRule 자동매매 규칙
type AutoTradeRule struct {
ID string `json:"id"`
Name string `json:"name"`
// 활성화 여부
Enabled bool `json:"enabled"`
// 진입 조건 (ScannerService 신호 기반)
MinRiseScore int `json:"minRiseScore"` // 최소 상승점수 (0~100, 기본 60)
MinCntrStr float64 `json:"minCntrStr"` // 최소 체결강도 (기본 110)
RequireBullish bool `json:"requireBullish"` // AI 호재(Sentiment=="호재") 필요 여부
// 주문 설정
OrderAmount int64 `json:"orderAmount"` // 1종목당 주문금액(원)
MaxPositions int `json:"maxPositions"` // 동시 최대 보유 종목 수 (기본 3)
// 청산 조건
StopLossPct float64 `json:"stopLossPct"` // 손절 % (예: -3.0)
TakeProfitPct float64 `json:"takeProfitPct"` // 익절 % (예: 5.0)
MaxHoldMinutes int `json:"maxHoldMinutes"` // 최대 보유 시간(분, 0=무제한)
ExitBeforeClose bool `json:"exitBeforeClose"` // 장 마감 전 청산(15:20 기준)
CreatedAt time.Time `json:"createdAt"`
}
// AutoTradePosition 자동매매 포지션
type AutoTradePosition struct {
Code string `json:"code"`
Name string `json:"name"`
BuyPrice int64 `json:"buyPrice"` // 매수 체결가
Qty int64 `json:"qty"` // 수량
OrderNo string `json:"orderNo"` // 매수 주문번호
EntryTime time.Time `json:"entryTime"` // 진입 시각
RuleID string `json:"ruleId"` // 규칙 ID
StopLoss int64 `json:"stopLoss"` // 절대 손절가
TakeProfit int64 `json:"takeProfit"` // 절대 익절가
// 상태: "pending"=체결 대기 | "open"=보유중 | "closed"=청산완료
Status string `json:"status"`
ExitTime time.Time `json:"exitTime,omitempty"`
ExitPrice int64 `json:"exitPrice,omitempty"`
// 청산 사유: "익절"|"손절"|"시간초과"|"장마감"|"긴급"
ExitReason string `json:"exitReason,omitempty"`
}
// AutoTradeLog 자동매매 이벤트 로그
type AutoTradeLog struct {
At time.Time `json:"at"`
Level string `json:"level"` // "info"|"warn"|"error"
Message string `json:"message"`
Code string `json:"code"` // 관련 종목코드 (없으면 "")
}
// ThemeRef 감시 소스로 선택된 테마 참조
type ThemeRef struct {
Code string `json:"code"` // 테마 코드
Name string `json:"name"` // 테마 이름 (UI 표시용)
}
// AutoTradeWatchSource 자동매매 감시 소스 설정
type AutoTradeWatchSource struct {
UseScanner bool `json:"useScanner"` // 체결강도 자동감지 사용
SelectedThemes []ThemeRef `json:"selectedThemes"` // 감시할 테마 목록
}