거래 빠르게 안티에서 병신만든거 커서로
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:
@@ -126,6 +126,10 @@ def _row_to_ob(
|
||||
else:
|
||||
verdict = "BODY" # 주기 스냅 — 판정 메타 없음 (매도도 본체 위주)
|
||||
near_only = int(delta_sec) > _STRICT_DELTA_SEC
|
||||
# ratio = L3 매수/매도 잔량비, or_ratio = 전체 잔량비
|
||||
# mid_ratio/whale_ratio = 웹 표(M/W) 호환 별칭 (동일 값)
|
||||
ratio_r = round(ratio, 3) if ratio is not None else None
|
||||
or_r_r = round(or_r, 3) if or_r is not None else None
|
||||
return {
|
||||
"side": side,
|
||||
"snap_time": str(row.get("snap_time") or "")[:14],
|
||||
@@ -136,10 +140,12 @@ def _row_to_ob(
|
||||
"spread_pct": round(_spread_pct(bid, ask) or 0.0, 3),
|
||||
"bid_qty_l3": bid_l3,
|
||||
"ask_qty_l3": ask_l3,
|
||||
"ratio": round(ratio, 3) if ratio is not None else None,
|
||||
"ratio": ratio_r,
|
||||
"mid_ratio": ratio_r,
|
||||
"total_bid_qty": tot_bid,
|
||||
"total_ask_qty": tot_ask,
|
||||
"or_ratio": round(or_r, 3) if or_r is not None else None,
|
||||
"or_ratio": or_r_r,
|
||||
"whale_ratio": or_r_r,
|
||||
"reject_code": rej,
|
||||
"reject_msg": msg,
|
||||
"verdict": verdict,
|
||||
|
||||
Reference in New Issue
Block a user