Skip to main content

Crypto Trader Py

A lightweight Python toolkit for building, backtesting, and paper-trading cryptocurrency strategies.

Features

  • Unified market data from Binance, Coinbase, and Kraken (REST + WebSocket)
  • Simple strategy API: subclass Strategy and implement on_tick
  • Vectorized backtester with configurable fees, slippage, and funding rates
  • Paper-trading engine that runs strategies against live price feeds
  • Built-in indicators: SMA, EMA, RSI, MACD, Bollinger Bands, ATR
  • Risk management helpers: position sizing, stop-loss, take-profit
  • CSV/JSON trade logs and matplotlib equity curves

Installation

Install from PyPI:

pip install crypto-trader-py

Or from source:

git clone https://github.com/example/crypto-trader-py
cd crypto-trader-py
pip install -e .

Quick Start

from crypto_trader import Backtest, SMA, Strategy

class SmaCross(Strategy):
    def on_tick(self, candle):
        fast = SMA(candle.close, 10)
        slow = SMA(candle.close, 50)
        if fast > slow:
            self.buy(size=0.1)
        elif fast < slow:
            self.close()

bt = Backtest(strategy=SmaCross, exchange='binance', pair='BTC/USDT')
bt.run(start='2023-01-01', end='2023-12-31')
print(bt.stats())
bt.plot_equity('equity.png')

Paper Trading

Run a strategy against live prices without risking real funds:

from crypto_trader.paper import PaperEngine

engine = PaperEngine(strategy=SmaCross, exchange='binance', pair='BTC/USDT')
engine.start()

Disclaimer

This project is educational software and is not financial advice. Trading cryptocurrencies carries a high risk of loss.

License

MIT

Release files for crypto-trader-py 1.0.0

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

Source distribution (sdist)

Source distribution for crypto-trader-py 1.0.0
File Size Uploaded
crypto_trader_py-1.0.0.tar.gz 3.0 kB Details

Release files / crypto_trader_py-1.0.0.tar.gz

Download URL crypto_trader_py-1.0.0.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c20440226e70689325df502dae45e7dd813c91670a2367c57f3fe7e2a739d478
BLAKE2b-256 checksum
How to use checksums
e83c7e9a1405f2b629e95e48ccd7a6f3c0b963756862923d895716e9af6a8750
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file

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