Skip to main content

A shared-core trading package for SB3 backtests and MT5 live trading.

Project description

crosstrade

crosstrade is a shared-core trading package for two runtime surfaces:

  • Gymnasium backtests for stable-baselines3
  • MT5 live trading sessions driven by the same portfolio, execution, and risk logic

The intended model stack is crosstrade + crosslearn + stable-baselines3. The deprecated timeseries_trader and timeseries_agent workflows are no longer part of the package.

Install

Core package:

pip install crosstrade

With Chronos embeddings:

pip install "crosstrade[chronos]"

With MT5 live trading support:

pip install "crosstrade[extra]"

Public API

from crosstrade import (
    FeaturePipeline,
    TradingEnv,
    build_offline_embeddings,
    evaluate_policy,
    load_binance_ohlcv,
    make_offline_env,
    make_online_env,
)
from crosstrade.core import ExecutionConfig, RiskConfig

Backtest Example

import pandas as pd

from crosstrade import FeaturePipeline, make_online_env
from crosstrade.core import ExecutionConfig, RiskConfig

df = pd.read_csv("notebooks/data/DOGEUSDT_train.csv")
pipeline = FeaturePipeline(add_technical=True)
featured = pipeline.fit_transform(df)

env = make_online_env(
    featured,
    window_size=30,
    frame_bound=(30, len(featured)),
    feature_columns=["open", "high", "low", "close", "volume"],
    execution_config=ExecutionConfig(commission_rate=0.001, spread=0.05),
    risk_config=RiskConfig(stop_loss_pct=0.02, take_profit_pct=0.04),
)

Live Trading Example

from stable_baselines3 import PPO

from crosstrade import FeaturePipeline
from crosstrade.live import MT5Broker, MT5TradingSession

broker = MT5Broker(symbol="DOGUSD", timeframe="M5")
model = PPO.load("models/ppo_doge")
pipeline = FeaturePipeline(add_technical=True)

session = MT5TradingSession(
    broker=broker,
    policy=model,
    feature_pipeline=pipeline,
    feature_columns=["open", "high", "low", "close", "volume"],
    window_size=30,
    poll_interval=60.0,
)

Set MT5_SERVER, MT5_LOGIN, and MT5_PASSWORD in the environment before running live sessions.

License

CrossLearn is released under the Apache License 2.0. See the 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

crosstrade-0.1.0-py3-none-any.whl (43.8 kB view details)

Uploaded Python 3

File details

Details for the file crosstrade-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: crosstrade-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 43.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.0 CPython/3.14.3

File hashes

Hashes for crosstrade-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1823ed4702088053dd6c37a296661556fbd52afb5e77edef77b776a0da9b72b0
MD5 18b98ffc24f2a9b4644d243d46c4376f
BLAKE2b-256 697afb37816990709b12d5f807ca0a1b633e58047c3458668eb826a9b055e37e

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