SQX Stockpicker, "#Bars in trade" don't match Export

Hi,

Info in the SQX summary doesn't match xlsx Export  in terms of "# AVG bars in trade".
In my research also "Exposure" is also not "right", but I don't know how you count it. Please check these measures for Stockpicker if possible.


There are very important numbers for portfolio creation.


The screens and sample strategy are attached.


Thanks!
Michal

Attachments
Export.png
(44.26 KiB)
TradelistExport BB.xlsx
(150.07 KiB)
Summary.png
(92.75 KiB)
Sample_BB_Rev.sqx
(321.91 KiB)
ExportSQX.png
(178.91 KiB)
image-1.png
(236.42 KiB)
  • Votes +1
  • Project StrategyQuant X
  • Type Bug
  • Status Fixed
  • Priority Normal

History

m
#1

Michal

29.05.2023 18:10

Task created

E
#2

Emmanuel

30.05.2023 13:06
Voted for this task.
TT
#3

Tamas

30.05.2023 22:56

Attachment image-1.png added

image-1.png
(417.41 KiB)

Hello,


statistical values of the strategies are calculating using Databanks snippets.

You can open CodeEditor and check the exact formula of each metric (AvgBarsInTrade, Exposure...)


Please check it and let me know if you have any further questions. 

m
#4

Michal

31.05.2023 10:18

Attachment 2023-05-31 09-54-04.mp4 added

Attachment TradelistExport.xlsx added

Attachment Sample_Limit.sqx added

Sample_Limit.sqx
(70.34 KiB)
2023-05-31 09-54-04.mp4
(9.00 MiB)
TradelistExport.xlsx
(46.92 KiB)
Thanks for the details. I'm not a Java programmer but can see your formulas now ;)


1. I'm sure that # of bars is wrong - please see a short movie I have recorded showing the problem. Avg. need and is 5 in this example (in Excel also), but the measure is showing 1.7. All files are attached.

2. I see that exposure assumption is "Exposure = # bars in all positions / total # bars in the sample",

Then it is based on #of bars, 

if #of bars is wrong, then all measures based on that measure are wrong also.


MF
#5

Mark Fric

31.05.2023 12:41

Status changed from New to Waiting for information

you were right about Avg. bars in trade, we fixed the formula.


As for the exposure - the idea behind formula is as you write: # in days when there was a position / total # of all days.


But when computing the metrics we don't get information about the bars - we know only start+end date of the data, and open+close time for every trade.

We compute exposure from this - so it is computed using days between these dates, not real bars.


Holidays and weekends are included - but both on the total side and on the trades side. So computed exposure is not 100% exact, but it should be very close to the real value.

m
#6

Michal

31.05.2023 14:14

Attachment Sample_Limi.sqx added

Attachment screen1.png added

Attachment screen2.png added

Attachment TradelistExportStockpicker.xlsx added

screen2.png
(33.52 KiB)
screen1.png
(183.16 KiB)
TradelistExportStockpicker.xlsx
(1.56 MiB)
Sample_Limi.sqx
(1.23 MiB)
Hello Mark, nice to meet you :) I have a lot of respect for your and your team work.

Thanks for the fix about Avg. bars in trade.


I agree with the Exposure formula "# in days when there was a position / total # of all days".
But my question is:  is the current calculation accurate also for Stockpicker? Because in stockpicker we split the capital between "Max open positions" number.
In my calculations the answer is no. 


Let me ilustrate it by Tradelist example:

1. I created a column Days in trade = Close Date - Open Date (screen1).

2. I created a pivot table and summary on top of that (screen2).
3. I count a "Max load" assuming that in all days, are open all 20 positions (my set in max open position settings)
3. Avg exposure in this period is 57%, SQX exposure is showing me 99,85% 

I know it is not simply subject but quite important during creating of the Portfolio process. I'm sure you will find the right solution to it :)

Best regards,

Michal 

PS. Spreadsheet and s
trategy with my settings are attached. 


MF
#7

Mark Fric

02.06.2023 13:56

Status changed from Waiting for information to Fixed

Nice to meet you too, I appreciate al your help and work testing the project.


As for exposure - it depends on what exactly exposure it - there are multiple definitions.


In the exposure algorithm we use the definition that doesn't consider number of positions, only if that day was something open or not.


But your point of view is useful as well, so we'll add another  ExposurePosition metric that will consider also number of open positions compared to total max positions allowed. 

This is what you describe. It will bein the next public build.



m
#8

Michal

07.07.2023 14:26

Attachment scr_.png added

scr_.png
(204.02 KiB)
Hello Mark,


I don't see the ExposurePosition in RC4 build. Did you publish it already?

Best regards,

Michal

TT
#9

Tamas

07.07.2023 14:38

Attachment image-0.png added

image-0.png
(26.37 KiB)
Hello, yes it was added. 

You have to go to Databanks and create a new view with column "Exposure Position".


You can also create a new Overview template using CodeEditor and display the metric if your want :)


Tamas

m
#10

Michal

07.07.2023 17:04

Attachment scr2.png added

scr2.png
(319.23 KiB)

Hello Tamas,


I see a new column, thanks!


I stuck a bit in the new view creation :P 

Can you help me?


1. I cloned DefaultOpenDD view.

2. I renamed it - it is appearing OK

3. I try to fill a blank space below "Exposure". 


I see it is row 228:

replace("S4_3", "", "");


I try to fill it like original Exposure, but the new measure is not available on the list to chose -> see the screen.


What do I need to change?


This is my current 228 row:


 replace("S4_3", L.t("Exposure Position"), stats==null ? NA : d2(stats.getDouble(StatsKey.Exposure, 0))+" %");

TT
#11

Tamas

07.07.2023 18:59

Attachment image-0.png added

image-0.png
(434.65 KiB)
Please modify the line to
replace("S4_3", L.t("Exposure Position"), stats==null ? NA : d2(stats.getDouble("ExposurePosition", 0))+" %");

TT
#12

Tamas

07.07.2023 19:04
I have also added the missing constant to StatsKey

public static final String EXPOSURE_POSITION = "ExposurePosition";


It will be available in the next version. But it is just a string constant :)

It doesn't matter if you write there directly the name of the metric "ExposurePosition" or StatsKey.EXPOSURE_POSITION 

m
#13

Michal

10.07.2023 12:10
It is working! The first CodeEditor lesson is behind me ;)
Thanks Tamas!
TT
#14

Tamas

10.07.2023 12:41
Perfect, I am glad that it works :)

Votes: +1

Drop files to upload

or

choose files

Max size: 5MB

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

...
Wait please