Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (MadJack, AndrewAMD, Quad), 540 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 5
Page 1 of 3 1 2 3
Z9 system performance 2008-2014 #469985
12/18/17 02:37
12/18/17 02:37
Joined: Dec 2017
Posts: 129
Halifax, NS
K
kujo Offline OP
Member
kujo  Offline OP
Member
K

Joined: Dec 2017
Posts: 129
Halifax, NS
Hi,

I was interested in Z9 system performance before 2012. However, it's not possible to change a start date yet (waiting for version 1.74). So, I decided to tweak data a bit and shift dates. As a result, data is from 2007/04/11 to 2014/03/27 with timestamps 2010/12/30 - 2017/12/15. Again, it was needed to feed earlier data to Z9 system.

The results are below:


The asset list is default

Attached Files
Z9.txt (360 downloads)
Z9_CSJ_test.txt (351 downloads)
Last edited by kujo; 12/18/17 02:46.
Re: Z9 system performance 2008-2014 [Re: kujo] #469986
12/18/17 03:39
12/18/17 03:39
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
Great creative solution to a real problem with backtesting Z9!

It is actually rather funny to see that my first attempt DualMomentumV1.1 code performs considerably better over the same time period (the only changes I made was setting Lookback=12*20; instead of 24*20, and adjusting the dates). And I should point out that I personally consider the below performance to be complete garbage and a waste of time and money to trade live in that time period:


the asset list is the original one for Z9 (with SPY still on it). See attachments for the results.

Attached Files
AssetsZ9.csv (261 downloads)
DualMomentumV1.1.txt (390 downloads)
DualMomentumV1.1_test.txt (352 downloads)
Last edited by Hredot; 12/18/17 03:52.
Re: Z9 system performance 2008-2014 [Re: Hredot] #469987
12/18/17 07:52
12/18/17 07:52
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
This is the Z9 performance 2008-2017, with VOO replaced by SPY.



Within the next 2 days the new Zorro version will come out where you can set the Z9 start date with the asset list. It has also some modifications, f.i. capital is now reinvested and CAGR is displayed.

Re: Z9 system performance 2008-2014 [Re: jcl] #469990
12/18/17 14:04
12/18/17 14:04
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
jcl, this is amazing news! Thank you for implementing capital reinvestment!
I hope there will be a parameter to decide which power of the returns to reinvest.
For instance, the default setting could be "1/2" for reinvesting the square root of returns. But please allow for the option to adjust it:

Instead of
Code:
sqrt(...)



Use
Code:
pow(...,P)



where P=0.5 initially and can be changed by a slider.

Do you think you could make that happen?

Re: Z9 system performance 2008-2014 [Re: Hredot] #469991
12/18/17 14:15
12/18/17 14:15
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
The power depends on the ratio of max margin to max drawdown. If DD >> Margin, use the square root, if Margin >> DD, directly invest all profits. The Z9 backtest uses P = 0.9.

Re: Z9 system performance 2008-2014 [Re: jcl] #469994
12/18/17 14:40
12/18/17 14:40
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
This is just perfect, I like the update already! Thank you so much!
Eagerly waiting for it! grin

PS:

Somehow, the performance is still quite different on the same time period, despite Z9 now reinvesting. Thats kind of strange...


Re: Z9 system performance 2008-2014 [Re: Hredot] #470007
12/19/17 03:12
12/19/17 03:12
Joined: Dec 2017
Posts: 129
Halifax, NS
K
kujo Offline OP
Member
kujo  Offline OP
Member
K

Joined: Dec 2017
Posts: 129
Halifax, NS
Hredot, thanks for sharing your results! They really help to understand what's going on from the inside!


Jcl, thanks for Z9 update, performance looks more stable. I have some questions:

1. There are new types in an asset list: 0 - stock ETF, 1 - bond ETF. Could you please clarify types 2 and 3?

2. As I understood, Z9 reinvests Capital * pow(1 + (WinTotal -LossTotal) / Capital), 0.9). Is it correct?

3. If I want to withdraw profits monthly how to calculate optimal withdrawal amount in this case? How to withdraw it with the new Z9 system?



