Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
What is wrong with position size?

There seems to be something wrong with the algo, when I add a criteria to cover a short position on close > ema AND high > Highest High of Past 15 days, the position size seems to go haywire? If I comment out the else if and high portion the algo seems to present more normal results. Anyone know what's going on here?

5 responses

The only thing I can think of is in the IF statement it is continuously shorting 10,000 worth every day the statement is true, therefore compounding the trade rather then just once when the criteria is true?

Hi Nakul,

The order_target methods don't check for open orders when they make their purchasing logic. Take a look at this thread for more details: https://www.quantopian.com/posts/order-target-percent-ordering-too-much

Cheers,
Alisa

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 have a CSV file with data going back to 2004. However when I run the algo, it only back tests from 2009 (this is when the security began to trade, the previous 5 years data are simulated). I assume it has something to do with context.security using the Quantopian data versus my CSV? Thanks!

Hi Nakul,

You're exactly right, the algorithm only starts the backtest beginning 2009 because that's when the stock began trading. Unfortunately, even if you have simulated data for the previous 4 years, you'll only be able to actually execute orders for when we have data for the stock. E.g. order(context.security).

Does that make sense? I can clarify a little more if it doesn't.

Seong

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.

That makes sense but then makes my data pretty worthless unfortunately. Back to excel i guess!