API Support Forum
OEC API > API Support > GF API COM Custom Compound Help
Author Topic: GF API COM Custom Compound Help
(23 messages, Page 1 of 2)
Moderators: VPfau
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 14, 2022 @ 06:35 PM             Msg. 1 of 23
I am trying to create a custom compound option order but I am getting a rejected notice due to the custom compound type.

I have tried doing CompoundType::Unknown (fails to send the order), CompoundType::Generic (Order rejected message), and CompoundType::CustomOptionSpread is not shown in the COM API. Please put that into the COM API

Are there more in depth samples or documentation that I can see to create custom compound option orders?

Am I able to put in any legs inside of the custom compound order and put a generic compound type and have it go through?

Thanks
JSmith5611
Posts: 187
Joined:


Posted: Sep 15, 2022 @ 09:08 AM             Msg. 2 of 23
I have a test build with this that i can send you, and it should be released this weekend officially.
Jason Smith
VPfau
Moderator
Posts: 164
Joined:


Posted: Sep 15, 2022 @ 10:29 AM             Msg. 3 of 23
>Am I able to put in any legs inside of the custom compound order and put a generic compound type and have it go through?

Let me put here some more details. All custom compounds are split to groups:
- First one (including general) is for predefined contracts. Trade desk can manage such contracts;
- Second group is user defined compounds;

To send an order with custom compound you'll need to specify CustomCompound in order draft; CustomCompund field is a template class with type and set of legs.

On a client side we do a basic validation and send order to the trading platform.
Trading platform checks if we already have such contract in the system and if we have it, we will proceed with order.
If trading platform does not have it, we will check if set of legs matches one of predefined strategies (defined by uplink provider) and if it matches, we request a new contract.

Unfortunately not any legs allowed to created a contract. Legs are defined by contract type. For example: Straddle type has to have buy option call on a first leg and second leg has to match a base contract of first leg, same expiration, put, buy, same strike, side and qty.
Even CustomOptionSpread has limitation: all legs should share same underlying contract and it is not guaranteed that exchange will accept it.
Vitaliy Pfau
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 15, 2022 @ 11:40 AM             Msg. 4 of 23
For custom compound orders, is there something that needs to be done with the base OrderDraftBuilder? Like a specific contract id? Side? Qty? Rate? Since they are separate legs, it doesn't seem like any of those apply (with the exception of contract id of the base contract maybe)

So if I want to send off a user defined compound, what should I put in for the compound type?

Why wouldn't you always do a user defined compound and let the uplink provider handle the predefined strategies?

Even following the rules of how the specific legs are shown and putting in the compound type, it sends the order, but comes back with an invalid compound type. I have tried a synthetic long, I will try a straddle following the same values you have mentioned in your reply.
VPfau
Moderator
Posts: 164
Joined:


Posted: Sep 15, 2022 @ 12:15 PM             Msg. 5 of 23
> For custom compound orders, is there something that needs to be done with the base OrderDraftBuilder?
OrderDraftBuilder is a helper class that walks you thru a creation process. You can build a draft without it.

>Like a specific contract id?
you provide or contract id or customcompound, not both. If you provide both the contractid will be ignored in advance of compound information.

>Side?
Buy will open order as is, Sell actually flips legs.

>Qty?
Qty will multiply legs' qty. If strategy required 1/2/1 qty on legs then sending main 2 qty of 1/2/1 legs will mean 2/4/2 on legs


>Rate? Since they are separate legs, it doesn't seem like any of those apply (with the exception of contract id of the base contract maybe)
you specify base contract for each leg separately.

>So if I want to send off a user defined compound, what should I put in for the compound type?
Compound type is requirements for legs. If you provide IronButterfly compound type, you should provide valid legs for this strategy.


>Why wouldn't you always do a user defined compound and let the uplink provider handle the predefined strategies?
Because the uplink provider wants us do validation prior sending requests;

>Even following the rules of how the specific legs are shown and putting in the compound type, it sends the order, but comes back
> with an invalid compound type. I have tried a synthetic long, I will try a straddle following the same values you have mentioned in your reply.
SyntheticLong, FutureDoubleButterfly, FutureReverseSpread, Call_1X2, Put_1X2 discontinued or no longer supported in custom compounds.
Vitaliy Pfau
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 15, 2022 @ 01:14 PM             Msg. 6 of 23
So are you saying that we can't just send off legs defined by the user (with the same base contract) and have the api just take it?

If that is the case, what are compound types: Unknown, Generic, and CustomOptionSpread used for?

How would one do a Synthetic Long (or any of the other no longer supported custom compounds) if it is no longer supported? They just can't place those?

Thanks
VPfau
Moderator
Posts: 164
Joined:


Posted: Sep 15, 2022 @ 03:28 PM             Msg. 7 of 23
>So are you saying that we can't just send off legs defined by the user (with the same base contract) and have the api just take it?
Im saying that each custom compound goes thru validation procedure. For legs that shared same base contract we have CustomOptionSpread type.

