Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, TipmyPip, Edgar_Herrera), 804 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Portfolio Trading #470123
12/27/17 12:45
12/27/17 12:45
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Hi, JCL,

Merry Christmas and a Happy and prosperous coming New Year!

Would greatly appreciate your advice/clarification on the following:

1. What design pattern would you recommend for trading a portfolio of systems different mostly in parameters used?
e.g. 5x Sys1 x asset1 + 3x Sys1 x asset2 + 1x Sys1 x asset3 + 4x Sys2 x asset1 + 2x Sys3x Asset3...etc

Looping through Assets and Algo as described in the manual does not seem to fit elegantly with the problem -as one would have to name Algos differently for each parameter permutation ...

2. Do I understand correctly that algo names can be generated dynamically in the script (e.g. asset+algo+TimeFrame+Nr)?

3. There is mention of the "Component" variable in the manual. How is it enumerated and would typically be used?

4. At what point does Zorro calculate "Net"/Pool trade quantities per asset (when using Hedge) and actually sends orders to the Broker? Is it at the end of a run() function?

5. Can one have 2 or 3 asset/algo loops within run()?

6. If multiple Zorro instances are used with same algo names - will all saved Vars and files used be instance-specific and SaveStatus/LoadStatus be managed by Zorro correctly?

7. Would it be possible to enlarge the internal array of ResultsLong/Short from 20 to 50 last trades, and add one for ResultsTotal?

Thank you!

Re: Portfolio Trading [Re: Zheka] #470140
12/28/17 12:10
12/28/17 12:10
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Thanks, a good new year to your too. I did not understand the design pattern question, but as to the rest, algo names can be generated dynamically, but need not contain the asset since that's already in the Asset name. "Component" is used for the model number in a machine learning algo. Pool trades are sent at the end of the run function and when a position changes intrabar. You can have many asset/algo loops, but only 2 nested, and the number of assets and algos must not change between loops. Multiple instances of the same script will not be managed correctly, so rename the script for running it in several instances. You can store any number of trade results in a non-shifted series.

Re: Portfolio Trading [Re: jcl] #470142
12/28/17 13:12
12/28/17 13:12
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Thank you, JCL.

As for "design pattern" q: if a Portfolio consists of
- 5 parameter variations of Algo1 on Asset1, +
- 3 param var of Algo 1 on Asset 2, +
- 2 x (p v) of Algo 2 on Asset 3, +
-.....etc

then the suggested Asset/Algo nested loop will most probably not be an elegant/efficient solution - as one would have to create 5+3+2+...differently named algos, each one only applicable to a small subset in a big loop..

Another way would be to just loop through algos from 1..n and read params (incl. Asset and TF) from a file corresponding to the algo number. (Or do this per Zorro instance trading one asset).

How would you do this?

Thank you.
E.

Re: Portfolio Trading [Re: Zheka] #470144
12/28/17 14:35
12/28/17 14:35
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Hi Zheka,
variations of the same algo on different assets are different algos and you are trading 5+3+2+... different strategies. It is as it is.

There are several coding options to handle specifics differences between assets (market hours, with a CASE ... as an example), but a strategy trading from 9 to 5 is not the same that the same algo trading 24h. Differentiate with different algo- names or not is up to you.

Ciao

Re: Portfolio Trading [Re: MatPed] #470407
01/12/18 12:47
01/12/18 12:47
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
JCL,
To size positions in a portfolio of algos (which implement equity curve trading), I first wanted to poll all algos for their On/Off status and then re-allocate capital/size accordingly.

With this I hit several problems:
1)
Quote:
You can have many asset/algo loops, but only 2 nested, and the number of assets and algos must not change between loops.

I found that 2 Algo (only) loops do not work: the program just doesnt get into the second one (printf from the second loop does not print anything)

2) Alternatively, I tried to have one algo loop working in phantom mode to generate trades, and then change TradeLots of just opened trades in a for(open_trades) loop. Did not work because TradeLots appears to be read-only.

How can I achieve what I need?

Thanks a lot in advance for your advice.

Re: Portfolio Trading [Re: Zheka] #470410
01/12/18 13:28
01/12/18 13:28
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Put your algo names in a string array:

string Algos[10];
int N=0;
while(algo(loop("name1","Name2",...))) {
Algos[N++] = Algo;
...
}

Then you can later go through all your algos with a simple for loop:

for(i=0; i<N; i++) {
algo(Algos[i]);
...
}

You can not edit the lot number of an open trade. When you buy an asset, you must already know how many lots you want to buy.

Re: Portfolio Trading [Re: jcl] #470413
01/12/18 17:03
01/12/18 17:03
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Yes, thank you, I just got it working dynamically generating algo names in a for loop.

Moving to Equity Curve Trading:

- do I understand right that Balance- and EquityLong/Short is updated every bar/frame and so taking a moving average of it is not accurate - because a MA will be catching up with Equity during flat periods?

Re: Portfolio Trading [Re: Zheka] #470488
01/17/18 13:10
01/17/18 13:10
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
bump

Re: Portfolio Trading [Re: Zheka] #470491
01/17/18 13:53
01/17/18 13:53
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Yes, when you trade, your equity and balance can change at any bar, and when you do not trade, they are flat. So will be their MA (I hope). How different MA types work is described on many websites.

Re: Portfolio Trading [Re: jcl] #470495
01/17/18 15:25
01/17/18 15:25
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Quote:
when you do not trade, they are flat.So will be their MA (I hope)
An MA will continue changing,irrespective of the MA type. And after MA-length bars with no trades will be equal to Balance.

The correct mechanism requires creating/maintaining a separate array of equity@trade, not equity@bar.
And I thought this might be an enhancement to implement in one of the future versions.

Page 1 of 2 1 2

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1