API Support Forum
OEC API > API Support > GF API COM: Margin Calculation Request Help
Author Topic: GF API COM: Margin Calculation Request Help
(5 messages, Page 1 of 1)
Moderators: VPfau
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Dec 19, 2022 @ 04:15 PM             Msg. 1 of 5
I am looking at getting the margin calculation for a compound option order. I am looking at this documentation:

https://gainfutures.com/GFAPI/?topic=html/T_GF_Api_Margin_Calculation_MarginCalculationRequest.htm

1. The IHypoOrderPtr inside of the GF API COM is not allowing me to set the values for contract id, qty, and side saying that there is no put function.

2. The IMarginCalculationRequestBuilderPtr does not allow me to put in multiple orders like the documentation states.

3. To do a compound option order, if I put all legs in, with the list of orders, will it return the correct margin requirement for when I place the compound order? Or does it give me the individual leg margins? If so, how can I get the margin requirement for a compound option order?

Thanks
JSmith5611
Posts: 187
Joined:


Posted: Dec 21, 2022 @ 06:54 AM             Msg. 2 of 5
From what i remember about the margin calc, the best way would be to place each leg as an separate order in the calc request.

This can be done as the following:

GF_Api_COM::IMarginCalculationRequestBuilderPtr builder;
builder.CreateInstance(__uuidof(GF_Api_COM::MarginCalculationRequestBuilder));
GF_Api_COM::IAccountListPtr accs = GFAPI()->Accounts->Get();
GF_Api_COM::IAccountPtr account = accs->GetAt(0);
builder = builder->WithAccountID(account->id);

//Loop next line for each contract / side / quantity
builder = builder->WithOrder(GFAPI()->Margin->CreateHypoOrder(contract->id, GF_Api_COM::OrderSide_Buy, quantity));
Jason Smith
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Dec 21, 2022 @ 10:16 AM             Msg. 3 of 5
Okay perfect, I'll give that a shot.

Will you please add the ability to place multiple orders as shown in the documentation as well as the ability to set the values of an IHypoOrderPtr individually so that I can test that out as well.

Thanks.
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Jan 11, 2023 @ 05:40 PM             Msg. 4 of 5
I have tested doing the individual legs, and it does not give me the correct margin for compound options.

Will you please add the ability to place multiple orders as shown in the documentation as well as the ability to set the values of an IHypoOrderPtr individually so that I can test that out as well.

Thanks.
JSmith5611
Posts: 187
Joined:


Posted: Feb 16, 2023 @ 11:42 AM             Msg. 5 of 5
I've tested sending mutliple orders in a margin request with the latest COM api (4.11.210.227), and it works fine for me.
HypoOrders and HypoPositions are immutable by design (same for the .NET api)
Jason Smith