zelos-alpha/demeter
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.
Add Boros Experimental Support
Add gmx swap and perpetual market
Add quote token to BacktestConfig class Add gmx v2 perpetual position operation; Add uni && gmx delta neutral return analysis.
📋 Changes
- fix issue in check aave repay amount
- add on_error function in Strategy which will be called on exceptions
- fix duplicate values in ActionTypeEnum values
- Allow aave to test with non-stable coin as quote token
- Fix issue in gmx pool whose long token == short token.
Add pending pnl and net yield for GMX v2 market
📋 Changes
- Add gmx v2 market
- Add swap in broker, in case there is no swapble market in backtest
- Show net value in process bar during backtest
- AAVE market:
- [Breaking change] Improve aave market, you can download risk parameter with demeter-fetch
- Remove stable rate borrowing in aave v3
- [Breaking change] remove supply and borrow key, just use token instead, because there are only one interest rate.
- add ltv and max_ltv in market balance
Improve performance in deribit market. You should clear cache in your first running to make it work.
Change return value in subprocess to avoid large object copy between processes
Add BacktestManager
📋 Changes
- change order when saving backtest result
- data and price has updated. The value in the beginning of the minute will follow the value in the last minute(In old version it will be decided by the first transaction in this minute.)
- fix issues in data cache(when feather file is lost, a error will be raised)
- show market name when loading data
- add lp net value for uniswap market balance
- deribit: convert type of t when loading csv
- fix other bugs
Add GMX Market, now can simulate gmx action about buy GLP and sell GLP, and get glp fee profit.
📋 Changes
- Uniswap V3:Add get position status, this will help to calculate amounts and values of a liqudity position
- [Breaking change] Uniswap V3: Update delta gamma calucation, add get_greeks in helper.
- Add start liquidity index for aave position
- Add net value for metrics
- Add cache to backtest data
- You can set account status file format in actuator.save_result()
For uniswap v3, when price is in and out of price range in this minute, fee will be calculated more accurately
Fix bugs in aave
📋 Changes
- [Breaking change]Value of ChainType enum has changed to chain id.
- Add base_token to UniV3Pool class
📋 Changes
- Add comment to action.get_output_str()
- When exception was raised in backtesting, demeter will save actions and account status
- Deribit market add max_mark_price_multiple, to prevent buying options too expensive to mark price
- Update strategy.finalize(), so you can operate account_status_df in strategy.finalize().
- Fix issues that strategy.account_status_df is empty
fix bugs add estimate functions in deribit and uniswap market
update deribit market and backtest result
📋 Changes
- Out of date triggers will be removed. so it's free to add triggers during backtesting
- Add logs in backtest result, if you call self.log in strategy, you can leave a log in backtest result file.
- Add fee in return of buy and sell function in deribit market. So return has changed from ```List[Order]``` to ```Tuple[List[Order],Decimal]```
📋 Changes
- Fix error in volatility calculation
- Update backtesting description, add backtest time
- Update metrics
📋 Changes
- [breaking change]output result has updated, .action.json and action.pkl is removed. Instead, backtest description is
- Add a new parameter "file_name" to actuator.save_result, so you can specific file name of backtest result
- broker and markets have quote token now, quote token can be different among markets. It can be set in actuator.set_price()
- external_price parameter in UniLpMarket.get_market_balance has removed, because net value returned by unilpmarket should be quoted by quote token of this pool
- [breaking change]When adding liquidity, tick should be trim according to tick spacing. Call nearest_usable_tick to get an available tick
📋 Changes
- [breaking change]Update minimal python version to 3.11
- [breaking change]Update get_account_status_df function to account_status_df property. account_status_df is available after backtest finished.
- account_status_df contains token price now
- Add "comment_last_action" function, you can add comment to last action, If you want to record parameters or reason of this transaction, call comment_last_action() in strategy
- [breaking change]Account status df use multiindex column now.
- [breaking change]Actuator.output() has renamed to "print_result", "Output" parameter in Actuator.run() has renamed to "print".
- [breaking change]evaluating_indicator has been move to an independent module: metrics, and it's easy to use now. Also, some new performance metrics is added. Including sharp raito, alpha, beta.
📋 Changes
- add print action switch
- add get_output_str for action types
- add pending time to PeriodTrigger, so you can trigger at specific time of a day
- fix bug: when daily minute file is empty, an error will be thrown
- Multiple improves in uniswap market.
- add price range to position
- fix bug: base token amount was actually value in add_liquidity_by_value
Add function add_liquidity_by_value for uniswap market
📋 Changes
- Fix issue: Precision setting not working in console output
- Fix issues in uniswap market:
- in even_rebalance function, balance calculation did not count swap fee
- [breaking change]Base and quote is reversed in older version. To accommodate this change, you need to:
- Update uniswap market:
- Add swap function. Keep in line with the contract.
- Decimal precision has raised from 28 to 36
- [breaking change]Update function name in Uniswap.helper as the old names are confusing.
- + 11 more
📋 Changes
- Add Squeeth market
- Change unit of sell fee in uniswap from quote token to base token
- add a parameter on collect fee of uniswap market, to decide transfer token to user or not
- fix issue: data head or tail may be blank in uniswap market
Add deribit option market
Fix: When uniswap market load data, if the start time of the first day is not 00:00:00, row count of the first day will not be 1440. Fix: to json of aave market actions. Fix: action timestamp is nan when make transaction in strategy.initialize() Fix: json dump doesn't support decimal
