가상투자 설정 수정
This commit is contained in:
@@ -1019,6 +1019,10 @@ export interface LiveStrategySettingsDto {
|
||||
candleType?: string;
|
||||
/** 전략 조건 DSL에 포함된 평가 시간봉 (응답 전용) */
|
||||
strategyCandleTypes?: string[];
|
||||
/** true면 관심종목 동기화 생략 (가상투자 per-market) */
|
||||
skipWatchlistSync?: boolean;
|
||||
/** true면 gc_app_settings 전역 템플릿 갱신 생략 */
|
||||
skipGlobalTemplate?: boolean;
|
||||
}
|
||||
|
||||
/** 실시간 전략 체크 설정 로드 */
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
/** 가상·모의 체결 후 백테스팅 실시간 매매 목록 등 갱신용 */
|
||||
export const PAPER_TRADES_CHANGED_EVENT = 'gc_paper_trades_changed';
|
||||
|
||||
export function notifyPaperTradesChanged(): void {
|
||||
window.dispatchEvent(new CustomEvent(PAPER_TRADES_CHANGED_EVENT));
|
||||
}
|
||||
@@ -41,7 +41,7 @@ export const MENU_LABELS: Record<string, string> = {
|
||||
settings_indicators: '설정 · 보조지표',
|
||||
settings_backtest: '설정 · 백테스팅',
|
||||
settings_strategy: '설정 · 전략',
|
||||
settings_paper: '설정 · 모의투자',
|
||||
settings_paper: '설정 · 가상투자',
|
||||
settings_alert: '설정 · 알림',
|
||||
settings_network: '설정 · 네트워크',
|
||||
settings_admin: '설정 · 관리자',
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { saveLiveStrategySettings } from './backendApi';
|
||||
import type { VirtualSessionConfig, VirtualTargetItem } from './virtualTradingStorage';
|
||||
|
||||
/** 가상투자 대상 종목을 백엔드 live strategy 설정과 동기화 */
|
||||
export async function syncVirtualTargetsToBackend(
|
||||
targets: VirtualTargetItem[],
|
||||
session: VirtualSessionConfig,
|
||||
isLiveCheck: boolean,
|
||||
): Promise<void> {
|
||||
if (targets.length === 0) return;
|
||||
|
||||
const shared = {
|
||||
isLiveCheck,
|
||||
executionType: session.executionType,
|
||||
positionMode: session.positionMode,
|
||||
skipWatchlistSync: true,
|
||||
} as const;
|
||||
|
||||
await Promise.all(
|
||||
targets.map(t =>
|
||||
saveLiveStrategySettings({
|
||||
market: t.market,
|
||||
strategyId: t.strategyId ?? session.globalStrategyId,
|
||||
...shared,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
await saveLiveStrategySettings({
|
||||
market: targets[0].market,
|
||||
strategyId: session.globalStrategyId,
|
||||
...shared,
|
||||
});
|
||||
}
|
||||
|
||||
/** 가상투자 중지 — 대상 종목 체크 해제 + 전역 liveStrategyCheck OFF */
|
||||
export async function stopVirtualLiveOnBackend(
|
||||
targets: VirtualTargetItem[],
|
||||
session: VirtualSessionConfig,
|
||||
): Promise<void> {
|
||||
if (targets.length === 0) {
|
||||
await saveLiveStrategySettings({
|
||||
market: 'KRW-BTC',
|
||||
strategyId: session.globalStrategyId,
|
||||
isLiveCheck: false,
|
||||
executionType: session.executionType,
|
||||
positionMode: session.positionMode,
|
||||
skipWatchlistSync: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
await syncVirtualTargetsToBackend(targets, session, false);
|
||||
}
|
||||
@@ -36,6 +36,7 @@ export function loadVirtualTargets(): VirtualTargetItem[] {
|
||||
export function saveVirtualTargets(items: VirtualTargetItem[]): void {
|
||||
try {
|
||||
localStorage.setItem(TARGETS_KEY, JSON.stringify(items));
|
||||
notifyVirtualSessionChanged();
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
@@ -58,9 +59,16 @@ export function loadVirtualSession(): VirtualSessionConfig {
|
||||
export function saveVirtualSession(cfg: VirtualSessionConfig): void {
|
||||
try {
|
||||
localStorage.setItem(SESSION_KEY, JSON.stringify(cfg));
|
||||
notifyVirtualSessionChanged();
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
|
||||
export const VIRTUAL_SESSION_CHANGED_EVENT = 'gc_virtual_session_changed';
|
||||
|
||||
export function notifyVirtualSessionChanged(): void {
|
||||
window.dispatchEvent(new CustomEvent(VIRTUAL_SESSION_CHANGED_EVENT));
|
||||
}
|
||||
|
||||
function defaultSession(): VirtualSessionConfig {
|
||||
return {
|
||||
globalStrategyId: null,
|
||||
|
||||
Reference in New Issue
Block a user