API Support Forum
OEC API > Order Execution > CompoundType "Custom" cod. 88
Author Topic: CompoundType "Custom" cod. 88
(11 messages, Page 1 of 1)
Moderators: VPfau
FGiordano538
Posts: 24
Joined: May 09, 2022


Posted: Aug 23, 2022 @ 07:18 AM             Msg. 1 of 11
Visual Basic
Dim CustComp_ As GF.Api.Contracts.CustomCompounds.CustomCompoundTemplate
Dim List_CustomCompoundLegs = New List(Of CustomCompoundLegTemplate)
Dim Leg_1, Leg_2 As GF.Api.Contracts.CustomCompounds.CustomCompoundLegTemplate
Dim order As IOrder = Nothing
Dim OrderDraft = New OrderDraftBuilder()
Try
If TitoloAperto1 Is Nothing Or TitoloAperto2 Is Nothing Then Exit Sub
Leg_1 = New CustomCompoundLegTemplate(TitoloAperto1.ID, OrderSide.Buy, 1)
List_CustomCompoundLegs.Add(Leg_1)
Leg_2 = New CustomCompoundLegTemplate(TitoloAperto2.ID, OrderSide.Sell, 1)
List_CustomCompoundLegs.Add(Leg_2)
CustComp_ = New CustomCompoundTemplate(CompoundType.RatioSpread, List_CustomCompoundLegs)
OrderDraft.WithAccountID(AccountInvioAmeracato.ID)
OrderDraft.WithCustomCompound(CustComp_)
OrderDraft.WithSide(OrderSide.Buy)
OrderDraft.WithOrderType(OrderType.Limit)
OrderDraft.WithPrice(1)
OrderDraft.WithQuantity(1)
OrderDraft.WithEnd(DateTime.UtcNow.AddMinutes(1400))
OrderDraft.WithComments(CustComp_.CompoundType.ToString)
OrderDraft.WithFlags(0)
OrderDraft.Build()
Dim validationErrors As New List(Of OrderDraftValidationError)
validationErrors = Form1.gfClient.Orders.Drafts.Validate(OrderDraft.Build)
Dim FraseErrore As String = ""
If (validationErrors.Any()) Then
For id_ = 0 To validationErrors.Count - 1
FraseErrore = ($"\t{validationErrors(id_).Message}" & vbCrLf)

Next
Debug.Print(FraseErrore)

Else

Debug.Print(AccountInvioAmeracato.ID.ToString & " -- " & AccountInvioAmeracato.Spec & " -- " & OrderDraft.Build.Quantity & " / " &
OrderDraft.Build.Price & " - " & OrderDraft.Build.Side.ToString & " - " & OrderDraft.Build.Comments)

Form1.gfClient.Orders.SendOrder(OrderDraft.Build)
End If

Catch ex As Exception
MsgBox("Errore : " & ex.Message)

End Try
-----------------------------------------------------------------------------------------------------------------------
this is a compound order, (BUY 1 OESM23 P3000, SELL 1 OESM23 P2800)
if I send it as "PutHorizontal" or as "RatioSpread", in the end it always takes it as "RatioSpread" and goes to market exactly.
as seen from the attached order status pictures
https://imgur.com/a/1jQBqMa
I tried to do the following order in the same way (BUY 1 OESM23 P3000, SELL 1 OESH23 P3000)
i sent it as "PutHorizontal", which should be exact, but rejects it, as seen from the attached order status pictures,
and does not take it with any CompoundType. From the "GAIN Trader" only accepts it with
CompoundType "Custom" cod. 88 which does not exist in the API. Qulacuno can tell me if it is solvable?
Thank you.
JSmith5611
Posts: 187
Joined:


Posted: Sep 07, 2022 @ 02:54 PM             Msg. 2 of 11
From your image, the error
'No base contract for custom compound' was our error and has since been fixed.

BUY 1 OESM23 P3000, SELL 1 OESM23 P2800
isn't a valid PutHorizontal, but is a valid PutVertical
Jason Smith
FGiordano538
Posts: 24
Joined: May 09, 2022


