Page 1 of 1

Get Usable Margin

PostPosted: Thu Aug 09, 2018 7:02 am
by magretol
Hi,

I need to find the "Entry / Maintenance Margin" available for an account to check that there is enough margin in that account to open a position of the size I request.

I'm using IO2GAccountTableRow.getUsableMargin() since it's defined in the documentation as: "Gets the amount of funds available to open new positions or to absorb losses of the existing positions."

I'm expecting it to be equity - used_maintenance_margin (which is what I want).

It seems however that what is returned is equity - used_liquidation_margin, liquidation margin being typically 50% less than maintenance margin.

Am I correct?

If I were to use getEquity() - getUsedMargin(), would I get what I want?

Or should I use getUsedMargin3() (defined as "Gets the amount of funds used to maintain all open positions on the account with the three-level margin policy.")

Thanks for the clarification.

Re: Get Usable Margin

PostPosted: Thu Aug 09, 2018 11:45 am
by magretol
Actually, I've just tested all the options...

If anyone is interested, here is the result from an example with the margins has shown in the attached picture,

and the following API calls:
"equity: " << account->getEquity();
"usable marging in %: " << account->getUsableMarginInPercentage();
"usable maintenance marging in %: " << account->getUsableMaintMarginInPercentage();
"usable margin: " << account->getUsableMargin();
"used margin: " << account->getUsedMargin();
"used margin3: " << account->getUsedMargin3();

giving the following result (printout was taken few minutes after the result, so the usable values are a bit off since equity changed)

0000004 | 2018-08-09, 15:31:32.947270 [info] - equity: 41098.7
0000005 | 2018-08-09, 15:31:32.947514 [info] - usable marging in %: 96
0000006 | 2018-08-09, 15:31:32.947693 [info] - usable maintenance marging in %: 91
0000007 | 2018-08-09, 15:31:32.947880 [info] - usable margin: 39258.7
0000008 | 2018-08-09, 15:31:32.948018 [info] - used margin: 1840
0000009 | 2018-08-09, 15:31:32.948179 [info] - used margin3: 3680

Conclusion:
- getUsableMargin is equity minus liquidation margin
- getUsedMargin is liquidation margin
- getUsedMargin3 is maintenance margin.
- if you want to know available maintenance margin, use getEquity() - getUsedMargin3()