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
1 registered members (AndrewAMD), 600 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Stoken ACA strategy #486548
09/04/22 21:12
09/04/22 21:12
Joined: Aug 2022
Posts: 65
alun Offline OP
Junior Member
alun  Offline OP
Junior Member

Joined: Aug 2022
Posts: 65
Implementing my first strategy in Zorro - from Dick Stoken's book "Survival of the fittest for investors"

I will be glad to hear feedback on any suggestions for improvements.

Main repo - https://github.com/alun/stoken-aca

Older version - https://gist.github.com/alun/4424cb0e61a4955355ea82bb72286af3

I had strategy in Python before - https://katlex.com/stoken/

Currently results are quite different (even with Reinvest = true) - I keep working to make both implementations as close as possible.

Last edited by alun; 09/08/22 22:57.
Re: Stoken ACA strategy [Re: alun] #486551
09/04/22 22:32
09/04/22 22:32
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Nice clean code.
Your asset mix looks like Ray Dalio's all weather portfolio.
All your trade stats look great, except for the sharpe ratio. I wonder why that is.

Last edited by Grant; 09/04/22 22:35.
Re: Stoken ACA strategy [Re: alun] #486553
09/05/22 08:41
09/05/22 08:41
Joined: Aug 2022
Posts: 65
alun Offline OP
Junior Member
alun  Offline OP
Junior Member

Joined: Aug 2022
Posts: 65
Thanks for the feedback, Grant!

yes it's so different to why I found in Python (Sharpe ratio 1.07)

I thought that maybe due to my Zorro test does not reinvest-profits, but with reinvesting it's even less in Zorro - 0.54%

I think there might be differences in how Zorro calculates it.

Re: Stoken ACA strategy [Re: alun] #486555
09/05/22 09:25
09/05/22 09:25
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
I see that you use 'Capital' or '(Capital + Profit)' for your position sizing. This means that your position size is always based on your initial capital + your profit, but not a loss(!).
Do you have a particular reason for this?

I always use 'Balance' for position sizing, which is 'Capital + Wintotal - LossTotal' (see https://zorro-project.com/manual/en/balance.htm)

Always log variables for verification when in doubt about certain calculations, esp before switching to live trading. I believe that's the best way to keep bugs away.

Re: Stoken ACA strategy [Re: alun] #486556
09/05/22 09:46
09/05/22 09:46
Joined: Aug 2022
Posts: 65
alun Offline OP
Junior Member
alun  Offline OP
Junior Member

Joined: Aug 2022
Posts: 65
I think it's similar:

ProfitTotal - Realized and unrealized total profit so far; WinTotal-LossTotal+WinValTotal-LossValTotal.

So it's PnL of all realised and unrealised trades.

https://zorro-project.com/manual/en/winloss.htm

Re: Stoken ACA strategy [Re: alun] #486558
09/05/22 10:35
09/05/22 10:35
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
I understand, but personally I would never calculate a position size based on an unrealised profit or loss, as this can work against you.

Worst case scenario: open position X very profitable > take a large position in Y > open position X ends with a big loss.

Re: Stoken ACA strategy [Re: Grant] #486559
09/05/22 12:26
09/05/22 12:26
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Originally Posted by Grant
I understand, but personally I would never calculate a position size based on an unrealised profit or loss, as this can work against you.

I do this all the time in my stock portfolio rotation system. Positions are regularly adjusted from very long to slightly long to flat, and so on.

Re: Stoken ACA strategy [Re: alun] #486562
09/05/22 13:44
09/05/22 13:44
Joined: Aug 2022
Posts: 65
alun Offline OP
Junior Member
alun  Offline OP
Junior Member

Joined: Aug 2022
Posts: 65
Yeah I believe stock/ETF rotation (especially with no leverage) are quite different from futures/CFD/forex strategies in the sense of how you look at the realised and unrealised profits.

Here I need to look at cost of my overall portfolio - what I don't have yet is when I rotate one component between risk-on/risk-off, I need to rebalance the two other components so they take 33% of the portfolio each.

I plan to add in next versions.

Re: Stoken ACA strategy [Re: alun] #486563
09/05/22 15:04
09/05/22 15:04
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
True, esp with a leveraged portfolio open positions can fluctuate a lot. On the flip side, your strategy is low-frequency, so over time they can fluctuate a lot. To mitigate this you need to rebalance your portfolio indeed, esp in volatile markets. It will a tradeoff between rebalancing your portfolio/risk and limiting your costs.
Maybe a spreadsheet with past trades, powered by a solver could help to find an optimal rebalance frequency?

Re: Stoken ACA strategy [Re: alun] #486564
09/05/22 17:00
09/05/22 17:00
Joined: Aug 2022
Posts: 65
alun Offline OP
Junior Member
alun  Offline OP
Junior Member

Joined: Aug 2022
Posts: 65
I think transactional costs are miserable here.

I have modelled the strategy in Python since 2004 started from $10k initial deposit with reinvesting dividends and rebalance on each event of one of the components rotation.

The overall fee was 394.42 for 17+ years. 19721 ETF stocks traded. My broker has 0.02$ per stock per side.

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