Back

Short Selling Issues

Hi, 

I am trying to short sell using a negative decimal along with the self.SetHoldings function and I keep getting the error that it is," unable to compute order quantity  since lot size is less than 1". Any help is much appreciated.

Thanks,

Ken

Update Backtest








0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


https://www.quantconnect.com/forum/discussion/4743/pairs-trading-changing-time-resolution/p1/comment-13851

just searched for it 30 seconds :)

maybe it helps

oh you are using macd crossover

try to edit the EMA crossover from the python examples provided by Quantconnect

0

Thank you. I will give it a try.

0

https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/MovingAverageCrossAlgorithm.py
0

Thank you again for the info. I made some corrections based off the info provided and it fixed some issues. I also am getting an insufficient buying power error now. I am trying to do a version of the 130% long and 30% short strategy and I am not sure if it is correct. Thanks.

1


Hi Ken,

The insufficient buying power error is due to the fact that the cost of the order being placed is larger than the margin available in the account at the time. Based on the resolution of the data, this algorithm will attempt an enormous number of trades very quickly and this will eat up considerable margin -- having a daily indicator while using minute-resolution data without any position controls will mean this algorithm will place a trade every minute of a given day where the MACD conditions hold true. When working with such a fine resolution and placing trades nearly every minute (or every time a slice object gets pumped into the OnData method), I would suggest a shorter backtest period or combine coarse-resolution data (i.e. daily) with a longer testing period.

As for ensuring a 130%/30% long/short strategy, the current implementation of the algorithm is creating a 160%/30% long/short portfolio. I've attached a backtest where the algorithm uses self.SetHoldings to create long and short positions, and the self.Log statements provide a sanity-check and show a consistent 130%/30% ratio. More information about self.SetHoldings can be found here and here.

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Jack,

I really appreciate you getting back to me. Thank you for all of the information and guidance. I switched the resolution to hourly instead of every minute and changed the time-frame.  Here it is and it seems to work without issues. I will be paper-trading it live starting in the morning just to see if everything works properly. I will let you know if any issues come up. Thank you again.

0


No problem, glad that I could help. Good luck!

0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed