Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Slightly Confused About 'Daily Positions and Gains' Field

Problem I'm facing:
I was under the impression that Gains in the 'Daily Positions and Gains' bar was the summed $ returns on all assets in your portfolio on that day. One of my algorithms had a meltdown in October 2015, falling 5% in 2 days before continuing on as normal. I was going back through the Gains log to see if I'd fallen victim to an unaccounted for stock split. What I found instead is that these returns weren't even accounted for.

In the backtest the daily returns chart (underneath the main curve chart) showed my algorithm losing $3,007 on October 5th 2015 and $2,437 on October 6th 2015. However the Gains field for those days in the 'Daily Positions and Gains' showed me making $29.06 and $98.43 respectively.

Obviously a drawdown like this is strange no matter the context, but I was especially confused by Quantopian not accounting for it in their logs based on my interpretation of what they are. Can someone from Quantopian (or someone more well-versed in the platform than me) explain to me what is going on?

There wasn't a single stock which I lost more than $5 on on October 5th and on October 6th my biggest single loss was $155.

I'm not going to share the backtest because I'm very happy with what the performance is looking like at the moment. I have attached a notebook of the isolated problem though.

The Notebook seems to think the biggest loss in a single stock was -$2887.38, the Backtest is saying that the biggest loss in a single stock was -$155.02

4 responses

Hi Quant Trader,

Looking at that drop in returns, my guess is that there's a data issue somewhere, but I can't tell for sure without being able to access the backtest result. Unfortunately, even if I clone the notebook, I can't dig into the daily positions because the backtest isn't public, nor am I the 'owner' of it. Is there any chance you'd feel comfortable sharing the backtest privately with our support team? If so, please go to Help --> Contact Support and create a ticket with the relevant backtest attached.

If you don't feel comfortable sharing it, can you isolate the exact date where you see the drop? One reason that the offending asset might not be showing up in the Daily Positions and Gains is that the algo might have closed out the position (possibly because it believed the stock's price was tanking due to a missed corporate action). I'd also recommend looking into the algo's transactions on the day of the drop.

Let me know what you find.

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.

The exact drop occurs on October 5-6th 2015. That's the thing that confused me the most, it fell over two days consistently.

I think what I'll do is attach an older version of the algorithm in a message to the support team

Upon reviewing the older version of the algorithm that Quant Trader sent in, we discovered that the sudden drop in returns is due to a data bug with MSG and MSGN where the prices are unintentionally swapped on the day of the spinoff event. The issue has been filed internally. For now, the workaround is to omit MSG from the algo's pipeline using a StaticAssets filter.

Thank you @Quant Trader for reporting the issue and sorry for the inconvenience.

That seems to make sense, but these two stocks seem to report massively positive returns in the round trips analysis rather than the negative I'd expect. Those two stocks are up 91% and 85%, if these two stocks were at fault, would the portfolio not shoot up?