Skip to content

[feat] #80 Multi-Timeframe 서비스 레이어 및 HTF 캔들/조합/추세 전략 추가#86

Merged
fray-cloud merged 25 commits intodevfrom
feat/#73
Apr 2, 2026
Merged

[feat] #80 Multi-Timeframe 서비스 레이어 및 HTF 캔들/조합/추세 전략 추가#86
fray-cloud merged 25 commits intodevfrom
feat/#73

Conversation

@fray-cloud
Copy link
Copy Markdown
Owner

변경 사항

  • MultiTimeframeStrategyService 등록 및 HTF 캔들 fetch 로직 구현 (PRO-73)
  • CandleOHLCV / MultiTimeframeData 타입 정의
  • CombinationStrategy, TrendRegimeStrategy 등록 (PRO-72)
  • 인디케이터 전략 누락 파일 커밋, Candle 마이그레이션, 알림 피드 연동 (PRO-69)
  • strategy-card 테스트 픽스 — 누락 mock 및 getByText 모호성 해결

관련 이슈

Closes #80

테스트 방법

  • cd apps/worker-service && pnpm test 실행 후 MultiTimeframe 관련 테스트 통과 확인
  • 로컬 docker-compose up 후 Multi-TF 전략 등록 및 HTF 캔들 정상 fetch 확인

참고

⚠️ 이 PR은 미머지 브랜치 정리(PRO-100) 작업의 일환으로, PM 요청(PRO-101)에 따라 Backend Lead가 대리 생성하였습니다.

Co-Authored-By: Paperclip noreply@paperclip.ing

fray-cloud and others added 24 commits March 31, 2026 17:25
- Prisma: Flow, Backtest, BacktestTrace 모델 추가
- Kafka: FLOW_BACKTEST_REQUESTED/COMPLETED 토픽 + 이벤트
- Types: FlowDefinition, NodeTypeRegistry, Zod-free 검증 스키마
- FlowCompiler: Kahn's algorithm DAG 검증, 위상 정렬, 캔들별 실행
- Nodes: CandleStream, RSI, Threshold, MarketOrder (4개 초기 구현)
- Tests: 33개 전체 통과 (컴파일러 검증 14 + 노드 19)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Phase 2: API Server CQRS
- Flow CRUD + Toggle + Backtest 요청 9개 REST 엔드포인트
- FlowsKafkaProducer/Consumer — backtest 이벤트 Kafka 연동
- WebSocket backtest:completed 실시간 이벤트

Phase 3: React Flow UI
- @xyflow/react 기반 노드 빌더 (드래그&드롭, 포트 타입 검증)
- 4종 커스텀 노드 (data/indicator/condition/order) 색상별 구분
- NodePalette, NodeInspector, FlowToolbar, TimelineSlider
- Zustand flow store + React Query hooks
- /flows 목록 + /flows/[id] 빌더 페이지

Phase 4: Backtest Engine + Timeline Debugger
- BacktestService — Kafka consumer, 캔들 페치, flow 실행, trace 저장
- 노드 Glow 효과 (녹색=fired, 빨간색=blocked)
- WebSocket 백테스트 완료 리스너 + 자동 trace 로딩

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ariables

