/// <summary> /// ConsistirCancelamento - consistir CancelamentoInfo /// </summary> /// <param name="orderCancelInfo"></param> public static void ConsistirCancelamento(OrdemCancelamentoInfo orderCancelInfo) { // Basic order identification if (orderCancelInfo.Account < 0) { throw new ArgumentException("Account field must be provided"); } if (orderCancelInfo.OrigClOrdID == null || orderCancelInfo.OrigClOrdID.Length <= 0) { throw new ArgumentException("OrigClOrdID field must be provided"); } if (orderCancelInfo.ClOrdID == null || orderCancelInfo.ClOrdID.Length <= 0) { throw new ArgumentException("ClOrdID field must be provided"); } // Instrument Identification Block if (orderCancelInfo.Symbol == null || orderCancelInfo.Symbol.Length <= 0) { throw new ArgumentException("Symbol must be provided"); } if (orderCancelInfo.SecurityID == null || orderCancelInfo.SecurityID.Length <= 0) { throw new ArgumentException("SecurityID field must be provided"); } //ATP - 2012-10-29 //Qtde de contratos/papeis a serem cancelados if (orderCancelInfo.OrderQty <= 0) { throw new ArgumentException("OrderQty must be > 0 "); } // Cliente if (orderCancelInfo.ExecBroker == null || orderCancelInfo.ExecBroker.Length <= 0) { throw new ArgumentException("ExecBroker must be provided"); } }
private void cancelarOrdem(OrdemInfo ordem) { try { OrdemCancelamentoInfo info = new OrdemCancelamentoInfo(); info.ClOrdID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-C" + ordem.Symbol + ordem.ChannelID + ordem.Account; info.Account = ordem.Account; info.ChannelID = ordem.ChannelID; info.Exchange = ordem.Exchange; info.OrigClOrdID = ordem.ClOrdID; info.Symbol = ordem.Symbol; info.SecurityID = ordem.SecurityID; info.Side = ordem.Side; if (!String.IsNullOrEmpty(ordem.ExecBroker)) { info.ExecBroker = ordem.ExecBroker; } ExecutarCancelamentoOrdemRequest request = new ExecutarCancelamentoOrdemRequest(); IRoteadorOrdens roteador = Ativador.Get <IRoteadorOrdens>(); ExecutarCancelamentoOrdemResponse response = roteador.CancelarOrdem(request); if (response.DadosRetorno.StatusResposta != StatusRoteamentoEnum.Sucesso) { logger.Error("Erro ao cancelar ordem [" + ordem.ClOrdID + "] alteracao de [" + ordem.ClOrdID + "]"); foreach (OcorrenciaRoteamentoOrdem ocorr in response.DadosRetorno.Ocorrencias) { logger.Error("Erro: " + ocorr.Ocorrencia); } } } catch (Exception ex) { logger.Error("cancelarOrdem(): " + ex.Message, ex); } }
private OrdemFIXResponse <OrdemCancelamentoInfo> ParsearOrdemCancelamentoCliente(ClienteCancelamentoInfo pParametro) { OrdemFIXResponse <OrdemCancelamentoInfo> Response = new OrdemFIXResponse <OrdemCancelamentoInfo>(); try { OrdemInfo OrdemInfo = new PersistenciaOrdens().SelecionarOrdemCliente(pParametro.OrderID); OrdemCancelamentoInfo CancelamentoInfo = new OrdemCancelamentoInfo(); CancelamentoInfo.ClOrdID = CtrlNumber; CancelamentoInfo.OrigClOrdID = OrdemInfo.ClOrdID; CancelamentoInfo.ChannelID = OrdemInfo.ChannelID; CancelamentoInfo.Account = OrdemInfo.Account; CancelamentoInfo.OrderID = OrdemInfo.ExchangeNumberID; CancelamentoInfo.OrderQty = OrdemInfo.OrderQty; CancelamentoInfo.Side = OrdemInfo.Side; CancelamentoInfo.Symbol = OrdemInfo.Symbol; if ((OrdemInfo.OrdStatus != OrdemStatusEnum.NOVA) || (OrdemInfo.OrdStatus == OrdemStatusEnum.SUBSTITUIDA) || (OrdemInfo.OrdStatus == OrdemStatusEnum.PARCIALMENTEEXECUTADA)) { Lib.Info.PipeLineCriticaInfo info = new Lib.Info.PipeLineCriticaInfo(); info.Critica = "Não é possível cancelar uma oferta em processamento. Esta oferta pode estar cancelada ou cancelando / executada ou executando. "; info.CriticaTipo = CriticaRiscoEnum.ErroNegocio; info.DataHoraCritica = DateTime.Now; Response.CriticaInfo = new List <Lib.Info.PipeLineCriticaInfo>(); Response.CriticaInfo.Add(info); Response.StatusResposta = CriticaRiscoEnum.ErroNegocio; Response.DataResposta = DateTime.Now; Response.DescricaoResposta = "O Sistema de risco encontrou <" + Response.CriticaInfo.Count.ToString() + "> item(s) a serem verificados"; return(Response); } if (OrdemInfo.Symbol.Substring(OrdemInfo.Symbol.Length - 1, 1) == "F") { OrdemInfo.Symbol = OrdemInfo.Symbol.Remove(OrdemInfo.Symbol.Length - 1); } // Defini o Exchange pelo cadastro de papeis CadastroPapeisResponse <CadastroPapelInfo> CadastroPapeis = new ServicoCadastroPapeis().ObterInformacoesIntrumento( new CadastroPapeisRequest() { Instrumento = OrdemInfo.Symbol }); if (CadastroPapeis.Objeto == null) { Lib.Info.PipeLineCriticaInfo info = new Lib.Info.PipeLineCriticaInfo(); info.Critica = "Instrumento não encontrado"; info.CriticaTipo = CriticaRiscoEnum.ErroNegocio; info.DataHoraCritica = DateTime.Now; Response.CriticaInfo = new List <Lib.Info.PipeLineCriticaInfo>(); Response.CriticaInfo.Add(info); Response.StatusResposta = CriticaRiscoEnum.ErroNegocio; Response.DataResposta = DateTime.Now; Response.DescricaoResposta = "O Sistema de risco encontrou <" + Response.CriticaInfo.Count.ToString() + "> item(s) a serem verificados"; return(Response); } if (CadastroPapeis.Objeto.TipoMercado == OMS.CadastroPapeis.Lib.Enum.TipoMercadoEnum.FUTURO) { CancelamentoInfo.Exchange = "BMF"; CancelamentoInfo.SecurityID = new PersistenciaCadastroAtivos().ObterSecurityList(OrdemInfo.Symbol); } else { CancelamentoInfo.Exchange = "BOVESPA"; } Response.Objeto = CancelamentoInfo; Response.StatusResposta = CriticaRiscoEnum.Sucesso; Response.DataResposta = DateTime.Now; Response.DescricaoResposta = "Ordem parseado com sucesso"; } catch (Exception ex) { Lib.Info.PipeLineCriticaInfo info = new Lib.Info.PipeLineCriticaInfo(); info.Critica = ex.Message; info.CriticaTipo = CriticaRiscoEnum.ErroNegocio; info.DataHoraCritica = DateTime.Now; Response.CriticaInfo = new List <Lib.Info.PipeLineCriticaInfo>(); Response.CriticaInfo.Add(info); Response.StatusResposta = CriticaRiscoEnum.Exception; Response.DataResposta = DateTime.Now; Response.DescricaoResposta = "Ocorreu um erro ao parsear a mensagem"; } return(Response); }
/// <summary> /// Exclui as ordens selecionadas /// </summary> /// <returns>Retorna uma string com mensagem de sucesso ou erro ao excluir as ordens</returns> private string ResponderExcluirOrdens() { string lRetorno = string.Empty; try { string lIds = Request.Form["Ids"]; string lPortas = Request.Form["Portas"]; string lMensagem = ""; List <string> lstIdOrdem = new List <string>(); //IServicoOrdens lOrdem = Ativador.Get<IServicoOrdens>(); Gradual.Core.Ordens.Lib.IServicoOrdens lOrdem = Ativador.Get <Gradual.Core.Ordens.Lib.IServicoOrdens>(); Dictionary <string, string> lCriticas = new Dictionary <string, string>(); ExecutarCancelamentoOrdemResponse lResponse = new ExecutarCancelamentoOrdemResponse(); string[] Ordens = lIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] Portas = lPortas.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); OrdemCancelamentoInfo info; EnviarCancelamentoOrdemRequest lRequestCancel; for (int i = 0; i < Ordens.Length; i++) { info = new OrdemCancelamentoInfo(); info.OrigClOrdID = Ordens[i]; info.ChannelID = int.Parse(Portas[i]); lRequestCancel = new EnviarCancelamentoOrdemRequest() { ClienteCancelamentoInfo = info }; lResponse = lOrdem.CancelarOrdem(lRequestCancel); if (lResponse.DadosRetorno.StatusResposta != StatusRoteamentoEnum.Sucesso) { lCriticas.Add(info.OrderID, lResponse.DadosRetorno.StackTrace); } } if (lCriticas.Count > 0) { foreach (KeyValuePair <string, string> critica in lCriticas) { lMensagem += string.Concat("Ordem: ", critica.Key, "Crítica - ", critica.Value); } lRetorno = RetornarSucessoAjax(lMensagem); } else { lRetorno = RetornarSucessoAjax("Orden(s) cancelada(s) com sucesso"); base.RegistrarLogExclusao(string.Concat("Foram EXCLUÍDAS as seguintes ordens: ", lIds)); } } catch (Exception ex) { lRetorno = base.RetornarErroAjax("Erro ao tentar cancelar ordem.", ex); } return(lRetorno); }
public bool CancelarOrdem(OrdemCancelamentoInfo ordem, long ini = 0, long fim = 0, long oriini = 0, long orifim = 0, int delay = 0, string mnemonic = "", string senderSubID = "", string extraTags = "") { //Cria a mensagem FIX de NewOrderSingle QuickFix.FIX42.OrderCancelRequest ordercrr = new QuickFix.FIX42.OrderCancelRequest(); ordercrr.Set(new Account(ordem.Account.ToString())); if (!string.IsNullOrEmpty(mnemonic)) { ordercrr.SetField(new Account(mnemonic), true); } if (!string.IsNullOrEmpty(senderSubID)) { ordercrr.Header.SetField(new SenderSubID(senderSubID), true); } ordercrr.Set(new Symbol(ordem.Symbol)); ordercrr.Set(new ClOrdID(ordem.ClOrdID)); ordercrr.Set(new OrigClOrdID(ordem.OrigClOrdID)); // Armazena ClOrdID em Memo (5149) para posterior referência nos tratamentos de retornos QuickFix.Fields.StringField field5149 = new QuickFix.Fields.StringField(5149, ordem.ClOrdID); ordercrr.SetField(field5149); //ordersingle.Set(new IDSource()); if (ordem.Side == OrdemDirecaoEnum.Venda) { ordercrr.Set(new Side(Side.SELL)); } else { ordercrr.Set(new Side(Side.BUY)); } //TimeInForce tif = FixMessageUtilities.deOrdemValidadeParaTimeInForce(ordem.TimeInForce); //if (tif != null) // ordercrr.Set(tif); ordercrr.Set(new OrderQty(ordem.OrderQty)); ////if (ordem.TimeInForce == OrdemValidadeEnum.ValidoAteDeterminadaData) ////{ //// DateTime expiredate = Convert.ToDateTime(ordem.ExpireDate); //// ordercrr.Set(new ExpireDate(expiredate.ToString("yyyyMMdd"))); ////} ////OrdType ordType = FixMessageUtilities.deOrdemTipoParaOrdType(ordem.OrdType); ////if (ordType != null) //// ordercrr.Set(ordType); // Verifica envio do preco //switch (ordem.OrdType) //{ // case OrdemTipoEnum.Limitada: // case OrdemTipoEnum.MarketWithLeftOverLimit: // case OrdemTipoEnum.StopLimitada: // ordercrr.Set(new Price(Convert.ToDecimal(ordem.Price))); // break; // case OrdemTipoEnum.StopStart: // ordercrr.Set(new Price(Convert.ToDecimal(ordem.Price))); // ordercrr.Set(new StopPx(Convert.ToDecimal(ordem.StopPrice))); // break; // case OrdemTipoEnum.Mercado: // case OrdemTipoEnum.OnClose: // ordercrr.Set(new Price(Convert.ToDecimal(ordem.Price))); // break; // default: // ordercrr.Set(new Price(Convert.ToDecimal(ordem.Price))); // break; //} ordercrr.Set(new TransactTime(DateTime.Now)); //ordercrr.Set(new HandlInst('1')); //ordercrr.Set(new ExecBroker("227")); //if (ordem.MaxFloor > 0) // ordercrr.Set(new MaxFloor(Convert.ToDecimal(ordem.MaxFloor))); //if (ordem.MinQty > 0) // ordercrr.Set(new MinQty(Convert.ToDecimal(ordem.MinQty))); //QuickFix.FIX42.OrderCancelReplaceRequest.NoAllocsGroup noAllocsGrp = new QuickFix.FIX42.OrderCancelReplaceRequest.NoAllocsGroup(); //noAllocsGrp.Set(new AllocAccount("67")); //ordercrr.AddGroup(noAllocsGrp); bool bRet = false; // Tags Customizadas Bloomberg if (!string.IsNullOrEmpty(extraTags)) { string[] arr = extraTags.Split(';'); for (int i = 0; i < arr.Length; i++) { if (!string.IsNullOrEmpty(arr[i])) { string[] valor = arr[i].Split('='); StringField fld = new StringField(Convert.ToInt32(valor[0]), valor[1]); ordercrr.SetField(fld); } } } if (oriini != 0 && orifim != 0) { long times = fim - ini; logger.Info("=====================================> INICIO CANCELAR ORDEM========> Qtd: " + times); for (long i = 0; i < times; i++) { ClOrdID xx = new ClOrdID(ini.ToString()); OrigClOrdID xx2 = new OrigClOrdID(oriini.ToString()); ordercrr.ClOrdID = xx; ordercrr.OrigClOrdID = xx2; bRet = Session.SendToTarget(ordercrr, _session.SessionID); if (!bRet) { logger.Info("erro"); break; } if (0 != delay) { Thread.Sleep(delay); } ini++; oriini++; } logger.Info("=====================================> FIM CANCELAR ORDEM========> Qtd: " + times); } else { bRet = Session.SendToTarget(ordercrr, _session.SessionID); } return(bRet); }
public bool CancelarOrdem(OrdemCancelamentoInfo info) { return(false); }
public bool CancelarOrdem(OrdemCancelamentoInfo orderCancelInfo, long ini = 0, long fim = 0, long oriini = 0, long orifim = 0, int delay = 0, string mnemonic = "") { //Cria a mensagem FIX de OrderCancelRequest QuickFix.FIX44.OrderCancelRequest orderCancel = new QuickFix.FIX44.OrderCancelRequest(); if (orderCancelInfo.Account > 0) { orderCancel.Set(new Account(orderCancelInfo.Account.ToString())); } if (!string.IsNullOrEmpty(mnemonic)) { orderCancel.SetField(new Account(mnemonic), true); } orderCancel.Set(new OrigClOrdID(orderCancelInfo.OrigClOrdID)); orderCancel.Set(new ClOrdID(orderCancelInfo.ClOrdID)); if (orderCancelInfo.OrderID != null && orderCancelInfo.OrderID.Length > 0) { orderCancel.Set(new OrderID(orderCancelInfo.OrderID)); } // Instrument Identification Block orderCancel.Set(new Symbol(orderCancelInfo.Symbol)); orderCancel.Set(new SecurityID(orderCancelInfo.SecurityID)); orderCancel.Set(new SecurityIDSource(SecurityIDSource.EXCHANGE_SYMBOL)); if (orderCancelInfo.Side == OrdemDirecaoEnum.Venda) { orderCancel.Set(new Side(Side.SELL)); } else { orderCancel.Set(new Side(Side.BUY)); } orderCancel.Set(new TransactTime(DateTime.Now)); //ATP - 2012-10-29 //Qtde de contratos/papeis a serem cancelados orderCancel.Set(new OrderQty(orderCancelInfo.OrderQty)); // Cliente QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup PartyIDGroup1 = new QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup(); PartyIDGroup1.Set(new PartyID(orderCancelInfo.ExecBroker)); PartyIDGroup1.Set(new PartyIDSource(PartyIDSource.PROPRIETARY_CUSTOM_CODE)); PartyIDGroup1.Set(new PartyRole(PartyRole.ENTERING_TRADER)); // Corretora QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup PartyIDGroup2 = new QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup(); PartyIDGroup2.Set(new PartyID("227")); PartyIDGroup2.Set(new PartyIDSource(PartyIDSource.PROPRIETARY_CUSTOM_CODE)); PartyIDGroup2.Set(new PartyRole(PartyRole.ENTERING_FIRM)); QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup PartyIDGroup3 = new QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup(); if (orderCancelInfo.SenderLocation != null && orderCancelInfo.SenderLocation.Length > 0) { PartyIDGroup3.Set(new PartyID(orderCancelInfo.SenderLocation)); } else { PartyIDGroup3.Set(new PartyID("GRA")); } PartyIDGroup3.Set(new PartyIDSource(PartyIDSource.PROPRIETARY_CUSTOM_CODE)); PartyIDGroup3.Set(new PartyRole(54)); orderCancel.AddGroup(PartyIDGroup1); orderCancel.AddGroup(PartyIDGroup2); orderCancel.AddGroup(PartyIDGroup3); //BEI - 2012-Nov-14 if (orderCancelInfo.ForeignFirm != null && orderCancelInfo.ForeignFirm.Length > 0) { QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup PartyIDGroup4 = new QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup(); PartyIDGroup4.Set(new PartyID(orderCancelInfo.ForeignFirm)); PartyIDGroup4.Set(new PartyIDSource(PartyIDSource.PROPRIETARY_CUSTOM_CODE)); PartyIDGroup4.Set(new PartyRole(PartyRole.FOREIGN_FIRM)); orderCancel.AddGroup(PartyIDGroup4); } if (orderCancelInfo.ExecutingTrader != null && orderCancelInfo.ExecutingTrader.Length > 0) { QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup PartyIDGroup7 = new QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup(); PartyIDGroup7.Set(new PartyID(orderCancelInfo.ExecutingTrader)); PartyIDGroup7.Set(new PartyIDSource(PartyIDSource.PROPRIETARY_CUSTOM_CODE)); PartyIDGroup7.Set(new PartyRole(PartyRole.EXECUTING_TRADER)); orderCancel.AddGroup(PartyIDGroup7); } // Memo Field if (orderCancelInfo.Memo5149 != null && orderCancelInfo.Memo5149.Length > 0) { if (orderCancelInfo.Memo5149.Length > 50) { orderCancelInfo.Memo5149 = orderCancelInfo.Memo5149.Substring(0, 50); } StringField memo5149 = new StringField(5149, orderCancelInfo.Memo5149); orderCancel.SetField(memo5149); } bool bRet = false; if (oriini != 0 && orifim != 0) { long times = fim - ini; logger.Info("=====================================> INICIO CANCELAR ORDEM========> Qtd: " + times); for (long i = 0; i < times; i++) { ClOrdID xx = new ClOrdID(ini.ToString()); OrigClOrdID xx2 = new OrigClOrdID(oriini.ToString()); orderCancel.ClOrdID = xx; orderCancel.OrigClOrdID = xx2; bRet = Session.SendToTarget(orderCancel, _session.SessionID); if (!bRet) { logger.Info("erro"); break; } if (0 != delay) { Thread.Sleep(delay); } ini++; oriini++; //System.Windows.Forms.Application.DoEvents(); } logger.Info("=====================================> FIM CANCELAR ORDEM========> Qtd: " + times); } else { bRet = Session.SendToTarget(orderCancel, _session.SessionID); } return(bRet); }
/// <summary> /// Cancelamento da ordem /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btCancelar_Click(object sender, EventArgs e) { try { OrdemCancelamentoInfo ordem = new OrdemCancelamentoInfo(); ordem.ClOrdID = txtClOrdID.Text; ordem.OrigClOrdID = txtOrigOrdID.Text; ordem.ChannelID = Convert.ToInt32(txtOperador.Text); if (cmbBolsa.SelectedItem.Equals("BOVESPA")) { ordem.Exchange = "BOVESPA"; } else { ordem.Exchange = "BMF"; } ordem.OrderID = txtExchangeNumber.Text; ordem.Account = Convert.ToInt32(txtCodCliente.Text); ordem.Symbol = txtPapel.Text; ordem.SecurityID = txtSecurityId.Text; ordem.ExecBroker = txtTraderID.Text; ordem.Memo5149 = "Cancelto " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss.fff"); if (txtSenderLocation.Text.Length > 0) { ordem.SenderLocation = txtSenderLocation.Text; } if (txtExecTrader.Text.Length > 0) { ordem.ExecutingTrader = txtExecTrader.Text; } /*if (!String.IsNullOrEmpty(txtCompIDBolsa.Text)) * { * ordem.CompIDBolsa = txtCompIDBolsa.Text; * }*/ if (rdCompra.Checked) { ordem.Side = OrdemDirecaoEnum.Compra; } else { ordem.Side = OrdemDirecaoEnum.Venda; } ordem.OrderQty = Convert.ToInt32(txtQtde.Text); IRoteadorOrdens roteador = Ativador.Get <IRoteadorOrdens>(); if (roteador != null) { ExecutarCancelamentoOrdemRequest request = new ExecutarCancelamentoOrdemRequest(); request.info = ordem; ExecutarCancelamentoOrdemResponse resp = roteador.CancelarOrdem(request); if (resp.DadosRetorno != null) { string msg = ""; foreach (OcorrenciaRoteamentoOrdem ocorr in resp.DadosRetorno.Ocorrencias) { msg += ocorr.Ocorrencia + "\r\n"; } if (resp.DadosRetorno.StatusResposta == StatusRoteamentoEnum.Erro) { MessageBox.Show(msg); } else { _addMsg(msg); } } } } catch (Exception ex) { MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); logger.Error("Erro: " + ex.Message, ex); } }
public bool CancelarOrdem(OrdemCancelamentoInfo ordem) { //Cria a mensagem FIX de NewOrderSingle QuickFix.FIX42.OrderCancelRequest ordercrr = new QuickFix.FIX42.OrderCancelRequest(); ordercrr.Set(new Account(ordem.Account.ToString())); ordercrr.Set(new Symbol(ordem.Symbol)); ordercrr.Set(new ClOrdID(ordem.ClOrdID)); ordercrr.Set(new OrigClOrdID(ordem.OrigClOrdID)); // Armazena ClOrdID em Memo (5149) para posterior referência nos tratamentos de retornos QuickFix.Fields.StringField field5149 = new QuickFix.Fields.StringField(5149, ordem.ClOrdID); ordercrr.SetField(field5149); //ordersingle.Set(new IDSource()); if (ordem.Side == OrdemDirecaoEnum.Venda) { ordercrr.Set(new Side(Side.SELL)); } else { ordercrr.Set(new Side(Side.BUY)); } //TimeInForce tif = FixMessageUtilities.deOrdemValidadeParaTimeInForce(ordem.TimeInForce); //if (tif != null) // ordercrr.Set(tif); ordercrr.Set(new OrderQty(ordem.OrderQty)); ////if (ordem.TimeInForce == OrdemValidadeEnum.ValidoAteDeterminadaData) ////{ //// DateTime expiredate = Convert.ToDateTime(ordem.ExpireDate); //// ordercrr.Set(new ExpireDate(expiredate.ToString("yyyyMMdd"))); ////} ////OrdType ordType = FixMessageUtilities.deOrdemTipoParaOrdType(ordem.OrdType); ////if (ordType != null) //// ordercrr.Set(ordType); // Verifica envio do preco //switch (ordem.OrdType) //{ // case OrdemTipoEnum.Limitada: // case OrdemTipoEnum.MarketWithLeftOverLimit: // case OrdemTipoEnum.StopLimitada: // ordercrr.Set(new Price(Convert.ToDecimal(ordem.Price))); // break; // case OrdemTipoEnum.StopStart: // ordercrr.Set(new Price(Convert.ToDecimal(ordem.Price))); // ordercrr.Set(new StopPx(Convert.ToDecimal(ordem.StopPrice))); // break; // case OrdemTipoEnum.Mercado: // case OrdemTipoEnum.OnClose: // ordercrr.Set(new Price(Convert.ToDecimal(ordem.Price))); // break; // default: // ordercrr.Set(new Price(Convert.ToDecimal(ordem.Price))); // break; //} ordercrr.Set(new TransactTime(DateTime.Now)); //ordercrr.Set(new HandlInst('1')); //ordercrr.Set(new ExecBroker("227")); //if (ordem.MaxFloor > 0) // ordercrr.Set(new MaxFloor(Convert.ToDecimal(ordem.MaxFloor))); //if (ordem.MinQty > 0) // ordercrr.Set(new MinQty(Convert.ToDecimal(ordem.MinQty))); //QuickFix.FIX42.OrderCancelReplaceRequest.NoAllocsGroup noAllocsGrp = new QuickFix.FIX42.OrderCancelReplaceRequest.NoAllocsGroup(); //noAllocsGrp.Set(new AllocAccount("67")); //ordercrr.AddGroup(noAllocsGrp); bool bRet = Session.SendToTarget(ordercrr, _session.SessionID); return(bRet); }
public bool CancelarOrdem(OrdemCancelamentoInfo orderCancelInfo) { //Cria a mensagem FIX de OrderCancelRequest QuickFix.FIX44.OrderCancelRequest orderCancel = new QuickFix.FIX44.OrderCancelRequest(); if (orderCancelInfo.Account > 0) { orderCancel.Set(new Account(orderCancelInfo.Account.ToString())); } orderCancel.Set(new OrigClOrdID(orderCancelInfo.OrigClOrdID)); orderCancel.Set(new ClOrdID(orderCancelInfo.ClOrdID)); if (orderCancelInfo.OrderID != null && orderCancelInfo.OrderID.Length > 0) { orderCancel.Set(new OrderID(orderCancelInfo.OrderID)); } // Instrument Identification Block orderCancel.Set(new Symbol(orderCancelInfo.Symbol)); orderCancel.Set(new SecurityID(orderCancelInfo.SecurityID)); orderCancel.Set(new SecurityIDSource(SecurityIDSource.EXCHANGE_SYMBOL)); if (orderCancelInfo.Side == OrdemDirecaoEnum.Venda) { orderCancel.Set(new Side(Side.SELL)); } else { orderCancel.Set(new Side(Side.BUY)); } orderCancel.Set(new TransactTime(DateTime.Now)); //ATP - 2012-10-29 //Qtde de contratos/papeis a serem cancelados orderCancel.Set(new OrderQty(orderCancelInfo.OrderQty)); // Cliente QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup PartyIDGroup1 = new QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup(); PartyIDGroup1.Set(new PartyID(orderCancelInfo.ExecBroker)); PartyIDGroup1.Set(new PartyIDSource(PartyIDSource.PROPRIETARY_CUSTOM_CODE)); PartyIDGroup1.Set(new PartyRole(PartyRole.ENTERING_TRADER)); // Corretora QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup PartyIDGroup2 = new QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup(); PartyIDGroup2.Set(new PartyID("227")); PartyIDGroup2.Set(new PartyIDSource(PartyIDSource.PROPRIETARY_CUSTOM_CODE)); PartyIDGroup2.Set(new PartyRole(PartyRole.ENTERING_FIRM)); QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup PartyIDGroup3 = new QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup(); if (orderCancelInfo.SenderLocation != null && orderCancelInfo.SenderLocation.Length > 0) { PartyIDGroup3.Set(new PartyID(orderCancelInfo.SenderLocation)); } else { PartyIDGroup3.Set(new PartyID("GRA")); } PartyIDGroup3.Set(new PartyIDSource(PartyIDSource.PROPRIETARY_CUSTOM_CODE)); PartyIDGroup3.Set(new PartyRole(54)); orderCancel.AddGroup(PartyIDGroup1); orderCancel.AddGroup(PartyIDGroup2); orderCancel.AddGroup(PartyIDGroup3); //BEI - 2012-Nov-14 if (orderCancelInfo.ForeignFirm != null && orderCancelInfo.ForeignFirm.Length > 0) { QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup PartyIDGroup4 = new QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup(); PartyIDGroup4.Set(new PartyID(orderCancelInfo.ForeignFirm)); PartyIDGroup4.Set(new PartyIDSource(PartyIDSource.PROPRIETARY_CUSTOM_CODE)); PartyIDGroup4.Set(new PartyRole(PartyRole.FOREIGN_FIRM)); orderCancel.AddGroup(PartyIDGroup4); } if (orderCancelInfo.ExecutingTrader != null && orderCancelInfo.ExecutingTrader.Length > 0) { QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup PartyIDGroup7 = new QuickFix.FIX44.OrderCancelRequest.NoPartyIDsGroup(); PartyIDGroup7.Set(new PartyID(orderCancelInfo.ExecutingTrader)); PartyIDGroup7.Set(new PartyIDSource(PartyIDSource.PROPRIETARY_CUSTOM_CODE)); PartyIDGroup7.Set(new PartyRole(PartyRole.EXECUTING_TRADER)); orderCancel.AddGroup(PartyIDGroup7); } // Memo Field if (orderCancelInfo.Memo5149 != null && orderCancelInfo.Memo5149.Length > 0) { if (orderCancelInfo.Memo5149.Length > 50) { orderCancelInfo.Memo5149 = orderCancelInfo.Memo5149.Substring(0, 50); } StringField memo5149 = new StringField(5149, orderCancelInfo.Memo5149); orderCancel.SetField(memo5149); } bool bRet = Session.SendToTarget(orderCancel, _session.SessionID); return(bRet); }