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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finance_datagen-0.3.2.tar.gz (2.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

finance_datagen-0.3.2-cp310-abi3-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.10+Windows x86-64

finance_datagen-0.3.2-cp310-abi3-manylinux_2_28_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

finance_datagen-0.3.2-cp310-abi3-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file finance_datagen-0.3.2.tar.gz.

File metadata

  • Download URL: finance_datagen-0.3.2.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for finance_datagen-0.3.2.tar.gz
Algorithm Hash digest
SHA256 e6fe92966c043f663b41f153027b2c7807ef8248f5ff51cc2171d53f17e50266
MD5 0fd4a8ac78ca2497542c412bc51b6456
BLAKE2b-256 d5607c6dd48d805cea2f38e9a50f8f6a5bef7e34d4bf0763324a473592e86dad

See more details on using hashes here.

File details

Details for the file finance_datagen-0.3.2-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for finance_datagen-0.3.2-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c065544be573a988f3dcde2dc387997dd45bc20abc6b62ffdba27c43be7813af
MD5 3dd6dc822616087f563e9e3f5e258a94
BLAKE2b-256 a72b9aa0c3cab0e9726c274b71a508ce8572309296ddc7f6f146eea96af9f4c9

See more details on using hashes here.

File details

Details for the file finance_datagen-0.3.2-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for finance_datagen-0.3.2-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 87222609c601003ad078af00aae715dc965c2cb24595652d81649f9905bca165
MD5 f801260e28965a327d561fdc6724b5a7
BLAKE2b-256 2246ab3438564c1ca5783143ebc576663e92c1c691646af3ea26b22b12c3dac5

See more details on using hashes here.

File details

Details for the file finance_datagen-0.3.2-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for finance_datagen-0.3.2-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c3040429f2935bea10d56b1d21a774ba8e1dfadbc3c1a487f631c53f7177d55
MD5 b5fc419febf95c831326a2d96d67b447
BLAKE2b-256 7fd0705464b00a9b8f5d2d76f0b9ed99fdc3e49809000f3127fbacffe3e25d68

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.3

4 files

This release

0.3.2 This release

4 files

0.3.1

4 files

0.3.0

4 files

0.2.1

4 files

0.2.0

4 files

0.1.1

4 files

0.1.0

4 files

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