SQX_136_win_final_20221223 [SEVERE BUG]: SQX builds invalid strategies that are difficult to detect. SQX is looking into the future (stockpicker engine)

Hey. I made a small stock group consisting of 6 stocks. I used the stock group to find a few strategies. All the strategies are set to open trades at the last trading day of the month. I retested the strategies using start day 2022.11.30. In total 17 strategies were opened. So far so good.

Then I made another stock group with the same 6 stocks. This time I replaced the data from the last month with data from the previous month. I did this for all 6 stocks. Then I retested the strategies again with start day 2022.11.30 using the modified data. I would expect the strategies to open 17 trades again, but now only 12 trades were opened. This is not right. The replaced data was from 2022.11.30 an onwards, not including 2022.11.30.

To me this shows that SQX is looking into the future when retesting. SQX is using data after 2022.11.30 to open trades at 2022.11.30. This also shows that SQX is building strategies that look into the future. This is serious because these strategies will probably not trade at all when trading live! I have already addressed this before in another task, and it was fixed. But maybe not completely fixed. Please fix it for all indicators in the TA library, and not only the indicators in the strategies attached to this task. Please also fix it for both long and short strategies.

Thank you.

Regards.

Attachments
Portfolio TestGroup_modified.sqx
(107.14 KiB)
Portfolio TestGroup.sqx
(108.25 KiB)
Data.zip
(210.40 KiB)
Strategies.zip
(90.94 KiB)
Retest.cfx
(9.20 KiB)
  • Votes +3
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

d
#1

Hamselv

16.01.2023 02:14
Voted for this task.
E
#2

Emmanuel

16.01.2023 05:59
Voted for this task.
TT
#3

Tamas

16.01.2023 16:17

Status changed from New to Waiting for information

Attachment image-0.png added

Attachment image-1.png added

Attachment image-2.png added

image-2.png
(404.37 KiB)
image-1.png
(320.08 KiB)
image-0.png
(432.93 KiB)
Hello, thanks for reporting the issue but for me it is not clear. 


Can you turn on the detailed log and show me which signals are not valid ? 

You can do it by selecting Trading options -> Store stockpicker log. After backtest go to Results->Stockpicker log and check entry/exit signals + open positions for every day.

d
#4

Hamselv

16.01.2023 19:53

Attachment 1 Log Portfolio TestGroup.txt added

Attachment 1 Log Portfolio TestGroup_modified.txt added

1 Log Portfolio TestGroup.txt
(3.89 KiB)
1 Log Portfolio TestGroup_modified.txt
(3.24 KiB)
Sure, I have attached the detailed logs for both portfolios (TestGroup and TestGroup_modified). It looks like TestGroup is making more trades than TestGroup_modified according to the logs (at least one more trade). But I don't know which signals are valid and not valid. It could be either portfolios that is valid, I don't know. Furhtermore, when I wrote about the difference in trades (12 vs 17) I was looking in the List of trades in Retester.
d
#5

Hamselv

16.01.2023 19:54

Attachment 2 Log Portfolio TestGroup normal.txt added

Attachment 2 Log Portfolio TestGroup_shorter.txt added

Attachment Data TestGroup_shorter.rar added

Attachment Portfolio TestGroup normal.png added

Attachment Portfolio TestGroup normal.sqx added

Attachment Portfolio TestGroup_shorter.png added

Attachment Portfolio TestGroup_shorter.sqx added

Attachment Retest shorter.cfx added

Portfolio TestGroup_shorter.sqx
(100.90 KiB)
Portfolio TestGroup normal.sqx
(99.43 KiB)
Portfolio TestGroup normal.png
(137.90 KiB)
2 Log Portfolio TestGroup normal.txt
(6.74 KiB)
Data TestGroup_shorter.rar
(98.79 KiB)
2 Log Portfolio TestGroup_shorter.txt
(6.99 KiB)
Portfolio TestGroup_shorter.png
(153.80 KiB)
Retest shorter.cfx
(3.72 KiB)

I have tested a lot more. Maybe this scenario can help put light on the issue:

I took the data from the TestGroup and shortened the data for every stock by 2 months, so the last day was 2022.10.31. I made a stock group using this data and called it TestGroup_shorter.

Then I retested the same strategies as before using Start day = 2022.09.30 and End day = 2022.10.31. When I use the original stock group called TestGroup then the Retester shows 9 trades in total (attached as Portfolio Testgroup normal)). But when I switch to the new stock group called TestGroup_shorter then the Retester shows 13 trades in total (attached as Portfolio TestGroup_shorter). The interesting thing is that both log files seem to be identical.

It looks like if there is more data beyond the End day, then the trades are different compared to when the End day is the last day in the data set. I don't know which one is correct.

All files are attached.

Does it make any sense?

d
#6

Hamselv

16.01.2023 20:12
I just found out that the log files only contains the trades from a single strategy and not the whole portfolio it seems. So please disregard my comments about the log files.


Do you need other files from me?


d
#7

Hamselv

17.01.2023 09:43

Attachment TestGroup.png added

Attachment TestGroup_shorter.png added

TestGroup.png
(124.22 KiB)
TestGroup_shorter.png
(142.08 KiB)
HI again. I slept on it and realized that is it difficult for me to explain what the problem is. So here are 2 screenshots that explains it all:


One screenshot shows the stock group TestGroup. TestGroup uses data from 2017.01.03 to 2022.12.30.

The other screenshot shows the stock group TestGroup_shorter. TestGroup_shorter uses data from 2017.01.03 to 2022.10.31.


So both stock groups contain the same data except TestGroup_shorter which has 2 months less data than TestGroup. I filtered out 3 strategies that show the issue.


On both screenshots the retest period is 2022.09.30 - 2022.10.31. The stock group TestGroup shows 5 trades in total but TestGroup_shorter shows 9 trades in total. I would expect the number of trades to be the same. I don't know which one is correct or if they both are wrong.


It would be nice if the issue was fixed for both long and short trades and for all indicators in the TA library.


Does it make sense now please?


Regards

c
#8

crazyhedgehog

22.01.2023 10:07
Voted for this task.
TT
#9

Tamas

28.03.2023 09:21

Status changed from Waiting for information to Fixed


Votes: +3

Drop files to upload

or

choose files

Max size: 5MB

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

...
Wait please