Last edited by kujo; 12/19/17 03:13.
Re: Z9 system performance 2008-2014 [Re: kujo] #470012
12/19/17 11:39
12/19/17 11:39
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
2 is for non-us indexes and 3 for a lead index that represents the US market. The formula is correct, although Z9 calculates the same in a different way. For withdrawing, you need normally no complex formula. The difference between pow(0.9) and pow(1) in the backtest is marginal.

Re: Z9 system performance 2008-2014 [Re: jcl] #470017
12/19/17 13:40
12/19/17 13:40
Joined: Dec 2017
Posts: 129
Halifax, NS
K
kujo Offline OP
Member
kujo  Offline OP
Member
K

Joined: Dec 2017
Posts: 129
Halifax, NS
Originally Posted By: jcl
The difference between pow(0.9) and pow(1) in the backtest is marginal.


Thanks, as I understand the new Z9 is heavily focused on reinvestments because difference between pow(0.9) and pow(1) will be not so big: not much to withdraw.

Also I have a question about a margin call conditions. Below is a piece of Z9_test.log and a first trade:
Originally Posted By: jcl

TLT 1.00 0 -> 123
[TLT::L2301] Long 123@81.06330 at 00:00:00
Vol $9973 Bonds $9973 Margin 4986 Levg 2.0

[424: Thu 08-09-18 00:00] 5000 +51.50 1/0 (81.83)
[425: Fri 08-09-19 00:00] 5000 -94.87 0/1 (81.04)
[426: Mon 08-09-22 00:00] 5000 -409 0/1 (77.65)
[427: Tue 08-09-23 00:00] 5000 -410 0/1 (76.88)
[428: Wed 08-09-24 00:00] 5000 -446 0/1 (77.45)



To avoid margin call MarginVal should be < Equity.

MarginVal on [428: Wed 08-09-24 00:00] equals (9973 - 446) * 0.5 = 4763.5, where 9973 - volume , 446 - open loss, 0.5 - 50% margin requirement.

Equity on [428: Wed 08-09-24 00:00] equals 5000 - 446 = 4554, where 5000 - current balance, 446 - open loss.

In this case Equity(4554) < MarginVal(4763). So, it's a margin call.
I wonder where my calculation are wrong?

Re: Z9 system performance 2008-2014 [Re: kujo] #470018
12/19/17 14:19
12/19/17 14:19
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Margin call detection is switched off with Z8 and Z9. Otherwise you'd naturally get margin calls all the time, since the Capital slider sets up the margin, not the balance. The minimum that you need on your account is displayed under "Required Capital".

Re: Z9 system performance 2008-2014 [Re: jcl] #470019
12/19/17 15:11
12/19/17 15:11
Joined: Dec 2017
Posts: 129
Halifax, NS
K
kujo Offline OP
Member
kujo  Offline OP
Member
K

Joined: Dec 2017
Posts: 129
Halifax, NS
Hm, I get Required Capital 5295 in Zorro's wondow
Quote:

Z9.03: H 4 W 2 V 1
Loading 12 assets..
Multiple assets............
Test: Z9 2002..2017
Assets AssetsZ9
Max Leverage 2.0 Avg Bonds 27.4%
Monte Carlo Analysis... Median AR 21%
Win 14181$ MI 122$ DD 446$ Capital 5295$
Trades 290 Win 76.9% Avg +470.6p Bars 103
CAGR 14.89% PF 4.19 SR 0.88 UI 6% R2 0.80
Chart... ok
Chart... ok


and 3915 in performance report

Quote:

Gross win/loss 18633$ / -4451$ (+136486p)
Average profit 1464$/year, 122$/month, 5.63$/day
Max drawdown -330$ 2.3% (MAE -2270$ 16.0%)
Total down time 15% (TAE 82%)
Max down time 32 weeks from Apr 2008
Max open margin 3732$
Max open risk 99.71$
Trade volume 344057$ (35509$/year)
Transaction costs -814$ spr, 0.83$ slp, 0$ rol, -163$ com
Capital required 3915$

Re: Z9 system performance 2008-2014 [Re: kujo] #470021
12/19/17 16:18
12/19/17 16:18
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
I am also confused by the statement about margin call.
Isn't it the case that as soon as Equity drops below open margin a broker like IB will just close all your positions?

