Custom Fee Structures
Directory Structure
custom_modules/fees/<your_fee_model>.py
Implementing a Custom Fee Model
from ats.exchanges.fees.base_fees import BaseFees from typing import Dict, Union, Literal class CustomFeeModel(BaseFees): def _calculate(self, size: Union[int, float], price: Union[int, float], order_type: Literal['LIMIT', 'MARKET'], order_side: Literal['BUY', 'SELL']) -> Dict: """ Custom fee calculation logic. Args: size: The size of the order. price: The price of the base asset. order_type: The type of the order ('LIMIT' or 'MARKET'). order_side: The side of the order ('BUY' or 'SELL'). Returns: A dictionary containing the calculated fees in terms of the base and quote assets. """ fee_rate = 0.001 if order_type == 'LIMIT' else 0.002 # Example: different fees for LIMIT vs MARKET orders base_fee = size * fee_rate quote_fee = size * price * fee_rate return { 'base_fee': base_fee, 'quote_fee': quote_fee }
Using a Custom Fee Model
Example Directory Structure
Notes on Fee Models
Last updated