Multi-Market Trading Bot REST API 및 WebSocket 서버 문서입니다.
Base URL: http://localhost:3000
API Version: v1
모든 보호된 엔드포인트는 JWT Bearer 토큰을 요구합니다.
Authorization: Bearer <token>
| Role | Level | Description |
|---|---|---|
admin |
100 | 모든 권한 (시스템 관리 포함) |
trader |
50 | 거래 및 전략 관리 |
viewer |
10 | 읽기 전용 |
로그인 및 토큰 발급
Request:
{
"username": "string",
"password": "string"
}Response:
{
"access_token": "string",
"refresh_token": "string",
"expires_in": 1800,
"token_type": "Bearer"
}Liveness check
Response: 200 OK
{
"status": "healthy",
"timestamp": "2026-01-28T12:00:00Z"
}Readiness check (모든 컴포넌트 상태)
Response:
{
"status": "healthy",
"components": {
"database": { "status": "healthy", "latency_ms": 5 },
"redis": { "status": "healthy", "latency_ms": 2 },
"exchange": { "status": "healthy" }
},
"timestamp": "2026-01-28T12:00:00Z"
}전략 목록 조회
Response:
{
"strategies": [
{
"id": "grid_btc",
"name": "BTC Grid Trading",
"version": "1.0.0",
"running": true,
"signals_generated": 150
}
],
"total": 1,
"running": 1
}특정 전략 상세 조회
Response:
{
"id": "grid_btc",
"name": "BTC Grid Trading",
"version": "1.0.0",
"running": true,
"stats": {
"signals_generated": 150,
"orders_submitted": 120,
"orders_filled": 115
}
}전략 시작
Response:
{
"success": true,
"strategy_id": "grid_btc",
"action": "start",
"message": "Strategy 'grid_btc' started successfully"
}전략 중지
전략 설정 변경
Request:
{
"config": {
"grid_spacing_pct": 1.5,
"grid_levels": 10
}
}엔진 통계 조회
Response:
{
"total_strategies": 5,
"running_strategies": 2,
"total_signals_generated": 500,
"total_orders_filled": 450,
"total_market_data_processed": 100000
}활성 주문 목록 조회
Response:
{
"orders": [
{
"id": "uuid",
"exchange_order_id": "12345",
"symbol": "BTC/USDT",
"side": "Buy",
"order_type": "Limit",
"quantity": "0.1",
"filled_quantity": "0.05",
"price": "50000",
"average_fill_price": "49950",
"status": "PartiallyFilled",
"strategy_id": "grid_btc",
"created_at": "2026-01-28T12:00:00Z",
"updated_at": "2026-01-28T12:05:00Z"
}
],
"total": 1
}특정 주문 상세 조회
주문 취소
Request Body (optional):
{
"reason": "Manual cancellation"
}Response:
{
"success": true,
"order_id": "uuid",
"message": "Order cancelled successfully"
}주문 통계
Response:
{
"total": 10,
"by_status": {
"pending": 2,
"open": 5,
"partially_filled": 3
},
"by_side": {
"buy": 6,
"sell": 4
}
}열린 포지션 목록 조회
Response:
{
"positions": [
{
"id": "uuid",
"exchange": "binance",
"symbol": "BTC/USDT",
"side": "Buy",
"quantity": "0.5",
"entry_price": "50000",
"current_price": "51000",
"unrealized_pnl": "500",
"realized_pnl": "0",
"notional_value": "25500",
"return_pct": "2.0",
"strategy_id": "grid_btc",
"opened_at": "2026-01-28T10:00:00Z",
"updated_at": "2026-01-28T12:00:00Z"
}
],
"total": 1,
"summary": {
"total_positions": 1,
"total_unrealized_pnl": "500",
"total_realized_pnl": "0",
"total_notional_value": "25500",
"long_count": 1,
"short_count": 0
}
}특정 심볼 포지션 조회
포지션 요약 통계
Endpoint: ws://localhost:3000/ws
- WebSocket 연결 수립
- 서버에서
welcome메시지 전송 - 클라이언트에서
auth메시지로 인증 (선택) - 클라이언트에서
subscribe메시지로 채널 구독 - 서버에서 실시간 데이터 스트리밍
{
"type": "subscribe",
"channels": ["market:BTC-USDT", "orders", "positions"]
}{
"type": "unsubscribe",
"channels": ["market:BTC-USDT"]
}{
"type": "ping"
}{
"type": "auth",
"token": "jwt_token_here"
}{
"type": "welcome",
"version": "0.1.0",
"timestamp": 1706436000000
}{
"type": "subscribed",
"channels": ["market:BTC-USDT", "orders"]
}{
"type": "pong",
"timestamp": 1706436000000
}{
"type": "ticker",
"symbol": "BTC-USDT",
"price": "50000.00",
"change_24h": "2.5",
"volume_24h": "1000000",
"high_24h": "51000",
"low_24h": "49000",
"timestamp": 1706436000000
}{
"type": "trade",
"symbol": "BTC-USDT",
"trade_id": "123456",
"price": "50000.00",
"quantity": "0.1",
"side": "Buy",
"timestamp": 1706436000000
}{
"type": "order_update",
"order_id": "uuid",
"symbol": "BTC/USDT",
"status": "Filled",
"side": "Buy",
"order_type": "Limit",
"quantity": "0.1",
"filled_quantity": "0.1",
"price": "50000",
"average_price": "49990",
"timestamp": 1706436000000
}{
"type": "position_update",
"symbol": "BTC/USDT",
"side": "Buy",
"quantity": "0.5",
"entry_price": "50000",
"current_price": "51000",
"unrealized_pnl": "500",
"return_pct": "2.0",
"timestamp": 1706436000000
}{
"type": "strategy_update",
"strategy_id": "grid_btc",
"name": "BTC Grid Trading",
"running": true,
"event": "signal_generated",
"data": { "signal_type": "Entry", "side": "Buy" },
"timestamp": 1706436000000
}{
"type": "error",
"code": "INVALID_CHANNEL",
"message": "Unknown channel: xyz"
}| Channel | Description |
|---|---|
market:{symbol} |
특정 심볼의 시장 데이터 (ticker, trades) |
orders |
주문 상태 업데이트 |
positions |
포지션 업데이트 |
strategies |
전략 상태 변경 |
all_markets |
모든 시장 요약 데이터 |
모든 에러는 동일한 형식으로 반환됩니다:
{
"code": "ERROR_CODE",
"message": "Human readable error message"
}| Code | HTTP Status | Description |
|---|---|---|
MISSING_TOKEN |
401 | 인증 토큰 누락 |
INVALID_TOKEN |
401 | 유효하지 않은 토큰 |
TOKEN_EXPIRED |
401 | 토큰 만료 |
INSUFFICIENT_PERMISSION |
403 | 권한 부족 |
STRATEGY_NOT_FOUND |
404 | 전략을 찾을 수 없음 |
ORDER_NOT_FOUND |
404 | 주문을 찾을 수 없음 |
POSITION_NOT_FOUND |
404 | 포지션을 찾을 수 없음 |
INVALID_ORDER_ID |
400 | 잘못된 주문 ID 형식 |
ALREADY_RUNNING |
400 | 전략이 이미 실행 중 |
NOT_RUNNING |
400 | 전략이 실행 중이 아님 |
CANCEL_FAILED |
500 | 주문 취소 실패 |
- REST API: 1200 requests/minute
- WebSocket: 100 messages/second
Rate limit 초과 시 429 Too Many Requests 반환
cargo test --workspacecargo test --workspace --test '*'- Unit Tests: 258 (258 passed)
- Integration Tests: 28 (28 passed)
- Total: 286 tests passing
다중 타임프레임 Kline 데이터 조회
Query Parameters:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| symbol | string | ✓ | 심볼 (예: "005930") |
| timeframes | string | ✓ | 타임프레임 목록 (쉼표 구분: "1m,5m,1h") |
| limit | number | 각 타임프레임당 캔들 수 (기본: 100) |
Response:
{
"symbol": "005930",
"data": {
"1m": [{ "timestamp": 1706436000, "open": 50000, ... }],
"5m": [...],
"1h": [...]
}
}글로벌 스코어 랭킹 조회
Query Parameters:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| market | string | 시장 필터 (KR, US, CRYPTO) | |
| route_state | string | RouteState 필터 (ATTACK, ARMED, WAIT) | |
| limit | number | 결과 수 (기본: 100) |
7Factor 스코어 조회
Response:
{
"ticker": "005930",
"factors": {
"momentum": 75.5,
"value": 62.3,
"quality": 88.1,
"volatility": 45.2,
"liquidity": 92.0,
"growth": 55.8,
"sentiment": 70.0
},
"total_score": 72.4
}7Factor 배치 조회
Request:
{
"tickers": ["005930", "000660", "035720"]
}관심종목 목록 조회
관심종목 그룹 생성
Request:
{
"name": "반도체 관련주",
"description": "반도체 섹터 관심종목"
}관심종목 추가
Request:
{
"symbol": "005930"
}관심종목 삭제
보유 포지션 목록 조회
체결 내역 조회
Query Parameters:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| from | string | 시작 날짜 (YYYY-MM-DD) | |
| to | string | 종료 날짜 (YYYY-MM-DD) | |
| symbol | string | 심볼 필터 | |
| side | string | 매수/매도 필터 (buy, sell) |
FIFO 원가 계산 조회
Response:
{
"symbol": "005930",
"average_cost": "65000",
"total_cost": "650000",
"realized_pnl": "15000",
"lots": [
{ "quantity": 5, "cost": "64000", "date": "2026-01-15" },
{ "quantity": 5, "cost": "66000", "date": "2026-01-20" }
]
}에러 목록 조회
Query Parameters:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| severity | string | 심각도 필터 (critical, error, warning) | |
| category | string | 카테고리 필터 (database, exchange, strategy) |
Critical 에러만 조회
에러 통계 (심각도별/카테고리별)
시스템 요약 (디버깅용)
수집 실패한 심볼 목록 조회 (3회 연속 실패 시 자동 비활성화)
비활성화된 심볼 재활성화
심볼 동기화 실행
캐시된 데이터셋 목록 조회
새 데이터셋 다운로드 요청
심볼 검색 (티커/이름 패턴 매칭)
여러 티커의 심볼 정보 일괄 조회
수집 실패한 심볼 목록 조회
심볼 상태 통계 (비활성화/임계/경고)
비활성화된 심볼 재활성화
심볼 삭제 + 관련 데이터 연쇄 정리 (delete_symbol_cascade DB 함수 호출)
Query Parameters:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| market | string | ✓ | 시장 코드 (KR, US, CRYPTO 등) |
Response:
{
"success": true,
"ticker": "005930",
"market": "KR",
"deletedTables": [
{"tableName": "ohlcv", "deletedCount": 1200},
{"tableName": "ohlcv_metadata", "deletedCount": 3}
],
"message": "심볼 '005930' (KR) 삭제 완료 (총 1203건)"
}symbol_info에 없는 심볼의 고아 데이터 일괄 정리 (cleanup_orphan_symbol_data DB 함수 호출)
Response:
{
"success": true,
"cleanedTables": [
{"tableName": "ohlcv", "deletedCount": 500},
{"tableName": "execution_cache", "deletedCount": 12}
],
"totalDeleted": 512,
"message": "고아 데이터 정리 완료 (총 512건 삭제)"
}특정 심볼의 캔들 데이터 조회 (정렬/페이지네이션 지원)
특정 심볼 캐시 삭제 (ohlcv + ohlcv_metadata)
조건 기반 종목 스크리닝
스크리닝 프리셋 목록 조회
스크리닝 캐시 새로고침 (Materialized View 갱신)
전일 추천 종목의 익일 실제 성과 검증 통계
검증 이력 조회
Query Parameters:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| days | number | 조회 기간 (기본: 30) |
Telegram 테스트 메시지 전송
실시간 캔들 데이터 스트리밍
Subscribe:
{
"type": "subscribe",
"channels": ["kline:005930:1m", "kline:005930:5m"]
}Server Message:
{
"type": "kline",
"symbol": "005930",
"timeframe": "1m",
"data": {
"timestamp": 1706436000,
"open": "50000",
"high": "50500",
"low": "49800",
"close": "50300",
"volume": "1000000"
}
}- Multi Timeframe API 추가
- 7Factor Scoring API 추가
- Watchlist API 추가
- Journal API 확장 (FIFO 원가 계산)
- WebSocket Kline 브로드캐스트 추가
- TypeScript 바인딩 자동 생성 (ts-rs)
- OpenAPI/Swagger 문서화 추가
- StrategyType enum 추가
- Repository 패턴 확장 (9개 repository)
- 286 tests passing (258 unit + 28 integration)