Skip to main content

finance datagen

Standard financial data generation

Build Status codecov License PyPI

Overview

finance-datagen produces synthetic financial time series for testing, demos, and benchmarking the rest of the finance-* stack without relying on real market data. The numerical core is implemented in Rust and emits Apache Arrow RecordBatch values; the Python layer wraps each generator so the public API returns polars.DataFrame objects.

All public generator classes inherit from DataGenerator, a pydantic base model that validates typed parameters on construction. Use .generate() for the table output, or next(generator) for one-shot iterator-style use. Convenience functions such as generate_prices(...), generate_gbm(...), and generate_signal(...) instantiate the matching model and return .generate().

Generators

Price models (Rust core)

Symbol Model Output columns
GBMGenerator Geometric Brownian Motion (log-Euler) timestamp, symbol, price
HestonGenerator Heston (1993) stochastic volatility (full-truncation Euler) timestamp, symbol, price, variance
GARCHGenerator GARCH(1,1) returns timestamp, symbol, price, return, sigma
ohlc_from_close OHLCV synthesis from any close series timestamp, symbol, open, high, low, close, volume

Price-path convenience wrappers are also exported as generate_prices, generate_gbm, generate_heston, and generate_garch. generate_prices is a plain alias for generate_gbm for examples and tests that want a model-neutral name.

Python generators

Symbol Output
SignalGenerator Long-form [date, symbol, signal, fwd_returns] with target Pearson IC
FactorLoadingsGenerator Wide [symbol, market, value, momentum, size, quality] Barra-style loadings
BenchmarkGenerator [date, benchmark] Gaussian benchmark return series
PositionsGenerator Long-form position panel [date, symbol, price, quantity, market_value, weight]
TransactionsGenerator Transaction log with enum-backed side/position-effect labels and explicit costs
OrdersGenerator Enum-backed order fixtures with side, order type, status, and time-in-force
ExecutionsGenerator Enum-backed execution fixtures for simulated fills
MultiAssetGBMGenerator Correlated multi-asset GBM panel [timestamp, symbol, price, return]
RegimeSwitchingGenerator Markov regime-switching price path [timestamp, symbol, price, return, regime]
MarketImpactCurveGenerator Participation-rate impact curves with temporary, permanent, and total impact in bps
StatisticalRiskModelGenerator PCA-style factor loadings, factor returns, and specific variance
FundamentalRiskModelGenerator Barra-style enum-backed sector/style loadings plus specific variance
FactorCovarianceGenerator Symmetric positive semidefinite factor covariance matrix
SpecificVarianceGenerator Positive idiosyncratic variance vector

Every Python generator has a matching generate_* convenience wrapper, including the legacy generate_signal, generate_factor_loadings, and generate_benchmark functions.

All Rust generators accept an optional seed: int for bit-reproducible output across platforms (ChaCha8 RNG); the Python generators accept a seed for numpy.random.default_rng.

Portfolio, transaction, order, execution, and market-model generators also support enum-backed metadata columns where applicable, including currency, exchange, region, instrument_type, market_type, and venue_type. Portfolio and transaction generators can use finance-dates.Calendar exchange calendars so generated dates and timestamps align with actual business days and session hours.

Quick start

from finance_datagen import OrdersGenerator, generate_prices, generate_signal, ohlc_from_close

closes = generate_prices(symbol="ACME", seed=0)
bars   = ohlc_from_close(closes["price"], symbol="ACME", seed=0)
signal = generate_signal(n_dates=20, n_assets=50, seed=0)
orders = OrdersGenerator(n_dates=3, n_assets=5, orders_per_day=10, exchange="XNYS", currency="USD", seed=0).generate()

See the Data page for model math, parameter ranges, and output schemas, and the API page for a complete function-level reference.

Architecture

The Rust core (rust/src/) is polars-free: every generator builds an arrow_array::RecordBatch and returns it through the Arrow C Data Interface PyCapsule via pyo3-arrow. The Python wrappers call polars.from_arrow(batch) on the receiving end. This keeps the polars-rs and polars-py codebases on opposite sides of a stable ABI boundary, avoiding the binary-incompatibility issues that come with linking polars from both Rust and CPython.

Metadata

Release files for finance-datagen 0.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for finance-datagen 0.3.4
File Size Uploaded Provenance Actions
finance_datagen-0.3.4.tar.gz 46.8 kB Without provenance Details for finance_datagen-0.3.4.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for finance-datagen 0.3.4
File Actions
finance_datagen-0.3.4-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for finance_datagen-0.3.4-cp310-abi3-win_amd64.whl
finance_datagen-0.3.4-cp310-abi3-manylinux_2_28_x86_64.whl CPython 3.10 abi3 Linux glibc 2.28+ x86-64 Details for finance_datagen-0.3.4-cp310-abi3-manylinux_2_28_x86_64.whl
finance_datagen-0.3.4-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details for finance_datagen-0.3.4-cp310-abi3-manylinux_2_28_aarch64.whl
finance_datagen-0.3.4-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for finance_datagen-0.3.4-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 10.7 MB

Release files / finance_datagen-0.3.4.tar.gz

Download URL finance_datagen-0.3.4.tar.gz
Size 46.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1f6c898af96f3537c7eed62c8bf3e3c8de64ae85f1a102bf29946d976a45c501
BLAKE2b-256 checksum
How to use checksums
e4165b54df37d6bb36725b6679c7d23c9c396e2d213f39bb9a14388d1a804050
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finance_datagen-0.3.4-cp310-abi3-win_amd64.whl

Download URL finance_datagen-0.3.4-cp310-abi3-win_amd64.whl
Size 2.5 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
cc459c64379fa7166845ba73c397c4d36c615792d93abbc34ed4e4457c9fadd3
BLAKE2b-256 checksum
How to use checksums
5c262e1b753ceb4270ef43710b8ba2cf08348872da89d7c06e17089898f29dcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finance_datagen-0.3.4-cp310-abi3-manylinux_2_28_x86_64.whl

Download URL finance_datagen-0.3.4-cp310-abi3-manylinux_2_28_x86_64.whl
Size 3.0 MB
Tags CPython 3.10 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
db2dbf8b72df2ea41f6e49355e3a20bd12ce1f50f2862012d7a7494e5debf0e9
BLAKE2b-256 checksum
How to use checksums
9231976272166431c0195cccc0e1ad22f0a6319604a240fc57825205417dee03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finance_datagen-0.3.4-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL finance_datagen-0.3.4-cp310-abi3-manylinux_2_28_aarch64.whl
Size 2.8 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
fa0171960c1cd1d9eb39568559b2675b27974a71cd47c0f5771c1c94c0acef52
BLAKE2b-256 checksum
How to use checksums
40c41ecc8526abbcadbfa260441d401324b15f2b54254ecc7694791eee0c0daf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / finance_datagen-0.3.4-cp310-abi3-macosx_11_0_arm64.whl

Download URL finance_datagen-0.3.4-cp310-abi3-macosx_11_0_arm64.whl
Size 2.4 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ed90b887a6867142e1fc7d319688464df859ddcf52ef99e2c8ff6ad4388797f4
BLAKE2b-256 checksum
How to use checksums
b7f2ca9d4830a0088e983867d07b104a01afe72a318284022a42d78408f3f249
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for finance-datagen 0.3.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page