인사이트 구조
인사이트는 거래 의도와, 나중에 해당 의도가 어떻게 처리되었는지 확인하는 데 필요한 실행 상태를 저장합니다.
핵심 필드는 다음과 같습니다.
- 심볼
- 매매 방향
- 신뢰도
- 타임프레임
- 상위 및 하위 관계
- 수량
- 계약 수
- 진입 구조
- 익절 및 손절 수준
- 트레일링 스톱 간격
- 체결가 및 청산가
- 브로커 실현 손익, 수수료, 스왑
- 실행 레그
- 상태 이력
pub struct Insight { pub insight_id: Uuid, pub parent_id: Option<Uuid>, pub state: InsightState, pub children: Vec<Insight>,
// Order information pub order_id: Option<String>, pub side: OrderSide, pub symbol: String, pub quantity: Option<f64>, pub contracts: Option<f64>,
// Order execution details pub order_type: OrderType, pub order_class: OrderClass, pub limit_price: Option<f64>, pub stop_price: Option<f64>, pub take_profit_levels: Option<Vec<f64>>, pub stop_loss_levels: Option<Vec<f64>>, pub trailing_stop_price: Option<f64>,
// Strategy information pub strategy_type: StrategyType, pub confidence: u8, pub timeframe: TimeFrame, pub period_unfilled: Option<u32>, pub period_till_tp: Option<u32>, pub execution_depends: Vec<StrategyDependentConfirmation>,
// Closing information pub filled_price: Option<f64>, pub close_order_id: Option<String>, pub close_price: Option<f64>, pub broker_realized_pnl: Option<f64>, pub commission: Option<f64>, pub swap: Option<f64>, pub partial_closes: Vec<PartialCloseResult>, pub created_at: DateTime<Utc>, pub updated_at: DateTime<Utc>, pub filled_at: Option<DateTime<Utc>>, pub closed_at: Option<DateTime<Utc>>, pub legs: OrderLegs,
// Market conditions pub market_changed: bool,
// Internal flags pub submitted: bool, pub cancelling: bool, pub closing: bool, pub first_on_fill: bool, pub partial_filled_quantity: Option<f64>,
// State tracking pub state_history: Vec<(DateTime<Utc>, InsightState, Option<String>)>, pub context: Option<InsightStrategyContext>,}인사이트 생성하기
섹션 제목: “인사이트 생성하기”가장 일반적인 인사이트 생성 패턴은 다음과 같습니다.
let mut insight = Insight::new( OrderSide::Buy, "AAPL".to_string(), StrategyType::Testing, ctx.timeframe().clone(), 80, None,);
insight .set_limit_price(Some(200.0)) .set_take_profit_levels(Some(vec![206.0])) .set_stop_loss(Some(197.5)) .set_period_unfilled(Some(5)) .set_period_till_tp(Some(12));
ctx.add_insight(insight);이후 인사이트 파이프라인에서 수량 산정, 검증, 주문 제출 동작을 추가할 수 있습니다.
필수 쿠키 및 저장소
로그인, 계정 보안, 색상 테마 설정, 이 알림 표시와 PostHog의 필수 내부 이용 현황·세션 품질·안정성 지표 수집을 위해 필수 쿠키와 저장소를 사용합니다. 광고 쿠키는 사용하지 않습니다.
