거래 빠르게 안티에서 병신만든거 커서로

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:
Your Name
2026-08-13 16:03:40 +09:00
parent c6bd62a25f
commit 2c7ad867f4
53 changed files with 15251 additions and 637 deletions

View File

@@ -4870,3 +4870,16 @@
{"ts": "2026-08-12T05:57:42+09:00", "kind": "overseas_sell_cooldown_skip", "strategy_id": "US_MOMENTUM", "side": "SELL", "code": "QQQM", "msg_cd": "COOLDOWN", "msg1": "order_api_skipped", "rt_cd": "", "http": "", "path": "order_manager", "fingerprint": "bb7a668daab6556e", "extra": {"remain_sec": 810}}
{"ts": "2026-08-12T05:58:29+09:00", "kind": "overseas_sell_cooldown_skip", "strategy_id": "US_MOMENTUM", "side": "SELL", "code": "SPYM", "msg_cd": "COOLDOWN", "msg1": "order_api_skipped", "rt_cd": "", "http": "", "path": "order_manager", "fingerprint": "7ca0a5f6999ae4e8", "extra": {"remain_sec": 1176}}
{"ts": "2026-08-12T05:59:14+09:00", "kind": "overseas_sell_cooldown_skip", "strategy_id": "US_MOMENTUM", "side": "SELL", "code": "SPCX", "msg_cd": "COOLDOWN", "msg1": "order_api_skipped", "rt_cd": "", "http": "", "path": "order_manager", "fingerprint": "c1523c0aa8ef4b36", "extra": {"remain_sec": 3479}}
{"ts": "2026-08-13T09:11:14+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "136150", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "7dd98c44f0b72b81", "extra": {"mock": true}}
{"ts": "2026-08-13T14:48:06+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "014440", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "f96fd7bec81fae11", "extra": {"mock": true}}
{"ts": "2026-08-13T15:14:08+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "475230", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "90937ad99c4f13ed", "extra": {"mock": true}}
{"ts": "2026-08-13T15:17:16+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "475230", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "90937ad99c4f13ed", "extra": {"mock": true}}
{"ts": "2026-08-13T15:19:36+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "084730", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "e2db3ad5ccfa88ef", "extra": {"mock": true}}
{"ts": "2026-08-13T15:22:49+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "093190", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "0ea6a9e99c040697", "extra": {"mock": true}}
{"ts": "2026-08-13T15:22:55+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "100790", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "ebe234c4e8f6540b", "extra": {"mock": true}}
{"ts": "2026-08-13T15:23:09+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "136150", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "7dd98c44f0b72b81", "extra": {"mock": true}}
{"ts": "2026-08-13T15:23:13+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "382900", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "fa05ce2f5b25a22f", "extra": {"mock": true}}
{"ts": "2026-08-13T15:23:23+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "394420", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "cacd383105d57c6e", "extra": {"mock": true}}
{"ts": "2026-08-13T15:27:25+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "114810", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "acf6433c88ee951e", "extra": {"mock": true}}
{"ts": "2026-08-13T15:27:31+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "126340", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "3103f6a9cecadfe9", "extra": {"mock": true}}
{"ts": "2026-08-13T15:27:36+09:00", "kind": "domestic_order_reject", "strategy_id": "", "side": "SELL", "code": "264850", "msg_cd": "40240000", "msg1": "모의투자 잔고내역이 없습니다.", "rt_cd": "1", "http": 200, "path": "/uapi/domestic-stock/v1/trading/order-cash", "fingerprint": "07f84693aa3df706", "extra": {"mock": true}}

View File

@@ -1 +1 @@
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_breakout_fast_20260808_022923.json
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_breakout_fast_20260813_001301.json

View File

@@ -1 +1 @@
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_breakout_fast_20260808_022923.json
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_breakout_tpe_20260813_010648.json

View File

@@ -1 +1 @@
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_breakout_tpe_20260731_112436.json
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_breakout_tpe_20260813_010648.json

View File

@@ -1 +1 @@
logs/optuna_breakout_tpe_20260808_022529.log
/home/hoon/kis_bot/logs/optuna_breakout_tpe_20260812_1300_400_20260813_010100.log

View File

@@ -1 +1 @@
breakout_tpe_20260807_20260807_20260808_022529
breakout_tpe_20260812_1300_400_20260813_010100

View File

@@ -1 +1 @@
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_scalp_fast_20260812_001823.json
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_breakout_tpe_20260813_010648.json

View File

@@ -1 +1 @@
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_momentum_fast_20260808_021231.json
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_momentum_fast_20260812_235406.json

View File

@@ -1 +1 @@
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_momentum_fast_20260808_021231.json
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_momentum_fast_20260812_235406.json

View File

@@ -1 +1 @@
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_scalp_fast_20260812_001823.json
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_scalp_fast_20260812_233958.json

View File

@@ -1 +1 @@
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_scalp_fast_20260812_001823.json
/home/hoon/kis_bot/kis_trader/backtest/results/optuna_scalp_fast_20260812_233958.json