Gamestudio Links
Zorro Links
Newest Posts
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Petra, AndrewAMD, Quad, VoroneTZ, 1 invisible), 488 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Position management for portfolio strategies #484009
08/27/21 12:34
08/27/21 12:34
Joined: Aug 2021
Posts: 101
M
MegaTanker Offline OP
Member
MegaTanker  Offline OP
Member
M

Joined: Aug 2021
Posts: 101
Hello,
I have calculated weights for a number of assets in a portfolio strategy, but I can't find any good instructions in the manual how to properly "execute" those weights.

I have used other platforms that had a function that lets you set a weight for an asset and the platform will then execute trades (long or short) until this weight is reached (based on account balance).

I haven't found such thing for Zorro. Alternatively I could calculate the new amount of lots myself (I have found the assign and distribute functions) and compare it with the current lots to find out if I need to buy or sell or do nothing. But how do I see how many open positions the account has for an asset? Only thing I found in the manual is a for(open_trade) loop where I would have to check every loop if the current trade corresponds to the asset I want to check with TradeAsset. That seems suboptimal.

Is there a better way to automatically reach weights or is there a better way to check the current open position (if any) for an asset? Currently for testing I simply close all positions when it's time to reassign and then just create the new ones in full but that creates unnecessary commission/spread when lots stay the same or nearly the same.

Re: Position management for portfolio strategies [Re: MegaTanker] #484010
08/27/21 14:27
08/27/21 14:27
Joined: Aug 2021
Posts: 237
L
Lapsa Offline
Member
Lapsa  Offline
Member
L

Joined: Aug 2021
Posts: 237
Quote

But how do I see how many open positions the account has for an asset?


NumOpenLong
NumOpenShort
NumOpenTotal

I do remember something written along the lines of managing portfolio strategies on the manual.

One topic was Markowitz optimization. Might be what you need or perhaps - lead to something else that's useful.

Last edited by Lapsa; 08/27/21 14:35.
Re: Position management for portfolio strategies [Re: MegaTanker] #484011
08/27/21 18:00
08/27/21 18:00
Joined: Aug 2021
Posts: 101
M
MegaTanker Offline OP
Member
MegaTanker  Offline OP
Member
M

Joined: Aug 2021
Posts: 101
Thank you for the quick reply. Those variables look like they should solve the problem but I have noticed that they do not store the number of open lots, only the number of open trades. So if I buy 25 shares of one asset, NumOpenLong is now 1 instead of 25. After another buy of 25, NumOpenLong is 2. So it only returns the number of actual trades and doesn't account for the size of the trades.

Now that I know that it keeps track of open positions in Trades, I have found something that seems to work: for(current_trades) loops over the open trades of the current asset and I can sum up the TradeLots of each trade.

Re: Position management for portfolio strategies [Re: MegaTanker] #484013
08/28/21 11:01
08/28/21 11:01
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
Open lots and all other variables are on this page: https://manual.zorro-project.com/winloss.htm . Look for "LotsPool".

Re: Position management for portfolio strategies [Re: MegaTanker] #484016
08/28/21 17:40
08/28/21 17:40
Joined: Aug 2021
Posts: 101
M
MegaTanker Offline OP
Member
MegaTanker  Offline OP
Member
M

Joined: Aug 2021
Posts: 101
Thanks, don't know how I missed that when I was looking at NumOpenLong.

Re: Position management for portfolio strategies [Re: MegaTanker] #487142
01/27/23 02:25
01/27/23 02:25
Joined: Jan 2023
Posts: 15
Q
qin Offline
Newbie
qin  Offline
Newbie
Q

Joined: Jan 2023
Posts: 15
I run the demo Workshop4, and print out LotsPool at every bar, it is always zero. Why? It seems it's not open positions we are holding.
what I want is a way to check the current open position (if any) for an asset.

Last edited by qin; 01/27/23 03:00.
Re: Position management for portfolio strategies [Re: MegaTanker] #487163
01/31/23 07:24
01/31/23 07:24
Joined: Jan 2023
Posts: 15
Q
qin Offline
Newbie
qin  Offline
Newbie
Q

Joined: Jan 2023
Posts: 15
My fault, LotsPool is correct. previously I print with %f, it should be %d


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1