Demeter is a blockchain backtesting tool that supports trading types such as swaps, liquidity provider, lending, and options. It is compatible with markets including Uniswap, GMX, Aave, Deribit, and Squeeth.
Demeter
Introduction
Demeter is a backtesting framework for Defi of ethereum-like chain. It allows investors test their strategy and evaluate return rate with real market data. At present, demeter support backtest on uniswap v3 and aave v3
Demeter's style is borrowed from backtrader, allowing developers of traditional financial engineering to get started quickly.
Demeter has good testing accuracy, it can calculate income and net worth close to the real world. Demeter has also made some optimizations for backtesting speed.
Features
- backtrader style: Demeter's design style and operation process are modeled after Backtrader, making it easier for
- broker/market: Demeter draws on the concepts of brokers and markets from real markets. Broker holds the asset and
- Data feeding: Backtesting requires real market data. Thanks to the transparency of blockchain, those data can be
- Accuracy: In the design of demeter, accuracy is an important consideration. In order to provide higher accuracy,
- Rich output: In order to allow users to evaluate strategies intuitively, demeter provides a wealth of output,
- Indicators: Besides the simulation of defi market, demeter also provides various indicators. Those indicators will
- Rich interface in strategy: In strategy, demeter provide a lot of interface, which help user to write strategy
- Price: Price is the key to calculate token net value, since it will be used among markets. We separate price from
- Decimal places: You can define decimal places to avoid long decimal.
Markets
- Uniswap V3 As a popular automated market maker, uniswap is famous for its complexity. To raise fund
- Aave V3 Aave is a popular liquidity protocol which allow user to deposit and borrow assets. Through supply
- Deribit
- Sequeeth
- GMX V1
- GMX V2
- Boros (experimental)
Boros Experimental Support
This repository now includes experimental Boros support under demeter.boros_v4.
Two sample workflows are available:
samples/strategy-example/72borosfunding_convergence.py
samples/strategy-example/77borosconvergencewithperp_funding.py
The Boros implementation currently supports:
raw Boros event loading from orderbook/.csv and liquidity/*.csv
- Boros settlement recovery using
latestFTime,floating_index, and
fee_index - taker-only replay with
TXREPLAYBEST_EXEC - higher-fidelity event replay with
EVENTREPLAYFULL_PROTO - result exports including trade, settlement, spread, and perp funding ledgers
samples/boros-backtest-modes/README.mdsamples/boros-backtest-modes/CURRENT_COMPARISON.mdsamples/boros-backtest-modes/RELEASE_GUIDANCE.md
- no standalone perp market yet
- no maker queue simulation
- no full liquidation or external margin model
- still marked experimental rather than protocol-perfect
Conclusion
Our vision is to become the best Defi backtesting tool, you can check our release_note for the latest updates.
Links
- website: https://zelos-demeter.readthedocs.io/
- Medium: https://medium.com/zelos-research
- Pypi: https://pypi.org/project/zelos-demeter
- demeter-fetch: https://github.com/zelos-alpha/demeter-fetch
- Deribit option data(ETH): https://www.dropbox.com/scl/fo/kwk5kgiseu5rvccjscd0f/ANswtRLzpCxOc6cMTH0oRlE?rlkey=ai071f9695uz287lt8k0bci5e&e=1&st=ntbog1sr&dl=0
Donation
If you like this project and would like to support our development, please consider donating. Your support will help us continue to improve and expand our features, thank you for your generosity!
| Chain | Address | | -------- | -------------------------------------------------------------- | | Bitcoin | bc1pex0d2rkpsgmwauahauxlthakqz27c0ura75zjqhmj0vet07mu65swur90n | | Ethereum | 0x41FE1FFdF42121496b2e67287962E25Bb75dAA2D | | Polygon | 0x41FE1FFdF42121496b2e67287962E25Bb75dAA2D | | TRON | TM3DG2TzEvyv9Amv9oBHJA7Q2URJZWPFmz | | Solana | DHS2KwrNbeHEfSnfiEMNYB15dWv9qnbMSYJtayAWCw2s | | BSC | 0x41FE1FFdF42121496b2e67287962E25Bb75dAA2D |