Posted: Sep 08, 2022 @ 04:21 AM             Msg. 3 of 11
Thanks for the reply J.Smith.
If I want to place an order with 3 legs (BUY 1 OESM23 P3000, SELL 1 OESM23 P2800, SELL 1 OESH23 P2700) what can I do?
What type of "CompoundType" should I use?
Edited by FGiordano538 on Sep 08, 2022 04:23 AM
JSmith5611
Posts: 187
Joined:


Posted: Sep 09, 2022 @ 09:15 AM             Msg. 4 of 11
Which version of the API are you using?
the nuget package, or the COM api?
Jason Smith
FGiordano538
Posts: 24
Joined: May 09, 2022


Posted: Sep 12, 2022 @ 04:33 AM             Msg. 5 of 11
GFAPI.4.0.3.44.nupkg
JSmith5611
Posts: 187
Joined:


Posted: Sep 12, 2022 @ 06:32 AM             Msg. 6 of 11
I've pushed a new version of the nuget package that should have code 88
Jason Smith
FGiordano538
Posts: 24
Joined: May 09, 2022


Posted: Sep 13, 2022 @ 04:13 AM             Msg. 7 of 11
I have installed the new version, but it returns this error. In the link I have also inserted the image of the installed packages. https://imgur.com/a/YVS4Hjn
Then I updated the versions of all the packages, and it gives me a different error. I'll post the error and packages with versions.https://imgur.com/a/ihAklZW
What am I doing wrong?
Thank you.
JSmith5611
Posts: 187
Joined:


Posted: Sep 13, 2022 @ 01:15 PM             Msg. 8 of 11
OK, there seems to be an issue with our nuget package missing a requirement.
If you restore the package versions to what's in the first image you posted, and install the nuget package
'System.Threading.Tasks.Extensions' version 4.5.4 it should work.
Jason Smith
FGiordano538
Posts: 24
Joined: May 09, 2022


Posted: Sep 14, 2022 @ 02:14 AM             Msg. 9 of 11
Thanks now it works
JSmith5611
Posts: 187
Joined:


Posted: Sep 14, 2022 @ 06:56 AM             Msg. 10 of 11
You're welcome. Is there anything else you need assistance with?
Jason Smith
FGiordano538
Posts: 24
Joined: May 09, 2022


Posted: Sep 15, 2022 @ 09:40 AM             Msg. 11 of 11
TK.
With the API of a Block Account, is it possible to have the total position? I have the position of the individual accounts, but the total one, as if it were a single account, gives me back 0. I solved it by cycling the sub-accounts, but if it were possible to have it directly it would be better.

Thanks and sorry if I take advantage.
I write you the code that I use now

Dim GL_Account_AB As IAccount = gfClient.Accounts.Wash.Get.First
Dim GL_Account_ As IAccount = gfClient.Accounts.Get().First

Dim account As Accounts.IAccount = Nothing
Dim totalBalance As Balances.IBalance = Nothing
If GL_Account_AB Is GL_Account_ Then
Dim Disp_ As Double = 0
Dim Liq_ As Double = 0
For Each Account_ In gfClient.Accounts.Get
totalBalance = Account_.TotalBalance
Disp_ += totalBalance.NetLiq - totalBalance.PortfolioMargin.RiskValue
Liq_ += totalBalance.PortfolioMargin.MaintenanceReq
Next

Lbl_Disponibilita.Text = FormatNumber(Disp_, 0)
Lbl_LiquiditaVinc.Text = FormatNumber(Liq_, 0)

Else
totalBalance = GL_Account_.TotalBalance
Lbl_Disponibilita.Text = FormatNumber(totalBalance.NetLiq - totalBalance.PortfolioMargin.RiskValue, 0)
Lbl_LiquiditaVinc.Text = FormatNumber(totalBalance.PortfolioMargin.MaintenanceReq, 0)

End If
Edited by FGiordano538 on Sep 15, 2022 09:46 AM
Edited by FGiordano538 on Sep 15, 2022 12:21 PM
Edited by FGiordano538 on Sep 27, 2022 03:41 AM