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), 552 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
Rate Thread
Option Margin Cost and Z13 #480974
07/28/20 15:23
07/28/20 15:23
Joined: Mar 2020
Posts: 41
J
jbhunter Offline OP
Newbie
jbhunter  Offline OP
Newbie
J

Joined: Mar 2020
Posts: 41
I am trying to wrap my head around Margin Costs when running some options strategies.

I am using the IB equations from here, IB Margin Eqs

As an example I will use the first Z13 trade. See log below. This is using the Put strategy with Leverage of 6.
Code
Sell at prem 1462.00 max win 1462.00
[SPY::SP11102] Place 2 Put 20120218 134.0 200@7.31 Unl 127.50 at 15:40:00
Com 2.00  Mrg 4702  Net 0  Prem 1462
Units 90.0000  MTotal 0.00  MCost 23.5088 PCost 0.90000 Opn 111


Underlying, 127.50
Bid, 7.31
Strike, 134

Index Options
Margin = Put Price + Maximum ((15% * Underlying Price - Out of the Money Amount), (10% * Strike Price))

Margin = 7.31 + Max(0.15*127.50-0, 0.1*134)
Margin = 7.31 + 19.125 = 26.435

So with Multiplier=100 and Lots=2...
Total margin cost is $5287, correct?

Looking at the Z13 log the premium seems correct. 7.31*100*2=1462
However how is the margin only 4702? I see the MCost*100*2=4702 which matches the Mrg value. But I don't understand where this comes from.
What is the last line in the log? I cannot find anything in the manual describing these names.

Code
Units 90.0000  MTotal 0.00  MCost 23.5088 PCost 0.90000 Opn 111

Units 90? PCost 0.9? Opn 111?

Re: Option Margin Cost and Z13 [Re: jbhunter] #481001
07/31/20 08:05
07/31/20 08:05
Joined: Mar 2018
Posts: 62
hast29 Offline
Junior Member
hast29  Offline
Junior Member

Joined: Mar 2018
Posts: 62
Hi jbhunter,

The code is in the contract.c script in the include folder. Look for the function „contractMargin“. Manual section here https://www.zorro-trader.com/manual/en/contract.htm .

I have looked at it briefly and did not find any difference between the IB formula and the formula in the code. Also, no idea where the „Units 90? PCost 0.9? Opn 111?“ come from. Sorry.

But if you code yourself, you will investigate on those functions and resolve it. To my understanding, the key issue is to match the Margin costs in your code with the real margin requirements of IB ?

Last edited by hast29; 07/31/20 08:07.

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