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
1 registered members (AndrewAMD), 945 guests, and 8 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
set the AssetsFix file for trading US equities #459216
04/27/16 15:28
04/27/16 15:28
Joined: Mar 2016
Posts: 2
W
windwine Offline OP
Guest
windwine  Offline OP
Guest
W

Joined: Mar 2016
Posts: 2
Hi,

I am new to this forum and I am trying to play with Zorro to trade US equities, say SPY. I am able to convert my 1 min csv file into bar file with slight modification to the convert script and I can test a simple sma script by setting the AssetFix to be
Name Price Spread RollLong RollShort PIP PIPCost MarginCost Leverage LotAmount Commission Symbol
SPY 200 0 0 0 0.01 0.01 0 1 1 0

Basically I set the leverage to be 1.

In the test script it is always trading 1 lot which is 1 share. Now I want to workshop 5 money management to reinvest all the profit by setting
Capital = 100000; // reinvestment mode
Margin = 1 * (Capital + ProfitClosed);

The the backtest aborted after the first loss of only $80 as of margin call.

How should I set the AssetsFix file or my reinvest mode to make it and all-in approach to reinvest all the capital for each trade?(only one position open at each time)

Thanks.

Re: set the AssetsFix file for trading US equities [Re: windwine] #459218
04/28/16 00:23
04/28/16 00:23
Joined: Apr 2014
Posts: 482
Sydney, Australia
B
boatman Offline
Senior Member
boatman  Offline
Senior Member
B

Joined: Apr 2014
Posts: 482
Sydney, Australia
I think your issue is related to the line
Margin = 1 * (Capital + ProfitClosed);

This line actually has the result of putting up your entire account balance as margin! That is, you are getting margin called whenever price moves against you.

Try setting that line to

Margin = 0.1 * (Capital + ProfitClosed) for putting up 10% of your account as margin.

Re: set the AssetsFix file for trading US equities [Re: boatman] #459222
04/29/16 01:45
04/29/16 01:45
Joined: Mar 2016
Posts: 2
W
windwine Offline OP
Guest
windwine  Offline OP
Guest
W

Joined: Mar 2016
Posts: 2
Thank you for your reply. But I am still not sure about the concept of margin in zorro yet. Thank you for bearing with me in my following thoughts to see what I have missed.

In the AssetsFix I set the margincost to be 0 and leverage to be 1 (no leverage for US equity) or 2 (reg-T margin).

In the backtest/live trading I want to reinvest every penny I earned/lost for every single signal. Assuming I am doing a long only system with only SPY and only 1 position would be held at every time point. Under such simple scenario I should not have any margin call in my mind. If I am trading with 5X or 10X leverage I believe Margin = 1 * (Capital + ProfitClosed) would run into margin call but I am not using any leverage and the worst case would just be going to 0 with long only SPY.


Following the suggestion of setting
Capital = 10000;
Margin = 0.1 * (Capital + ProfitClosed);
I reran the backtest. I checked the log file and the first order used 248 which is only 2.5%. Later in the backtest with a capital of
11497 another trade used 1406 which is ~12%. I am totally confused with the meaning of margin now and how I could reinvest with a fixed percentage of total capitals like in other platforms like quantconnect and quantpian.

Thank you.

Re: set the AssetsFix file for trading US equities [Re: windwine] #459227
04/29/16 11:06
04/29/16 11:06
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Margin has the same meaning in all platforms and with all brokers. It's simply the money you have to pay to the broker for buying 1 lot of the asset. So, with your 10000 Capital and at $200 SPY price, 0.1*(Capital+ProfitClosed) will initially buy you 0.1*10000/200 = 5 contracts.

I am sure that this math is also the same in all platforms and with all brokers.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1