Metadata-Version: 2.4
Name: crosstrade
Version: 0.1.0
Summary: A shared-core trading package for SB3 backtests and MT5 live trading.
Home-page: https://github.com/cpohagwu/crosstrade
Author: Collins Patrick Ohagwu
Author-email: Collins Patrick Ohagwu <cpohagwu@gmail.com>
Project-URL: Homepage, https://github.com/cpohagwu/crosstrade
Project-URL: Repository, https://github.com/cpohagwu/crosstrade
Project-URL: Issues, https://github.com/cpohagwu/crosstrade/issues
Project-URL: Documentation, https://crosstrade.readthedocs.io/en/latest/
Keywords: trading,stable-baselines3,gymnasium,chronos,metatrader5
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Topic :: Office/Business :: Financial :: Investment
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy!=1.24.0,>=1.20
Requires-Dist: pandas>=1.2
Requires-Dist: PyYAML>=6.0
Requires-Dist: gymnasium>=0.29
Requires-Dist: stable-baselines3>=2.0.0
Requires-Dist: matplotlib!=3.6.1,>=3.4
Requires-Dist: ccxt>=4.0.0
Requires-Dist: ta-lib>=0.5.1
Provides-Extra: chronos
Requires-Dist: crosslearn[chronos]>=0.1.0; extra == "chronos"
Provides-Extra: extra
Requires-Dist: crosslearn[chronos]>=0.1.0; extra == "extra"
Requires-Dist: MetaTrader5>=5.0; extra == "extra"
Requires-Dist: python-dotenv>=1.0.0; extra == "extra"
Requires-Dist: tensorboard>=2.0.0; extra == "extra"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# 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:

```bash
pip install crosstrade
```

With Chronos embeddings:

```bash
pip install "crosstrade[chronos]"
```

With MT5 live trading support:

```bash
pip install "crosstrade[extra]"
```

## Public API

```python
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

```python
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

```python
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](https://github.com/cpohagwu/crosstrade/blob/main/LICENSE).
