Skip to main content

Standard financial data generation

Project description

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_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_gbm, generate_heston, and generate_garch.

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
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.

Quick start

from finance_datagen import GBMGenerator, generate_signal, ohlc_from_close

closes = GBMGenerator(s0=100.0, mu=0.07, sigma=0.25, seed=0).generate()
bars   = ohlc_from_close(closes["price"], seed=0)
signal = generate_signal(n_dates=20, n_assets=50, seed=0)

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.

[!NOTE] This library was generated using copier from the Base Python Project Template repository.

Project details


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.1.1.tar.gz (42.2 kB 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.1.1-cp310-abi3-win_amd64.whl (2.2 MB view details)

Uploaded CPython 3.10+Windows x86-64

finance_datagen-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl (2.8 MB view details)

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

finance_datagen-0.1.1-cp310-abi3-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: finance_datagen-0.1.1.tar.gz
  • Upload date:
  • Size: 42.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for finance_datagen-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f3fa5e4e2e648aeda2cf8c13027aa953086785157ebe14e8bd4397c958bb0851
MD5 129a82d1d0524769caabcbaf8b6ced3f
BLAKE2b-256 e1aaa77aae06635b66a3b037ce24c62f70b31a03eb4f6be02b92590f701182a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for finance_datagen-0.1.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 14e91c8181f8064fdda57d17e392fd95c72091f8d99c673237afe2b1485a4a5d
MD5 0b51efdb9d6016cfb5f7c54ae7ae967d
BLAKE2b-256 edd4da706d9e5ff4c04e4f7025f5a58074d6f4f44a4f152801f15c58bc54154d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for finance_datagen-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f4891c27c60960ba4e57ae704421caab612dd8cafd9eb124eddd8b7f45b78749
MD5 8fc974f06298279d9049a9bd482a379f
BLAKE2b-256 02dcd1fe41f54d9c0840e843951d3808a71bf98a6e329412fbeab7b085e5a402

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for finance_datagen-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7172171573a6ed8ea5b843935dcb740fd9a1847161d2edcbbc7c17c7402bd90c
MD5 3a47af70b91ddbda9f851c6b3a6abf3b
BLAKE2b-256 745288223a2171987ad9c83ac9f910bbe907a612be15f7de2de136702e06674b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page