Back

Expected 2D Array, got scalar array

Attempting this tutorial. 

https://www.quantconnect.com/tutorials/strategy-library/trading-with-wti-brent-spread

 it worked fine a couple days ago and now i get this error. i copied the code fresh from the page.

 

Runtime Error: ValueError : Expected 2D array, got scalar array instead:
array=46.1700.
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
at OnData in main.py:line 47
ValueError : Expected 2D array, got scalar array instead:
array=46.1700.
Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample. (Open Stacktrace)

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.


Hi Apollos.

Thank you for pointing out the error you encountered. I have fixed the bug that caused the strategy to break down. The error was caused because scalar was being passed to the function regr.predict(), instead of a 2d array. You can now access the fixed WTI/Brent Spread strategy in the Strategy Library and in the attached backtest.

0


Thanks Halldor!

0

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