Stagnation bug

Sometimes QuantAnalyzer has an issue when calculating the stagnation period. This issue has been reported on the forum here: https://strategyquant.com/forum/topic/5914-stagnation-bug/

In short, the stagnation period is not correct and attached are two pictures where the issue can be seen.

Thank you very much for taking the time to help!
Attachments
Stagnation 2.png
(320.89 KiB)
Stagnation 1.png
(136.64 KiB)
  • Votes 0
  • Project QuantAnalyzer
  • Type Bug
  • Status Fixed
  • Priority Low

History

X
#1

Xenon

31.05.2018 09:59

Task created

X
#2

Xenon

01.06.2018 18:21

Attachment Time period.png added

I found the issue. The stagnation period is calculated correctly, so in my picture (Stagnation 1.png) above, the stagnation is 100 days (and is correct). HOWEVER, the equity line on the EQUITY CHART and the table with the MONTHLY PERFORMANCE are calculated with trades arranged with OPEN TIME and not CLOSE TIME.


This means that the monthly performance numbers in the table can be vastly different. In my case, booking the trades using open time (standard in Quant Analyzer) means that my strategy had 21 losing months, but booking the trades using close time results in my strategy having 15 losing months (out of 136 total months).


If trades in the equity chart and monthly performance table should be booked according to open time or close time can be debatable, but it would be nice to have the option to choose! In the "Time Analysis" tab this can be chosen, and it would be fantastic if we could have this option on the "Overview" tab and "Equity chart" tab as well (or a global option to apply it everywhere)!


Thank you once again for your help!

X
#3

Xenon

08.06.2018 10:49

Attachment Stagnation bugpart1.rar added

Attachment Stagnation bugpart2.rar added

Attachment Stagnation bugpart1.rar deleted

Attachment Stagnation bugpart2.rar deleted

Attachment Stagnation bugpart1.rar added

Attachment Stagnation bugpart2.rar added

UPDATE: June 8, 2018


I have done further testing now, and believe I have found part of the issue. There is a stagnation bug.


If the first trade of a strategy/portfolio is a loss and following trades are also losses, this stagnation will not be counted because the first trade is a loss. If, however, the first trade of a strategy/portfolio is a profit and the following trades are losses, then the stagnation will be counted. Maybe the reason for this is that in the second example the balance went above 0 and then down, compared to the first example where the balance never touched 0 and went down directly.


Please see the attached RAR file (containing the SQA file "Stagnation.sqa" and "Stagnation and month issue.xlsx") where you can see an example.


If I manually calculate the stagnation by exporting the trade list to Excel, I get maximum stagnation of 245 days.

If I import the SQA file in Quant Analyzer, Quant Analyzer will say that the stagnation is 91 days.

If I use "What If analysis" and select "Take trades from 30.01.2007 to 01.01.2017", the suddenly the stagnation of the same SQA file goes from 94 days to 178 days.


Another strange thing, is that there seems to be an issue with "Monthly Performance ($)" on the "Overview" tab. The results are not correct.

If I manually calculate the number of months with losses in the "Overview" tab, I get 36 months.

If I calculate the number of months with losses by exporting the trade list to Excel, I get 35 months.


This issue with the number of months with losses are perhaps of less importance, but the stagnation days is a very important issue in my opinion!


Thank you very much for your help!

TT
#4

Tamas

16.01.2019 14:19

Status changed from New to Fixed

Both of the problems have been fixed.


Monthly stats are computed from Close time.

The code for computing max stagnation was adjusted to count also stagnation when the first trade is a loss.


Thanks for reporting!


Votes: 0

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please