Skip to main content

Tradetropy

Tradetropy

PyPI Python versions Downloads License Tests Docs

A professional backtesting and live trading framework for algorithmic trading strategies, with first-class support for footprint analysis and market microstructure.

Write a strategy once and run it unchanged across backtest, live and replay - the engine differences are a transport detail behind the same Strategy API.

Features

  • Backtesting engine over candles or ticks with realistic order simulation.
  • Live trading over WebSockets (CCXT Pro) and MetaTrader 5.
  • Order flow and footprint: large trades, Deep Trades (L2/L3 absorption and sweeps), cumulative delta, COT, volume profile and liquidity overlays.
  • Indicator library: the classic studies plus market-structure tools, all through one declarative contract.
  • Optimization and pools, Monte Carlo robustness and interactive Bokeh plotting.
  • Data management with NumPy .npz / CSV IO built in (Parquet and HDF5 optional) and bundled sample datasets.

Installation

pip install tradetropy

The base install includes everything for backtesting, plotting and data IO. Broker integrations and Parquet are optional extras:

pip install tradetropy[mt5]       # MetaTrader 5
pip install tradetropy[ccxt]      # CCXT crypto exchanges (live + streaming)
pip install tradetropy[bybit]     # Bybit (pybit)
pip install tradetropy[parquet]   # Parquet IO (pyarrow)
pip install tradetropy[hdf5]      # HDF5 IO (PyTables; not available on Termux)
pip install tradetropy[all]       # all runtime extras

On desktop (Windows/macOS/Linux) every dependency installs as a prebuilt wheel, so no compiler is needed. Termux (Android) is the exception - the scientific stack builds from source there; see the Termux install guide.

Quickstart

Every loader in tradetropy.datasets returns ready-to-use data, so this runs with no data files or API keys:

from tradetropy import Strategy, BacktestEngine
from tradetropy.ta import SMA
from tradetropy.datasets import load_btcusd_1m


class SmaCross(Strategy):
    def init(self):
        self.btc = self.subscribe_ohlc('BTCUSD', '1m', window_size=200)
        self.fast = self.add_indicator(self.btc.close, SMA(10))
        self.slow = self.add_indicator(self.btc.close, SMA(30))

    def on_data(self):
        if self.fast[-1] > self.slow[-1]:
            if not self.sesh.positions('BTCUSD'):
                self.sesh.buy('BTCUSD', volume=1)
        else:
            for pos in self.sesh.positions('BTCUSD'):
                self.sesh.position_close(pos.ticket)


bt = BacktestEngine.by_klines(SmaCross(), data=(load_btcusd_1m(),))
bt.run()
print(bt.stats)

bt.plot() renders the full interactive chart (candles, indicators, equity, drawdown and a per-trade P&L panel). Static preview of that same chart, from the docs example - see the interactive version there (zoom, pan, hover tooltips):

Tradetropy interactive chart

More runnable scripts are in examples/.

Documentation

Full documentation - user guide and API reference - is at https://michiTrader.github.io/tradetropy/.

To build the docs locally:

pip install tradetropy[docs]
mkdocs serve

Contributing

See CONTRIBUTING.md. Development setup:

git clone https://github.com/michiTrader/tradetropy.git
cd tradetropy
uv sync
uv run pytest

Risk disclaimer

Tradetropy is provided "AS IS", without warranty of any kind. Trading financial instruments involves risk of loss of capital - you may lose part or all of your funds. Always test first on a demo / testnet / paper account and verify that orders, positions and balances behave as expected before trading with real money. Broker and exchange APIs may change without notice and break a connector. The authors and contributors are not responsible for any losses, damages or execution failures arising from the use of this software. This is not financial, investment or legal advice, and you are responsible for complying with the laws of your jurisdiction and your broker/exchange terms of service.

The full disclaimer is available at runtime as tradetropy.LIVE_DISCLAIMER.

License

MIT - see LICENSE.

Metadata

Release files for tradetropy 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tradetropy 0.3.2
File Size Uploaded Provenance Actions
tradetropy-0.3.2.tar.gz 952.3 kB Without provenance Details for tradetropy-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tradetropy 0.3.2
File Interpreter ABI Platform Actions
tradetropy-0.3.2-py3-none-any.whl Python 3 none any Details for tradetropy-0.3.2-py3-none-any.whl

Total release size: 2.0 MB

Release files / tradetropy-0.3.2.tar.gz

Download URL tradetropy-0.3.2.tar.gz
Size 952.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0d938438f021c239cfd75c4c7864070209c4532c4734fcd2ee80b9eec0159b24
BLAKE2b-256 checksum
How to use checksums
1b9109e809c66b311cd93037e3ddf8fe52df55812e48f64c160bde642a46017e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / tradetropy-0.3.2-py3-none-any.whl

Download URL tradetropy-0.3.2-py3-none-any.whl
Size 1.1 MB
Tags Python 3
SHA-256 checksum
How to use checksums
77bfd75930673bc016e108d63f6f7f2b83e99ebebbe3a324fe2e2f444026abf2
BLAKE2b-256 checksum
How to use checksums
fbb4b98f7a8980adddda5c35b70579940e53610d74d544081d6c0297c47c1fe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for tradetropy 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page