set the AssetsFix file for trading US equities

Posted By: windwine

set the AssetsFix file for trading US equities - 04/27/16 15:28

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.
Posted By: boatman

Re: set the AssetsFix file for trading US equities - 04/28/16 00:23

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.
Posted By: windwine

Re: set the AssetsFix file for trading US equities - 04/29/16 01:45

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.
Posted By: jcl

Re: set the AssetsFix file for trading US equities - 04/29/16 11:06

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.
© 2024 lite-C Forums