public static decimal ReadVolume <T>(this BitArrayReader reader, BinaryMetaInfo <T> info) where T : BinaryMetaInfo <T> { 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 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.Exchange.TimeZoneInfo.BaseUtcOffset); }
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 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 WriteVolume <T>(this BitArrayWriter writer, decimal volume, BinaryMetaInfo <T> info, SecurityId securityId) where T : BinaryMetaInfo <T> { 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 { 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); } } }