Skip to main content

GPU-accelerated quantitative time-series feature extraction for financial data

Project description

ts-quant ๐Ÿš€

GPU-Accelerated Quantitative Feature Extraction for Financial Time Series

PyPI Python 3.9+ PyTorch License: MIT

Extract 2000+ quantitative features from OHLCV stock data using 5 powerful engines โ€” all running on GPU via PyTorch.

๐ŸŽฏ Why ts-quant?

Feature tsfresh (CPU) ts-quant (GPU)
Speed ~60s per stock ~0.3s per stock
Memory OOM on large data VRAM-managed, crash-proof
Features 794 (statistical only) 2000+ (statistical + wavelets + rocket + signatures)
GPU โŒ โœ… PyTorch/CUDA

๐Ÿ“ฆ Installation

pip install ts-quant

Requirements: Python 3.9+, PyTorch 2.0+ (with CUDA for GPU acceleration)

๐Ÿš€ Quick Start

import pandas as pd
from ts_quant import generate_features

# Load your OHLCV data
df = pd.read_csv('stocks.csv')
# Expected columns: symbol, date, close, volume, open, high, low

# Extract features (GPU)
df_features = generate_features(
    df,
    device='cuda',              # 'cpu' for CPU-only
    tsfresh_mode='comprehensive',
    window_sizes=[20],
)

print(f"New features: {df_features.shape[1] - df.shape[1]}")

๐Ÿ”ง 5 Feature Engines

Engine A: MultiRocket ๐ŸŽฏ

Random convolutional kernels with multi-scale dilations.

from ts_quant import RocketEngine

engine = RocketEngine(n_kernels=250)
features, names = engine.extract(x)  # x: [B, T]
# โ†’ 1000 features (250 kernels ร— 4 pooling ops)

Engine B: Catch22 ๐Ÿ“Š

22 canonical time-series features (ACF, DFA, entropy, etc.).

from ts_quant import Catch22Engine

engine = Catch22Engine()
features, names = engine.extract(x)
# โ†’ 22 features per window

Engine C: Path Signatures โœ๏ธ

Ordered interaction features via iterated integrals.

from ts_quant import SignaturesEngine

engine = SignaturesEngine(depth=3, channels=['close', 'volume'])
features, names = engine.extract(x_multivariate)  # [B, T, d]
# โ†’ d + dยฒ + dยณ features

Engine D: Wavelets ๐ŸŒŠ

Discrete wavelet transform (Haar, db4, db2, sym4).

from ts_quant import WaveletsEngine

engine = WaveletsEngine(wavelet_types=['haar', 'db4'])
features, names = engine.extract(x)
# โ†’ 62 features (energy, entropy, mean, std, max per level)

Engine E: Tsfresh Complete ๐Ÿ“ˆ

63 mathematical functions, 361 features in comprehensive mode.

from ts_quant import TsfreshEngine

engine = TsfreshEngine(mode='comprehensive')
features, names = engine.extract(x)
# โ†’ 361 features (statistics, ACF, FFT, entropy, trend, ...)

โšก VRAM Management

ts-quant automatically manages GPU memory to prevent OOM crashes:

# Works on any GPU size (8GB - 80GB)
df_features = generate_features(
    df,
    device='cuda',
    max_vram_gb=8,  # Optional: manual VRAM limit
)

๐Ÿ”ฌ Feature Selection

Built-in redundancy removal:

from ts_quant import auto_select_features

selected, names = auto_select_features(
    features_tensor,
    feature_names,
    correlation_threshold=0.95,  # Remove highly correlated
)

๐Ÿ“ Input Format

Your DataFrame should have this structure:

symbol date open high low close volume
BBCA 2024-01-02 9500 9600 9400 9550 1000000
BBRI 2024-01-02 5200 5300 5100 5250 2000000

๐Ÿ—๏ธ Architecture

ts-quant/
โ”œโ”€โ”€ ts_quant/
โ”‚   โ”œโ”€โ”€ api.py              # Orchestrator โ€” generate_features()
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ memory_manager.py   # Dynamic VRAM management
โ”‚   โ”‚   โ”œโ”€โ”€ tensor_utils.py     # DataFrame โ†” Tensor conversion
โ”‚   โ”‚   โ””โ”€โ”€ windowing.py        # GPU sliding windows
โ”‚   โ”œโ”€โ”€ engines/
โ”‚   โ”‚   โ”œโ”€โ”€ rocket.py           # Engine A: MultiRocket
โ”‚   โ”‚   โ”œโ”€โ”€ catch22.py          # Engine B: Catch22
โ”‚   โ”‚   โ”œโ”€โ”€ signatures.py       # Engine C: Path Signatures
โ”‚   โ”‚   โ”œโ”€โ”€ wavelets.py         # Engine D: Wavelets
โ”‚   โ”‚   โ””โ”€โ”€ tsfresh_core.py     # Engine E: Tsfresh Complete
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ”œโ”€โ”€ config.py           # Default configurations
โ”‚       โ”œโ”€โ”€ validation.py       # Input validation
โ”‚       โ””โ”€โ”€ feature_selection.py # Redundancy removal
โ””โ”€โ”€ tests/

๐Ÿ“„ License

MIT 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

ts_quant-0.1.2.tar.gz (55.0 kB view details)

Uploaded Source

Built Distribution

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

ts_quant-0.1.2-py3-none-any.whl (50.0 kB view details)

Uploaded Python 3

File details

Details for the file ts_quant-0.1.2.tar.gz.

File metadata

  • Download URL: ts_quant-0.1.2.tar.gz
  • Upload date:
  • Size: 55.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for ts_quant-0.1.2.tar.gz
Algorithm Hash digest
SHA256 31ed61e70535cab21e0e0f00b2da04dcd9bb87f56bf21a3e6eb8d9e19f6c3d07
MD5 d67eb93c5737eefd57a1c36aab7bc733
BLAKE2b-256 c7f016232639c70e86caeea6b378f19754ba7f686ba8eb0f66f1cbeb10984f84

See more details on using hashes here.

File details

Details for the file ts_quant-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ts_quant-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 50.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for ts_quant-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f2fcadb93a2e45719199f0c888cbd72a6e92c90d047f25ba4c30b8315733836
MD5 a5edaf570d6f5dbef2b71f7f91695699
BLAKE2b-256 9e2aec6af7ebdecdfc639b7b989a14d4cb76494c6a856f77899993a9e469c770

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