The Trading Strategy protocol has created new Python-based trade and algorithmic strategy execution framework for decentralised exchanges.
In the past, the Trading Strategy protocol used Python-based Backtrader and QSTrader algorithmic trading frameworks to trade on decentralised exchanges. These frameworks had been originally designed with stock trading in mind. Furthermore, both of these projects are no longer maintained. Due to the specialised nature of decentralised markets, these frameworks could not sufficiently work for live trading or complex strategy scenarios.
Trading Strategy's new trade execution framework
We have been working for the last six months on a new trade execution framework that is built from the ground up to support decentralised exchanges and decentralised finance services. The new framework takes inspiration from its predecessors, but also includes flexibility making it suitable for on-chain trading.
The framework focuses on directional trading strategies, unlike high-frequency trading (HFT), miner extractable value (MEV) and passive yield farming strategies you often see with decentralised finance.
The features include, but are not limited to:
- No software installations are needed: the framework runs on a cloud-based MyBinder notebook service, Google Colab or any compatible Jupyter Notebook service
- Trading pairs with non-US quote tokens like ETH and BNB quoted pairs
- Trading and asset pairs with different quote tokens and exchange rate conversion
- Tracking of blockchain transactions, transaction confirmation and gas management
- Routing across multiple different decentralised exchanges that can all trade the same assets with different pairs
- A single trade needs to be split across multiple physical transactions like ERC-20 approve() management
- Support for different client asset and fund shares management schemes: single investor, hot wallets, vaults (EIP-4626) and fund protocols like Enzyme
- Support for deterministic oracle mode for Trading Strategy protocol
- Supports single trading pair strategies, but also strategies with dynamic trading universes of thousands of trading pairs (Trading Strategy currently lists more than 1M trading pairs)
- Live trading and backtesting result analysis using interactive Plotly based charts
- Each trade execution process runs as an isolated Docker process, in microservice like manner
- Shareable JSON state between the TypeScript frontend and Python backend
- 100% API documentation coverage
- Fully type hinted Python code to enable robust autocompletion and inline help for the strategy development
- Learning materials for Python developers who want enter to algorithmic trading industry
- Glossary for understanding algorithmic and DeFi trading terminology
Technical analysis features
The trade execution framework uses open source pandas_ta library for technical analysis, indicators, statistics and performance calculations.
Currently, it supports over 100 functions. All the indicators are documented.
Low-level blockchain integration
The trade execution framework integrates EVM-compatible blockchains using the open source Web3-Ethereum-Defi Python library. The development of Web3-Ethereum-Defi was sponsored by a Uniswap grant.
Web3-Ethereum-Defi features include but are not limited to
- Fast parallel event reader for EVM blockchains
- ERC-20 token management
- Hot wallet management
- Uniswap v2 and compatible DEX support
- Uniswap v3 based DEX support
Strategy and code examples
Although the current release is an early beta, there are some backtesting examples available in the documentation.
- Synthetic trading data example using randomly generated OHLCV data. This is mostly for testing the technical indicators on deterministic data.
- PancakeSwap BNB/USD strategy using exponential moving average indicators and their overlap for trade decisions
Try the code examples in the documentation and start playing with backtests. more releases coming in the upcoming weeks, enabling more DEXes, and integrations like Enzyme Protocol and Aave.
Trading Strategy is hiring. If you have experience with quant finance, data research or Python SQLAlchemy backends please contact us at [email protected].
Trading Strategy is an algorithmic trading protocol for decentralised markets, enabling automated trading on decentralised exchanges (DEXs). Learn more about algorithmic trading here.