Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
library_name: xgboost
|
| 4 |
+
tags:
|
| 5 |
+
- finance
|
| 6 |
+
- cryptocurrency
|
| 7 |
+
- market-microstructure
|
| 8 |
+
- liquidity-stress
|
| 9 |
+
- time-series
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# MAIC — Liquidity Stress Detection (XGBoost, Pooled, Binary)
|
| 13 |
+
|
| 14 |
+
Production model from "An Early Warning System for Liquidity Stress in
|
| 15 |
+
Cryptocurrency Markets Using Trade Flow Analysis and Machine Learning."
|
| 16 |
+
|
| 17 |
+
Code: https://github.com/Goodie-Goody/maic
|
| 18 |
+
Results, labels, logs: https://huggingface.co/datasets/Goooddy/maic-results
|
| 19 |
+
|
| 20 |
+
## What this model does
|
| 21 |
+
|
| 22 |
+
Given seven market-microstructure features (OFI, RV, Kyle's lambda, ILLIQ,
|
| 23 |
+
VWAP deviation, trade intensity, TCI) plus fractionally differenced price,
|
| 24 |
+
computed on 300-second bars of Binance BTC/ETH/SOL trade data, predicts the
|
| 25 |
+
probability the current bar reflects a liquidity-stress regime.
|
| 26 |
+
|
| 27 |
+
## Performance (Fold 4, 18.8M training rows, held-out test set)
|
| 28 |
+
|
| 29 |
+
| Metric | Score |
|
| 30 |
+
|-----------------|--------|
|
| 31 |
+
| F1 (weighted) | 0.9706 |
|
| 32 |
+
| Seed variance | 0.0006 |
|
| 33 |
+
|
| 34 |
+
56-108 minutes of advance warning before externally documented crisis
|
| 35 |
+
timestamps (FTX bankruptcy, Terra-Luna collapse), measured against reference
|
| 36 |
+
definitions the model never saw during training.
|
| 37 |
+
|
| 38 |
+
## Files
|
| 39 |
+
|
| 40 |
+
- `xgb_binary_pooled_fold4_seed42.pkl` -- production model, pooled across
|
| 41 |
+
BTC/ETH/SOL with an asset identifier feature. **Recommended default.**
|
| 42 |
+
- `xgb_multiclass_pooled_fold4_seed42.pkl` -- multiclass variant (calm /
|
| 43 |
+
elevated / stress), backs Table 2's multiclass row.
|
| 44 |
+
- `lr_binary_pooled_fold4_seed42.pkl`, `lr_multiclass_pooled_fold4_seed42.pkl`
|
| 45 |
+
-- logistic regression baselines used for comparison in the paper.
|
| 46 |
+
|
| 47 |
+
**No Random Forest pickle is published.** `06d_train_production.py`
|
| 48 |
+
deliberately saves `{"model": None, "scaler": scaler}` for RF rather than the
|
| 49 |
+
fitted model object, since the underlying cuML RF classifier doesn't reliably
|
| 50 |
+
reload across different GPU sessions/driver versions. RF's metrics and
|
| 51 |
+
predictions are still valid and included in the results dataset -- only the
|
| 52 |
+
serialized model artifact itself doesn't exist in a usable form.
|
| 53 |
+
|
| 54 |
+
Asset-specific models at the same 5-seed production rigor don't exist:
|
| 55 |
+
`06d_train_production.py` trains pooled only by design (see code comment).
|
| 56 |
+
Single-seed asset-specific models exist in the results dataset repo under
|
| 57 |
+
`v2/results_run1/` but are exploratory, not production-grade.
|
| 58 |
+
|
| 59 |
+
## Usage
|
| 60 |
+
|
| 61 |
+
Load with `pickle.load()`. Expects a dict with `model` (XGBoost classifier)
|
| 62 |
+
and `scaler` (fitted feature scaler). See `scripts/12_inference.py` in the
|
| 63 |
+
code repo for the full feature-construction and inference pipeline --
|
| 64 |
+
loading the pickle alone is not sufficient without matching feature
|
| 65 |
+
engineering.
|
| 66 |
+
|
| 67 |
+
## Important caveats
|
| 68 |
+
|
| 69 |
+
- Stress probability reflects liquidity *conditions*, not a price prediction.
|
| 70 |
+
Price impact is not guaranteed.
|
| 71 |
+
- Labels are HMM-derived (see paper Section 3.3) with a documented
|
| 72 |
+
look-ahead in retrospective Viterbi decoding, justified empirically via a
|
| 73 |
+
three-tier external validation framework (Section 3.4/4.4).
|
| 74 |
+
- Live inference reconstructs features on a single 300s window; this differs
|
| 75 |
+
from the multi-scale rolling-window construction used in training. See the
|
| 76 |
+
code repo for details on this known gap.
|