qtpylib icon indicating copy to clipboard operation
qtpylib copied to clipboard

Fee modelling

Open andrewcz opened this issue 6 years ago • 1 comments

Hi @ranaroussi ! Love the package! Really light! Was wondering if fee modelling, slippage is available in the test environment. Best, Andrew

andrewcz avatar Nov 12 '18 22:11 andrewcz

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

lionelyoung avatar Jan 21 '19 15:01 lionelyoung