/// <summary> /// Returns the string presentation of the object /// </summary> /// <returns>String presentation of the object</returns> public override string ToString() { var sb = new System.Text.StringBuilder(); sb.Append("class OrderResponse {\n"); sb.Append(" OrderID: ").Append(OrderId.ToString()).Append("\n"); sb.Append(" ClOrdID: ").Append(ClOrdId.ToString()).Append("\n"); sb.Append(" ClOrdLinkID: ").Append(ClOrdLinkId.ToString()).Append("\n"); sb.Append(" Account: ").Append(Account.ToString()).Append("\n"); sb.Append(" Symbol: ").Append(Symbol.ToString()).Append("\n"); sb.Append(" Side: ").Append(Side.ToString()).Append("\n"); sb.Append(" OrderQty: ").Append(OrderQty.ToString()).Append("\n"); sb.Append(" Price: ").Append(Price.ToString()).Append("\n"); sb.Append(" DisplayQty: ").Append((DisplayQty == null) ? "null" : DisplayQty.ToString()).Append("\n"); sb.Append(" StopPx: ").Append((StopPx == null) ? "null" : StopPx.ToString()).Append("\n"); sb.Append(" PegOffsetValue: ").Append((PegOffsetValue == null) ? "null" : PegOffsetValue.ToString()).Append("\n"); sb.Append(" PegPriceType: ").Append((PegPriceType == null) ? "null" : PegPriceType.ToString()).Append("\n"); sb.Append(" Currency: ").Append((Currency == null) ? "null" : Currency.ToString()).Append("\n"); sb.Append(" SettlCurrency: ").Append((SettlCurrency == null) ? "null" : SettlCurrency.ToString()).Append("\n"); sb.Append(" OrdType: ").Append((OrdType == null) ? "null" : OrdType.ToString()).Append("\n"); sb.Append(" TimeInForce: ").Append((TimeInForce == null) ? "null" : TimeInForce.ToString()).Append("\n"); sb.Append(" ExecInst: ").Append((ExecInst == null) ? "null" : ExecInst.ToString()).Append("\n"); sb.Append(" ContingencyType: ").Append((ContingencyType == null) ? "null" : ContingencyType.ToString()).Append("\n"); sb.Append(" ExDestination: ").Append((ExDestination == null) ? "null" : ExDestination.ToString()).Append("\n"); sb.Append(" OrdStatus: ").Append((OrdStatus == null) ? "null" : OrdStatus.ToString()).Append("\n"); sb.Append(" Triggered: ").Append((Triggered == null) ? "null" : Triggered.ToString()).Append("\n"); sb.Append(" WorkingIndicator: ").Append((WorkingIndicator == null) ? "null" : WorkingIndicator.ToString()).Append("\n"); sb.Append(" OrdRejReason: ").Append((OrdRejReason == null) ? "null" : OrdRejReason.ToString()).Append("\n"); sb.Append(" LeavesQty: ").Append((LeavesQty == null) ? "null" : LeavesQty.ToString()).Append("\n"); sb.Append(" CumQty: ").Append((CumQty == null) ? "null" : CumQty.ToString()).Append("\n"); sb.Append(" AvgPx: ").Append((AvgPx == null) ? "null" : AvgPx.ToString()).Append("\n"); sb.Append(" MultiLegReportingType: ").Append((MultiLegReportingType == null) ? "null" : MultiLegReportingType.ToString()).Append("\n"); sb.Append(" Text: ").Append((Text == null) ? "null" : Text.ToString()).Append("\n"); sb.Append(" TransactTime: ").Append(TransactTime.ToString()).Append("\n"); sb.Append(" Timestamp: ").Append(Timestamp.ToString()).Append("\n"); sb.Append("}\n"); return(sb.ToString()); }
public void Init(Instrument instrument, OrdType ordType, Side side, byte route) { this.Text = string.Format("{0} - {1} {2}", instrument, side, ordType); int decimalPlaces = PriceFormatHelper.GetDecimalPlaces(instrument); Decimal num1 = (Decimal)Math.Pow(0.1, (double)decimalPlaces); this.nudLimitPrice.DecimalPlaces = decimalPlaces; this.nudStopPrice.DecimalPlaces = decimalPlaces; this.nudLimitPrice.Increment = num1; this.nudStopPrice.Increment = num1; this.nudLimitPrice.Enabled = false; this.nudStopPrice.Enabled = false; switch (ordType) { case OrdType.Market: switch (side) { case Side.Buy: this.nudLimitPrice.Value = (Decimal)instrument.Quote.Ask; this.nudStopPrice.Value = (Decimal)instrument.Quote.Ask; break; case Side.Sell: this.nudLimitPrice.Value = (Decimal)instrument.Quote.Bid; this.nudStopPrice.Value = (Decimal)instrument.Quote.Bid; break; default: throw new NotSupportedException("Not supported order side - " + ((object)side).ToString()); } this.cbxTIFs.BeginUpdate(); this.cbxTIFs.Items.Clear(); foreach (OpenQuant.API.TimeInForce timeInForce in Enum.GetValues(typeof (OpenQuant.API.TimeInForce))) this.cbxTIFs.Items.Add((object)timeInForce); this.cbxTIFs.SelectedItem = (object)OpenQuant.API.TimeInForce.Day; this.cbxTIFs.EndUpdate(); if ((int)route > 0) { OrderMiniBlotterForm orderMiniBlotterForm = this; int num2 = orderMiniBlotterForm.Height + 32; orderMiniBlotterForm.Height = num2; Button button1 = this.btnSend; int num3 = button1.Top + 32; button1.Top = num3; Button button2 = this.btnCancel; int num4 = button2.Top + 32; button2.Top = num4; GroupBox groupBox = this.groupBox1; int num5 = groupBox.Height + 32; groupBox.Height = num5; Label label = new Label(); label.AutoSize = false; label.TextAlign = ContentAlignment.MiddleLeft; label.Location = new Point(16, 144); label.Size = new Size(70, 20); label.Text = "Route"; this.groupBox1.Controls.Add((Control)label); this.cbxRoutes = new ComboBox(); this.cbxRoutes.DropDownStyle = ComboBoxStyle.DropDownList; this.cbxRoutes.Location = new Point(104, 144); this.cbxRoutes.Size = new Size(98, 21); this.cbxRoutes.Sorted = true; this.groupBox1.Controls.Add((Control)this.cbxRoutes); this.cbxRoutes.BeginUpdate(); this.cbxRoutes.Items.Clear(); IEnumerator enumerator = ((ProviderList)ProviderManager.ExecutionProviders).GetEnumerator(); try { while (enumerator.MoveNext()) { IExecutionProvider iexecutionProvider = (IExecutionProvider)enumerator.Current; RouteItem routeItem = new RouteItem(iexecutionProvider.Name, iexecutionProvider.Id); this.cbxRoutes.Items.Add((object)routeItem); if ((int)((IProvider)iexecutionProvider).Id == (int)route) this.cbxRoutes.SelectedItem = (object)routeItem; } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) disposable.Dispose(); } if (this.cbxRoutes.Items.Count > 0 && this.cbxRoutes.SelectedItem == null) this.cbxRoutes.SelectedIndex = 0; this.cbxRoutes.EndUpdate(); break; } else { this.cbxRoutes = (ComboBox)null; break; } case OrdType.Limit: this.nudLimitPrice.Enabled = true; goto case OrdType.Market; case OrdType.Stop: this.nudStopPrice.Enabled = true; goto case OrdType.Market; case OrdType.StopLimit: this.nudLimitPrice.Enabled = true; this.nudStopPrice.Enabled = true; goto case OrdType.Market; default: throw new NotSupportedException("Not supported order type - " + ordType.ToString()); } }
public static void ConsistirNovaOrdem(NewOrderSingle nos, string exchange) { // Basic order identification if (string.IsNullOrEmpty(nos.Account.ToString())) { throw new ArgumentException("Account field must be provided"); } if (string.IsNullOrEmpty(nos.ClOrdID.ToString())) { throw new ArgumentException("ClOrdID field must be provided"); } // Instrument Identification Block if (string.IsNullOrEmpty(nos.Symbol.ToString())) { throw new ArgumentException("Symbol must be provided"); } // "obrigatorio" somente para bmf (nao obrigatorio na mensageria, mas dah erro se enviar // sem este campo para bmf) //if (exchange.Equals(ExchangePrefixes.BMF, StringComparison.InvariantCultureIgnoreCase)) //{ // if (string.IsNullOrEmpty(nos.SecurityID.ToString())) // throw new ArgumentException("SecurityID field must be provided"); //} if (string.IsNullOrEmpty(nos.OrderQty.ToString())) { throw new ArgumentException("OrderQty must be > 0 "); } // obrigatorio se for FIX.4.4 if (nos.IsSetField(Tags.NoPartyIDs)) { try { Group partyIDs = nos.GetGroup(1, Tags.NoPartyIDs); if (string.IsNullOrEmpty(partyIDs.GetField(Tags.PartyID))) { throw new ArgumentException("ExecBroker must be provided"); } } catch { throw new ArgumentException("ExecBroker must be provided"); } } // Somente validar se o campo estiver atribuido, nao obrigatorio na mensageria if (nos.IsSetField(Tags.TimeInForce)) { TimeInForce tif = nos.TimeInForce; if (tif == null) { throw new ArgumentException("TimeInForce is invalid"); } if (tif.ToString().Equals(TimeInForce.GOOD_TILL_DATE.ToString())) { if (!string.IsNullOrEmpty(nos.ExpireDate.ToString())) { DateTime dtExpireDate = DateTime.ParseExact(nos.ExpireDate.ToString(), "yyyyMMdd", CultureInfo.InvariantCulture); if (dtExpireDate.Date < DateTime.Now.Date) { throw new ArgumentException("ExpireDate is invalid"); } } else { throw new ArgumentException("ExpireDate is invalid"); } } } OrdType ordType = nos.OrdType; if (ordType == null) { throw new ArgumentException("OrdType is invalid"); } // Verifica envio do preco switch (ordType.ToString()[0]) { case OrdType.LIMIT: // OrdemTipoEnum.Limitada: case OrdType.MARKET_WITH_LEFTOVER_AS_LIMIT: // OrdemTipoEnum.MarketWithLeftOverLimit: if (nos.Price.getValue() <= new Decimal(0.0)) { throw new ArgumentException("Price must be > 0"); } break; case OrdType.STOP_LIMIT: // OrdemTipoEnum.StopLimitada: //case OrdType.STO OrdemTipoEnum.StopStart: if (nos.Price.getValue() <= new Decimal(0.0)) { throw new ArgumentException("Price must be > 0"); } if (nos.StopPx.getValue() <= new Decimal(0.0)) { throw new ArgumentException("StopPrice must be > 0"); } break; case OrdType.MARKET: // OrdemTipoEnum.Mercado: case OrdType.ON_CLOSE: //OrdemTipoEnum.OnClose: break; default: if (nos.Price.getValue() <= new Decimal(0.0)) { throw new ArgumentException("Price must be > 0"); } break; } if (nos.IsSetMaxFloor()) { if (nos.MaxFloor.getValue() < new Decimal(0)) { throw new ArgumentException("MaxFloor must be >= 0"); } } if (nos.IsSetMinQty()) { if (nos.MinQty.getValue() < new Decimal(0)) { throw new ArgumentException("MinQty must be >= 0"); } } }
public static void ConsistirNovaOrdemCross(NewOrderCross noc, string exchange) { string strAccount1 = string.Empty; if (!noc.IsSetCrossID()) { throw new ArgumentException("CrossID field must be provided"); } if (!noc.IsSetCrossType()) { throw new ArgumentException("CrossType field must be provided"); } if (!noc.IsSetCrossPrioritization()) { throw new ArgumentException("CrossPriorization field must be provided"); } if (noc.IsSetNoSides() && noc.NoSides.getValue() == 2) { QuickFix.Group grpNoSides = noc.GetGroup(1, Tags.NoSides); OrdensConsistencia.ProcessGroupNOC(grpNoSides); grpNoSides = noc.GetGroup(2, Tags.NoSides); OrdensConsistencia.ProcessGroupNOC(grpNoSides); } // Instrument Identification Block if (string.IsNullOrEmpty(noc.Symbol.ToString())) { throw new ArgumentException("Symbol field must be provided"); } if (exchange.Equals(ExchangePrefixes.BMF, StringComparison.InvariantCultureIgnoreCase)) { if (string.IsNullOrEmpty(noc.SecurityID.ToString())) { throw new ArgumentException("SecurityID field must be provided"); } } OrdType ordType = noc.OrdType; if (ordType == null) { throw new ArgumentException("OrdType is invalid"); } // Verifica envio do preco bool aux = false; switch (ordType.ToString()[0]) { case OrdType.LIMIT: // OrdemTipoEnum.Limitada: break; default: aux = true; break; } if (aux) { throw new ArgumentException("OrderType must be 2 - Limit"); } if (noc.IsSetPrice()) { if (noc.Price.getValue() <= new Decimal(0)) { throw new ArgumentException("Must must be >= 0"); } } }
public void Init(Instrument instrument, OrdType ordType, Side side, byte route) { this.Text = string.Format("{0} - {1} {2}", instrument, side, ordType); int decimalPlaces = PriceFormatHelper.GetDecimalPlaces(instrument); Decimal num1 = (Decimal)Math.Pow(0.1, (double)decimalPlaces); this.nudLimitPrice.DecimalPlaces = decimalPlaces; this.nudStopPrice.DecimalPlaces = decimalPlaces; this.nudLimitPrice.Increment = num1; this.nudStopPrice.Increment = num1; this.nudLimitPrice.Enabled = false; this.nudStopPrice.Enabled = false; switch (ordType) { case OrdType.Market: switch (side) { case Side.Buy: this.nudLimitPrice.Value = (Decimal)instrument.Quote.Ask; this.nudStopPrice.Value = (Decimal)instrument.Quote.Ask; break; case Side.Sell: this.nudLimitPrice.Value = (Decimal)instrument.Quote.Bid; this.nudStopPrice.Value = (Decimal)instrument.Quote.Bid; break; default: throw new NotSupportedException("Not supported order side - " + ((object)side).ToString()); } this.cbxTIFs.BeginUpdate(); this.cbxTIFs.Items.Clear(); foreach (OpenQuant.API.TimeInForce timeInForce in Enum.GetValues(typeof(OpenQuant.API.TimeInForce))) { this.cbxTIFs.Items.Add((object)timeInForce); } this.cbxTIFs.SelectedItem = (object)OpenQuant.API.TimeInForce.Day; this.cbxTIFs.EndUpdate(); if ((int)route > 0) { OrderMiniBlotterForm orderMiniBlotterForm = this; int num2 = orderMiniBlotterForm.Height + 32; orderMiniBlotterForm.Height = num2; Button button1 = this.btnSend; int num3 = button1.Top + 32; button1.Top = num3; Button button2 = this.btnCancel; int num4 = button2.Top + 32; button2.Top = num4; GroupBox groupBox = this.groupBox1; int num5 = groupBox.Height + 32; groupBox.Height = num5; Label label = new Label(); label.AutoSize = false; label.TextAlign = ContentAlignment.MiddleLeft; label.Location = new Point(16, 144); label.Size = new Size(70, 20); label.Text = "Route"; this.groupBox1.Controls.Add((Control)label); this.cbxRoutes = new ComboBox(); this.cbxRoutes.DropDownStyle = ComboBoxStyle.DropDownList; this.cbxRoutes.Location = new Point(104, 144); this.cbxRoutes.Size = new Size(98, 21); this.cbxRoutes.Sorted = true; this.groupBox1.Controls.Add((Control)this.cbxRoutes); this.cbxRoutes.BeginUpdate(); this.cbxRoutes.Items.Clear(); IEnumerator enumerator = ((ProviderList)ProviderManager.ExecutionProviders).GetEnumerator(); try { while (enumerator.MoveNext()) { IExecutionProvider iexecutionProvider = (IExecutionProvider)enumerator.Current; RouteItem routeItem = new RouteItem(iexecutionProvider.Name, iexecutionProvider.Id); this.cbxRoutes.Items.Add((object)routeItem); if ((int)((IProvider)iexecutionProvider).Id == (int)route) { this.cbxRoutes.SelectedItem = (object)routeItem; } } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } if (this.cbxRoutes.Items.Count > 0 && this.cbxRoutes.SelectedItem == null) { this.cbxRoutes.SelectedIndex = 0; } this.cbxRoutes.EndUpdate(); break; } else { this.cbxRoutes = (ComboBox)null; break; } case OrdType.Limit: this.nudLimitPrice.Enabled = true; goto case OrdType.Market; case OrdType.Stop: this.nudStopPrice.Enabled = true; goto case OrdType.Market; case OrdType.StopLimit: this.nudLimitPrice.Enabled = true; this.nudStopPrice.Enabled = true; goto case OrdType.Market; default: throw new NotSupportedException("Not supported order type - " + ordType.ToString()); } }