Author |
Topic: Option spreads (4 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
FGiordano538 Posts: 24 Joined: May 09, 2022 |
Is it possible via the API to trade Option Spreads?
I would like to trade Ratio Spreads on /ES. The CME allows 1x2, 1x3 and 2x3 ratios. Grazie. |
||||
CMicciche902 Posts: 367 Joined: |
Yes. Review CustomCompound https://gainfutures.com/GFAPI/?topic=html/P_GF_Api_Orders_Drafts_OrderDraft_CustomCompound.htm
Chris M
|
||||
FGiordano538 Posts: 24 Joined: May 09, 2022 |
is there an example in visual basic.net o C#?
Edited by FGiordano538 on Jul 11, 2022 03:00 AM |
||||
FGiordano538 Posts: 24 Joined: May 09, 2022 |
AzzeraPreOrdineOrdine()
Dim CustComp_ As GF.Api.Contracts.CustomCompounds.CustomCompoundTemplate Dim List_CustomCompoundLegs = New List(Of CustomCompoundLegTemplate) Dim Leg_1, Leg_2, Leg_3, Leg_4 As GF.Api.Contracts.CustomCompounds.CustomCompoundLegTemplate Dim Segno_Figura As OrderSide Dim Segno_Titolo_1 As OrderSide Dim Segno_Titolo_2 As OrderSide Dim Segno_Titolo_3 As OrderSide Dim Segno_Titolo_4 As OrderSide Dim order As IOrder = Nothing Try If Side_ = "BUY" Then Segno_Figura = OrderSide.Buy ElseIf Side_ = "SELL" Then Segno_Figura = OrderSide.Sell End If If Cmb_Segno1.SelectedItem.ToString.ToUpper = "BUY" Then Segno_Titolo_1 = OrderSide.Buy ElseIf Cmb_Segno1.SelectedItem.ToString.ToUpper = "SELL" Then Segno_Titolo_1 = OrderSide.Sell End If If Cmb_Segno2.SelectedItem.ToString.ToUpper = "BUY" Then Segno_Titolo_2 = OrderSide.Buy ElseIf Cmb_Segno2.SelectedItem.ToString.ToUpper = "SELL" Then Segno_Titolo_2 = OrderSide.Sell End If If Cmb_Segno3.SelectedItem.ToString.ToUpper = "BUY" Then Segno_Titolo_3 = OrderSide.Buy ElseIf Cmb_Segno3.SelectedItem.ToString.ToUpper = "SELL" Then Segno_Titolo_3 = OrderSide.Sell End If If Cmb_Segno4.SelectedItem.ToString.ToUpper = "BUY" Then Segno_Titolo_4 = OrderSide.Buy ElseIf Cmb_Segno4.SelectedItem.ToString.ToUpper = "SELL" Then Segno_Titolo_4 = OrderSide.Sell End If If Not TitoloAperto1 Is Nothing Then Leg_1 = New CustomCompoundLegTemplate(TitoloAperto1.ID, Segno_Titolo_1, CInt(Tbx_Qta_1.Text)) List_CustomCompoundLegs.Add(Leg_1) If Not TitoloAperto2 Is Nothing Then Leg_2 = New CustomCompoundLegTemplate(TitoloAperto2.ID, Segno_Titolo_2, CInt(Tbx_Qta_2.Text)) List_CustomCompoundLegs.Add(Leg_2) If Not TitoloAperto3 Is Nothing Then Leg_3 = New CustomCompoundLegTemplate(TitoloAperto3.ID, Segno_Titolo_3, CInt(Tbx_Qta_3.Text)) List_CustomCompoundLegs.Add(Leg_3) If Not TitoloAperto4 Is Nothing Then Leg_4 = New CustomCompoundLegTemplate(TitoloAperto4.ID, Segno_Titolo_4, CInt(Tbx_Qta_4.Text)) List_CustomCompoundLegs.Add(Leg_4) End If End If End If End If CustComp_ = New CustomCompoundTemplate(CompoundType.Synthetic, List_CustomCompoundLegs) Dim OrderDraft = New OrderDraftBuilder() OrderDraft.WithAccountID(Form1.AccountID_) OrderDraft.WithCustomCompound(CustComp_) OrderDraft.WithSide(Segno_Figura) If Cmb_TipoPrz.SelectedItem.ToString.ToUpper = "LIMIT" Then OrderDraft.WithOrderType(OrderType.Limit) Else OrderDraft.WithOrderType(OrderType.Market) End If OrderDraft.WithPrice(CDbl(Tbx_PrzSintetico.Text)) OrderDraft.WithQuantity(CInt(Tbx_QtaFigure.Text)) OrderDraft.WithEnd(DateTime.UtcNow.AddMinutes(1400)) OrderDraft.WithComments("Synthetic") OrderDraft.WithFlags(0) OrderDraft.Build() OrdineDaInviare_COMPL = OrderDraft Dim validationErrors As New List(Of OrderDraftValidationError) validationErrors = Form1.gfClient.Orders.Drafts.Validate(OrderDraft.Build) Dim FraseErrore As String = "" Pnl_PreparaOrdine.Visible = False Pnl_ConfermaOrdine.Visible = True If (validationErrors.Any()) Then For id_ = 0 To validationErrors.Count - 1 FraseErrore = ($"\t{validationErrors(id_).Message}" & vbCrLf) Next Tbx_Messaggio.Text = FraseErrore Cmd_Esegui.Enabled = False Else Dim RiepilogoOrdine As String = "" Lbl_Account.Text = GL_Account_Conto Lbl_PrezzoNetto.Text = FormatNumber(OrderDraft.Build.Price, 2) Lbl_NumeroFig.Text = OrderDraft.Build.Quantity Dim ORDER_ As IOrder ORDER_ = Form1.gfClient.Orders.SendOrder(OrdineDaInviare_COMPL.Build) End If ControlloOrdineDaConfermare_C(Segno_Figura.ToString, OrderDraft.Build.Price) Catch ex As Exception MsgBox("Errore : " & ex.Message) End Try ---------------------------------------------------------- This works, but is there a way to review the entire order before sending it to market? Thank you Edited by FGiordano538 on Jul 13, 2022 12:15 PM |
||||