I have an algo thats been running for a while live on FXCM using EURUSD as my security. I'd like to switch to USDJPY but when running the backtest I get a new stacktrace error and I can't figure out why.
Any ideas? Same algo, different currency pair
146 | 10:33:07:Runtime Error: Division by zero (Open Stacktrace)
at System.Decimal.op_Division (Decimal d1, Decimal d2) [0x00000] in :0 at QuantConnect.Algorithm.QCAlgorithm.CalculateOrderQuantity (QuantConnect.Symbol symbol, Decimal target) [0x00000] in :0 at QuantConnect.FXCMBollengerBands.OnDataFifteen (System.Object sender, QuantConnect.Data.Market.TradeBar consolidated) [0x00000] in :0
Ray Bohac
I wonder if unitPrice is somehow 0 here
https://github.com/QuantConnect/Lean/blob/master/Algorithm/QCAlgorithm.Trading.cs#L626
Jared Broad
Disabling the warm up it works fine but takes 10 days to warm up. It may be an issue with the SetWarmup logic. We'll have to look into this deeper and will get back to you here.
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.
Alexandre Catarino
unitPrice is zero here, because Security.QuoteCurrency.ConversionRate is zero here.
The conversion rate is updated when the CashBook is updated which only occurs after the warming up period.
The IsWarmingUp condition check is missing from the algorithm:
private void OnDataFifteen(object sender, TradeBar consolidated) { if (IsWarmingUp) return; // ... }
So why did it work for EURUSD?
Because the AccountCurrency is USD, therefore the conversion rate is 1.
When the algorithm traded EURUSD without the IsWarmingUp condition check, it didn't throw "Division by zero" exception, but it was buying it on 10 days before the StartDate. Since it was running in live mode, that detail passed unnoticed.
Ray Bohac
Great catch thank yiou
Sagi
Alexandre Catarino I have similar problem following are my init paramsÂ
In portfolio construction I am trying to access the quote conversion which always comes as zero even after warm up period
Since rate is always zero my script does not generate any target. Just to be clear I have downloaded audusd hourly data prior to run above.Â
Ray Bohac
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!