When I'm backtesting the portfolio, I get a message : divide by zero exception. There are many instruments in the portfolio, but each one works on the same signal. While I'm finding a solution through disabling the tools. The same signal on the other instruments continues to work. I also run this signal outside of portfolio testing and everything works without errors.
What is the solution of problem with this exception ?
Divide by zero exception during the portfolio backtesting [SOLVED]
-
- Posts: 43
- Joined: 27 Oct 2019
- Has thanked: 29 times
- Been thanked: 1 time
Divide by zero exception during the portfolio backtesting
- Attachments
-
- 2023-11-12_01-57-37.png
- (22.21 KiB) Not downloaded yet
- Kate MultiCharts
- Posts: 606
- Joined: 21 Oct 2020
- Has thanked: 12 times
- Been thanked: 152 times
-
- Posts: 43
- Joined: 27 Oct 2019
- Has thanked: 29 times
- Been thanked: 1 time
Re: Divide by zero exception during the portfolio backtesting
Kate, thank you!
I know why it can appear.
In my case i see this exception at 30% of instruments while testing portfolio, and it never appears during test at terminal with same instruments and signals.
I started this topic because i thought that something wrong with instruments in portfolio.
I know why it can appear.
In my case i see this exception at 30% of instruments while testing portfolio, and it never appears during test at terminal with same instruments and signals.
I started this topic because i thought that something wrong with instruments in portfolio.
- TJ
- Posts: 7746
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2225 times
Re: Divide by zero exception during the portfolio backtesting [SOLVED]
GIGO
The only variable is the input data.
If the input has a zero, or the resultant of your logic calculation returns a zero, you will get a "Divide by Zero" error.
The solution is simple -- go through your code with a fine-tooth comb.
The only variable is the input data.
If the input has a zero, or the resultant of your logic calculation returns a zero, you will get a "Divide by Zero" error.
The solution is simple -- go through your code with a fine-tooth comb.
-
- Posts: 43
- Joined: 27 Oct 2019
- Has thanked: 29 times
- Been thanked: 1 time