Gamestudio Links
Zorro Links
Newest Posts
Conversion to Easylanguage, pls
by jcl
Today at 08:41
Error with data - EURUSD
by jcl
Today at 08:38
Game Maker Terrain editor 2 (GMTE2) to GST terrain (MED)
by NeoDumont
Today at 01:13
pp pixelation with proper blurring
by 3run
Yesterday at 21:08
extern static array of structs
by sdh309795gaas
Yesterday at 20:33
Cyrpto currency arbitrage
by Sphin
Yesterday at 19:22
Experienced 2D|3D Character artist|Concept Artist@ Indie Prices|
by DeathstalkerArs
Yesterday at 18:40
AUM Magazine
Latest Screens
Forgotten Tales - Demo version
RPG PARTY
Triton Wing now available on Steam
AckCon'17: Lotter vs The World
Who's Online
10 registered (Iglarion, Kartoffel, jyd, StefanS, Dalla, Matt_Aufderheide, jenGs, wingt, oligodar, 1 invisible), 135 Guests and 4 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
lizmerrill, QuangDalat, davefollmers, abcdef656188, luisd
17871 Registered Users
Page 1 of 2 1 2 >
Topic Options
Rate This Topic
#470123 - 12/27/17 13:45 Portfolio Trading
Zheka Offline
Member

Registered: 07/03/17
Posts: 140
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!

Top
#470140 - 12/28/17 13:10 Re: Portfolio Trading [Re: Zheka]
jcl Online

Chief Engineer

Registered: 07/22/00
Posts: 26129
Loc: 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.

Top
#470142 - 12/28/17 14:12 Re: Portfolio Trading [Re: jcl]
Zheka Offline
Member

Registered: 07/03/17
Posts: 140
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.

Top
#470144 - 12/28/17 15:35 Re: Portfolio Trading [Re: Zheka]
MatPed Offline
Senior Member

Registered: 02/28/15
Posts: 384
Loc: 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

Top
#470407 - 01/12/18 13:47 Re: Portfolio Trading [Re: MatPed]
Zheka Offline
Member

Registered: 07/03/17
Posts: 140
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.

Top
#470410 - 01/12/18 14:28 Re: Portfolio Trading [Re: Zheka]
jcl Online

Chief Engineer

Registered: 07/22/00
Posts: 26129
Loc: 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.

Top
#470413 - 01/12/18 18:03 Re: Portfolio Trading [Re: jcl]
Zheka Offline
Member

Registered: 07/03/17
Posts: 140
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?

Top
#470488 - 01/17/18 14:10 Re: Portfolio Trading [Re: Zheka]
Zheka Offline
Member

Registered: 07/03/17
Posts: 140
bump

Top
#470491 - 01/17/18 14:53 Re: Portfolio Trading [Re: Zheka]
jcl Online

Chief Engineer

Registered: 07/22/00
Posts: 26129
Loc: 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.

Top
#470495 - 01/17/18 16:25 Re: Portfolio Trading [Re: jcl]
Zheka Offline
Member

Registered: 07/03/17
Posts: 140
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.

Top
Page 1 of 2 1 2 >



Gamestudio download | chip programmers | Zorro platform | shop | resources | magazine | manual | support faq | bugs

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) 3dgamestudio.net