SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue Nov 21, 2017 11:25 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Jun 17, 2012 6:29 pm 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Greatly, appreciate anyone’s comments here?

Has anyone seen or is happy to share some good FX margin calculator code?

I’m trying to develop some code which will calculate margin on the fly and allow me to set parameters prior to strategy launch. E.g. margin rate = 200, don’t use more than 50% of account, etc.

A good base for the calculations required are here:

http://www.interactivebrokers.com/en/p. ... ex-default

http://ibkb.interactivebrokers.com/node/970

Thanks and regards,

drolles


Top
 Profile  
 
 Post subject: Margin Calcuation for FX
PostPosted: Wed Jul 11, 2012 9:58 pm 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
Hi,

I’m wondering if someone could please help.

I’m working with a broker who is providing 200:1 leverage / margin on positions.

I would like to model this so I can ensure that I’m always well within the account margin requirements.

I’ve searched the forum on Margin & Margin Requirements.

I can’t find any reference to Margin other than the open positions within the Portfolio screen.

In this thread the question gets asked if this is a percentage, dollars, etc: viewtopic.php?t=6858. It doesn’t get answered.

Given Currenex doesn’t provide broker information (which I assumes includes something like remaining margin: ) I need to calculate this manually.

Any thoughts?

Thanks,

drolles


Top
 Profile  
 
PostPosted: Thu Jul 12, 2012 12:43 am 
Offline

Joined: Sat Feb 25, 2012 8:51 pm
Posts: 154
I’ve done some further testing on this.

You can use the Instrument Margin as a decimal to achieve this. E.g. if leverage is 200:1 you can 1/200 = 0.005. This seems to work on most cases. However, the challenges is with JPY crosses. The differences between Qty and Value of the position.

I’ve got an example with USDJPY of this not being quite right. The margin is calculated on Qty and not Value. A broker with use margin on the value of the trade not on the Qty.

Strategy.Position does have GetValue. I’ve included a screen shot here:

1. Shows the position details in the Portfolio screen
2. Show the some of the Output screen with a line of code

Code:
Console.WriteLine("Position Margin is: " + Position.Margin + " Instrument = " + Instrument.ToString());

OQ support – Could we please have a comment here? This doesn’t appear to make sense. With FX should Margin be calculated on Value, as opposed to Qty?

Thanks and regards,

drolles


Attachments:
Margin calucation - value.JPG
Margin calucation - value.JPG [ 12.14 KiB | Viewed 4380 times ]
Margin calucation - position.JPG
Margin calucation - position.JPG [ 17.45 KiB | Viewed 4380 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group