Back

TradeBar not working for forex

I'm trying to make an algorithm using forex tradebars, but I keep getting an error. the curious thing is that when I use the exact same algorithm for equities, it works perfectly.

The line that causes the error is:

self.window.Add(data[self.syl])

The error message is " Runtime Error: 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 Add method. Please checkout the API documentation. "

 

I can't attach the backtest with the error, so I am attaching the backtest that works. I have commented out the adding of the forex symbol and replaced it with SPY.  But if you use the forex symbol you can reproduce the error.

self.aaa = self.AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute)
#self.aaa = self.AddForex("EURUSD", Resolution.Minute)

 

Thank you in advance for the help.

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.


Please attach a backtest or even a code snippet for assistance.



It works fine but likely the algos type declarations are mixed up
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 Jared,

Thanks for the reply. I cannot attach the backtest with the error for EURUSD because it does not get saved.

I have attached the working backtest in for SPY the first post. If you # the SPY line and remove # from the EURUSD line, you will get the error i described.

self.aaa = self.AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute)
#self.aaa = self.AddForex("EURUSD", Resolution.Minute)

0

The window is declared to hold tradebars; but Forex are QuoteBars.
self.window = RollingWindow[TradeBar](2)https://www.quantconnect.com/docs/algorithm-reference/handling-data
 Its actually not documented very well so we'll rewrite this section today.
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.


Thank you for your assistance.

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