Last edited by Hredot; 12/19/17 16:19.
Re: Z9 system performance 2008-2014 [Re: kujo] #470022
12/19/17 16:20
12/19/17 16:20
Joined: Dec 2017
Posts: 129
Halifax, NS
K
kujo Offline OP
Member
kujo  Offline OP
Member
K

Joined: Dec 2017
Posts: 129
Halifax, NS
One more question about MarginVal. According to the manual, during backtest MarginVal remains constant until the trade closes. In live trading situation could be different because brokers adapt MarginVal based on the asset price (i.e. IB). So, margin call conditions change as well. I assume I need to calculate manually MarginVal or MarginTotal during backtest to simulate broker's margin call conditions.
Could you please advise what variable to calculate and how? Thanks



Last edited by kujo; 12/19/17 16:33.
Re: Z9 system performance 2008-2014 [Re: kujo] #470041
12/20/17 14:02
12/20/17 14:02
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
The capital in the zorro window is correct. The other one is wrong - I'll forward this to the developers. - Yes, the broker will start closing your positions when you have not enough capital for the open margin. - The variable to calculate is TradeMarginCost.

Re: Z9 system performance 2008-2014 [Re: jcl] #470058
12/21/17 03:48
12/21/17 03:48
Joined: Dec 2017
Posts: 129
Halifax, NS
K
kujo Offline OP
Member
kujo  Offline OP
Member
K

Joined: Dec 2017
Posts: 129
Halifax, NS
I continue to test Z9 system and found out the following:
Quote:

Simulated account AssetsZ9 (NFA)
Bar period 24 hours (avg 2088 min)
Test period 2006-03-13..2017-12-21 (2966 bars)
Lookback period 252 bars (52 weeks)
Montecarlo cycles 200
Simulation mode Realistic (slippage 5.0 sec)
Capital invested 5000$

Gross win/loss 28666$ / -6027$ (+85764p)
Average profit 1923$/year, 160$/month, 7.39$/day
Max drawdown -331$ 1.5% (MAE -3551$ 15.7%)
Total down time 26% (TAE 82%)
Max down time 82 weeks from Aug 2015
Max open margin 1435$
Max open risk 269$
Trade volume 493123$ (41877$/year)
Transaction costs -1578$ spr, -14.55$ slp, 0$ rol, -316$ com
Capital required 1602$


Capital required << Capital invested
Max open margin is 1435, however it should be around 5000

Please find asset list and logs attached

Attached Files
AssetsZ9.csv (253 downloads)
Z9.txt (345 downloads)
Z9_test.txt (344 downloads)
Last edited by kujo; 12/21/17 03:51.
Re: Z9 system performance 2008-2014 [Re: kujo] #470060
12/21/17 06:12
12/21/17 06:12
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
True, the margin is too low for the capital. I suspect that reducing the asset list to just a few assets also reduces market participation, since probably only a fixed maximal fraction of all assets in the list are traded, and each likely has a participation cap.

However, even if we keep the standard asset selection, maximal open margin is about $3500 and that's even though Equity has grown to $15000! Way too small participation, definitely needs to be reballanced in my opinion.

Last edited by Hredot; 12/21/17 06:13.
Re: Z9 system performance 2008-2014 [Re: Hredot] #470062
12/21/17 07:11
12/21/17 07:11
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Required capital is max margin plus max drawdown. Of course adjusted to the simulation start, so it won't be $15000 even when the equity has grown to that. It's displayed in the Zorro window and normally about 10% higher than the Margin set with slider.

Re: Z9 system performance 2008-2014 [Re: jcl] #470075
12/21/17 14:13
12/21/17 14:13
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
jcl, does this imply that when trading live the system expects a manual readjustment of the capital slider by the user according to the profits made, when the trade button is hit every few weeks?

If that is the case, the system in reality does not reinvest profits automatically and requires manual adjustment.

Re: Z9 system performance 2008-2014 [Re: jcl] #470078
12/21/17 14:50
12/21/17 14:50
Joined: Dec 2017
Posts: 129
Halifax, NS
K
kujo Offline OP
Member
kujo  Offline OP
Member
K

