Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Possible Real Money Bug

I started a real money algo with Quantopian the other day; so far so good! I stopped the algorithm, made adjustments, and fired it back up to test the state discovery and noticed that the cost_basis for a couple positions did not update.

This was in the logger:
2014-02-06 06:31SYSTEMINFO(IB) IB reports position in sid XOM is 1, not 0 shares; updating Quantopian blotter
2014-02-06 06:31SYSTEMINFO(IB) IB reports position in sid STX is 1, not 0 shares; updating Quantopian blotter

While the position was updated, the average cost is set at $0.00. While it would be nice to get stocks for free, it's not the case, so I thought I should share this.

4 responses

That is indeed a bug. The code is supposed to get the cost basis from IB and populate that into your algorithm, with the position. I'll look into it.

Let me elaborate further. When you have a position in IB that doesn't match what Quantopian has, Quantopian accepts IB's position as "truth" and updates the Quantopian status. That breaks into a couple main sub-cases.

  • If Quantopian has a zero position, and IB has non-zero, then Quantopian updates everything - the position, the cost basis, etc.
  • If Quantopian has non-zero position, and IB has non-zero, then it's a bit trickier. The position is updated in Quantopian, of course. However, we don't adjust the cost basis. IB and Quantopian use different cost basis calculation methods, and it's very difficult to infer the cost basis when you have mis-matched amounts.
  • The third case is if Quantopian has non-zero and IB has zero, in which case the point is moot - zero shares means no cost basis!
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.

Glad I made it known then. It seems like this would fall under the first case, in which case IB would have to be saying the shares were free. This is sort of a soft launch for me to test these things out so I'll keep you guys posted on any strange happenings. Thanks for the quick response.

We found the bug. We're testing the fix today. Presuming the tests work out well, the fix will be on the servers for Monday's market open.

Thanks again for reporting it.

Thank you Dan!