feat: Enhance trading system with new permanent subscription features and order book management

Changes:
- Added a new API endpoint for managing permanent subscriptions, allowing users to enable or disable subscriptions dynamically.
- Implemented a function to fill candle data from Kiwoom, ensuring that only relevant data is inserted into the database.
- Introduced a mechanism to handle master subscription states, improving the management of subscription statuses.
- Updated the database schema to include new fields for managing subscription states and order book filtering.

Impact:
- These enhancements improve the flexibility and reliability of the trading system, allowing for better management of subscriptions and order book data, while reducing the risk of data inconsistencies.

히스토리 align 제거 븅신같은 초기설계 아예 제거
진입모드에 구멍메움
호가진입을 켜도 호가가 안들어올때 호가 안보고 그냥 사버림
This commit is contained in:
Your Name
2026-08-15 23:01:14 +09:00
parent 4a18ce2697
commit 36a3e2b4a1
94 changed files with 6368 additions and 1639 deletions

View File

@@ -231,7 +231,9 @@ graph TD
| `optuna_briefing.py` | 432 | 🔬 백테스트 | `database`, `env` |
| `optuna_common.py` | 672 | 🔬 백테스트 | `database`, `optuna_briefing`, `env` |
| `optuna_daily_trail_recommend.py` | 315 | 🔬 백테스트 | `param_search_apply_snapshot`, `env` |
| `optuna_mode_combo.py` | 278 | 🔬 백테스트 | `optuna_daily_trail_recommend`, `optuna_tpe_common`, `env` |
| `optuna_mode_combo.py` | 278 | 🔬 백테스트 | `optuna_postprocess_topn`, `optuna_tpe_common`, `env` |
| `optuna_postprocess_topn.py` | — | 🔬 백테스트 | `optuna_orderbook_recommend`, `optuna_whipsaw_recommend` |
| `optuna_rerun_postprocess.py` | — | 🔬 백테스트 | `optuna_postprocess_topn`, `optuna_momentum` |
| `optuna_search_space.py` | 89 | 🔬 백테스트 | `param_search_breakout`, `param_search_momentum`, `param_search_scalping` +1 |
| `optuna_tpe_common.py` | 218 | 🔬 백테스트 | |
| `optuna_web_jobs.py` | 1,121 | 🔬 백테스트 | `backtest_portfolio_common`, `optuna_common`, `optuna_daily_trail_recommend` +6 |
@@ -258,7 +260,7 @@ graph TD
| `ls_feed_gate.py` | 20 | ⚙️ 엔진 | `env`, `ls_ws` |
| `mid_enroll_entry_gate.py` | 241 | ⚙️ 엔진 | `env` |
| `orderbook_env.py` | 187 | ⚙️ 엔진 | `env` |
| `orderbook_filter.py` | 245 | ⚙️ 엔진 | `env`, `orderbook_cache`, `trigger_eval_recorder` |
| `orderbook_filter.py` | 276 | ⚙️ 엔진 | `env`, `orderbook_cache`, `trigger_eval_recorder` |
| `post_sell_candle_backfill.py` | 439 | ⚙️ 엔진 | `database`, `candle_rollup`, `env` +2 |
| `program_filter.py` | 229 | ⚙️ 엔진 | `env`, `program_cache`, `trigger_eval_recorder` |
| `strategy_eod.py` | 149 | ⚙️ 엔진 | |
@@ -725,7 +727,7 @@ graph TD
| `kis_trader/engine/momentum_hts_logic.py` | 587 | `kis_trader.engine.momentum_chase_patterns`, `kis_trader.engine.momentum_env_keys`, `kis_trader.engine.orderbook_filter`, `kis_trader.engine.program_filter`, `kis_trader.engine.whipsaw_filter`, `kis_trader.utils.env`, `kis_trader.utils.session_hm`, `kis_trader.utils.trade_time` | - |
| `kis_trader/engine/momentum_tick_replay.py` | 620 | `kis_trader.backtest.shared_ticks`, `kis_trader.engine.momentum_engine`, `kis_trader.engine.whipsaw_filter`, `kis_trader.utils.env`, `kis_trader.utils.trade_time` | - |
| `kis_trader/engine/orderbook_env.py` | 187 | `kis_trader.utils.env` | - |
| `kis_trader/engine/orderbook_filter.py` | 245 | `kis_trader.utils.env`, `kis_trader.ws.orderbook_cache`, `kis_trader.ws.trigger_eval_recorder` | `orderbook_env`, `trigger_eval_collect` |
| `kis_trader/engine/orderbook_filter.py` | 276 | `kis_trader.utils.env`, `kis_trader.ws.orderbook_cache`, `kis_trader.ws.trigger_eval_recorder` | `orderbook_env`, `trigger_eval_collect` |
| `kis_trader/engine/post_sell_candle_backfill.py` | 439 | `database`, `kis_trader.engine.candle_rollup`, `kis_trader.utils.env`, `kis_trader.utils.logger`, `kis_trader.ws.kis_ws` | - |
| `kis_trader/engine/program_filter.py` | 229 | `kis_trader.utils.env`, `kis_trader.ws.program_cache`, `kis_trader.ws.trigger_eval_recorder` | `trigger_eval_collect` |
| `kis_trader/engine/range_break_engine.py` | 460 | `database`, `kis_trader.backtest.range_break_portfolio_backtest`, `kis_trader.engine.range_break_env_keys`, `kis_trader.strategies.breakout`, `kis_trader.utils.trade_time` | - |
@@ -1007,7 +1009,7 @@ graph TD
4. RAM=0 이면 **`LS_T1859_EMPTY_RETRY_SEC`(기본 15)** 로 t1859 재시도.
- **`=0` = 재시도 OFF** (무한 연타 아님 · 영구 0 위험).
- RAM>0 되면 재시도 안 함. REST 폭주 방지.
5. 빈 t1859 결과는 `ls_candidates_history`**저장하지 않음** (ALIGN 깨짐 방지).
5. 빈 t1859 결과는 `ls_candidates_history`**저장하지 않음**.
### 관련 ENV
@@ -1017,6 +1019,15 @@ graph TD
| `LS_T1859_EMPTY_RETRY_SEC` | 1 | RAM0만 재시드(초). 공식 t1859 1건/초 · 실간격≥TR_GAP(1.1). 0=OFF |
| `LS_T1859_ALLOW_SHRINK` | false | t1859 축소 전체교체 허용 |
| `CONDITION_JOB_EVENTS_SAVE` | true | job 이벤트 INSERT |
| `LIVE_UNIVERSE_SLOT_ALIGN` | (운영 ON) | live ∩ history |
웹「조건 이벤트」탭: `/api/condition_job_events`, `/api/condition_parity`.
## 수동 노트: 호가필터 TTL (2026-08-15)
> AST 재생성 시 이 섹션 유지.
- 판정: `kis_trader/engine/orderbook_filter.py` `_fetch_snapshot``WS_ORDERBOOK_FILTER_MAX_AGE_SEC`(기본 0). 사진 없음+필터 ON → `WS_ORDERBOOK_FILTER_REJECT_IF_EMPTY`(기본 true).
- 저장: `trigger_snapshot_recorder``WS_ORDERBOOK_TICK_MAX_AGE_SEC`(기본 30). **공유 금지.**
- 캐시: `orderbook_cache.get(..., max_age_sec)``<=0` 이면 나이 무시.
- 후처리 격자: `optuna_common.ensure_optuna_gate_env_defaults` `OPTUNA_OB_ENTRY_*` / `ASK_MULT_*`.
- 구 JSON 후처리만: `optuna_rerun_postprocess.py`.