Simulation toolkit for financial machine learning: scholarly market, microstructure, and execution simulators for teaching and research.
Project description
finmlsim
Scholarly simulators for financial machine learning — a small, NumPy-only package of citation-anchored simulation models for research, teaching, and self-study. Twenty-plus generators across classical return series (Gaussian, Student-t, ARMA, GARCH, regime-switching, jump-diffusion, Cont–Bouchaud), continuous-time price processes (Heston, Bates, SABR, rough Bergomi, Ornstein–Uhlenbeck / Vasicek, fractional Brownian motion), and market microstructure / execution (Hawkes, Roll, Glosten–Milgrom, Kyle, a Cont–Stoikov limit-order book, Almgren–Chriss). Each model is one short function with a citation in its docstring.
Dial any stylized fact of markets on and off — fat tails, volatility clustering, jumps, regime switching, long memory, order-flow self-excitement, adverse selection — and watch what the methods you care about do under those conditions, before you turn them loose on real data.
import finmlsim as fms
# Volatility clustering plus fat tails
r = fms.simulate.garch(n=2000, dist="t", seed=0)
fms.stylized.summary(r)
prices = fms.stylized.to_prices(r)
# Stochastic-vol pricing with Heston
S, v = fms.simulate.heston(n=252, seed=0)
# Cont-Stoikov limit-order-book dynamics
book = fms.simulate.limit_order_book(n_events=20_000, seed=0)
Install
pip install finmlsim
# core needs only numpy; analysis extras: pip install "finmlsim[analysis]"
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.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):ff_factors,ff_momentum,industries,market_return. Offline; seedatasets/famafrench/in the source repository.
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 and research models, not production calibrations. Planned additions:
a cost-aware backtest module and leak-free features helpers.
License
MIT. See LICENSE in the source repository.
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.1.tar.gz.
File metadata
- Download URL: finmlsim-0.4.1.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4783ca98ed5076aa7d2d3ada3936f0d493a3b73e34c1606a0b61b67c215e08ab
|
|
| MD5 |
59b6b45220f88eef087c7e73ebdb36f5
|
|
| BLAKE2b-256 |
70c53c66892693801564e1f3be0ae758355c14dd3d26b8676feea3c358d58d4e
|
File details
Details for the file finmlsim-0.4.1-py3-none-any.whl.
File metadata
- Download URL: finmlsim-0.4.1-py3-none-any.whl
- Upload date:
- Size: 23.8 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 |
e61d545c98e0b83ff207680133044512458c457e321c40022d27eaf3187f6517
|
|
| MD5 |
3fbd47846ab77e79060f0ec53af41547
|
|
| BLAKE2b-256 |
57b3b7391a0b38a6b8a5c1a30ab8e41427868741417dedbabcdd37f7336371d7
|