A modular library for synthetic time series generation.
Project description
tsg – Modular Time Series Generator Library
tsg is a lightweight Python library for generating synthetic time series data using modular and composable generators.
It is designed for research, simulation, and testing of sequential decision-making algorithms, especially in finance and machine learning.
🚀 Features
- 📈 Core generators: linear trend, periodic trend, constant value
- 🎲 Noise wrappers: add Gaussian noise or build your own modifiers
- 🔁 Stateful generators with
reset()support - 🧱 Easy to extend with your own generator or modifier classes
📦 Installation
Install through GitHub from any location:
pip install git+https://github.com/MSCA-DN-Digital-Finance/tsg.git
Install through PyPi from any location:
pip install tsg-lib
🛠️ Example Usage
Here’s how to generate a noisy linear trend time series using tsg:
from tsg.generators import LinearTrendGenerator
from tsg.modifiers import GaussianNoise
# Create a linear trend generator (increasing by +1 each step)
linear_generator = LinearTrendGenerator(start_value=100, slope=1)
# Wrap it with Gaussian noise (mean=0, std=1)
noisy_generator = GaussianNoise(linear_generator, mu=0.0, sigma=1.0)
# Generate a few data points
values = []
for _ in range(10):
value = noisy_generator.generate_value(None)
values.append(value)
print(values)
🧠 API Overview
Core Generators (tsg.generators)
| Class | Description | Parameters |
|---|---|---|
LinearTrendGenerator |
Linearly increases or decreases the value at each step | start_value, slope |
ConstantGenerator |
Returns a fixed value (e.g., simulates cash) | None (uses last_value in generate_value) |
PeriodicTrendGenerator |
Generates a sinusoidal time series with set amplitude and frequency | start_value, amplitude, frequency |
RandomWalkGenerator |
Simulates Brownian motion: a drifting random walk with optional noise | start_value, mu, sigma |
OrnsteinUhlenbeckGenerator |
Simulates mean-reverting noise with drift toward a long-term mean | mu, theta, sigma, dt, start_value |
Modifier Wrappers (tsg.modifiers)
| Class | Description | Parameters |
|---|---|---|
GaussianNoise |
Adds Gaussian noise (N(mu, sigma)) to any base generator |
mu, sigma |
Meta-Generators (tsg.meta_generators)
| Class | Description | Parameters |
|---|---|---|
RegimeSwitchGenerator |
Switches between generators at predefined time steps | generator_classes, generator_params_list, switch_times |
MarkovSwitchGenerator |
Switches between generators using a Markov transition matrix | generator_classes, generator_params_list, transition_matrix, initial_state |
All components implement the BaseGenerator interface with:
generate_value(last_value)– returns the next value in the sequencereset()– resets any internal state (optional for stateless generators)
Acknowledgments
Funded by the European Union. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or European Research Executive Agency (REA). Neither the European Union nor the granting authority can be held responsible for them.
License
MIT — see LICENSE.
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 tsg_lib-0.1.8.tar.gz.
File metadata
- Download URL: tsg_lib-0.1.8.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7723c4cf6ee955441c932640f140ef0317d2d83760397f4d5072b780d3400bd
|
|
| MD5 |
1b2d11acb3d81a84361120ad8bd99f89
|
|
| BLAKE2b-256 |
54f1846a629ae64bf39af3e25f379a29a949989e3afe6ad84173e4db396badd2
|
Provenance
The following attestation bundles were made for tsg_lib-0.1.8.tar.gz:
Publisher:
pypi-publish.yml on MSCA-DN-Digital-Finance/tsg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsg_lib-0.1.8.tar.gz -
Subject digest:
a7723c4cf6ee955441c932640f140ef0317d2d83760397f4d5072b780d3400bd - Sigstore transparency entry: 311980084
- Sigstore integration time:
-
Permalink:
MSCA-DN-Digital-Finance/tsg@7a012040e34ba785b47420871571957fe92e5841 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/MSCA-DN-Digital-Finance
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@7a012040e34ba785b47420871571957fe92e5841 -
Trigger Event:
release
-
Statement type:
File details
Details for the file tsg_lib-0.1.8-py3-none-any.whl.
File metadata
- Download URL: tsg_lib-0.1.8-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dddab0d904649c4a8954fbcf6431da5a44e87afa622a3580912e8db1259c206
|
|
| MD5 |
bbae557c259e697d5c04989fe82d9933
|
|
| BLAKE2b-256 |
f3ca541751ff3622c827d5370d9546a33553e452d23fe9632291e3af2914d00d
|
Provenance
The following attestation bundles were made for tsg_lib-0.1.8-py3-none-any.whl:
Publisher:
pypi-publish.yml on MSCA-DN-Digital-Finance/tsg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tsg_lib-0.1.8-py3-none-any.whl -
Subject digest:
6dddab0d904649c4a8954fbcf6431da5a44e87afa622a3580912e8db1259c206 - Sigstore transparency entry: 311980095
- Sigstore integration time:
-
Permalink:
MSCA-DN-Digital-Finance/tsg@7a012040e34ba785b47420871571957fe92e5841 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/MSCA-DN-Digital-Finance
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@7a012040e34ba785b47420871571957fe92e5841 -
Trigger Event:
release
-
Statement type: