/// <inheritdoc /> protected override NewsMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var news = new NewsMessage { ServerTime = reader.ReadTime(metaInfo.Date), Headline = reader.ReadString(), Source = reader.ReadString(), Url = reader.ReadString().To <Uri>(), Id = reader.ReadString(), BoardCode = reader.ReadString(), }; var secCode = reader.ReadString(); if (!secCode.IsEmpty()) { news.SecurityId = new SecurityId { SecurityCode = secCode } } ; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { news.Priority = reader.ReadNullableEnum <NewsPriorities>(); } return(news); } }
/// <inheritdoc /> protected override TCandleMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var message = new TCandleMessage { SecurityId = SecurityId, Arg = Arg, OpenTime = reader.ReadTime(metaInfo.Date), OpenPrice = reader.ReadDecimal(), HighPrice = reader.ReadDecimal(), LowPrice = reader.ReadDecimal(), ClosePrice = reader.ReadDecimal(), TotalVolume = reader.ReadDecimal(), State = CandleStates.Finished }; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { message.BuildFrom = reader.ReadBuildFrom(); } if ((reader.ColumnCurr + 1) < reader.ColumnCount) { message.SeqNum = reader.ReadNullableLong() ?? 0L; } return(message); }
/// <inheritdoc /> protected override ExecutionMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var ol = new ExecutionMessage { SecurityId = SecurityId, ExecutionType = ExecutionTypes.OrderLog, ServerTime = reader.ReadTime(metaInfo.Date), TransactionId = reader.ReadLong(), OrderId = reader.ReadLong(), OrderPrice = reader.ReadDecimal(), OrderVolume = reader.ReadDecimal(), Side = reader.ReadEnum <Sides>(), OrderState = reader.ReadEnum <OrderStates>(), TimeInForce = reader.ReadNullableEnum <TimeInForce>(), TradeId = reader.ReadNullableLong(), TradePrice = reader.ReadNullableDecimal(), PortfolioName = reader.ReadString(), IsSystem = reader.ReadNullableBool(), }; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { ol.Balance = reader.ReadNullableDecimal(); } return(ol); }
/// <inheritdoc /> protected override ExecutionMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var execMsg = new ExecutionMessage { SecurityId = SecurityId, ExecutionType = ExecutionTypes.Tick, ServerTime = reader.ReadTime(metaInfo.Date), TradeId = reader.ReadNullableLong(), TradePrice = reader.ReadNullableDecimal(), TradeVolume = reader.ReadNullableDecimal(), OriginSide = reader.ReadNullableEnum <Sides>(), OpenInterest = reader.ReadNullableDecimal(), IsSystem = reader.ReadNullableBool(), }; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { execMsg.IsUpTick = reader.ReadNullableBool(); execMsg.TradeStringId = reader.ReadString(); execMsg.Currency = reader.ReadNullableEnum <CurrencyTypes>(); } if ((reader.ColumnCurr + 1) < reader.ColumnCount) { execMsg.BuildFrom = reader.ReadBuildFrom(); } return(execMsg); }
/// <summary> /// Read data from the specified reader. /// </summary> /// <param name="reader">CSV reader.</param> /// <param name="date">Date.</param> /// <returns>Data.</returns> protected override NewsMessage Read(FastCsvReader reader, DateTime date) { var news = new NewsMessage { ServerTime = reader.ReadTime(date), Headline = reader.ReadString(), Source = reader.ReadString(), Url = reader.ReadString().To <Uri>(), Id = reader.ReadString(), BoardCode = reader.ReadString(), }; var secCode = reader.ReadString(); if (!secCode.IsEmpty()) { news.SecurityId = new SecurityId { SecurityCode = secCode } } ; return(news); } }
/// <inheritdoc /> protected override NewsMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var news = new NewsMessage { ServerTime = reader.ReadTime(metaInfo.Date), Headline = reader.ReadString(), Source = reader.ReadString(), Url = reader.ReadString(), Id = reader.ReadString(), BoardCode = reader.ReadString(), }; var secCode = reader.ReadString(); if (!secCode.IsEmpty()) { news.SecurityId = new SecurityId { SecurityCode = secCode } } ; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { news.Priority = reader.ReadNullableEnum <NewsPriorities>(); } if ((reader.ColumnCurr + 1) < reader.ColumnCount) { news.Language = reader.ReadString(); } if ((reader.ColumnCurr + 1) < reader.ColumnCount) { var boardCode = reader.ReadString(); if (news.SecurityId != null) { var secId = news.SecurityId.Value; secId.BoardCode = boardCode; news.SecurityId = secId; } } if ((reader.ColumnCurr + 1) < reader.ColumnCount) { news.ExpiryDate = reader.ReadString().TryToDateTimeOffset(_expiryFormat); } if ((reader.ColumnCurr + 1) < reader.ColumnCount) { news.SeqNum = reader.ReadNullableLong() ?? 0L; } return(news); } }
/// <inheritdoc /> protected override PositionChangeMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var posMsg = new PositionChangeMessage { SecurityId = SecurityId, ServerTime = reader.ReadTime(metaInfo.Date), PortfolioName = reader.ReadString(), ClientCode = reader.ReadString(), DepoName = reader.ReadString(), LimitType = reader.ReadString().To <TPlusLimits?>(), }; foreach (var type in _types) { switch (type) { case PositionChangeTypes.Currency: { var currency = reader.ReadNullableEnum <CurrencyTypes>(); if (currency != null) { posMsg.Changes.Add(type, currency); } break; } case PositionChangeTypes.State: { var state = reader.ReadNullableEnum <PortfolioStates>(); if (state != null) { posMsg.Changes.Add(type, state); } break; } default: { var value = reader.ReadNullableDecimal(); if (value != null) { posMsg.Changes.Add(type, value); } break; } } } return(posMsg); }
/// <summary> /// Read data from the specified reader. /// </summary> /// <param name="reader">CSV reader.</param> /// <param name="date">Date.</param> /// <returns>Data.</returns> protected override TimeQuoteChange Read(FastCsvReader reader, DateTime date) { return(new TimeQuoteChange { ServerTime = reader.ReadTime(date), Price = reader.ReadDecimal(), Volume = reader.ReadDecimal(), Side = reader.ReadEnum <Sides>() }); }
/// <summary> /// Read data from the specified reader. /// </summary> /// <param name="reader">CSV reader.</param> /// <param name="metaInfo">Meta-information on data for one day.</param> /// <returns>Data.</returns> protected override NullableTimeQuoteChange Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { return(new NullableTimeQuoteChange { ServerTime = reader.ReadTime(metaInfo.Date), Price = reader.ReadNullableDecimal(), Volume = reader.ReadDecimal(), Side = reader.ReadEnum <Sides>() }); }
/// <inheritdoc /> protected override BoardStateMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var state = new BoardStateMessage { ServerTime = reader.ReadTime(metaInfo.Date), BoardCode = reader.ReadString(), State = reader.ReadEnum <SessionStates>() }; return(state); }
/// <summary> /// Read data from the specified reader. /// </summary> /// <param name="reader">CSV reader.</param> /// <param name="date">Date.</param> /// <returns>Data.</returns> protected override TCandleMessage Read(FastCsvReader reader, DateTime date) { return(new TCandleMessage { SecurityId = SecurityId, Arg = Arg, OpenTime = reader.ReadTime(date), OpenPrice = reader.ReadDecimal(), HighPrice = reader.ReadDecimal(), LowPrice = reader.ReadDecimal(), ClosePrice = reader.ReadDecimal(), TotalVolume = reader.ReadDecimal(), }); }
public TCandleMessage Read(FastCsvReader reader) { return(new TCandleMessage { SecurityId = _securityId, Arg = _arg, OpenTime = reader.ReadTime(Date), OpenPrice = reader.ReadDecimal(), HighPrice = reader.ReadDecimal(), LowPrice = reader.ReadDecimal(), ClosePrice = reader.ReadDecimal(), TotalVolume = reader.ReadDecimal(), State = CandleStates.Finished }); }
/// <summary> /// Load data from the specified reader. /// </summary> /// <param name="reader">CSV reader.</param> /// <param name="date">Date.</param> /// <returns>Data.</returns> protected override ExecutionMessage Read(FastCsvReader reader, DateTime date) { return(new ExecutionMessage { SecurityId = SecurityId, ExecutionType = ExecutionTypes.Tick, ServerTime = reader.ReadTime(date), TradeId = reader.ReadNullableLong(), TradePrice = reader.ReadNullableDecimal(), TradeVolume = reader.ReadNullableDecimal(), OriginSide = reader.ReadNullableEnum <Sides>(), OpenInterest = reader.ReadNullableDecimal(), IsSystem = reader.ReadNullableBool(), }); }
/// <summary> /// Read data from the specified reader. /// </summary> /// <param name="reader">CSV reader.</param> /// <param name="metaInfo">Meta-information on data for one day.</param> /// <returns>Data.</returns> protected override TCandleMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { return(new TCandleMessage { SecurityId = SecurityId, Arg = Arg, OpenTime = reader.ReadTime(metaInfo.Date), OpenPrice = reader.ReadDecimal(), HighPrice = reader.ReadDecimal(), LowPrice = reader.ReadDecimal(), ClosePrice = reader.ReadDecimal(), TotalVolume = reader.ReadDecimal(), State = CandleStates.Finished }); }
/// <inheritdoc /> protected override NullableTimeQuoteChange Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var quote = new NullableTimeQuoteChange { ServerTime = reader.ReadTime(metaInfo.Date), }; var price = reader.ReadNullableDecimal(); var volume = reader.ReadNullableDecimal(); quote.Side = reader.ReadEnum <Sides>(); int?ordersCount = null; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { ordersCount = reader.ReadNullableInt(); } QuoteConditions condition = default; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { condition = reader.ReadNullableEnum <QuoteConditions>() ?? default; } if (price != null) { var qq = new QuoteChange { Price = price.Value, Volume = volume ?? 0, OrdersCount = ordersCount, Condition = condition, }; quote.Quote = qq; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { qq.StartPosition = reader.ReadNullableInt(); qq.EndPosition = reader.ReadNullableInt(); qq.Action = reader.ReadNullableEnum <QuoteChangeActions>(); } } return(quote); }
/// <inheritdoc /> protected override ExecutionMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var ol = new ExecutionMessage { SecurityId = SecurityId, DataTypeEx = DataType.OrderLog, ServerTime = reader.ReadTime(metaInfo.Date), TransactionId = reader.ReadLong(), OrderId = reader.ReadNullableLong(), OrderPrice = reader.ReadDecimal(), OrderVolume = reader.ReadDecimal(), Side = reader.ReadEnum <Sides>(), OrderState = reader.ReadEnum <OrderStates>(), TimeInForce = reader.ReadNullableEnum <TimeInForce>(), TradeId = reader.ReadNullableLong(), TradePrice = reader.ReadNullableDecimal(), PortfolioName = reader.ReadString(), IsSystem = reader.ReadNullableBool(), }; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { ol.Balance = reader.ReadNullableDecimal(); } if ((reader.ColumnCurr + 1) < reader.ColumnCount) { ol.SeqNum = reader.ReadNullableLong() ?? 0L; } if ((reader.ColumnCurr + 1) < reader.ColumnCount) { ol.OrderStringId = reader.ReadString(); ol.TradeStringId = reader.ReadString(); ol.OrderBuyId = reader.ReadNullableLong(); ol.OrderSellId = reader.ReadNullableLong(); ol.IsUpTick = reader.ReadNullableBool(); ol.Yield = reader.ReadNullableDecimal(); ol.TradeStatus = reader.ReadNullableInt(); ol.OpenInterest = reader.ReadNullableDecimal(); ol.OriginSide = reader.ReadNullableEnum <Sides>(); } return(ol); }
/// <inheritdoc /> protected override NullableTimeQuoteChange Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var quote = new NullableTimeQuoteChange { ServerTime = reader.ReadTime(metaInfo.Date), Price = reader.ReadNullableDecimal(), Volume = reader.ReadDecimal(), Side = reader.ReadEnum <Sides>() }; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { quote.OrdersCount = reader.ReadNullableInt(); } return(quote); }
public override void Read(Stream stream) { CultureInfo.InvariantCulture.DoInCulture(() => { var count = 0; var firstTimeRead = false; string lastLine = null; var reader = new FastCsvReader(stream, _encoding); while (reader.NextLine()) { lastLine = reader.CurrentLine; if (!firstTimeRead) { FirstTime = reader.ReadTime(Date).UtcDateTime; firstTimeRead = true; } count++; } Count = count; if (lastLine != null) { reader = new FastCsvReader(lastLine); if (!reader.NextLine()) { throw new InvalidOperationException(); } LastTime = reader.ReadTime(Date).UtcDateTime; _lastId = _readId?.Invoke(reader); } stream.Position = 0; }); }
/// <summary> /// Load data from the specified reader. /// </summary> /// <param name="reader">CSV reader.</param> /// <param name="date">Date.</param> /// <returns>Data.</returns> protected override ExecutionMessage Read(FastCsvReader reader, DateTime date) { return(new ExecutionMessage { SecurityId = SecurityId, ExecutionType = ExecutionTypes.OrderLog, ServerTime = reader.ReadTime(date), TransactionId = reader.ReadLong(), OrderId = reader.ReadLong(), OrderPrice = reader.ReadDecimal(), OrderVolume = reader.ReadDecimal(), Side = reader.ReadEnum <Sides>(), OrderState = reader.ReadEnum <OrderStates>(), TimeInForce = reader.ReadNullableEnum <TimeInForce>(), TradeId = reader.ReadNullableLong(), TradePrice = reader.ReadNullableDecimal(), PortfolioName = reader.ReadString(), IsSystem = reader.ReadNullableBool(), }); }
/// <inheritdoc /> protected override ExecutionMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var msg = new ExecutionMessage { SecurityId = SecurityId, ExecutionType = ExecutionTypes.Transaction, ServerTime = reader.ReadTime(metaInfo.Date), TransactionId = reader.ReadLong(), OriginalTransactionId = reader.ReadLong(), OrderId = reader.ReadNullableLong(), OrderStringId = reader.ReadString(), OrderBoardId = reader.ReadString(), UserOrderId = reader.ReadString(), OrderPrice = reader.ReadDecimal(), OrderVolume = reader.ReadNullableDecimal(), Balance = reader.ReadNullableDecimal(), VisibleVolume = reader.ReadNullableDecimal(), Side = reader.ReadEnum <Sides>(), OriginSide = reader.ReadNullableEnum <Sides>(), OrderState = reader.ReadNullableEnum <OrderStates>(), OrderType = reader.ReadNullableEnum <OrderTypes>(), TimeInForce = reader.ReadNullableEnum <TimeInForce>(), TradeId = reader.ReadNullableLong(), TradeStringId = reader.ReadString(), TradePrice = reader.ReadNullableDecimal(), TradeVolume = reader.ReadNullableDecimal(), PortfolioName = reader.ReadString(), ClientCode = reader.ReadString(), BrokerCode = reader.ReadString(), DepoName = reader.ReadString(), IsSystem = reader.ReadNullableBool(), HasOrderInfo = reader.ReadBool(), HasTradeInfo = reader.ReadBool(), Commission = reader.ReadNullableDecimal(), Currency = reader.ReadNullableEnum <CurrencyTypes>(), Comment = reader.ReadString(), SystemComment = reader.ReadString(), //DerivedOrderId = reader.ReadNullableLong(), //DerivedOrderStringId = reader.ReadString(), }; reader.ReadNullableLong(); reader.ReadString(); msg.IsUpTick = reader.ReadNullableBool(); msg.IsCancellation = reader.ReadBool(); msg.OpenInterest = reader.ReadNullableDecimal(); msg.PnL = reader.ReadNullableDecimal(); msg.Position = reader.ReadNullableDecimal(); msg.Slippage = reader.ReadNullableDecimal(); msg.TradeStatus = reader.ReadNullableInt(); msg.OrderStatus = reader.ReadNullableLong(); msg.Latency = reader.ReadNullableLong().To <TimeSpan?>(); var error = reader.ReadString(); if (!error.IsEmpty()) { msg.Error = new InvalidOperationException(error); } var dtStr = reader.ReadString(); if (dtStr != null) { msg.ExpiryDate = (dtStr.ToDateTime() + reader.ReadString().ToTimeMls()).ToDateTimeOffset(TimeSpan.Parse(reader.ReadString().Remove("+"))); } else { reader.Skip(2); } msg.LocalTime = reader.ReadTime(metaInfo.Date); msg.IsMarketMaker = reader.ReadNullableBool(); if ((reader.ColumnCurr + 1) < reader.ColumnCount) { msg.CommissionCurrency = reader.ReadString(); } if ((reader.ColumnCurr + 1) < reader.ColumnCount) { msg.IsMargin = reader.ReadNullableBool(); msg.IsManual = reader.ReadNullableBool(); } return(msg); }
/// <summary> /// Load data from the specified reader. /// </summary> /// <param name="reader">CSV reader.</param> /// <param name="date">Date.</param> /// <returns>Data.</returns> protected override ExecutionMessage Read(FastCsvReader reader, DateTime date) { var msg = new ExecutionMessage { SecurityId = SecurityId, ExecutionType = ExecutionTypes.Transaction, ServerTime = reader.ReadTime(date), TransactionId = reader.ReadLong(), OriginalTransactionId = reader.ReadLong(), OrderId = reader.ReadNullableLong(), OrderStringId = reader.ReadString(), OrderBoardId = reader.ReadString(), UserOrderId = reader.ReadString(), OrderPrice = reader.ReadDecimal(), OrderVolume = reader.ReadNullableDecimal(), Balance = reader.ReadNullableDecimal(), VisibleVolume = reader.ReadNullableDecimal(), Side = reader.ReadEnum <Sides>(), OriginSide = reader.ReadNullableEnum <Sides>(), OrderState = reader.ReadNullableEnum <OrderStates>(), OrderType = reader.ReadNullableEnum <OrderTypes>(), TimeInForce = reader.ReadNullableEnum <TimeInForce>(), TradeId = reader.ReadNullableLong(), TradeStringId = reader.ReadString(), TradePrice = reader.ReadNullableDecimal(), TradeVolume = reader.ReadNullableDecimal(), PortfolioName = reader.ReadString(), ClientCode = reader.ReadString(), BrokerCode = reader.ReadString(), DepoName = reader.ReadString(), IsSystem = reader.ReadNullableBool(), HasOrderInfo = reader.ReadBool(), HasTradeInfo = reader.ReadBool(), Commission = reader.ReadNullableDecimal(), Currency = reader.ReadNullableEnum <CurrencyTypes>(), Comment = reader.ReadString(), SystemComment = reader.ReadString(), DerivedOrderId = reader.ReadNullableLong(), DerivedOrderStringId = reader.ReadString(), IsUpTick = reader.ReadNullableBool(), IsCancelled = reader.ReadBool(), OpenInterest = reader.ReadNullableDecimal(), PnL = reader.ReadNullableDecimal(), Position = reader.ReadNullableDecimal(), Slippage = reader.ReadNullableDecimal(), TradeStatus = reader.ReadNullableInt(), OrderStatus = reader.ReadNullableEnum <OrderStatus>(), Latency = reader.ReadNullableLong().To <TimeSpan?>(), }; var error = reader.ReadString(); if (!error.IsEmpty()) { msg.Error = new InvalidOperationException(error); } var dt = reader.ReadNullableDateTime(DateFormat); if (dt != null) { msg.ExpiryDate = (dt.Value + reader.ReadDateTime(TimeFormat).TimeOfDay).ToDateTimeOffset(TimeSpan.Parse(reader.ReadString().Replace("+", string.Empty))); } return(msg); }
/// <inheritdoc /> protected override NullableTimeQuoteChange Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var quote = new NullableTimeQuoteChange { ServerTime = reader.ReadTime(metaInfo.Date), }; var price = reader.ReadNullableDecimal(); var volume = reader.ReadNullableDecimal(); quote.Side = reader.ReadEnum <Sides>(); int?ordersCount = null; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { ordersCount = reader.ReadNullableInt(); } QuoteConditions condition = default; if ((reader.ColumnCurr + 1) < reader.ColumnCount) { condition = reader.ReadNullableEnum <QuoteConditions>() ?? default; } QuoteChange?qq = null; if (price != null) { qq = quote.Quote = new QuoteChange { Price = price.Value, Volume = volume ?? 0, OrdersCount = ordersCount, Condition = condition, }; } if ((reader.ColumnCurr + 1) < reader.ColumnCount) { var startPosition = reader.ReadNullableInt(); var endPosition = reader.ReadNullableInt(); var action = reader.ReadNullableEnum <QuoteChangeActions>(); if (qq != null) { var temp = qq.Value; temp.StartPosition = startPosition; temp.EndPosition = endPosition; temp.Action = action; quote.Quote = temp; } } if ((reader.ColumnCurr + 1) < reader.ColumnCount) { quote.State = reader.ReadNullableEnum <QuoteChangeStates>(); quote.SeqNum = reader.ReadNullableLong(); quote.BuildFrom = reader.ReadBuildFrom(); } return(quote); }
/// <inheritdoc /> protected override Level1ChangeMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var level1 = new Level1ChangeMessage { SecurityId = SecurityId, ServerTime = reader.ReadTime(metaInfo.Date), }; foreach (var pair in _level1Fields) { // backward compatibility if (reader.ColumnCurr == reader.ColumnCount) { break; } var field = pair.Key; if (pair.Value == typeof(DateTimeOffset)) { var dtStr = reader.ReadString(); if (dtStr != null) { level1.Changes.Add(field, (dtStr.ToDateTime() + reader.ReadString().ToTimeMls()).ToDateTimeOffset(TimeSpan.Parse(reader.ReadString().Remove("+")))); } else { reader.Skip(2); } } else if (pair.Value == typeof(int)) { var value = reader.ReadNullableInt(); if (value != null) { level1.Changes.Add(field, value.Value); } } else if (pair.Value == typeof(long)) { var value = reader.ReadNullableLong(); if (value != null) { level1.Changes.Add(field, value.Value); } } else if (pair.Value == typeof(bool)) { var value = reader.ReadNullableBool(); if (value != null) { level1.Changes.Add(field, value.Value); } } else if (pair.Value == typeof(SecurityStates)) { var value = reader.ReadNullableEnum <SecurityStates>(); if (value != null) { level1.Changes.Add(field, value.Value); } } else if (pair.Value == typeof(Sides)) { var value = reader.ReadNullableEnum <Sides>(); if (value != null) { level1.Changes.Add(field, value.Value); } } else { var value = reader.ReadNullableDecimal(); if (value != null) { level1.Changes.Add(field, value.Value); } } } return(level1); }
/// <summary> /// Read data from the specified reader. /// </summary> /// <param name="reader">CSV reader.</param> /// <param name="metaInfo">Meta-information on data for one day.</param> /// <returns>Data.</returns> protected override Level1ChangeMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var level1 = new Level1ChangeMessage { SecurityId = SecurityId, ServerTime = reader.ReadTime(metaInfo.Date), }; foreach (var field in _level1Fields) { // backward compatibility if (reader.ColumnCurr == reader.ColumnCount) { break; } switch (field) { case Level1Fields.BestAskTime: case Level1Fields.BestBidTime: case Level1Fields.LastTradeTime: case Level1Fields.BuyBackDate: var dtStr = reader.ReadString(); if (dtStr != null) { level1.Changes.Add(field, (dtStr.ToDateTime() + reader.ReadString().ToTimeMls()).ToDateTimeOffset(TimeSpan.Parse(reader.ReadString().Remove("+")))); } else { reader.Skip(2); } break; case Level1Fields.LastTradeId: var id = reader.ReadNullableLong(); if (id != null) { level1.Changes.Add(field, id.Value); } break; case Level1Fields.AsksCount: case Level1Fields.BidsCount: case Level1Fields.TradesCount: case Level1Fields.Decimals: var count = reader.ReadNullableInt(); if (count != null) { level1.Changes.Add(field, count.Value); } break; case Level1Fields.LastTradeUpDown: case Level1Fields.IsSystem: var flag = reader.ReadNullableBool(); if (flag != null) { level1.Changes.Add(field, flag.Value); } break; case Level1Fields.State: var state = reader.ReadNullableEnum <SecurityStates>(); if (state != null) { level1.Changes.Add(field, state.Value); } break; case Level1Fields.LastTradeOrigin: var side = reader.ReadNullableEnum <Sides>(); if (side != null) { level1.Changes.Add(field, side.Value); } break; default: var value = reader.ReadNullableDecimal(); if (value != null) { level1.Changes.Add(field, value.Value); } break; } } return(level1); }
/// <summary> /// Read data from the specified reader. /// </summary> /// <param name="reader">CSV reader.</param> /// <param name="date">Date.</param> /// <returns>Data.</returns> protected override Level1ChangeMessage Read(FastCsvReader reader, DateTime date) { var level1 = new Level1ChangeMessage { SecurityId = SecurityId, ServerTime = reader.ReadTime(date), }; foreach (var field in _level1Fields) { switch (field) { case Level1Fields.BestAskTime: case Level1Fields.BestBidTime: case Level1Fields.LastTradeTime: var dtStr = reader.ReadString(); if (dtStr != null) { level1.Changes.Add(field, (dtStr.ToDateTime() + reader.ReadString().ToTimeMls()).ToDateTimeOffset(TimeSpan.Parse(reader.ReadString().Remove("+")))); } else { reader.Skip(2); } break; case Level1Fields.LastTradeId: var id = reader.ReadNullableLong(); if (id != null) { level1.Changes.Add(field, id); } break; case Level1Fields.AsksCount: case Level1Fields.BidsCount: case Level1Fields.TradesCount: var count = reader.ReadNullableLong(); if (count != null) { level1.Changes.Add(field, count); } break; case Level1Fields.LastTradeUpDown: case Level1Fields.IsSystem: var flag = reader.ReadNullableBool(); if (flag != null) { level1.Changes.Add(field, flag); } break; default: var value = reader.ReadNullableDecimal(); if (value != null) { level1.Changes.Add(field, value); } break; } } return(level1); }
/// <inheritdoc /> protected override PositionChangeMessage Read(FastCsvReader reader, IMarketDataMetaInfo metaInfo) { var posMsg = new PositionChangeMessage { SecurityId = SecurityId, ServerTime = reader.ReadTime(metaInfo.Date), PortfolioName = reader.ReadString(), ClientCode = reader.ReadString(), DepoName = reader.ReadString(), LimitType = reader.ReadNullableEnum <TPlusLimits>(), Description = reader.ReadString(), StrategyId = reader.ReadString(), Side = reader.ReadNullableEnum <Sides>(), BuildFrom = reader.ReadBuildFrom(), }; reader.Skip(_reserved.Length); var count = reader.ReadInt(); foreach (var type in _types.Take(count)) { switch (type) { case PositionChangeTypes.Currency: { var currency = reader.ReadNullableEnum <CurrencyTypes>(); if (currency != null) { posMsg.Changes.Add(type, currency); } break; } case PositionChangeTypes.State: { var state = reader.ReadNullableEnum <PortfolioStates>(); if (state != null) { posMsg.Changes.Add(type, state); } break; } case PositionChangeTypes.ExpirationDate: { var dtStr = reader.ReadString(); if (dtStr != null) { posMsg.Changes.Add(type, (dtStr.ToDateTime() + reader.ReadString().ToTimeMls()).ToDateTimeOffset(TimeSpan.Parse(reader.ReadString().Remove("+")))); } else { reader.Skip(2); } break; } default: { var value = reader.ReadNullableDecimal(); if (value != null) { posMsg.Changes.Add(type, value); } break; } } } return(posMsg); }