Skip to main content

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)
base_generator = LinearTrendGenerator(start_value=100, up=True)

# Wrap it with Gaussian noise (mean=0, std=1)
noisy_generator = GaussianNoise(base_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
LinearTrendGenerator Linearly increases or decreases the value at each step
ConstantGenerator Returns a fixed value (e.g., simulates cash)
PeriodicTrendGenerator Generates a sinusoidal time series with set amplitude and frequency

Modifier Wrappers (tsg.modifiers)

Class Description
GaussianNoise Adds Gaussian noise (N(mu, sigma)) to any base generator

All components implement the BaseGenerator interface with:

  • generate_value(last_value) – returns the next value in the sequence
  • reset() – 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.

EU Logo

License

MIT — see LICENSE.

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

tsg_lib-0.1.3.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

tsg_lib-0.1.3-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file tsg_lib-0.1.3.tar.gz.

File metadata

  • Download URL: tsg_lib-0.1.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for tsg_lib-0.1.3.tar.gz
Algorithm Hash digest
SHA256 86e44c49efcc75e0e67e682abab1852944c6c1c8f2eae821ff82b2aee91c3c73
MD5 75a18b845e7f3b5656ece33048e0a524
BLAKE2b-256 8d71b02953d6591c3afbdd13d1c89dabbc4af2e3f80c13a4f8f93cede52391c1

See more details on using hashes here.

File details

Details for the file tsg_lib-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: tsg_lib-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for tsg_lib-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 32f2b8c06f526cc2eb1a33af5fe7bea7be070b2f4aace988a3a9655166cb0f54
MD5 64cd825f42c55d19e58137eb07febdbc
BLAKE2b-256 95940af7947edb70b8792d05e13c2dafea5d189081848e6a76d0ab177a0d98e8

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