All flow builder components now use theme-aware CSS variables
(bg-card, border-border, text-foreground, text-muted-foreground)
instead of hardcoded hex colors (#0f1117, #1a1a24, zinc-*).
This fixes light mode rendering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ility

Trace state now shows CheckCircle2/XCircle icons alongside green/red
glow effects, so color-blind users can distinguish fired vs blocked.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…vigation

All interactive elements in flow builder now show focus rings
for keyboard navigation (WCAG AA compliance).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All flow builder components now use useTranslations('flows')
instead of hardcoded Korean strings. Added 26 new translation
keys to ko.json and en.json.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…pace

t('loading', { ns: 'common' }) is not valid next-intl syntax.
Use useTranslations('common') separately. Also add onNodeDoubleClick
handler to prevent unhandled events.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
useFlowStore(backtestStatus) was called after early return,
violating React hooks rules. Moved all hooks before conditional
return to ensure consistent call order.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Failed backtests store { error: "..." } in summary, not the full
BacktestSummary. Guard winRate/realizedPnl access with null check.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- indicator-macd.node: MACD (macd/signal/histogram 출력)
- indicator-bollinger.node: Bollinger Bands (upper/middle/lower 출력)
- indicator-ema.node: EMA 지수 이동평균
- condition-crossover.node: 크로스오버 감지 (state 기반, above/below 방향)
- condition-and-or.node: AND/OR 로직 조합 노드
- order-alert.node: 알림 전용 터미널 노드
- NODE_REGISTRY에 모든 신규 노드 등록
- determineFired 함수 수정: 다중 출력 인디케이터(MACD, Bollinger) 지원
- FlowsService: 활성 Flow 실시간 평가 루프 (StrategiesService 패턴 적용)
  - 30초 폴링으로 활성 Flow 동기화
  - 캔들 인터벌 기반 평가 주기 자동 설정
  - FlowOrderAction → DB Order 생성 → Kafka TRADING_ORDER_REQUESTED 발행
  - RiskService 연동 (stopLoss, dailyMaxLoss, maxPositionSize)
  - 연속 동일 side 주문 중복 방지
- FlowsModule 생성 및 AppModule 등록
- nodes.test.ts: 신규 노드 38개 테스트 케이스 추가 (총 52개 통과)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Replace horizontal-scroll table on mobile (<md) with a card-based layout.
Each card shows symbol, direction (buy/sell), qty, price, and status.
Two tabs split orders into Open (pending/placed) and Completed.
Desktop table (≥md) is unchanged.

Adds openOrders / closedOrders translation keys to en.json and ko.json.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Add VaR/CVaR, dynamic drawdown limits, ATR-based volatility sizing,
Kelly Criterion position sizing, tail risk monitoring, and
cross-symbol correlation matrix to RiskService.

- Extend RiskConfig and RiskCheckResult with new fields
- Add checkDrawdownLimit: pause strategy after X% drawdown from peak
- Add checkVarAndCVar: historical simulation VaR/CVaR checks
- Add applyAtrSizing: scale down position size when ATR > baseline
- Add applyKellySizing: win-rate-based half-Kelly position sizing
- Add getCorrelationMatrix: Pearson correlation across symbols
- Propagate adjustedQuantity through AutoTradeSaga RiskCheckStep
- 30 unit tests covering all new risk checks (all passing)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Add card view to the Portfolio assets section showing coin, current price,
holdings, valuation, and P&L with % color-coded. Toggle between card/table view
with LayoutGrid/LayoutList buttons. Card view is the default.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
BacktestingModule was imported in app.module.ts but the source files were
never committed, causing TS2307 build errors in CI.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Migration 20260401000000_add_candle_table created the table but the model
definition was never added to schema.prisma. Adds Candle model with all
fields matching the migration, fixing TS2339 errors in backtesting/data.service.ts.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
… onboarding, risk dialog

- Add CSS @Keyframes flash-up/flash-down animations to globals.css
- Refactor TickerTable to use TickerRow component with per-row price flash animation on WebSocket updates; add onRowClick prop
- Wire QuickOrderPanel into Markets page — clicking a ticker row opens the slide-in order panel
- Add OnboardingWizard to root layout so new users see the 5-step wizard on first login
- Add real-trading risk confirmation dialog (Dialog component) to QuickOrderPanel and OrderForm when switching from paper to real mode
- Add i18n keys (en/ko) for the confirmation dialog

Closes PRO-38 P1 items

Co-Authored-By: Paperclip <noreply@paperclip.ing>
…feed RT, tooltip + terminology

- Strategy card: add live status badge (대기/신호감지/주문실행/리스크차단/오류) and realized PnL
  using new useStrategyRuntime hook (polls last log + performance API at 30s/60s)
- Notification feed: pipe WebSocket notification:received events to feed store so
  the bell panel populates in real time (previously only toasts were shown)
- Tooltip component: new /ui/tooltip.tsx — CSS-only hover tooltip, no new deps
- Terminology: en.json updated with plain-language labels (Signal-only, Auto-execute,
  Simulation, Live Trading) + tooltip copy; strategy card now renders these via i18n
  with cursor-help tooltips on mode/tradingMode badges

Co-Authored-By: Paperclip <noreply@paperclip.ing>
… rules

- Add GitHub Issue/Milestone sync rules per board direction (PRO-56)
- Clarify that feature PRs must be opened by developers, not team leads
- Document Paperclip Approval flow for dev → main release PRs

Co-Authored-By: Paperclip <noreply@paperclip.ing>
…ion-feed, and .gitignore update (PRO-69)

These files were present on disk but never tracked — discovered during feat/#53 branch cleanup.

- apps/worker-service: add combination, multi-timeframe, and trend-regime indicator strategies with tests
- packages/database/prisma/migrations/20260401000000_add_candle_table: add migration for Candle table (pairs with existing schema.prisma Candle model fix)
- apps/web: add notification-feed component and use-notification-feed-store (referenced in feat(web) P2 sprint commit but not staged)
- .gitignore: broaden tmp/ rule from tmp/test-results/ to tmp/ to suppress screenshot artifacts

Co-Authored-By: Paperclip <noreply@paperclip.ing>
…gister combination/trend-regime strategies (PRO-72)

- strategy.interface.ts: add CandleOHLCV and MultiTimeframeData types
- ITradingStrategy.evaluate(): add optional candles? and multiTimeframe? params
- strategies.service.ts: register CombinationStrategy and TrendRegimeStrategy in strategyMap

Co-Authored-By: Paperclip <noreply@paperclip.ing>
…eStrategy + HTF candle fetch (PRO-73)

- Register MultiTimeframeStrategy in strategyMap
- Add getCandleOHLCV() to fetch full OHLCV data (needed for volume/ATR)
- evaluateStrategy fetches htf1/htf2 close prices and primary OHLCV for multi-timeframe type
- HTF intervals configurable via strategy.config.htf1Interval/htf2Interval (defaults: 4h/1d)
- Redis caching reused for HTF candles using existing CANDLE_CACHE_TTL (4h→1800s, 1d→3600s)
- DB migration (add_candle_table) already present in feat/#48

Co-Authored-By: Paperclip <noreply@paperclip.ing>
…mbiguity

- Add vi.mock for next-intl useTranslations (missing context error)
- Add vi.mock for useStrategyRuntime with correct StrategyRuntime shape (realizedPnl: null)
- Add vi.mock for @/components/icons to avoid icon rendering issues
- Fix 'displays exchange/symbol' assertion to use getAllByText (multiple matches)

All 49 web unit tests now pass.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @fray-cloud, your pull request is larger than the review limit of 150000 diff characters

…l UI/type files

All conflicts involved frontend flow builder files and shared types where dev
has newer, more complete versions. feat/#73's core Multi-TF backend work
(MultiTimeframeStrategyService, HTF candle fetch) has no conflicts.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@fray-cloud fray-cloud merged commit 52749fe into dev Apr 2, 2026
2 checks passed
@fray-cloud fray-cloud deleted the feat/#73 branch April 2, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant