Full Code
How It Works
Flat fees (default)
A singlepaper_fee_rate is applied to every fill regardless of whether the order was resting in the book (maker) or crossing the spread (taker).
Split maker/taker fees
Set different rates for each role. Makers add liquidity and typically pay lower fees. Takers remove liquidity and pay higher fees.paper_fee_rate:
Checking fill type
EveryFill includes an is_maker boolean:
When to Use Split Fees
- Backtesting market-making strategies where most fills should be maker fills at lower fees
- Modeling real exchange fee tiers (Polymarket charges 0 bps maker / 100 bps taker)
- Comparing strategy profitability under different fee structures
- Stress testing to see if your edge survives higher taker fees
In the paper exchange, maker/taker classification is based on the order price relative to the mid price at fill time. For more realistic classification using L2 orderbook data, use
hz.backtest() with book_data which switches to the BookSim exchange.