Additional What If or Money Management option: adjust trades in a strategy using a ratio with round up or round down option

Can you please add the option to modify orders in a strategy by a ratio with a round down and round up option.


For example if 3 orders in a strategy are 0.02, 0.05, 0.04 lots (with trade size decimals = 2) and a 50% or 0.5x ratio adjustment is applied, this option will modify orders with the round down option to 0.01, 0.02 and 0.02 lots and the round up option will modify to 0.01, 0.03 and 0.02 lots and all trading statistics will be modified accordingly e.g. profit or loss etc.

Attachments
No attachments
  • Votes +1
  • Project QuantAnalyzer
  • Type Feature
  • Status Fixed
  • Priority Low

History

JK
#1

Insanity82007

21.02.2020 10:03

Task created

JK
#2

Insanity82007

21.02.2020 11:43
Voted for this task.
TT
#3

Tamas

03.03.2020 08:12

Status changed from New to Fixed

It should be simple. Open CodeEditor and create a new MM snippet.

...

@Override public double computeTradeSize(SQOrder order, double tickSize, double pointValue) throws Exception {      return order.Size / 2; }


JK
#4

Insanity82007

04.03.2020 02:33
Thanks Thamas.


I have very little understanding of how java works and don't know how to implement this snippet to make it work.


Can you please give me some instructions for this.


I'm assuming this is not the complete code and that I need to combine it with other code to make it work?

Where do I put this?

How do I make sure it works? 

How do I use it?

How do I modify a strategy and automatically save it back to a databank?

What else do I need to know?

TT
#5

Tamas

04.03.2020 07:51

Attachment PctAmount.java added

Copy the snippet from the attachment to your QA installation directory \extend\MoneyManagementTypes\PctAmount.java and restart QA.


If you want to edit the snippet do it via QuantEditor.

JK
#6

Insanity82007

05.03.2020 11:59

Attachment NormaliseDrawdown.java added

Attachment NormaliseDrawdown.java deleted

Attachment NormaliseDrawdown.java added

Thanks Tamas


I played around with this and worked on understanding java and the QuantEditor and I managed to succeed with creating a whatIf snippet that does this :)


I also managed to get it to work with my bulk whatif script that you and Tomas sent me too and was very happy with this.


However, I want to extend this further by normalising Drawdown $ for each strategy and I've got the script doing that, but only when I enter a static Current Drawdown value. I've tried very hard to find a way to get the Drawdown value for the strategy I'm working with into a variable called currDD, but can't find a way when looking at other scripts. It looks very complex and I'm stumped.


Can you please help?

Current script attached



TT
#7

Tamas

05.03.2020 12:33

Attachment NormaliseDrawdown.java added

Attachment WhatIf.jpg added

We need a little hack to get it work. Please see the attachments



JK
#8

Insanity82007

05.03.2020 13:00

Attachment WhatIfBulk.java added

Attachment WhatIf Results.png added

Tamas YOU ARE A LEGEND!!!! THANK YOU SO MUCH!


It works like a charm :) and it works even better with the WhatifBulk script too!! :) 


Can I ask for one more favour. How do I transfer the note from the original stratregy to the new What If strategy as per the picture (attached) using my WhatifBulk script (also attached)?


Thanks :)

TT
#9

Tamas

05.03.2020 14:10

Attachment setNote.jpg added

strategyResultsNew.set("Note", "custom text");
JK
#10

Insanity82007

05.03.2020 22:42

Attachment Results.png added

Thanks for pointing me in the right direction.


It wasn't quite what I was looking for, but I was able to figure out the rest and ultimately used strategyResultsNew.set("Note", rg.get("Note")); to give me exactly what I was looking for.


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