Skip to main content

TimeStrader Preprocessing Package for Historical Data Processing and Normalization

Project description

TimeStrader Preprocessing Package

PyPI version Python

A comprehensive data preprocessing package optimized for TimesNet and PPO model training in financial trading systems. This package provides historical data processing, normalization, and technical indicator calculation for financial time series data.

Features

  • Historical Data Processing: Efficient processing of financial time series data
  • Advanced Normalization: Multiple normalization methods including z-score with customizable scalers
  • Technical Indicators: Built-in technical analysis indicators
  • Data Leakage Prevention: Proper train/validation/test splitting with scaler management
  • Performance Optimized: Designed for high-frequency trading applications

Installation

pip install timestrader-preprocessing

Quick Start

import pandas as pd
from timestrader_preprocessing import HistoricalProcessor

# Initialize processor
processor = HistoricalProcessor()

# Process your financial data
data = pd.DataFrame({
    'open': [100, 101, 102, 103, 104],
    'high': [101, 102, 103, 104, 105],
    'low': [99, 100, 101, 102, 103],
    'close': [100.5, 101.5, 102.5, 103.5, 104.5],
    'volume': [1000, 1100, 1200, 1300, 1400]
})

# Normalize data with proper train/validation/test splitting
train_data, scaler = processor.normalize_data(train_data, return_scaler=True)
val_data = processor.normalize_data(val_data, scaler=scaler)
test_data = processor.normalize_data(test_data, scaler=scaler)

Advanced Usage

Data Leakage Prevention

The package provides robust data leakage prevention for machine learning pipelines:

from sklearn.preprocessing import StandardScaler
from timestrader_preprocessing import HistoricalProcessor

processor = HistoricalProcessor()

# Training phase - fit scaler on training data only
train_normalized, scaler = processor.normalize_data(
    training_data,
    return_scaler=True,
    method='zscore'
)

# Validation phase - use existing scaler
val_normalized = processor.normalize_data(
    validation_data,
    scaler=scaler
)

# Test phase - use existing scaler
test_normalized = processor.normalize_data(
    test_data,
    scaler=scaler
)

Technical Indicators

# Calculate technical indicators
processed_data = processor.calculate_technical_indicators(data)

# Available indicators include:
# - Moving Averages (SMA, EMA)
# - RSI (Relative Strength Index)
# - MACD (Moving Average Convergence Divergence)
# - Bollinger Bands
# - And many more...

Requirements

  • Python 3.9+
  • pandas>=2.0.0
  • numpy>=1.26.0
  • scikit-learn>=1.3.0
  • pydantic>=1.10.0

Integration with TimeStrader

This package is designed to work seamlessly with the TimeStrader trading system:

  1. TimesNet Training: Provides properly normalized historical data for time series forecasting
  2. PPO Training: Supplies normalized features with proper train/validation/test splits
  3. Production Inference: Efficient real-time data processing for trading decisions

Version History

Version 1.0.9

  • Fixed data leakage prevention in normalize_data method
  • Added scaler parameter support for consistent normalization
  • Improved train/validation/test data splitting
  • Enhanced performance for high-frequency trading applications

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For technical support and questions, please visit our GitHub repository.

Contributing

We welcome contributions! Please see our contributing guidelines for more information.

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

timestrader_preprocessing-1.0.11.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

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

timestrader_preprocessing-1.0.11-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file timestrader_preprocessing-1.0.11.tar.gz.

File metadata

File hashes

Hashes for timestrader_preprocessing-1.0.11.tar.gz
Algorithm Hash digest
SHA256 0e21d06892025b7e4f809230804d33449433713a30f3190e11b30ff050c9a70a
MD5 d6ea1995cb37a6bc66fefde4adfb65cb
BLAKE2b-256 670ddcbac8f2e74ee5ee0e2a65bf2a45e71047775d119ea1fdb497d20fedcfb5

See more details on using hashes here.

File details

Details for the file timestrader_preprocessing-1.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for timestrader_preprocessing-1.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 aab8ac4b7cc9f51b7a57322c9e2458afd77b7142206e7f335d9ac7a2e175b2f1
MD5 d20a80c82a2453648675f555c1c0504e
BLAKE2b-256 c9d60038d96926c7e13a1a4baa11e00d9c2bdaf6d0e3ea3c1513ad82d9fff7fb

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