Files
stocksearch/models/autotrade.go
hayato5246 5aeb5f2b80
Some checks failed
Build Push and Restart Compose / deploy (push) Failing after 11m20s
자산 현황 및 자동매매 페이지 제거:
- `/templates/pages/asset.html`, `/templates/pages/autotrade.html` HTML 템플릿 삭제.
- `/static/js/asset.js`, `/static/js/autotrade.js` 클라이언트 스크립트 제거.
- 관련 함수 및 초기화 로직 삭제 (자산 조회 및 자동매매 기능 비활성화).
2026-04-07 21:43:24 +09:00

78 lines
3.4 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)
// 청산 조건
// 2중 손절 구조:
// 1차 - StopLoss1Pct 에 StopLoss1Count 회 터치 시 매도
// 2차 - StopLossPct 에 닿으면 즉시 매도 (StopLoss1Count==0 이면 단일 손절)
StopLoss1Pct float64 `json:"stopLoss1Pct"` // 1차 손절 % (예: -2.0, 0=비활성)
StopLoss1Count int `json:"stopLoss1Count"` // 1차 손절 터치 횟수 (예: 3)
StopLossPct float64 `json:"stopLossPct"` // 2차 손절 % (예: -4.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 {
DBID int `json:"-"` // DB 시퀀스 ID (API 노출 안함)
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
StopLoss1 int64 `json:"stopLoss1"` // 절대 1차 손절가 (0=비활성)
StopLoss1Touches int `json:"stopLoss1Touches"` // 1차 손절가 터치 누적 횟수
StopLoss int64 `json:"stopLoss"` // 절대 2차 손절가 (즉시 매도)
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"` // 감시할 테마 목록
}