/// <inheritdoc /> protected override bool?OnRead(IFixReader reader, string msgType, Action <Message> messageHandler) { switch (msgType) { // reading custom CFH message (not compatible with FIX standard) case CfhFixMessages.AccountInfo: { string account = null; var sendingTime = default(DateTimeOffset); decimal? closedPnL = null; decimal? openPnL = null; decimal? balance = null; CurrencyTypes?currency = null; var isOk = reader.ReadMessage(tag => { switch (tag) { case FixTags.Account: account = reader.ReadString(); return(true); case FixTags.SendingTime: sendingTime = reader.ReadUtc(TimeStampParser); return(true); case CfhFixTags.ClosedPnL: closedPnL = reader.ReadDecimal(); return(true); case CfhFixTags.OpenPnL: openPnL = reader.ReadDecimal(); return(true); case CfhFixTags.Balance: balance = reader.ReadDecimal(); return(true); case FixTags.Currency: currency = reader.ReadString().FromMicexCurrencyName(this.AddErrorLog); return(true); default: return(false); } }); if (!isOk) { return(null); } var msg = new PositionChangeMessage { SecurityId = SecurityId.Money, PortfolioName = account, ServerTime = sendingTime } .TryAdd(PositionChangeTypes.RealizedPnL, closedPnL, true) .TryAdd(PositionChangeTypes.UnrealizedPnL, openPnL, true) .TryAdd(PositionChangeTypes.CurrentValue, balance, true); if (currency != null) { msg.Add(PositionChangeTypes.Currency, currency.Value); } messageHandler(msg); return(true); } default: return(base.OnRead(reader, msgType, messageHandler)); } }
public static bool ReadOrderCondition(this IFixReader reader, FixTags tag, TimeZoneInfo timeZone, string dateTimeFormat, Func <QuikOrderCondition> getCondition) { if (getCondition == null) { throw new ArgumentNullException(nameof(getCondition)); } switch ((QuikFixTags)tag) { case QuikFixTags.Type: getCondition().Type = (QuikOrderConditionTypes)reader.ReadInt(); return(true); case QuikFixTags.StopPriceCondition: getCondition().StopPriceCondition = (QuikStopPriceConditions)reader.ReadInt(); return(true); case QuikFixTags.ConditionOrderSide: getCondition().ConditionOrderSide = (Sides)reader.ReadInt(); return(true); case QuikFixTags.LinkedOrderCancel: getCondition().LinkedOrderCancel = reader.ReadBool(); return(true); case QuikFixTags.Result: getCondition().Result = (QuikOrderConditionResults)reader.ReadInt(); return(true); case QuikFixTags.OtherSecurityCode: getCondition().OtherSecurityId = new SecurityId { SecurityCode = reader.ReadString() }; return(true); case QuikFixTags.StopPrice: getCondition().StopPrice = reader.ReadDecimal(); return(true); case QuikFixTags.StopLimitPrice: getCondition().StopLimitPrice = reader.ReadDecimal(); return(true); case QuikFixTags.IsMarketStopLimit: getCondition().IsMarketStopLimit = reader.ReadBool(); return(true); case QuikFixTags.ActiveTimeFrom: if (getCondition().ActiveTime == null) { getCondition().ActiveTime = new Range <DateTimeOffset>(); } getCondition().ActiveTime.Min = reader.ReadDateTime(dateTimeFormat).ToDateTimeOffset(timeZone); return(true); case QuikFixTags.ActiveTimeTo: if (getCondition().ActiveTime == null) { getCondition().ActiveTime = new Range <DateTimeOffset>(); } getCondition().ActiveTime.Max = reader.ReadDateTime(dateTimeFormat).ToDateTimeOffset(timeZone); return(true); case QuikFixTags.ConditionOrderId: getCondition().ConditionOrderId = reader.ReadLong(); return(true); case QuikFixTags.ConditionOrderPartiallyMatched: getCondition().ConditionOrderPartiallyMatched = reader.ReadBool(); return(true); case QuikFixTags.ConditionOrderUseMatchedBalance: getCondition().ConditionOrderUseMatchedBalance = reader.ReadBool(); return(true); case QuikFixTags.LinkedOrderPrice: getCondition().LinkedOrderPrice = reader.ReadDecimal(); return(true); case QuikFixTags.Offset: getCondition().Offset = reader.ReadString().ToUnit(); return(true); case QuikFixTags.StopSpread: getCondition().Spread = reader.ReadString().ToUnit(); return(true); case QuikFixTags.IsMarketTakeProfit: getCondition().IsMarketTakeProfit = reader.ReadBool(); return(true); default: return(false); } }
public static bool ReadOrderCondition(this IFixReader reader, FixTags tag, TimeSpan dateTimeOffset, QuikOrderCondition condition) { switch ((QuikFixTags)tag) { case QuikFixTags.Type: condition.Type = (QuikOrderConditionTypes)reader.ReadInt(); return(true); case QuikFixTags.StopPriceCondition: condition.StopPriceCondition = (QuikStopPriceConditions)reader.ReadInt(); return(true); case QuikFixTags.ConditionOrderSide: condition.ConditionOrderSide = (Sides)reader.ReadInt(); return(true); case QuikFixTags.LinkedOrderCancel: condition.LinkedOrderCancel = reader.ReadBool(); return(true); case QuikFixTags.Result: condition.Result = (QuikOrderConditionResults)reader.ReadInt(); return(true); case QuikFixTags.OtherSecurityCode: condition.OtherSecurityId = new SecurityId { SecurityCode = reader.ReadString() }; return(true); case QuikFixTags.StopPrice: condition.StopPrice = reader.ReadDecimal(); return(true); case QuikFixTags.StopLimitPrice: condition.StopLimitPrice = reader.ReadDecimal(); return(true); case QuikFixTags.IsMarketStopLimit: condition.IsMarketStopLimit = reader.ReadBool(); return(true); case QuikFixTags.ActiveTimeFrom: if (condition.ActiveTime == null) { condition.ActiveTime = new Range <DateTimeOffset>(); } condition.ActiveTime.Min = reader.ReadDateTime().ApplyTimeZone(dateTimeOffset); return(true); case QuikFixTags.ActiveTimeTo: if (condition.ActiveTime == null) { condition.ActiveTime = new Range <DateTimeOffset>(); } condition.ActiveTime.Max = reader.ReadDateTime().ApplyTimeZone(dateTimeOffset); return(true); case QuikFixTags.ConditionOrderId: condition.ConditionOrderId = reader.ReadLong(); return(true); case QuikFixTags.ConditionOrderPartiallyMatched: condition.ConditionOrderPartiallyMatched = reader.ReadBool(); return(true); case QuikFixTags.ConditionOrderUseMatchedBalance: condition.ConditionOrderUseMatchedBalance = reader.ReadBool(); return(true); case QuikFixTags.LinkedOrderPrice: condition.LinkedOrderPrice = reader.ReadDecimal(); return(true); case QuikFixTags.Offset: condition.Offset = reader.ReadString().ToUnit(); return(true); case QuikFixTags.StopSpread: condition.Spread = reader.ReadString().ToUnit(); return(true); case QuikFixTags.IsMarketTakeProfit: condition.IsMarketTakeProfit = reader.ReadBool(); return(true); default: return(false); } }