>If that is the case, what are compound types: Unknown, Generic, and CustomOptionSpread used for?
Unknown, Generic are for predefined contracts; These are not participate in user's contract request procedure.
See above for CustomOptionSpread.

>How would one do a Synthetic Long (or any of the other no longer supported custom compounds) if it is no longer supported? They just can't place those?
They can place order for Synthetic Long contracts if we have them in the system already. Basically if you can look up contract and obtain contract id.
Vitaliy Pfau
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 15, 2022 @ 04:36 PM             Msg. 8 of 23
Okay thank you,

I think my last question, is there a way to determine if the position was placed with a compound order? Every combination I have tried doesn't seem to correctly associate the IsCompound and the legs correctly.

Thanks for all of your help
VPfau
Moderator
Posts: 164
Joined:


Posted: Sep 16, 2022 @ 08:28 AM             Msg. 9 of 23
>I think my last question, is there a way to determine if the position was placed with a compound order? Every combination I have tried doesn't seem to correctly associate the IsCompound and the legs correctly.
An order should contain reference to a compound.
Position has reference to a basic contract. We split compounds by it's legs for positions.
Vitaliy Pfau
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 16, 2022 @ 10:56 AM             Msg. 10 of 23
This is what I am seeing:

I placed a straddle order with Compound type of Straddle and it successfully went through.

I get the position from this dictionary:

IAvgPositionDictionaryPtr poses = pAcct->AvgPositions;//average positions
IPositionPtr p = poses->GetValue(poses->KeyByIndex(i));

I have checked the position using this:
if (p->PositionContract->IsCompound) //this is false
if (p->Contract->IsCompound) //this is false

I checked the compound type of the position using:
p->Contract->CompoundType
p->PositionContract->IsCompound
and both of these return Unknown

I have also checked the fills:
IPositionFillPtr fill = p->Fills->GetAt(i);
if (fill->SourceFill->Order->CustomCompound) //this is null
if (fill->SourceFill->Contract->IsCompound) //this is false
if (fill->SourceFill->Order->ParentOrder && fill->SourceFill->Order->ParentOrder->CustomCompound) //this is null
if (fill->SourceFill->Order->Parent && fill->SourceFill->Order->Parent->CustomCompound) //this is null
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 16, 2022 @ 11:22 AM             Msg. 11 of 23
I am placing a Straddle option on symbol NQZ22 and getting this message:

OQNEU22 Straddle C11800,P11800: Rejected Unsupported contract: 279366379

I was able to place one on the September contract, but not the December.
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 18, 2022 @ 11:20 PM             Msg. 12 of 23
CompoundType::CustomOptionSpread was supposed to release in the most recent update and it is not there. The version I just downloaded is version GAIN GFAPI COM 4.7.912.197
JSmith5611
Posts: 187
Joined:


Posted: Sep 19, 2022 @ 07:42 AM             Msg. 13 of 23
Please check 4.7.917.200
Jason Smith
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 19, 2022 @ 08:30 AM             Msg. 14 of 23
Where do I get this version?
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 20, 2022 @ 02:11 PM             Msg. 15 of 23
The CustomOptionSpread is now in there, thanks for getting that done.

Can I please get some help with determining if the position was linked with an order that I mentioned above?

Additionally, from what I have found, when placing a custom compound order, it only returns a single order back?

It doesn't make too much sense there, but I do see that the order contract has legs with the correct amount of legs. The ILegPtr only has a quantity and a contract pointer as available properties. What happens if they place a buy leg and a sell leg? Why doesn't the leg have a side attached to it?

Just looking into the documentation, it might be that the side was left out of the COM API. Can that please get added in.

I'm not exactly how a COM API is created, but it seems like random things are being left out, is there not a way to sync everything so that the COM API has all of the member variables that the normal API has?

Thanks
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 21, 2022 @ 10:37 AM             Msg. 16 of 23
After play with it for a minute, I actually like the way you guys have it setup where it is just one order that comes back. Now that I know there is a Side property that should be in there it makes things easier.
JSmith5611
Posts: 187
Joined:


Posted: Sep 21, 2022 @ 02:30 PM             Msg. 17 of 23
Legs of contracts (once created) don't really have a side. They do have a quantity, which can be negative.
Jason Smith
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 21, 2022 @ 02:32 PM             Msg. 18 of 23
So negative quantity means a sell? Why does the documentation show that legs should have a side property?
JSmith5611
Posts: 187
Joined:


Posted: Sep 21, 2022 @ 03:02 PM             Msg. 19 of 23
Where does it say that?

There's no side property here:

https://gainfutures.com/GFAPI/html/T_GF_Api_Contracts_Legs_Leg.htm
Jason Smith
RWare2020
Posts: 206
Joined: Feb 11, 2020


Posted: Sep 21, 2022 @ 03:05 PM             Msg. 20 of 23
There is a side property here:

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