Simulation toolkit for financial machine learning: scholarly market, microstructure, and execution simulators for teaching and research.
Project description
finmlsim
Simulation and analysis toolkit for the FIN 70xx — Financial Machine Learning & AI course.
The course is simulation-driven: before confronting messy empirical data, we generate return
series under controlled assumptions, turn each stylized fact of markets on and off, and watch the
effect. finmlsim provides those generators and the tools to measure what they produce.
import finmlsim as fms
r = fms.simulate.garch(n=2000, dist="t", seed=0) # volatility clustering + fat tails
fms.stylized.summary(r) # measure the stylized facts
prices = fms.stylized.to_prices(r) # log returns -> price path for plotting
Install
pip install -e . # from the repo root (editable)
# core needs only numpy; figures/analysis also use pandas, scipy, matplotlib, statsmodels
Modules
simulate— generators grouped by family:- Return series (1-D log returns):
gaussian,student_t,arma,garch,regime_switching,jump_diffusion,cont_bouchaud. - Cross-sectional panel:
panel(2-D, common-factor structure). - Continuous-time price processes:
ornstein_uhlenbeck/vasicek,heston(1993),bates(1996),sabr(Hagan et al. 2002),rbergomi(Bayer-Friz-Gatheral 2016),fbm/fgn(Hurst-parametrized). - Microstructure and execution:
hawkes(1971 self-exciting),roll_bounce(1984),glosten_milgrom(1985),kyle(1985),limit_order_book(Cont-Stoikov style),almgren_chriss(2000 optimal execution). Every generator takes aseedfor reproducibility.
- Return series (1-D log returns):
stylized— diagnostics:acf,excess_kurtosis,vol_clustering,summary,to_prices.metrics— strategy evaluation:sharpe,max_drawdown,rank_ic,ic_ir,turnover,deflated_sharpe,min_track_record_length(used in Chapters 15 and 16).resample— block bootstraps for dependent series:stationary_bootstrap(Politis-Romano 1994),circular_block_bootstrap(Politis-Romano 1992). Pairs with the multiple-testing diagnostics inmetrics.data— loaders for the bundled empirical datasets (Ken French daily factors, momentum, and 12 industry portfolios) used for the book's real-data "empirical companion" figures:ff_factors,ff_momentum,industries,market_return. Offline; seedatasets/famafrench/.
The stylized facts each return-series generator produces
| Generator | Fat tails | Vol clustering | Mean autocorrelation |
|---|---|---|---|
gaussian |
– | – | – |
student_t |
✓ | – | – |
arma |
– | – | ✓ (by design) |
garch |
mild | ✓ | – |
garch(dist="t") |
✓ | ✓ | – |
regime_switching |
✓ (mixed) | ✓ | – |
jump_diffusion |
✓ | – | – |
cont_bouchaud |
✓ (endogenous) | (weak) | – |
What the continuous-time and microstructure models give you
| Generator | Returns | Key parameter | Use case |
|---|---|---|---|
ornstein_uhlenbeck / vasicek |
path | kappa (mean-reversion rate) |
pairs, short rates, vol state |
heston |
(S, v) |
xi, rho, kappa |
stochastic vol; smile/skew |
bates |
(S, v) |
+ jump_intensity |
stoch-vol with crash risk |
sabr |
(F, alpha) |
beta, nu, rho |
FX / rates vol surfaces |
rbergomi |
(S, xi) |
H < 0.5 |
rough volatility |
fbm / fgn |
path / increments | H |
Hurst-parameterized paths |
hawkes |
event times | alpha, beta |
order-flow clustering, contagion |
roll_bounce |
tx-price log returns | half_spread |
bid-ask bounce, negative AC(1) |
glosten_milgrom |
dict (ask/bid/spread/belief) | alpha (informed prob) |
adverse-selection spread |
kyle |
dict (v, u, x, y, price) | sigma_v / sigma_u |
strategic informed trading |
limit_order_book |
dict (mid, spread, depth) | lam0, theta, mu_mkt |
LOB dynamics, depth, impact |
almgren_chriss |
dict (path, costs) | lam (risk aversion) |
execution trajectories |
These are teaching models, not calibrations. Planned additions: a cost-aware backtest and
leak-free features helpers. The package will evolve with the course.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file finmlsim-0.4.0.tar.gz.
File metadata
- Download URL: finmlsim-0.4.0.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e2cb57a2ceab1699919d444a2c0ef0b7aba4660263922e395a83c729a858d4f
|
|
| MD5 |
979924dd944a9b316663838af5b2e169
|
|
| BLAKE2b-256 |
292725172ace4cb641a857424f3e917849f843778f89c6e442b2f89091003f3f
|
File details
Details for the file finmlsim-0.4.0-py3-none-any.whl.
File metadata
- Download URL: finmlsim-0.4.0-py3-none-any.whl
- Upload date:
- Size: 23.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d868625fb7294dd3610b94d75a482404ea2d8fafa9467912a609ec813c6769ac
|
|
| MD5 |
ae525f1b2f6afb16212c8d1219851d9d
|
|
| BLAKE2b-256 |
84f646cfb9a9ec37dc29ab83fc5f090ad70d1c8473eabb6f0cdffc19edb74848
|