거래 빠르게 안티에서 병신만든거 커서로
feat: Implement backtest source management and enhance candle data handling Changes: - Introduced a new function `_apply_backtest_source_env_from_request` to manage the environment variables for candle, tick, and order book sources based on incoming requests. - Added a teardown function `_teardown_backtest_source_env` to ensure that environment variables do not persist between requests, enhancing the stability of the backtesting environment. - Refactored existing code to utilize the new source management functions, improving code readability and maintainability. - Added new utility functions in `bt_candle_source.py` for fetching and managing candle data, ensuring consistency with live trading data sources. Impact: - These changes improve the flexibility and reliability of the backtesting framework, allowing for better management of data sources and reducing the risk of cross-request contamination.
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
</div>
|
||||
<div class="d-flex flex-column ms-1">
|
||||
<span id="kis_mock_status" class="text-muted" style="font-size:11px;white-space:nowrap">…</span>
|
||||
<span id="live_source_status" class="text-muted" style="font-size:10px;white-space:nowrap">캔들: - | 시세: -</span>
|
||||
<span id="live_source_status" class="text-muted" style="font-size:10px;white-space:nowrap;cursor:help" title="로딩 중…">시세: - | 호가: - | DB: -</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -336,7 +336,7 @@
|
||||
<th>종목</th><th>매수시각</th><th>매도시각</th>
|
||||
<th>매수가</th><th>매도가</th><th>수량</th>
|
||||
<th>손익(원)</th><th>수익률%</th><th>누적손익</th><th>누적%</th>
|
||||
<th>보유(분)</th><th>체결디버그</th><th>매도사유</th>
|
||||
<th>보유(분)</th><th>체결디버그</th><th title="매수 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매수호가</th><th title="매도 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매도호가</th><th>매도사유</th>
|
||||
</tr></thead>
|
||||
<tbody id="act_tbody"></tbody>
|
||||
</table>
|
||||
@@ -536,8 +536,8 @@
|
||||
<option value="ls">LS (ls_candidates)</option>
|
||||
</select>
|
||||
<label class="mb-0 ms-2">캔들</label>
|
||||
<select class="form-select form-select-sm" id="bt_candle_source" style="width:70px">
|
||||
<option value="">기본</option><option value="kis">KIS</option><option value="kiwoom">키움</option>
|
||||
<select class="form-select form-select-sm" id="bt_candle_source" style="width:70px" title="기본=실매 LIVE_TICK_PROVIDER 우선 병합">
|
||||
<option value="" title="실매 LIVE_TICK_PROVIDER 순서 (kiwoom→kis→rest)">기본</option><option value="kis">KIS</option><option value="kiwoom">키움</option>
|
||||
</select>
|
||||
<label class="mb-0 ms-1">시세(틱)</label>
|
||||
<select class="form-select form-select-sm" id="bt_tick_source" style="width:70px">
|
||||
@@ -617,32 +617,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- EOD 장마감 청산 -->
|
||||
<div class="row g-2 align-items-center mt-2 p-2 rounded" style="background:#161b22;border:1px solid #30363d">
|
||||
<div class="col-12"><span class="text-muted" style="font-size:11px"><b style="color:#79c0ff">EOD 장마감 청산</b></span></div>
|
||||
<div class="col-auto d-flex align-items-end">
|
||||
<div class="form-check mb-2">
|
||||
<input class="form-check-input" type="checkbox" id="bt_eod_enabled" checked>
|
||||
<label class="form-check-label" for="bt_eod_enabled">적용</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="form-label param-row" title="청산 시작 시간 (HH:MM)">시간</label>
|
||||
<input type="time" class="form-control form-control-sm" id="bt_eod_time" value="15:25">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="form-label param-row" title="미체결 주문(지정가 등) 전체 취소 여부">미체결취소</label>
|
||||
<select class="form-select form-select-sm" id="bt_eod_cancel_open">
|
||||
<option value="1" selected>Y (전체취소)</option>
|
||||
<option value="0">N (유지)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="form-label param-row" title="보유 종목 시장가 전량 매도 여부">시장가매도</label>
|
||||
<select class="form-select form-select-sm" id="bt_eod_sell_holdings">
|
||||
<option value="1" selected>Y (전량매도)</option>
|
||||
<option value="0">N (오버나잇)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto d-flex align-items-end">
|
||||
<div class="form-check mb-2">
|
||||
<input class="form-check-input" type="checkbox" id="bt_eod_enabled" checked>
|
||||
@@ -654,6 +631,7 @@
|
||||
<input type="text" class="form-control" id="bt_eod_hm" value="15:25" placeholder="15:25">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TRIGGER (SCAN vs TRIGGER — tail·모멘텀 탭과 동일 패턴) -->
|
||||
<div class="row g-2 align-items-center mt-2 p-2 rounded" style="background:#0d1117;border:1px solid #21262d">
|
||||
<div class="col-12"><span class="text-muted" style="font-size:11px"><b style="color:var(--accent)">TRIGGER 필터</b> — HTS SCAN 통과 후 엔진 검사</span></div>
|
||||
@@ -809,7 +787,7 @@
|
||||
<thead><tr>
|
||||
<th>종목</th><th>매수시각</th><th>매도시각</th>
|
||||
<th>매수가</th><th>매도가</th><th>수량</th>
|
||||
<th>손익(원)</th><th>수익률%</th><th>누적손익</th><th>누적%</th><th>보유(분)</th><th>매도사유</th><th>진입RSI</th>
|
||||
<th>손익(원)</th><th>수익률%</th><th>누적손익</th><th>누적%</th><th>보유(분)</th><th title="매수 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매수호가</th><th title="매도 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매도호가</th><th>매도사유</th><th>진입RSI</th>
|
||||
</tr></thead>
|
||||
<tbody id="bt_tbody"></tbody>
|
||||
</table>
|
||||
@@ -895,8 +873,8 @@
|
||||
<option value="ls">LS (ls_candidates)</option>
|
||||
</select>
|
||||
<label class="mb-0 ms-2">캔들</label>
|
||||
<select class="form-select form-select-sm" id="tl_candle_source" style="width:70px">
|
||||
<option value="">전체</option><option value="kis">KIS</option><option value="kiwoom">키움</option>
|
||||
<select class="form-select form-select-sm" id="tl_candle_source" style="width:70px" title="기본=실매 LIVE_TICK_PROVIDER 우선 병합">
|
||||
<option value="" title="실매 LIVE_TICK_PROVIDER 순서 (kiwoom→kis→rest)">기본</option><option value="kis">KIS</option><option value="kiwoom">키움</option>
|
||||
</select>
|
||||
<label class="mb-0 ms-1">시세(틱)</label>
|
||||
<select class="form-select form-select-sm" id="tl_tick_source" style="width:70px">
|
||||
@@ -1399,7 +1377,7 @@
|
||||
<th>종목</th><th>매수시각</th><th>매도시각</th>
|
||||
<th>매수가</th><th>매도가</th><th>수량</th>
|
||||
<th>손익(원)</th><th>수익률%</th><th>누적손익</th><th>누적%</th>
|
||||
<th>보유(분)</th><th>체결디버그</th><th>매도사유</th>
|
||||
<th>보유(분)</th><th>체결디버그</th><th title="매수 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매수호가</th><th title="매도 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매도호가</th><th>매도사유</th>
|
||||
</tr></thead>
|
||||
<tbody id="tl_tbody"></tbody>
|
||||
</table>
|
||||
@@ -1828,8 +1806,8 @@
|
||||
<option value="ls">LS (ls_candidates)</option>
|
||||
</select>
|
||||
<label class="mb-0 ms-2">캔들</label>
|
||||
<select class="form-select form-select-sm" id="bo_candle_source" style="width:70px">
|
||||
<option value="">기본</option><option value="kis">KIS</option><option value="kiwoom">키움</option>
|
||||
<select class="form-select form-select-sm" id="bo_candle_source" style="width:70px" title="기본=실매 LIVE_TICK_PROVIDER 우선 병합">
|
||||
<option value="" title="실매 LIVE_TICK_PROVIDER 순서 (kiwoom→kis→rest)">기본</option><option value="kis">KIS</option><option value="kiwoom">키움</option>
|
||||
</select>
|
||||
<label class="mb-0 ms-1">시세(틱)</label>
|
||||
<select class="form-select form-select-sm" id="bo_tick_source" style="width:70px">
|
||||
@@ -1972,7 +1950,7 @@
|
||||
<th>종목</th><th>매수시각</th><th>매도시각</th>
|
||||
<th>매수가</th><th>매도가</th><th>수량</th>
|
||||
<th>손익(원)</th><th>수익률%</th><th>누적손익</th><th>누적%</th>
|
||||
<th>보유(분)</th><th>체결디버그</th><th>매도사유</th>
|
||||
<th>보유(분)</th><th>체결디버그</th><th title="매수 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매수호가</th><th title="매도 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매도호가</th><th>매도사유</th>
|
||||
</tr></thead>
|
||||
<tbody id="bo_tbody"></tbody>
|
||||
</table>
|
||||
@@ -2252,8 +2230,8 @@
|
||||
<option value="ls">LS (ls_candidates)</option>
|
||||
</select>
|
||||
<label class="mb-0 ms-2">캔들</label>
|
||||
<select class="form-select form-select-sm" id="mom_candle_source" style="width:70px">
|
||||
<option value="">기본</option><option value="kis">KIS</option><option value="kiwoom">키움</option>
|
||||
<select class="form-select form-select-sm" id="mom_candle_source" style="width:70px" title="기본=실매 LIVE_TICK_PROVIDER 우선 병합">
|
||||
<option value="" title="실매 LIVE_TICK_PROVIDER 순서 (kiwoom→kis→rest)">기본</option><option value="kis">KIS</option><option value="kiwoom">키움</option>
|
||||
</select>
|
||||
<label class="mb-0 ms-1">시세(틱)</label>
|
||||
<select class="form-select form-select-sm" id="mom_tick_source" style="width:70px">
|
||||
@@ -2671,7 +2649,7 @@
|
||||
<th>종목</th><th>매수시각</th><th>매도시각</th>
|
||||
<th>매수가</th><th>매도가</th><th>수량</th>
|
||||
<th>손익(원)</th><th>수익률%</th><th>누적손익</th><th>누적%</th>
|
||||
<th>보유(분)</th><th>체결디버그</th><th>매도사유</th>
|
||||
<th>보유(분)</th><th>체결디버그</th><th title="매수 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매수호가</th><th title="매도 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매도호가</th><th>매도사유</th>
|
||||
</tr></thead>
|
||||
<tbody id="mom_tbody"></tbody>
|
||||
</table>
|
||||
@@ -3187,7 +3165,7 @@
|
||||
<th>종목</th><th>매수시각</th><th>매도시각</th>
|
||||
<th>매수가</th><th>매도가</th><th>수량</th>
|
||||
<th>손익</th><th>수익률%</th><th>누적손익</th><th>누적%</th>
|
||||
<th>보유(분)</th><th>체결디버그</th><th>매도사유</th>
|
||||
<th>보유(분)</th><th>체결디버그</th><th title="매수 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매수호가</th><th title="매도 시점 호가 (M:L3잔량비 W:전체잔량비 OR)">매도호가</th><th>매도사유</th>
|
||||
</tr></thead>
|
||||
<tbody id="usmom_tbody"></tbody>
|
||||
</table>
|
||||
@@ -3780,8 +3758,8 @@
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label class="form-label param-row">캔들소스</label>
|
||||
<select class="form-select form-select-sm" id="opt_candle_source" style="width:80px">
|
||||
<option value="" selected>기본</option>
|
||||
<select class="form-select form-select-sm" id="opt_candle_source" style="width:80px" title="기본=실매 LIVE_TICK_PROVIDER 우선 병합">
|
||||
<option value="" selected title="실매 LIVE_TICK_PROVIDER 순서 (kiwoom→kis→rest)">기본</option>
|
||||
<option value="kis">KIS</option>
|
||||
<option value="kiwoom">키움</option>
|
||||
</select>
|
||||
@@ -3866,6 +3844,24 @@
|
||||
<div class="text-muted mb-1">다단트레일 추천 <span class="text-muted">(탐색 축 아님 · DB 적용 시에만 반영)</span></div>
|
||||
<div id="opt_daily_trail_rec_body">완료 후 표시</div>
|
||||
</div>
|
||||
<div id="opt_postprocess_rec" class="mt-2 p-2 small" style="background:rgba(63,185,80,0.06);border:1px solid var(--border);border-radius:6px">
|
||||
<div class="text-muted mb-1">후처리 추천 표
|
||||
<span class="text-muted">(호가 진입+익절 · 휩쏘 · 트레일 · <b>STOP_OB 합의 아직 없음</b>)</span>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-hover mb-0" style="font-size:12px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>구분</th><th>상태</th><th>핵심 수치</th>
|
||||
<th class="text-end">모수/통계</th><th>비고</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="opt_postprocess_tbody">
|
||||
<tr><td colspan="5" class="text-muted">완료 후 표시</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card p-3 mb-3">
|
||||
|
||||
Reference in New Issue
Block a user