chanmacro: Signal Expectancy Engine V1 — Market Memory System

Phase A-C complete: 4 core factors, regime detection, signal tracking, Bayesian expectancy.

chanmacro/ (32 files, ~4000 lines):
- models: 12 enums + 15 Pydantic v2 models (DateAwareModel, MarketStateVector, etc.)
- fetchers: OHLCV + Breadth (from data_provider) + Derivatives (new endpoint)
- scoring: Price Structure / Breadth (quantile buckets) / OI Matrix (5 discrete states) / Volatility Regime
- regime_detector: 3-state (TREND/RANGE/PANIC), factor-locked (Price+Breadth+Vol), versioned, 2-day confirmation
- expectancy: SignalTracker (record+outcomes), TimeDecay (half-life=180d), BayesianExpectancyEngine (Empirical Bayes, Leveled, SufficiencyGuard)
- validation: FactorValidator (IC/ICIR/Hit Ratio), RegimeValidator (MI/KL/ANOVA), TransitionValidator (stability)
- CLI: fetch|score|regime|track|backfill|expectancy|validate|serve
- tests: 52 passing (models, scoring, regime, expectancy)

data_provider:
- /api/derivatives endpoint: funding rate, OI, OI change, basis
- _derivatives storage: same persist pattern as K-line (merge→lock→snapshot→atomic write)
- background refresh every 60s

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
jackyu66git
2026-06-24 17:44:55 +08:00
co-authored by Claude
parent 34040575c1
commit 71951019fb
43 changed files with 5036 additions and 2 deletions
+23
View File
@@ -0,0 +1,23 @@
{
"provider_url": "http://127.0.0.1:80",
"db_path": "data/macro.db",
"btc_symbol": "BTC/USDT:USDT",
"regime_version": "v1_price_breadth_vol",
"half_life_days": 180,
"sufficiency_min_effective": 30,
"sufficiency_low": 50,
"sufficiency_medium": 100,
"level_min_samples": 50,
"knn_max_distance": 0.35,
"knn_k": 200,
"oi_price_threshold_pct": 0.5,
"oi_oi_threshold_pct": 0.5,
"vol_low_threshold": 2.0,
"vol_high_threshold": 5.0,
"vol_explosive_threshold": 10.0,
"regime_w_price": 0.35,
"regime_w_breadth": 0.50,
"regime_w_vol": 0.15,
"trend_w_price": 0.30,
"trend_w_breadth": 0.70
}