트레이딩 전략 전반의 LEAN 동등성 감사
노트북 Machine Learning for Trading
요약
이 노트북은 실제 전략 감사에서 LEAN 엔진과 이에 맞춘 ML4T Backtest 프로필의 결과를 비교합니다. 고정된 입력이 지원하는 자산군 작업을 식별하고 체결, 평가액, 평가 시점, 주식 자산곡선의 공백, 최종 가치 전반의 동등성 근거를 보고합니다. CME 선물 작업은 이용 가능한 연속 근월물 가격에 네이티브 LEAN 구독에 필요한 날짜별 계약 체인과 롤 매핑이 없어 제외됩니다.
입력 로딩, 추론, 목표 구성, 준비, 보고를 제외하고 엔진 호출 전후를 측정한 엔진 단독 실행 시간도 비교합니다. 이 수치는 고정된 버전과 입력, 측정 경계에만 적용됩니다. 합성 스트레스 행은 실제 전략 비교와 별개로 규모와 프로필을 진단하기 위해 제시됩니다. 노트북은 프레임워크의 속도나 동등성에 대한 일반적인 주장이 아니라 감사 결과를 제공하며, 동등성 결과는 지원되는 작업과 고정된 번들에 한정됩니다.
핵심 아이디어
- 감사에서는 체결, 평가액, 타임스탬프, 최종 결과에 대해 LEAN와 ML4T Backtest를 비교합니다.
- 고정 입력은 ETF, 암호화폐 무기한, USD 표시 FX, US 주식 작업을 지원합니다.
- 필요한 날짜별 계약 체인과 롤 맵이 없어 CME 선물 사례는 지원되지 않습니다.
- 엔진 단독 실행 시간에는 데이터 준비, 추론, 어댑터 작업, 보고가 포함되지 않습니다.
- 합성 스트레스 결과는 진단용이므로 실제 전략 근거와 구분해야 합니다.
태그
전문
# LEAN Parity on Current Case-Study Strategies
# LEAN Parity on Current Case-Study Strategies
This notebook isolates the LEAN rows from the current real-strategy audit. It uses retained results
generated by the native LEAN engine and the matching ML4T Backtest profiles. The shared inputs are
frozen before engine execution.
**Learning objectives**
- Identify which selected asset classes are valid LEAN comparisons
- Read LEAN parity across fills, valuations, and terminal value
- Interpret LEAN engine-only timing on the measured strategies
- Keep synthetic stress evidence separate from real-strategy equivalence
**Book reference**: Chapter 16, Section 16.3
## Setup
```python
"""Current LEAN parity evidence."""
import json
import polars as pl
from IPython.display import Markdown, display
from utils.paths import get_chapter_dir
```
```python
# Production defaults - Papermill injects overrides after this cell
ROUND_SECONDS = 3
```
```python
AUDIT_PATH = get_chapter_dir(16) / "resources" / "framework_parity_audit.json"
audit = json.loads(AUDIT_PATH.read_text(encoding="utf-8"))
lean = audit["frameworks"]["lean"]
LEAN_NAME = f"{lean['display_name']} {lean['version']}"
CASE_NAMES = {
"etfs": "ETF allocation",
"cme_futures": "CME futures",
"crypto_perps_funding": "Crypto perpetual funding",
"fx_pairs": "FX allocation (USD-quoted pairs)",
"us_equities_panel": "US equity panel",
}
```
```python
display(Markdown(f"**Pinned engine:** {LEAN_NAME} with ML4T profile `{lean['profile']}`"))
```
## 1. Supported real strategies
LEAN is required for the ETF, crypto-perpetual, USD-quoted foreign-exchange, and US equity-panel
workloads. The CME row is unsupported for this particular frozen bundle: it contains continuous
root prices but lacks the dated contract chain and roll map needed to construct a native LEAN
futures subscription.
```python
lean_results = (
pl.DataFrame(audit["real_strategy_records"])
.filter(pl.col("framework") == "lean")
.with_columns(pl.col("case_study").replace_strict(CASE_NAMES).alias("strategy"))
.select(
"strategy",
"status",
"fills",
"valuations",
"valuation_timestamps_match",
"equity_gap",
"equity_raw_gap",
"terminal_gap",
"terminal_raw_gap",
"negative_control_detected",
)
)
assert lean_results.height == 4
assert lean_results["status"].to_list() == ["pass"] * 4
assert lean_results["valuation_timestamps_match"].all()
assert lean_results["negative_control_detected"].all()
display(lean_results)
```
```python
lean_unsupported = (
pl.DataFrame(audit["unsupported_records"])
.filter(pl.col("framework") == "lean")
.with_columns(pl.col("case_study").replace_strict(CASE_NAMES).alias("strategy"))
.select("strategy", "reason")
)
display(lean_unsupported)
```
The table reports the complete fill and valuation counts for each supported workload. LEAN uses
native equity, crypto-future, and foreign-exchange securities. The audit does not convert the
continuous CME roots into a different instrument merely to add a LEAN row.
## 2. Engine-only timing
The timer starts immediately before the engine call and stops when it returns. One warmup and ten
process-isolated samples are used. Input loading, model inference, target construction, adapter
preparation, result extraction, and reporting are outside the timed region.
```python
lean_timing = (
pl.DataFrame(audit["performance_records"])
.filter(pl.col("framework") == "lean")
.with_columns(
pl.col("case_study").replace_strict(CASE_NAMES).alias("strategy"),
pl.col("framework_median_seconds").round(ROUND_SECONDS).alias("lean_seconds"),
pl.col("ml4t_median_seconds").round(ROUND_SECONDS).alias("ml4t_seconds"),
pl.col("framework_to_ml4t_ratio").round(2).alias("lean_div_ml4t"),
)
.select("strategy", "lean_seconds", "ml4t_seconds", "lean_div_ml4t")
)
display(lean_timing)
```
The timing result applies to these pinned versions, bundles, and engine boundaries. It is not a
general LEAN performance claim.
## 3. Synthetic stress remains diagnostic
```python
lean_stress = (
pl.DataFrame(audit["synthetic_stress"]["records"])
.filter(pl.col("framework") == "lean")
.select("intents", "fills", "trades", "terminal_value", "status")
)
display(lean_stress)
```
The retained stress row tests scale and the calibrated LEAN profile on generated inputs. The
supported rows above provide the real-data evidence.출처의 라이선스에 따라 출처를 표시하고 전문을 공개합니다. 라이선스: MIT
이 요약은 원문을 바탕으로 Stratmill의 리서치 에이전트가 작성했으며, 원문을 복사한 것이 아닙니다.