public override void CopyFrom(BinaryMetaInfo src) { base.CopyFrom(src); var posInfo = (PositionMetaInfo)src; BeginValue = Clone(posInfo.BeginValue); CurrentValue = Clone(posInfo.CurrentValue); BlockedValue = Clone(posInfo.BlockedValue); CurrentPrice = Clone(posInfo.CurrentPrice); AveragePrice = Clone(posInfo.AveragePrice); UnrealizedPnL = Clone(posInfo.UnrealizedPnL); RealizedPnL = Clone(posInfo.RealizedPnL); VariationMargin = Clone(posInfo.VariationMargin); Leverage = Clone(posInfo.Leverage); Commission = Clone(posInfo.Commission); CurrentValueInLots = Clone(posInfo.CurrentValueInLots); Portfolios.Clear(); Portfolios.AddRange(posInfo.Portfolios); ClientCodes.Clear(); ClientCodes.AddRange(posInfo.ClientCodes); DepoNames.Clear(); DepoNames.AddRange(posInfo.DepoNames); SettlementPrice = Clone(posInfo.SettlementPrice); }
public static decimal ReadPriceEx(this BitArrayReader reader, BinaryMetaInfo info, bool useLong, bool largeDecimal) { if (info.Version < MarketDataVersions.Version41) { var prevPrice = info.FirstPrice; return(info.FirstPrice = reader.ReadPrice(ref prevPrice, info)); } else { if (reader.TryReadLargeDecimal(largeDecimal, out var price)) { return(price); } if (reader.Read()) { var prevPrice = info.FirstPrice; return(info.FirstPrice = reader.ReadPrice(ref prevPrice, info, useLong)); } else { return(info.FirstFractionalPrice = reader.ReadDecimal(info.FirstFractionalPrice)); } } }
//public override TMetaInfo Clone() //{ // var copy = typeof(TMetaInfo).CreateInstance<TMetaInfo>(Date); // copy.CopyFrom((TMetaInfo)this); // return copy; //} public virtual void CopyFrom(BinaryMetaInfo src) { Version = src.Version; Count = src.Count; PriceStep = src.PriceStep; //StepPrice = src.StepPrice; FirstTime = src.FirstTime; LastTime = src.LastTime; LocalOffset = src.LocalOffset; ServerOffset = src.ServerOffset; FirstFractionalPrice = src.FirstFractionalPrice; LastFractionalPrice = src.LastFractionalPrice; VolumeStep = src.VolumeStep; FirstFractionalVolume = src.FirstFractionalVolume; LastFractionalVolume = src.LastFractionalVolume; FirstLocalTime = src.FirstLocalTime; LastLocalTime = src.LastLocalTime; FirstLocalOffset = src.FirstLocalOffset; LastLocalOffset = src.LastLocalOffset; FirstServerOffset = src.FirstServerOffset; LastServerOffset = src.LastServerOffset; FirstItemLocalTime = src.FirstItemLocalTime; LastItemLocalTime = src.LastItemLocalTime; FirstItemLocalOffset = src.FirstItemLocalOffset; LastItemLocalOffset = src.LastItemLocalOffset; //FirstPriceStep = src.FirstPriceStep; LastPriceStep = src.LastPriceStep; FirstPrice = src.FirstPrice; LastPrice = src.LastPrice; }
public static decimal ReadVolume(this BitArrayReader reader, BinaryMetaInfo info) { if (info.Version < MarketDataVersions.Version44) { if (reader.Read()) { return(reader.ReadLong()); } else { throw new NotSupportedException(LocalizedStrings.Str1011); } } else { if (reader.Read()) { return(reader.ReadLong() * info.VolumeStep); } else { return(info.FirstFractionalVolume = reader.ReadDecimal(info.FirstFractionalVolume)); } } }
public static void WritePriceEx(this BitArrayWriter writer, decimal price, BinaryMetaInfo info, SecurityId securityId, bool useLong = false) { if (info.Version < MarketDataVersions.Version41) { var prevPrice = info.LastPrice; writer.WritePrice(price, ref prevPrice, info, securityId); info.LastPrice = price; } else { var isAligned = (price % info.LastPriceStep) == 0; writer.Write(isAligned); if (isAligned) { if (info.FirstPrice == 0) { info.FirstPrice = info.LastPrice = price; } var prevPrice = info.LastPrice; writer.WritePrice(price, ref prevPrice, info, securityId, useLong); info.LastPrice = price; } else { if (info.FirstFractionalPrice == 0) { info.FirstFractionalPrice = info.LastFractionalPrice = price; } info.LastFractionalPrice = writer.WriteDecimal(price, info.LastFractionalPrice); } } }
public override void CopyFrom(BinaryMetaInfo src) { base.CopyFrom(src); var quoteInfo = (QuoteMetaInfo)src; IncrementalOnly = quoteInfo.IncrementalOnly; }
public override void CopyFrom(BinaryMetaInfo src) { base.CopyFrom(src); var tickInfo = (TickMetaInfo)src; FirstId = tickInfo.FirstId; PrevId = tickInfo.PrevId; }
public static TimeSpan GetTimeZone(this BinaryMetaInfo metaInfo, bool isUtc, SecurityId securityId, IExchangeInfoProvider exchangeInfoProvider) { if (isUtc) { return(metaInfo.ServerOffset); } var board = exchangeInfoProvider.GetExchangeBoard(securityId.BoardCode); return(board == null ? metaInfo.LocalOffset : board.TimeZone.BaseUtcOffset); }
public static TimeSpan GetTimeZone <TMetaInfo>(this BinaryMetaInfo <TMetaInfo> metaInfo, bool isUtc, SecurityId securityId) where TMetaInfo : BinaryMetaInfo <TMetaInfo> { if (isUtc) { return(metaInfo.ServerOffset); } var board = ExchangeBoard.GetBoard(securityId.BoardCode); return(board == null ? metaInfo.LocalOffset : board.TimeZone.BaseUtcOffset); }
public override void CopyFrom(BinaryMetaInfo src) { base.CopyFrom(src); var tsInfo = (TransactionSerializerMetaInfo)src; FirstOrderId = tsInfo.FirstOrderId; LastOrderId = tsInfo.LastOrderId; FirstTradeId = tsInfo.FirstTradeId; LastTradeId = tsInfo.LastTradeId; FirstTransactionId = tsInfo.FirstTransactionId; LastTransactionId = tsInfo.LastTransactionId; FirstOriginalTransactionId = tsInfo.FirstOriginalTransactionId; LastOriginalTransactionId = tsInfo.LastOriginalTransactionId; FirstCommission = tsInfo.FirstCommission; LastCommission = tsInfo.LastCommission; FirstPnL = tsInfo.FirstPnL; LastPnL = tsInfo.LastPnL; FirstPosition = tsInfo.FirstPosition; LastPosition = tsInfo.LastPosition; FirstSlippage = tsInfo.FirstSlippage; LastSlippage = tsInfo.LastSlippage; Portfolios.Clear(); Portfolios.AddRange(tsInfo.Portfolios); ClientCodes.Clear(); ClientCodes.AddRange(tsInfo.ClientCodes); BrokerCodes.Clear(); BrokerCodes.AddRange(tsInfo.BrokerCodes); DepoNames.Clear(); DepoNames.AddRange(tsInfo.DepoNames); UserOrderIds.Clear(); UserOrderIds.AddRange(tsInfo.UserOrderIds); Comments.Clear(); Comments.AddRange(tsInfo.Comments); SystemComments.Clear(); SystemComments.AddRange(tsInfo.SystemComments); Errors.Clear(); Errors.AddRange(tsInfo.Errors); StrategyIds.Clear(); StrategyIds.AddRange(tsInfo.StrategyIds); }
public static decimal ReadPriceEx <T>(this BitArrayReader reader, BinaryMetaInfo <T> info) where T : BinaryMetaInfo <T> { if (info.Version < MarketDataVersions.Version41) { return(info.FirstPrice = reader.ReadPrice(info.FirstPrice, info)); } else { if (reader.Read()) { return(info.FirstPrice = reader.ReadPrice(info.FirstPrice, info)); } else { return(info.FirstNonSystemPrice = reader.ReadDecimal(info.FirstNonSystemPrice)); } } }
public static void WriteVolume(this BitArrayWriter writer, decimal volume, BinaryMetaInfo info, bool largeDecimal) { if (info.Version < MarketDataVersions.Version44) { var intVolume = volume.Truncate(); if (intVolume == volume) // объем целочисленный { writer.Write(true); writer.WriteLong((long)intVolume); } else { writer.Write(false); throw new NotSupportedException(LocalizedStrings.Str1010Params.Put(volume)); } } else { if (writer.TryWriteLargeDecimal(largeDecimal, volume)) { return; } var isAligned = (volume % info.VolumeStep) == 0; writer.Write(isAligned); if (isAligned) { writer.WriteLong((long)(volume / info.VolumeStep)); } else { if (info.FirstFractionalVolume == 0) { info.FirstFractionalVolume = info.LastFractionalVolume = volume; } info.LastFractionalVolume = writer.WriteDecimal(volume, info.LastFractionalVolume); } } }
public override void CopyFrom(BinaryMetaInfo src) { base.CopyFrom(src); var olInfo = (OrderLogMetaInfo)src; FirstOrderId = olInfo.FirstOrderId; FirstTradeId = olInfo.FirstTradeId; LastOrderId = olInfo.LastOrderId; LastTradeId = olInfo.LastTradeId; FirstTransactionId = olInfo.FirstTransactionId; LastTransactionId = olInfo.LastTransactionId; FirstOrderPrice = olInfo.FirstOrderPrice; LastOrderPrice = olInfo.LastOrderPrice; Portfolios.Clear(); Portfolios.AddRange(olInfo.Portfolios); }
public static decimal ReadPriceEx(this BitArrayReader reader, BinaryMetaInfo info) { if (info.Version < MarketDataVersions.Version41) { var prevPrice = info.FirstPrice; return(info.FirstPrice = reader.ReadPrice(ref prevPrice, info)); } else { if (reader.Read()) { var prevPrice = info.FirstPrice; return(info.FirstPrice = reader.ReadPrice(ref prevPrice, info)); } else { return(info.FirstFractionalPrice = reader.ReadDecimal(info.FirstFractionalPrice)); } } }
public static decimal ReadPrice(this BitArrayReader reader, ref decimal prevPrice, BinaryMetaInfo info, bool useLong = false, bool nonAdjustPrice = false) { if (!nonAdjustPrice || reader.Read()) { return(prevPrice = ReadPrice(reader, prevPrice, info.PriceStep, useLong)); } else { if (reader.Read()) { info.PriceStep = ReadDecimal(reader, 0); } return(info.FirstFractionalPrice = ReadPrice(reader, info.FirstFractionalPrice, info.PriceStep, useLong)); } }
public static void ReadSeqNum <TMessage>(this BitArrayReader reader, TMessage message, BinaryMetaInfo metaInfo) where TMessage : ISeqNumMessage { metaInfo.FirstSeqNum += reader.ReadLong(); message.SeqNum = metaInfo.FirstSeqNum; }
public static void WritePriceEx <T>(this BitArrayWriter writer, decimal price, BinaryMetaInfo <T> info, SecurityId securityId) where T : BinaryMetaInfo <T> { if (info.Version < MarketDataVersions.Version41) { writer.WritePrice(price, info.LastPrice, info, securityId); info.LastPrice = price; } else { var isAligned = (price % info.PriceStep) == 0; writer.Write(isAligned); if (isAligned) { if (info.FirstPrice == 0) { info.FirstPrice = info.LastPrice = price; } writer.WritePrice(price, info.LastPrice, info, securityId); info.LastPrice = price; } else { if (info.FirstNonSystemPrice == 0) { info.FirstNonSystemPrice = info.LastNonSystemPrice = price; } info.LastNonSystemPrice = writer.WriteDecimal(price, info.LastNonSystemPrice); } } }
public static void WritePrice(this BitArrayWriter writer, decimal price, ref decimal prevPrice, BinaryMetaInfo info, SecurityId securityId, bool useLong = false, bool nonAdjustPrice = false) { var priceStep = info.LastPriceStep; if (priceStep == 0) { throw new InvalidOperationException(LocalizedStrings.Str2925); } if ((price % priceStep) != 0) { if (!nonAdjustPrice) { throw new ArgumentException(LocalizedStrings.Str1007Params.Put(priceStep, securityId, price), nameof(info)); } writer.Write(false); var priceStepChanged = false; if ((price % info.LastPriceStep) != 0) { var newPriceStep = 1m; var found = false; for (var i = 0; i < 10; i++) { if ((price % newPriceStep) == 0) { found = true; break; } newPriceStep /= 10; } if (!found) { throw new ArgumentException(LocalizedStrings.Str1007Params.Put(priceStep, securityId, price), nameof(info)); } info.LastPriceStep = newPriceStep; //if (info.FirstPriceStep == 0) // info.FirstPriceStep = info.LastPriceStep; priceStepChanged = true; } writer.Write(priceStepChanged); if (priceStepChanged) { WriteDecimal(writer, info.LastPriceStep, 0); } if (info.FirstFractionalPrice == 0) { info.FirstFractionalPrice = info.LastFractionalPrice = price; } var stepCount = (long)((price - info.LastFractionalPrice) / info.LastPriceStep); if (useLong) { writer.WriteLong(stepCount); } else { writer.WriteInt((int)stepCount); } info.LastFractionalPrice = price; return; } if (nonAdjustPrice) { writer.Write(true); } try { var stepCount = (long)((price - prevPrice) / priceStep); // ОЛ может содержать заявки с произвольно большими ценами if (useLong) { writer.WriteLong(stepCount); } else { if (stepCount.Abs() > int.MaxValue) { throw new InvalidOperationException("Range is overflow."); } writer.WriteInt((int)stepCount); } prevPrice = price; } catch (OverflowException ex) { throw new ArgumentException(LocalizedStrings.Str1008Params.Put(price, prevPrice, priceStep, useLong), ex); } }
public static void WriteSeqNum <TMessage>(this BitArrayWriter writer, TMessage message, BinaryMetaInfo metaInfo) where TMessage : ISeqNumMessage { metaInfo.PrevSeqNum = writer.SerializeId(message.SeqNum, metaInfo.PrevSeqNum); }