public void OnMessage(QuickFix.FIX44.QuoteRequest rfq, SessionID s) { try { Console.WriteLine("Received Quote Request Message: "); QuickFix.FIX44.Quote quote = new QuickFix.FIX44.Quote(); quote.SetField(new QuoteID(new Guid().ToString())); quote.SetField(new QuoteReqID(rfq.QuoteReqID.getValue())); quote.SetField(new BidPx(0)); quote.SetField(new OfferPx(Convert.ToDecimal(1.18))); quote.SetField(new OrderQty(Convert.ToDecimal(rfq.GetField(Tags.OrderQty)))); quote.SetField(new Side(Convert.ToChar(rfq.GetField(Tags.Side)))); quote.SetField(new SecurityType(rfq.GetField(Tags.SecurityType))); quote.SetField(new CFICode(rfq.GetField(Tags.CFICode))); quote.SetField(new TransactTime(DateTime.Now.Date)); quote.SetField(new SettlDate(rfq.GetField(Tags.SettlDate))); quote.SetField(new Account(rfq.GetField(Tags.Account))); quote.SetField(new Symbol(rfq.GetField(Tags.Symbol))); quote.SetField(new Currency(rfq.GetField(Tags.Currency))); Session.SendToTarget(quote, s); Console.WriteLine(quote.ToString()); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
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 void OnMessage(QuickFix.FIX44.Quote quote, SessionID sessionID) { //basic log // YJYGlobal.LogLine(quote.ToString()); // //detail log //YJYGlobal.LogLine(GetMessageString(quote)); //if (quote.SecurityID.getValue() == "20867") // YJYGlobal.LogLine("20867 " + quote.BidPx.getValue() + " " + quote.OfferPx.getValue()); ////count and add to list for saving //MsgCount++; //MsgTotalCount++; //quotes.Add(new Quote() //{ // Bid = quote.BidPx.getValue(), // Id = Convert.ToInt32(quote.SecurityID.getValue()), // Offer = quote.OfferPx.getValue(), // Time = quote.Header.GetDateTime(Tags.SendingTime) //}); ////do save Every Second //var now = DateTime.Now; //if (now - BeginTimeForMsgCount > TimeSpan.FromMilliseconds(500)) //{ // var dtBeginSave = DateTime.Now; // try // { // using (var redisClient = YJYGlobal.PooledRedisClientsManager.GetClient()) // { // var redisQuoteClient = redisClient.As<Quote>(); // redisQuoteClient.StoreAll(quotes); // } // } // catch (Exception e) // { // YJYGlobal.LogException(e); // } // YJYGlobal.LogLine("Count: " + MsgCount + "(" + quotes.Select(o => o.Id).Distinct().Count() + ")" + "/" + MsgTotalCount // + " Time: " + quotes.Min(o => o.Time).ToString(YJYGlobal.DATETIME_MASK_MILLI_SECOND) // + " ~ " + quotes.Max(o => o.Time).ToString(YJYGlobal.DATETIME_MASK_MILLI_SECOND) // + ". Save to redis " + (DateTime.Now - dtBeginSave).TotalMilliseconds); // //reset vars // BeginTimeForMsgCount = now; // MsgCount = 0; // quotes = new List<Quote>(); //} var secId = Convert.ToInt32(quote.SecurityID.getValue()); var bid = quote.BidPx.getValue(); var offer = quote.OfferPx.getValue(); var time = quote.Header.GetDateTime(Tags.SendingTime); QueueQuotes.Enqueue(new Quote { Bid = bid, Id = secId, Ask = offer, Time = time }); QueueQuotesForRawTick.Enqueue(new Quote { Bid = bid, Id = secId, Ask = offer, Time = time }); QueueQuotesForTick.Enqueue(new Quote { Bid = bid, Id = secId, Ask = offer, Time = time }); QueueQuotesForKLine.Enqueue(new Quote { Bid = bid, Id = secId, Ask = offer, Time = time }); QueueQuotesForRedistribution.Enqueue(new Quote { Bid = bid, Id = secId, Ask = offer, Time = time }); }