Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How would backtest results differ from log outputs?

Right now in my algo, i have a print statement every time an order is placed. However in backtesting, the transactions and the log output are not matching up, such that the log output is saying many more transactions are occurring than the backtest results. Anyone have any idea how this could be true?

3 responses

Rohit, I think you're seeing the difference between orders and transactions. A single order can have many transactions, or fills. That is particularly common when you're making an order that large compared to the minutely volume of the stock being traded. The default slippage model will constrain you to 2.5% of the trading volume, so a large order will fill over many minutes.

If that's not the right explanation, it will be helpful if you post a sample backtest with the problem.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

I noticed something similar, but it occurs when the logging limit is reached. I have a count incremented on a buy and reduced on a sell. On a six-month backtest, this count gets out of whack on the dates after the limit is reached (around the four month mark). Yet, if I do two three-month backtests so that it doesn't hit the log limit, the counts are fine.

Dave, I'd keep digging. The logging limit doesn't affect algorithm behavior, like keeping track of counts. You might not be able to see the output, but that count should be maintained according to the algorithm logic.

(It's possible there is a bug - I never say never on bugs - but I would be quite surprised.)