protected override bool?OnProcess(FixSession session, string msgType, IFixReader reader) { switch (msgType) { case QuikFixMessages.NewStopOrderSingle: { var condition = new QuikOrderCondition(); var dto = TimeHelper.Moscow.BaseUtcOffset; var regMsg = reader.ReadOrderRegisterMessage(dto, tag => reader.ReadOrderCondition(tag, dto, condition)); if (regMsg == null) { return(null); } regMsg.TransactionId = CreateTransactionId(session, regMsg.TransactionId.To <string>()); regMsg.Condition = condition; RaiseNewOutMessage(regMsg); return(true); } } return(base.OnProcess(session, msgType, reader)); }
protected override void OnProcess(FixSession session, string client, string msgStr, bool isMarketData) { var msgType = QuickFix.Message.GetMsgType(msgStr); switch (msgType) { case QuikFixMessages.NewStopOrderSingle: { this.AddInfoLog("From client {0}: NewStopOrderSingle", client); var fixMsg = session.ToMessage <NewStopOrderSingle>(msgStr); var regMsg = fixMsg.ToRegisterMessage(); regMsg.TransactionId = CreateTransactionId(client, regMsg.TransactionId); var condition = new QuikOrderCondition { Type = (QuikOrderConditionTypes)fixMsg.Type.Obj, Result = fixMsg.IsSetResult() ? (QuikOrderConditionResults?)fixMsg.Result.Obj : null, StopPriceCondition = (QuikStopPriceConditions)fixMsg.StopPriceCondition.Obj, StopPrice = fixMsg.IsSetStopPx() ? fixMsg.StopPx.Obj : (decimal?)null, StopLimitPrice = fixMsg.IsSetStopLimitPrice() ? fixMsg.StopLimitPrice.Obj : (decimal?)null, IsMarketStopLimit = fixMsg.IsSetIsMarketStopLimit() ? fixMsg.IsMarketStopLimit.Obj : (bool?)null, ConditionOrderId = fixMsg.IsSetConditionOrderId() ? fixMsg.ConditionOrderId.Obj : (long?)null, ConditionOrderSide = (Sides)fixMsg.ConditionOrderSide.Obj, ConditionOrderPartiallyMatched = fixMsg.IsSetConditionOrderPartiallyMatched() ? fixMsg.ConditionOrderPartiallyMatched.Obj : (bool?)null, ConditionOrderUseMatchedBalance = fixMsg.IsSetConditionOrderUseMatchedBalance() ? fixMsg.ConditionOrderUseMatchedBalance.Obj : (bool?)null, LinkedOrderPrice = fixMsg.IsSetLinkedOrderPrice() ? fixMsg.LinkedOrderPrice.Obj : (decimal?)null, LinkedOrderCancel = fixMsg.LinkedOrderCancel.Obj, Offset = fixMsg.IsSetOffset() ? fixMsg.Offset.Obj.ToUnit() : null, Spread = fixMsg.IsSetStopSpread() ? fixMsg.StopSpread.Obj.ToUnit() : null, IsMarketTakeProfit = fixMsg.IsSetIsMarketTakeProfit() ? fixMsg.IsMarketTakeProfit.Obj : (bool?)null, }; if (fixMsg.IsSetOtherSecurityCode()) { condition.OtherSecurityId = new SecurityId { SecurityCode = fixMsg.OtherSecurityCode.Obj } } ; if (fixMsg.IsSetActiveTimeFrom() && fixMsg.IsSetActiveTimeTo()) { condition.ActiveTime = new Range <DateTimeOffset>(fixMsg.ActiveTimeFrom.Obj.ApplyTimeZone(TimeHelper.Moscow), fixMsg.ActiveTimeTo.Obj.ApplyTimeZone(TimeHelper.Moscow)); } regMsg.Condition = condition; TransactionAdapter.SendInMessage(regMsg); return; } } base.OnProcess(session, client, msgStr, isMarketData); }
protected override long OnCreateTransactionId(FixSession session, string requestId) { return(requestId.To <long>()); }
protected override long OnCreateTransactionId(FixSession session, string requestId) { return requestId.To<long>(); }
static void Main(string[] args) { string configPath = "marketdatalistener.cfg"; if (args.Length > 1) { Console.WriteLine("MULTIPLE CONFIGS ENTERED. ERROR."); for (int index = 0; index < args.Length; index++) { Console.WriteLine(args[index]); configPath = args[index]; SessionSettings sessionSettings = new SessionSettings(configPath); //string host = sessionSettings.Get().GetString(SessionSettings.SENDERCOMPID); string host = "CLIENT1"; string target = "EXECUTOR"; FixSession fixClientApplication = new FixSession(QuickFix.FixValues.ApplVerID.FIX44, host, target); MarketPriceSource venue = new MarketPriceSource(QuickFix.FixValues.ApplVerID.FIX44, fixClientApplication); IMessageStoreFactory storeFactory = new FileStoreFactory(sessionSettings); ILogFactory logFactory = new FileLogFactory(sessionSettings); SocketInitiator acceptor = new SocketInitiator( fixClientApplication, storeFactory, sessionSettings, logFactory); acceptor.Start(); fixClientApplication.Run(); } } else { try { SessionSettings sessionSettings = new SessionSettings(configPath); string host = "CLIENT1"; string target = "EXECUTOR"; FixSession fixClientApplication = new FixSession(QuickFix.FixValues.ApplVerID.FIX44, host, target); MarketPriceSource venue = new MarketPriceSource(QuickFix.FixValues.ApplVerID.FIX44, fixClientApplication); IMessageStoreFactory storeFactory = new FileStoreFactory(sessionSettings); ILogFactory logFactory = new FileLogFactory(sessionSettings); SocketInitiator acceptor = new SocketInitiator( fixClientApplication, storeFactory, sessionSettings, logFactory); acceptor.Start(); fixClientApplication.Run(); } catch (Exception ex) { Models.Helpers.LogException(ex); } } }