Joined: Dec 2017
Posts: 129
Halifax, NS
I see, the behavior changed a little bit with the latest Zorro version (1.74.2). But it's still kind of weird.

When I run Z9 with the custom asset list (attached to the post above) I got:
Quote:

Capital invested 5000$
Max drawdown -937$ 4.1% (MAE -3551$ 15.7%)
Max open margin 4064$
Capital required 4537$


Capital required is lower then capital invested. However, you pointed out it's normally 10% higher then value of Capital slider (5000).

Also, the first trade in the log is:
Quote:

IAU 0.50 0 -> 1068
[IAU::L7801] Long 1068@5.85017 at 00:00:00
VGK 0.50 0 -> 133
[VGK::L7802] Long 133@46.71027 at 00:00:00
Vol $12460 Bonds $0 Margin 4984 Levg 2.5


Margin = 4984, however, performance report says that Max open margin = 4064$. So, the max margin is lower then margin of a first trade??

I wonder if it's a normal behavior? If yes, could you please explain these discrepancies.

Last edited by kujo; 12/21/17 14:51.
Re: Z9 system performance 2008-2014 [Re: kujo] #470082
12/21/17 15:52
12/21/17 15:52
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
It is normal, but you should use the parameters with care. The maximum margin is neither 4984 nor 4064, but more like 15000.

The reason is the capital reinvesting, which does not allow anymore to determine an initial capital from margin and drawdown. For doing it nevertheless, Z9 simply reduces the maximum drawdown and margin by the ratio of start and end capital. So the values are not precise, but estimated. In most cases they are ok, but with your asset list apparently quite off. So be careful. I'll put a warning in the manual.

Re: Z9 system performance 2008-2014 [Re: jcl] #470084
12/21/17 16:33
12/21/17 16:33
Joined: Dec 2017
Posts: 129
Halifax, NS
K
kujo Offline OP
Member
kujo  Offline OP
Member
K

Joined: Dec 2017
Posts: 129
Halifax, NS
I see, now it makes sense!

As to the Hredot point, about reinvesting...
With the default asset list test starts with Balance=5000. Margin is approx. the same, according to the log (=4989).
However, at the end of backtest balance = 15142 but the Margin = 7041.

I took this numbers from the log. I assumed, that with reinvesting according to pow(..., 0.9) formula, the margin will grow much faster and will be close to 15000 at the end of backtest.

I believe that's why Hredot mentioned that it's still needed to move Capital slider during live trading.

Jcl, could you please explain why margin grows so slowly while most of the profits are reinvested?

Last edited by kujo; 12/21/17 16:35.
Re: Z9 system performance 2008-2014 [Re: kujo] #470194
01/02/18 09:17
01/02/18 09:17
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Because the current beta version, as I just learned, only partially reinvested profit in the backtest. The mechanism was accidentally switched to a different formula. The next update will have the full reinvesting activated.

Re: Z9 system performance 2008-2014 [Re: jcl] #470197
01/02/18 12:20
01/02/18 12:20
Joined: Dec 2017
Posts: 129
Halifax, NS
K
kujo Offline OP
Member
kujo  Offline OP
Member
K

Joined: Dec 2017
Posts: 129
Halifax, NS
Thank you for the update!
I (and Hredot too, as he wrote above) would appreciate if the % of profit reinvestment could be controlled with a parameter. It would make the system more flexible.

Re: Z9 system performance 2008-2014 [Re: jcl] #470441
01/15/18 06:03
01/15/18 06:03
Joined: Dec 2016
Posts: 71
F
firecrest Offline
Junior Member
firecrest  Offline
Junior Member
F

Joined: Dec 2016
Posts: 71
Originally Posted By: jcl
This is the Z9 performance 2008-2017, with VOO replaced by SPY.



Within the next 2 days the new Zorro version will come out where you can set the Z9 start date with the asset list. It has also some modifications, f.i. capital is now reinvested and CAGR is displayed.


How do we change the Start Date with the asset list?

Re: Z9 system performance 2008-2014 [Re: firecrest] #470444
01/15/18 09:46
01/15/18 09:46
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
By using assets that existed back then.

Page 1 of 3 1 2 3

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