feat: 자동매매 신뢰성 개선 — 시세 실서버 라우팅·일일 한도 전역화·수동 매수 API
- korea_investment_api: KIS_QUOTES_VIA_REAL — 모의투자 모드에서 시세/차트/호가 조회를 실계좌 시세 서버(20/s)로 위임, 주문·잔고는 모의서버 유지 (EGW00201 대응) - recommendations: execute_auto_trade_background asyncio.Lock 중복 실행 방지 + MAX_DAILY_TRADES를 당일 BUY 건수 차감 전역 기준으로 적용 (11종목 동시 매수 재발 방지) - manual_buy.py 신규: POST /api/v1/portfolio/buy (리스크 가드 + safe_place_order + db_worker) - mcp-server: claude_code_client(claude -p 헤드리스 모드) 추가, trade_monitor 부분매도 시 active 유지·remaining_pct 갱신, API 키 헤더·/api/v1 경로 수정, ODNO 주문ID 수정 - config: MCP_REQUEST_TIMEOUT, MCP_RISK_CACHE_TTL, BATCH_ANALYSIS_INTERVAL, SWING_INDEX_BREAKER_ENABLED(OFF), API_TRIGGERED_AUTO_TRADE(OFF) 추가 - docker-compose: 포트 충돌 해소 (postgres 15433, frontend 3001) - frontend: 추천 패널 매수 버튼, 차트/호가/저널 패널 개선 - CLAUDE.md 압축 최적화 (규칙 변경 없음), _sweep_single_axis.py 백테스트 단일축 스윕 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -284,9 +284,12 @@ export const TradingChart = React.memo(({ data, livePrice: livePriceProp }: Trad
|
||||
try {
|
||||
const allCandles = pd.candles;
|
||||
const totalBars = allCandles.length;
|
||||
const visibleRange = {
|
||||
from: allCandles[Math.max(0, totalBars - 100)].time,
|
||||
to: allCandles[totalBars - 1].time,
|
||||
if (totalBars === 0) return;
|
||||
// 시간 기반 setVisibleRange는 차트가 아직 레이아웃되기 전(폭 0)이나 재마운트 직후
|
||||
// "Value is null"을 던짐 → 인덱스 기반 logical range로 교체 + 개별 try/catch
|
||||
const logicalRange = { from: Math.max(0, totalBars - 100), to: totalBars - 1 };
|
||||
const setRange = (chart: IChartApi | null) => {
|
||||
try { chart?.timeScale().setVisibleLogicalRange(logicalRange); } catch (_) { /* not laid out yet */ }
|
||||
};
|
||||
|
||||
// 메인 차트 데이터 교체
|
||||
@@ -299,11 +302,11 @@ export const TradingChart = React.memo(({ data, livePrice: livePriceProp }: Trad
|
||||
mainLines[3].setData(pd.sma5);
|
||||
mainLines[4].setData(pd.sma60);
|
||||
}
|
||||
mainChartInstanceRef.current?.timeScale().setVisibleRange(visibleRange);
|
||||
setRange(mainChartInstanceRef.current);
|
||||
|
||||
// 거래량 데이터 교체
|
||||
volumeSeriesRef.current?.setData(pd.volumes);
|
||||
volumeChartInstanceRef.current?.timeScale().setVisibleRange(visibleRange);
|
||||
setRange(volumeChartInstanceRef.current);
|
||||
|
||||
// RSI 데이터 교체
|
||||
const rsiLines = rsiLineSeriesRef.current;
|
||||
@@ -313,13 +316,13 @@ export const TradingChart = React.memo(({ data, livePrice: livePriceProp }: Trad
|
||||
rsiLines[2].setData(pd.rsi.line50);
|
||||
rsiLines[3].setData(pd.rsi.line70);
|
||||
}
|
||||
rsiChartInstanceRef.current?.timeScale().setVisibleRange(visibleRange);
|
||||
setRange(rsiChartInstanceRef.current);
|
||||
|
||||
// MACD 데이터 교체
|
||||
macdSeriesRef.current.histogram?.setData(pd.macd.histogram);
|
||||
macdSeriesRef.current.line?.setData(pd.macd.line);
|
||||
macdSeriesRef.current.signal?.setData(pd.macd.signal);
|
||||
macdChartInstanceRef.current?.timeScale().setVisibleRange(visibleRange);
|
||||
setRange(macdChartInstanceRef.current);
|
||||
} catch (error: unknown) {
|
||||
const err = error as Error | null;
|
||||
console.error('차트 데이터 업데이트 오류:', err?.message);
|
||||
@@ -402,11 +405,12 @@ export const TradingChart = React.memo(({ data, livePrice: livePriceProp }: Trad
|
||||
macdSeriesRef.current = { histogram: macdHistSeries, line: macdLineSeries, signal: macdSignalSeries };
|
||||
|
||||
// 시간축 동기화
|
||||
mainChart.timeScale().subscribeVisibleTimeRangeChange((timeRange) => {
|
||||
if (timeRange) {
|
||||
volumeChart.timeScale().setVisibleRange(timeRange);
|
||||
rsiChart.timeScale().setVisibleRange(timeRange);
|
||||
macdChart.timeScale().setVisibleRange(timeRange);
|
||||
// logical range 동기화: 하위 차트 시리즈에 해당 time이 아직 없을 때(setData 직전)
|
||||
// setVisibleRange가 "Value is null"을 던지므로 인덱스 기반으로 맞춘다
|
||||
mainChart.timeScale().subscribeVisibleLogicalRangeChange((range) => {
|
||||
if (!range) return;
|
||||
for (const c of [volumeChart, rsiChart, macdChart]) {
|
||||
try { c.timeScale().setVisibleLogicalRange(range); } catch (_) { /* series not ready */ }
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user