public void OnMessage(QuickFix.FIX44.NewOrderSingle n, SessionID s) { Symbol symbol = n.Symbol; Side side = n.Side; OrdType ordType = n.OrdType; OrderQty orderQty = n.OrderQty; Price price = new Price(DEFAULT_MARKET_PRICE); ClOrdID clOrdID = n.ClOrdID; switch (ordType.getValue()) { case OrdType.LIMIT: price = n.Price; if (price.Obj == 0) { throw new IncorrectTagValue(price.Tag); } break; case OrdType.MARKET: break; default: throw new IncorrectTagValue(ordType.Tag); } QuickFix.FIX44.ExecutionReport exReport = new QuickFix.FIX44.ExecutionReport( new OrderID(GenOrderID()), new ExecID(GenExecID()), new ExecType(ExecType.FILL), new OrdStatus(OrdStatus.FILLED), symbol, //shouldn't be here? side, new LeavesQty(0), new CumQty(orderQty.getValue()), new AvgPx(price.getValue())); exReport.Set(clOrdID); exReport.Set(symbol); exReport.Set(orderQty); exReport.Set(new LastQty(orderQty.getValue())); exReport.Set(new LastPx(price.getValue())); if (n.IsSetAccount()) { exReport.SetField(n.Account); } try { Session.SendToTarget(exReport, s); } catch (SessionNotFound ex) { Console.WriteLine("==session not found exception!=="); Console.WriteLine(ex.ToString()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public void OnMessage(QuickFix.FIX44.NewOrderSingle n, SessionID s) { Console.WriteLine("* Got a NewOrderSingle. Responding with an ExecutionReport."); Symbol symbol = n.Symbol; Side side = n.Side; OrdType ordType = n.OrdType; OrderQty orderQty = n.OrderQty; Price price = new Price(DEFAULT_MARKET_PRICE); ClOrdID clOrdID = n.ClOrdID; switch (ordType.getValue()) { case OrdType.LIMIT: price = n.Price; if (price.Obj == 0) throw new IncorrectTagValue(price.Tag); break; case OrdType.MARKET: break; default: throw new IncorrectTagValue(ordType.Tag); } QuickFix.FIX44.ExecutionReport exReport = new QuickFix.FIX44.ExecutionReport( new OrderID(GenOrderID()), new ExecID(GenExecID()), new ExecType(ExecType.FILL), new OrdStatus(OrdStatus.FILLED), symbol, //shouldn't be here? side, new LeavesQty(0), new CumQty(orderQty.getValue()), new AvgPx(price.getValue())); exReport.Set(clOrdID); exReport.Set(symbol); exReport.Set(orderQty); exReport.Set(new LastQty(orderQty.getValue())); exReport.Set(new LastPx(price.getValue())); if (n.IsSetAccount()) exReport.SetField(n.Account); try { Session.SendToTarget(exReport, s); } catch (SessionNotFound ex) { Console.WriteLine("==session not found exception!=="); Console.WriteLine(ex.ToString()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
private void SendExecution(SessionID s, char ordStatus, char execType, QuickFix.FIX44.NewOrderSingle n, decimal leavesQty, decimal cumQty, decimal avgPx, decimal lastQty, decimal lastPrice) { QuickFix.FIX44.ExecutionReport exReport = new QuickFix.FIX44.ExecutionReport( new OrderID(GenOrderID()), new ExecID(GenExecID()), new ExecType(execType), new OrdStatus(ordStatus), n.Symbol, //shouldn't be here? n.Side, new LeavesQty(leavesQty), new CumQty(cumQty), new AvgPx(avgPx)); exReport.ClOrdID = new ClOrdID(n.ClOrdID.getValue()); exReport.Set(new LastQty(lastQty)); exReport.Set(new LastPx(lastPrice)); if (n.IsSetAccount()) { exReport.SetField(n.Account); } try { Session.SendToTarget(exReport, s); } catch (SessionNotFound ex) { Console.WriteLine("==session not found exception!=="); Console.WriteLine(ex.ToString()); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public void OnMessage(QuickFix.FIX44.Quote quote, SessionID s) { try { Console.WriteLine("Received Quote Message."); QuickFix.FIX44.ExecutionReport exec = new QuickFix.FIX44.ExecutionReport(); exec.SetField(new OrderID(quote.QuoteID.getValue())); exec.SetField(new ClOrdID(quote.QuoteReqID.getValue())); exec.SetField(new Side(quote.Side.getValue())); exec.SetField(new Symbol(quote.Symbol.getValue())); exec.SetField(new Currency(quote.Currency.getValue())); exec.SetField(new SecurityType(quote.SecurityType.getValue())); exec.SetField(new CFICode(quote.CFICode.getValue())); if (quote.BidPx.getValue() > 0) { exec.SetField(new Price(quote.OfferPx.getValue())); } else { exec.SetField(new Price(quote.BidPx.getValue())); } exec.SetField(new OrderQty(quote.OrderQty.getValue())); exec.SetField(new TransactTime(DateTime.Now.Date)); exec.SetField(new SettlDate(quote.SettlDate.getValue())); exec.SetField(new Account(quote.Account.getValue())); _session.Send(exec); Console.WriteLine(exec.ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static QuickFix.FIX44.ExecutionReport Fix44Rejection2ExecutionReport(QuickFix.Message msgReject, QuickFix.Message msgOri) { try { QuickFix.FIX44.ExecutionReport er = new QuickFix.FIX44.ExecutionReport(); if (msgOri.IsSetField(Tags.OrderID)) { er.Set(new OrderID(msgOri.GetString(Tags.OrderID))); } else { er.Set(new OrderID("NONE")); } if (msgOri.IsSetField(Tags.ClOrdID)) { er.Set(new ClOrdID(msgOri.GetField(Tags.ClOrdID))); } if (msgOri.IsSetField(Tags.OrigClOrdID)) { er.Set(new OrigClOrdID(msgOri.GetField(Tags.OrigClOrdID))); } // Fazer atribuicao dos PartyIDs da mensagem original int len = msgOri.GetInt(Tags.NoPartyIDs); for (int i = 0; i < len; i++) { Group grp = msgOri.GetGroup(i + 1, Tags.NoPartyIDs); er.AddGroup(grp); } er.Set(new ExecID(DateTime.Now.ToString("yyyyMMddHHmmssfff"))); er.Set(new ExecType(ExecType.REJECTED)); er.Set(new OrdStatus(OrdStatus.REJECTED)); if (msgOri.IsSetField(Tags.Account)) { er.Set(new Account(msgOri.GetField(Tags.Account))); } er.Set(new Symbol(msgOri.GetField(Tags.Symbol))); if (msgOri.IsSetField(Tags.SecurityID)) { er.Set(new SecurityID(msgOri.GetField(Tags.SecurityID))); } if (msgOri.IsSetField(Tags.SecurityIDSource)) { er.Set(new SecurityIDSource(msgOri.GetField(Tags.SecurityIDSource))); } er.Set(new Side(msgOri.GetChar(Tags.Side))); er.Set(new OrderQty(msgOri.GetDecimal(Tags.OrderQty))); if (msgOri.IsSetField(Tags.OrdType)) { er.Set(new OrdType(msgOri.GetChar(Tags.OrdType))); } if (msgOri.IsSetField(Tags.Price)) { er.Set(new Price(msgOri.GetDecimal(Tags.Price))); } if (msgOri.IsSetField(Tags.StopPx)) { er.Set(new StopPx(msgOri.GetDecimal(Tags.StopPx))); } if (msgOri.IsSetField(Tags.TimeInForce)) { er.Set(new TimeInForce(msgOri.GetChar(Tags.TimeInForce))); } if (msgOri.IsSetField(Tags.ExpireDate)) { er.Set(new ExpireDate(msgOri.GetField(Tags.ExpireDate))); } er.Set(new LeavesQty(0)); er.Set(new CumQty(0)); er.Set(new AvgPx(Decimal.Zero)); DateTime transact = DateTime.UtcNow; er.Set(new TransactTime(transact)); if (msgOri.IsSetField(Tags.MaxFloor)) { er.Set(new MaxFloor(msgOri.GetDecimal(Tags.MaxFloor))); } if (msgOri.IsSetField(Tags.Memo)) { er.SetField(new Memo(msgOri.GetString(Tags.Memo))); } if (msgReject.IsSetField(Tags.Text)) { er.Set(new Text(msgReject.GetField(Tags.Text))); } if (msgReject.IsSetField(Tags.OrderID)) { er.Set(new OrderID(msgReject.GetField(Tags.OrderID))); } return(er); } catch (Exception ex) { logger.Error("Fix44Rejection2ExecutionReport(): " + ex.Message, ex); return(null); } }
public void OnMessage(QuickFix.FIX44.NewOrderSingle n, SessionID s) { Symbol symbol = n.Symbol; Side side = n.Side; OrdType ordType = n.OrdType; OrderQty orderQty = n.OrderQty; Price price = n.Price; ClOrdID clOrdID = n.ClOrdID; if (ordType.getValue() != OrdType.LIMIT) throw new IncorrectTagValue(ordType.Tag); QuickFix.FIX44.ExecutionReport exReport = new QuickFix.FIX44.ExecutionReport( new OrderID(GenOrderID()), new ExecID(GenExecID()), new ExecType(ExecType.FILL), new OrdStatus(OrdStatus.FILLED), symbol, //shouldn't be here? side, new LeavesQty(0), new CumQty(orderQty.getValue()), new AvgPx(price.getValue())); exReport.Set(clOrdID); exReport.Set(symbol); exReport.Set(orderQty); exReport.Set(new LastQty(orderQty.getValue())); exReport.Set(new LastPx(price.getValue())); if (n.IsSetAccount()) exReport.SetField(n.Account); try { Session.SendToTarget(exReport, s); } catch (SessionNotFound ex) { Console.WriteLine("==session not found exception!=="); Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine("==unknown exception=="); Console.WriteLine(ex.ToString()); Console.WriteLine(ex.StackTrace); } }