Repository navigation
Commit 59bf1c4
committed
feat: add prediction-market venue fee models (Kalshi, ForecastEx, Polymarket US)
Prediction-market research needs fee-adjusted returns at executable prices,
and backtests need the same fees inside the engine. Adds
ml4t.backtest.prediction_market_fees with:
- vectorized fee functions over NumPy arrays or Polars Series:
kalshi_fee, kalshi_order_fees, forecastex_fee, polymarket_us_fee
- CommissionModel adapters: KalshiCommission, ForecastExCommission,
PolymarketUSCommission
Kalshi: taker round_up(M * 0.07 * C * P * (1 - P)), maker factor 0 / 0.25 /
0.5 by series fee_type, trade fee rounded up to 0.000001, optional balance
alignment to 0.01 (non-direct) or 0.0001 (direct) and the per-order
rebate of accumulated overpayment. ForecastEx: 0.01 per contract per side.
Polymarket US: taker theta (per-market fee_coefficient, default 0.0695) and
maker rebate 0.0125, per-fill cent rounding half to even. Exact decimal
inputs are snapped before ceiling/rounding so float noise cannot move a fee
by a micro-dollar or a cent. Docstrings cite the venue documents read on
2026-10-08.1 parent 672804b commit 59bf1c4
5 files changed
Lines changed: 927 additions & 0 deletions
File tree
- docs
- api
- user-guide
- src/ml4t/backtest
- tests
- compatibility/snapshots
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
164 | 178 | | |
165 | 179 | | |
166 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
87 | 147 | | |
88 | 148 | | |
89 | 149 | | |
| |||
0 commit comments