Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
set_commission, set_slippage

I have noticed that when the parameters of set_commission and set_slippage are set to zero no trades are executed. I am using the template found here: https://www.quantopian.com/posts/long-short-pipeline-multi-factor

I also did a test where I commented out the set_commission and set_slippage lines and the backtester did execute trades, though the ending total return numbers were much lower than when the set_commission and set_slippage parameters were set with the defaults that come with the template:

set_commission(commission.PerShare(cost=0.0075, min_trade_cost=1.0))
set_slippage(slippage.VolumeShareSlippage(volume_limit=0.025, price_impact=0.1))

I then did a test where I with the following parameters:

set_commission(commission.PerShare(cost=0.00075, min_trade_cost=.01))
set_slippage(slippage.VolumeShareSlippage(volume_limit=0.0025, price_impact=0.01))

The results were as expected, the ending total returns were higher. But, not by the margin I expected them to be.

Can someone shed some light on this for me.

Thank you.

5 responses

Also, when I run this strategy (the one I mention above as well)

https://www.quantopian.com/posts/long-short-pipeline-multi-factor

no trades are executed. I can't seem to figure out why that would be the case.

Hello John,
This is a fairly common mistake. Ctrl+f the keywords: "slippage" and "commission" in the Help and API docs. When you don't specify a slippage or commission (commenting them out) the default will set one for you.
If no trades are executed try changing it from minute mode to daily or vice versa. Also fiddle with the start and end dates. Sometimes people post algos that don't work during the entire span from 2002 to now.

Thanks, Dan. I did try the algo with minute data and it did, as you say, execute trades. I couldn't however find anything in the docs that specifies what triggers minute data vs daily. I did notice that the algo clears open orders at the end of the day and thought maybe that was why. The other algos I've been looking at execute at the start of the day.

The daily vs minute mode will have an effect on the time required to run the algo. Some algos only need to execute once per day and can be run in daily mode because of this to save time. If you build an algo that needs to execute every minute, or for 2 or more minutes a day or maybe at a specific time, then it must be run in minute mode. The more times code is read, the longer the backtest will take to execute. Having those 2 options is useful. You'll get a feel for it when you've looked at many algos.

Thanks, Darth (sorry for the wrong name in the previous reply) I am reading the API docs now and getting a better idea of what the simulator is doing behind the scenes. Pretty cool actually. It'll be a while before I can create an algo without the help of the templates, but having the templates available sure gets you addicted in a hurry. I spent all weekend plugging and playing with different fundamental factors...