Back

Python version of Candlestick example

Hi guys, 

Can anybody spot the error in this simple attempt to extract a Doji candlestick from 1 minute bars?

I thought I was correctly converting a c# based version from this much older thread  : https://www.quantconnect.com/forum/discussion/1239/candlestick-ex . BTW , what is the preferred forum behavior? Post to the original thread or post to new thread if the original thread is pretty old?

 

Here's the error I get: 

uring the algorithm initialization, the following exception has occurred: Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the Doji method. Please checkout the API documentation.
at Initialize in main.py:line 34
TypeError : No method matches given arguments for Doji

Yet when I look up the arguments for CandlesticksPatterns.Doji I see: 

var doji = CandlestickPatterns.Doji(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)

So i interpret that as requiring only a symbol.  Note I was using Symbol.Value ( a string) in my algo, but I tried the Symbol object as well, with the same failure message.

 

Thanks

 

 

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 Serge,

Could you please share your code so we can replicate the error and assist you further?

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 Alethea, 

Here it is. While this produces no errors, if you look at the log files, the doji pattern never generates any results besides 0.0.  I suspect it is obtaining incorrect input variables into the tradebar, but have not yet figured out how to get accurate values in. 

If I cannot solve it I will use History fetches and the talib Candelsticks libraries to accomplish my goal but this appears to be a very inelegant solution, so hopefully you can shine a light on this for me.

Thanks

 

0


Hi Serge,

Please see the attached backtest for fixes! Create the indicator by calling self.CandlestickPatterns.Doji(self.symbol), and then use self.pattern.Current.Value to check the current value for the indicator. The self.pattern returns an object instead of the value you want.

Hope this helps!

2

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