No project description provided
Project description
QTradeX Core Framework
Welcome to QTradeX, a powerful and flexible Python framework for designing, backtesting, and deploying algorithmic trading bots. Built with cryptocurrency markets in mind, QTradeX provides high-level abstractions for trading strategies, technical indicators, data handling, and optimization, making it an ideal tool for both novice and experienced algo-traders.
This repository contains the core QTradeX framework.
For a collection of pre-built trading strategies, check out the companion repository:
QTradeX Algo Trading Strategies.
Overview
QTradeX simplifies the development of trading bots by offering a modular architecture and robust tools:
- Core Modules: Build bots, run backtests, and optimize with a QPSO or LSGA.
- Data Integration: Fetch market data from exchanges like BitShares, KuCoin, and others via built-in CCXT integration.
- Indicators: Leverage wrapped traditional fininancial technical indicators from Tulip for strategy logic.
- Visualization: Plot trades and metrics with ease.
- Extensibility: Customize bots and integrate with your preferred exchanges or data sources.
Whether you’re experimenting with moving averages or building complex multi-indicator systems, QTradeX provides the foundation to turn your ideas into actionable trading algorithms.
Features
- Bot Development: Subclass
BaseBotto define custom strategies, indicators, and fitness metrics. - Backtesting: Simulate trades with historical data using
qx.core.backtest, or use the built-in CLI withqx.core.dispatch. - Optimization: Tune parameters automatically with Quantum Particle Swarm Optimization (
qpso.py) or Local Search Genetic Algorithms (lsga.py). - Data Pipeline: Access candle data from any of over a hundred sources.
- Performance Metrics: Evaluate bots with built-in fitness functions like ROI, Sortino ratio, and Win Rate with our fitness implementations.
- DEX and CEX Integration: Works on both Bitshares Decentralized Exchange and 100+ Centralized Exchanges
Speed
- Fully Vectorized: All indicators are calculated once and cached as vectors
- Data Cache: All API candle data from exchanges is collected once and stored on disk
- Back Propagation: Achieve 50+ backtests per second on a Raspberry Pi during parameter optimization
- Instant Backtest: 1000 candles and 10 indicators in less than a 1/10th of second.
Roadmap
- Live Execution: Finalize and test the live execution pipeline on Centralized Exchange via CCXT SDK and Bitshares Decentralized Exchange
- Indicators: Add additional Technical Indicators from sources other than Tulip
- Tradfi: Create connector for Traditional Retail Finance Brokerage(s); Stocks, Forex, Comex, etc.
Project Structure
qtradex/
├── common/ # Utilities like JSON IPC and BitShares nodes
├── core/ # Core bot logic and backtesting
├── indicators/ # Technical indicators and fitness metrics
├── optimizers/ # Optimization algorithms (QPSO, LSGA)
├── plot/ # Visualization tools
├── private/ # Wallet and execution logic
├── public/ # Data fetching and market utilities
└── setup.py # Installation script
Key files:
core/base_bot.py: Base class for creating trading bots.core/dispatch.py: Allows for easy management of botscripts and tunes.public/data.py: Manages market data retrieval.indicators/tulipy_wrapped.py: Wrapped Tulipy indicators for cached speed.
Getting Started
Installation
pip install qtradex
Example: Creating a Simple Bot
Here’s a minimal bot using an EMA crossover strategy:
import qtradex as qx
from qtradex.indicators import tulipy as tu
from qtradex.private.signals import Buy, Sell, Thresholds
class EMACrossBot(qx.core.BaseBot):
def __init__(self):
self.tune = {"fast_ema": 10, "slow_ema": 50}
def indicators(self, data):
return {
"fast_ema": tu.ema(data["close"], self.tune["fast_ema"]),
"slow_ema": tu.ema(data["close"], self.tune["slow_ema"])
}
def strategy(self, tick_info, indicators):
price = tick_info["close"]
fast = indicators["fast_ema"][-1]
slow = indicators["slow_ema"][-1]
if fast > slow:
return Buy()
elif fast < slow:
return Sell()
return Thresholds(buying=price, selling=price)
# Run the bot
data = qx.public.Data(exchange="kucoin", asset="BTC", currency="USDT", begin="2023-01-01", end="2023-12-31")
wallet = qx.private.PaperWallet({"BTC": 1, "USDT": 0})
bot = EMACrossBot()
qx.core.dispatch(bot, data, wallet)
For more examples, see the QTradeX Algo Trading Strategies repo.
Usage
- Build a Bot: Subclass
BaseBotand define yourindicatorsandstrategy. - Backtest: Use
qx.core.dispatchwith historical data fromqx.Data. - Optimize: Run a QPSO of LSGA to fine-tune parameters, which will be stored in
<working directory>/tunes/. - Deploy: Work in progress
Resources
- Strategies Repo: QTradeX Algo Trading Strategies
- Tulipy Docs: GitHub
- CCXT Docs: CCXT
License
This project is licensed WTFPL
Happy coding and trading! Open an issue if you run into problems or have ideas to share.
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
File details
Details for the file qtradex-1.0.tar.gz.
File metadata
- Download URL: qtradex-1.0.tar.gz
- Upload date:
- Size: 113.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c733d4b075bc4962dc65647b36112f077c1bc63b7b5380cdb7e2ec1789bcb10d
|
|
| MD5 |
e034c30ab1ee16a32de7b610aea8e11b
|
|
| BLAKE2b-256 |
7ae6b5ceacfcc3a4c991e25a54edfb584d889d62744d09e9ebfd57edbb93a70c
|