qtpylib
qtpylib copied to clipboard
Fee modelling
Hi @ranaroussi ! Love the package! Really light! Was wondering if fee modelling, slippage is available in the test environment. Best, Andrew
Hi @andrewcz ,
I don't see a hook in the code, but a workaround could be tracking this in your strategy file
For example, whenever you have an instrument.order()
or instrument.exit()
, you could add in slippage and commissions to a running total
For example, pseudocode could be:
COMMS = 2.50
SLIPPAGE = 10
total_comms = 0
total_slippage = 0
if some_event:
instrument.order(...)
total_comms = total_comms + COMMS
total_slippage = total_slippage + SLIPPAGE
if exit_event:
instrument.exit(...)
total_comms = total_comms + COMMS
total_slippage = total_slippage + SLIPPAGE
Alternatively, you can count the records in your self.record() and multiply by slippage and commissions. So you can stick a self.record(slippage_and_comms=1)
anywhere you take an instrument order or exit