public Ticks AddTicks(XlTable xt, Ticks tics) { xt.ReadValue(); tics.date.Add(DateTime.Parse(xt.StringValue).TimeOfDay); xt.ReadValue(); tics.price.Add(xt.FloatValue); xt.ReadValue(); tics.count.Add((int)xt.FloatValue); return(tics); }
// ********************************************************************** public override void ProcessTable(XlTable xt) { sb.Clear(); for (int row = 0; row < xt.Rows; row++) { for (int col = 0; col < xt.Columns; col++) { xt.ReadValue(); switch (xt.ValueType) { case XlTable.BlockType.Float: sb.Append(xt.FloatValue.ToString().PadLeft(vspace)); break; case XlTable.BlockType.String: sb.Append(xt.StringValue.PadLeft(vspace)); break; default: sb.Append(xt.ValueType.ToString().PadLeft(vspace)); break; } } sb.AppendLine(); } Data = sb.ToString(); updated = true; }
protected override void ProcessTable(XlTable xt) { for (int row = 0; row < xt.Rows; row++) { for (int col = 0; col < xt.Columns; col++) { xt.ReadValue(); switch (col) { case 0: Time_change = xt.StringValue; break; case 1: Price_trade = (decimal)xt.FloatValue; break; case 2: Bid = (decimal)xt.FloatValue; break; case 3: Offer = (decimal)xt.FloatValue; break; case 4: High_possible_price = (decimal)xt.FloatValue; break; case 5: Minimum_possible_price = (decimal)xt.FloatValue; break; case 6: Step_price = (decimal)xt.FloatValue; break; case 7: StockCode = xt.StringValue; break; case 8: ClassCode = xt.StringValue; break; case 9: Time_trade = xt.StringValue; break; } } } }
public Ticks GetTicks(XlTable xt, string topic, int timeFrameForFill) { // TimeSpan time = DateTime.Now.AddSeconds(-timeFrameForFill).TimeOfDay; // TimeSpan timeHistory = new TimeSpan(22, 00, 00); Ticks tics = new Ticks(topic); for (int i = 0; i < xt.Rows - 2; i++) { xt.ReadValue(); xt.ReadValue(); xt.ReadValue(); } tics.date.Add(DateTime.Parse(xt.StringValue).TimeOfDay); xt.ReadValue(); tics.price.Add(xt.FloatValue); xt.ReadValue(); tics.count.Add((int)xt.FloatValue); /* * for (int i = 0; i < xt.Rows - 1; i++) * { * xt.ReadValue(); * if ((DateTime.Parse(xt.StringValue).TimeOfDay) > time) * { * tics.date.Add(DateTime.Parse(xt.StringValue).TimeOfDay); * xt.ReadValue(); * tics.price.Add(xt.FloatValue); * xt.ReadValue(); * tics.count.Add((int)xt.FloatValue); * } * else * { * xt.ReadValue(); * xt.ReadValue(); * } * }*/ return(tics); }
protected override void ProcessTable(XlTable xt) { DDeChannelsServiceEventArgs ddeServiceEventArgs = new DDeChannelsServiceEventArgs(); ddeServiceEventArgs.SetCountRowsExport(xt.Rows); ObtainingDataStartedEvent(this, ddeServiceEventArgs); int xtRows = xt.Rows; for (int row = 0; row < xtRows; row++) { DDEChannelsMarketEventArgs ddeMarketEventArgs = new DDEChannelsMarketEventArgs(); xt.ReadValue(); ddeMarketEventArgs.Number = xt.FloatValue; xt.ReadValue(); ddeMarketEventArgs.Securyti = xt.StringValue; xt.ReadValue(); ddeMarketEventArgs.Price = (double)xt.FloatValue; xt.ReadValue(); ddeMarketEventArgs.Date = xt.StringValue; xt.ReadValue(); ddeMarketEventArgs.Time = xt.StringValue; xt.ReadValue(); ddeMarketEventArgs.TimeMsc = xt.FloatValue; xt.ReadValue(); ddeMarketEventArgs.Operation = xt.StringValue; xt.ReadValue(); ddeMarketEventArgs.Quantity = (double)xt.FloatValue; LoadedLineEvent(this, ddeMarketEventArgs); } ObtainingDataCompletedEvent(this, ddeServiceEventArgs); }
// Обработчик данных public override void ProcessTable(XlTable xt) { // Поступили новые данные из таблицы, настроенной для экспорта // в "Рабочую книгу" trades. // Все переданные данные содержатся в переменной xt, являющейся // экземпляром класса XlTable, который содержит методы для их // распаковки. // xt.Rows - кол-во строк, xt.Columns - кол-во столбцов в полученной // таблице. Для чтения одной ячейки таблицы служит метод // xt.ReadValue(), который после своего вызова устанавливает // свойства xt.ValueType - тип прочитанных данных и xt.*Value - // значение в ячейке. От Квика поступают данные двух типов: // XlTable.BlockType.Float (double в C#) // XlTable.BlockType.String (в C# тоже string) // Отобразим всю полученную информацию for (int row = 0; row < xt.Rows; row++) { for (int col = 0; col < xt.Columns; col++) { xt.ReadValue(); switch (xt.ValueType) { case XlTable.BlockType.Float: Console.Write("D:{0}\t", xt.FloatValue); break; case XlTable.BlockType.String: Console.Write("S:{0}\t", xt.StringValue); break; default: Console.Write("{0}:{1}\t", xt.ValueType, xt.WValue); break; } } Console.WriteLine(); } }
protected override void ProcessTable(XlTable xt) { ObtainingDataStartedEvent(this, EventArgs.Empty); int xtRows = xt.Rows; SetCountRowsExport(xtRows); for (int row = 0; row < xtRows; row++) { xt.ReadValue(); Number = xt.FloatValue; xt.ReadValue(); Security = xt.StringValue; xt.ReadValue(); Price = (decimal)xt.FloatValue; xt.ReadValue(); Date = xt.StringValue; xt.ReadValue(); Time = xt.StringValue; xt.ReadValue(); TimeMsk = xt.FloatValue.ToString(); xt.ReadValue(); Operation = xt.StringValue; xt.ReadValue(); Quantity = (decimal)xt.FloatValue; LoadedLineEvent(this, EventArgs.Empty); } ObtainingDataCompletedEvent(this, EventArgs.Empty); }
// ********************************************************************** // Обработчик данных public override void ProcessTable(XlTable xt) { // Учитывая, что это простой пример, в очередь будем // класть уже готовую для отображения строку. for (int row = 0; row < xt.Rows; row++) { sb.Clear(); for (int col = 0; col < xt.Columns; col++) { xt.ReadValue(); switch (xt.ValueType) { case XlTable.BlockType.Float: sb.Append(xt.FloatValue); break; case XlTable.BlockType.String: sb.Append(xt.StringValue); break; default: sb.Append(xt.ValueType); sb.Append(":"); sb.Append(xt.WValue); break; } sb.Append("\t"); } sb.AppendLine(); Queue.Enqueue(sb.ToString()); } }
protected override void ProcessTable(XlTable xt) { DDeChannelsServiceEventArgs ddeServiceEventArgs = new DDeChannelsServiceEventArgs(); ddeServiceEventArgs.SetCountRowsExport(xt.Rows); ObtainingDataStartedEvent(this, ddeServiceEventArgs); int xtRows = xt.Rows; for (int row = 0; row < xtRows; row++) { DDEChannelsMarketEventArgs ddeMarketEventArgs = new DDEChannelsMarketEventArgs(); for (int col = 0; col < xt.Columns; col++) { xt.ReadValue(); SetValues(xt, col, ddeMarketEventArgs); } LoadedLineEvent(this, ddeMarketEventArgs); } ObtainingDataCompletedEvent(this, ddeServiceEventArgs); }
// ********************************************************************** public override void ProcessTable(XlTable xt) { if (xt.Rows < 3) { SetError("стакан пуст"); return; } // ------------------------------------------------------------ int cAskVolume = -1, cBidVolume = -1, cPrice = -1; for (int col = 0; col < xt.Columns; col++) { xt.ReadValue(); if (xt.ValueType == XlTable.BlockType.String) { switch (xt.StringValue) { case cnAskVolume: cAskVolume = col; break; case cnBidVolume: cBidVolume = col; break; case cnPrice: cPrice = col; break; } } } if (cAskVolume < 0 || cBidVolume < 0 || cPrice < 0) { SetError("нет нужных столбцов"); return; } // ------------------------------------------------------------ Quote[] quotes = new Quote[xt.Rows - 1]; int ask = -1, bid = -1; // ------------------------------------------------------------ for (int row = 0; row < quotes.Length; row++) { int p = 0, av = 0, bv = 0, sc = 0; for (int col = 0; col < xt.Columns; col++) { xt.ReadValue(); switch (xt.ValueType) { case XlTable.BlockType.Float: if (col == cAskVolume) { av = (int)xt.FloatValue; } else if (col == cBidVolume) { bv = (int)xt.FloatValue; } else if (col == cPrice) { p = Price.GetInt(xt.FloatValue); } break; case XlTable.BlockType.String: sc++; break; } } if (p <= 0) { if (sc == xt.Columns) { break; } else { SetError("ошибка в данных"); return; } } if (av > 0) { ask = row; quotes[row] = new Quote(p, av, QuoteType.Ask); } else if (bv > 0) { if (bid == -1) { bid = row; } quotes[row] = new Quote(p, bv, QuoteType.Bid); } else { SetError("нет объема"); return; } } // ------------------------------------------------------------ if (quotes[0].Price <= quotes[1].Price) { SetError("стакан перевернут"); return; } if (ask == -1 || bid == -1) { SetError("неполный спред"); return; } // ------------------------------------------------------------ quotes[ask].Type = QuoteType.BestAsk; quotes[bid].Type = QuoteType.BestBid; if (StockHandler != null) { StockHandler(quotes, new Spread(quotes[ask].Price, quotes[bid].Price)); } }
// ********************************************************************** public override void ProcessTable(XlTable xt) { int row = 0; // ------------------------------------------------------------ if (columnsUnknown) { cDate = -1; cTime = -1; cPrice = -1; cQuantity = -1; cOp = -1; cSecCode = -1; cClassCode = -1; for (int col = 0; col < xt.Columns; col++) { xt.ReadValue(); if (xt.ValueType == XlTable.BlockType.String) { switch (xt.StringValue) { case cnDate: cDate = col; break; case cnTime: cTime = col; break; case cnPrice: cPrice = col; break; case cnQuantity: cQuantity = col; break; case cnOperation: cOp = col; break; case cnSecCode: cSecCode = col; break; case cnClassCode: cClassCode = col; break; } } } if (cDate < 0 || cTime < 0 || cPrice < 0 || cQuantity < 0 || cOp < 0 || cSecCode < 0 || cClassCode < 0) { SetError("нет нужных столбцов"); return; } row++; columnsUnknown = false; } // ------------------------------------------------------------ while (row++ < xt.Rows) { bool rowCorrect = true; string secCode = string.Empty; string classCode = string.Empty; string date = string.Empty; string time = string.Empty; Tick t = new Tick(); // ---------------------------------------------------------- for (int col = 0; col < xt.Columns; col++) { xt.ReadValue(); if (col == cDate) { if (xt.ValueType == XlTable.BlockType.String) { date = xt.StringValue; } else { rowCorrect = false; } } else if (col == cTime) { if (xt.ValueType == XlTable.BlockType.String) { time = xt.StringValue; } else { rowCorrect = false; } } else if (col == cPrice) { if (xt.ValueType == XlTable.BlockType.Float) { t.RawPrice = xt.FloatValue; } else { rowCorrect = false; } } else if (col == cQuantity) { if (xt.ValueType == XlTable.BlockType.Float) { t.Volume = (int)xt.FloatValue; } else { rowCorrect = false; } } else if (col == cOp) { if (xt.ValueType == XlTable.BlockType.String) { switch (xt.StringValue) { case strBuyOp: t.Op = TradeOp.Buy; break; case strSellOp: t.Op = TradeOp.Sell; break; } } else { rowCorrect = false; } } else if (col == cSecCode) { if (xt.ValueType == XlTable.BlockType.String) { secCode = xt.StringValue; } else { rowCorrect = false; } } else if (col == cClassCode) { if (xt.ValueType == XlTable.BlockType.String) { classCode = xt.StringValue; } else { rowCorrect = false; } } } // ---------------------------------------------------------- if (rowCorrect) { if (DateTime.TryParseExact(date + time, dtFmt, dtFmtInfo, DateTimeStyles.None, out t.DateTime)) { if (TickHandler != null) { TickHandler(Security.GetKey(secCode, classCode), t); } } else { SetError("не распознан формат даты или времени"); return; } } else { SetError("ошибка в данных"); return; } // ---------------------------------------------------------- } }
// ********************************************************************** public override void ProcessTable(XlTable xt) { int row = 0; // ------------------------------------------------------------ if (columnsUnknown) { // -------------------проверка столбцов----------------------------------- cCode = -1; cClassName = -1; cClassCode = -1; cOptionBase = -1; cTrdDateCode = -1; cMatDate = -1; cDaysToMatDate = -1; cTime = -1; cNumbids = -1; cNumoffers = -1; cBiddeptht = -1; cOfferdeptht = -1; cVoltoday = -1; cValtoday = -1; cNumtrades = -1; cNumcontracts = -1; cSelldepo = -1; cBuydepo = -1; cChangetime = -1; cOptionStrike = -1; cOptionType = -1; cVolatility = -1; for (int col = 0; col < xt.Columns; col++) { xt.ReadValue(); if (xt.ValueType == XlTable.BlockType.String) { switch (xt.StringValue) { case cnCode: cCode = col; break; case cnClassName: cClassName = col; break; case cnClassCode: cClassCode = col; break; case cnOptionBase: cOptionBase = col; break; case cnTrdDateCode: cTrdDateCode = col; break; case cnMatDate: cMatDate = col; break; case cnDaysToMatDate: cDaysToMatDate = col; break; case cnTime: cTime = col; break; case cnNumbids: cNumbids = col; break; case cnNumoffers: cNumoffers = col; break; case cnBiddeptht: cBiddeptht = col; break; case cnOfferdeptht: cOfferdeptht = col; break; case cnVoltoday: cVoltoday = col; break; case cnValtoday: cValtoday = col; break; case cnNumtrades: cNumtrades = col; break; case cnNumcontracts: cNumcontracts = col; break; case cnSelldepo: cSelldepo = col; break; case cnBuydepo: cBuydepo = col; break; case cnChangetime: cChangetime = col; break; case cnOptionStrike: cOptionStrike = col; break; case cnOptionType: cOptionType = col; break; case cnVolatility: cVolatility = col; break; } } } if (cCode < 0 || cClassName < 0 || cClassCode < 0 || cOptionBase < 0 || cTrdDateCode < 0 || cMatDate < 0 || cDaysToMatDate < 0 || cTime < 0 || cNumbids < 0 || cNumoffers < 0 || cBiddeptht < 0 || cOfferdeptht < 0 || cVoltoday < 0 || cValtoday < 0 || cNumtrades < 0 || cNumcontracts < 0 || cSelldepo < 0 || cBuydepo < 0 || cChangetime < 0 || cOptionStrike < 0 || cVolatility < 0) { SetError("нет нужных столбцов"); return; } row++; columnsUnknown = false; } // ------------------------------------------------------------ while (row++ < xt.Rows) { bool rowCorrect = true; string secCode = string.Empty; string classCode = string.Empty; string className = string.Empty; string date = string.Empty; string time = string.Empty; string matDate = string.Empty; Setting s = new Setting(); // ---------------------------------------------------------- for (int col = 0; col < xt.Columns; col++) { xt.ReadValue(); if (col == cCode) { if (xt.ValueType == XlTable.BlockType.String) { s.SecCode = xt.StringValue; } else { rowCorrect = false; } } else if (col == cClassName) { if (xt.ValueType == XlTable.BlockType.String) { s.ClassName = xt.StringValue; } else { rowCorrect = false; } } else if (col == cClassCode) { if (xt.ValueType == XlTable.BlockType.String) { s.ClassCode = xt.StringValue; } else { rowCorrect = false; } } else if (col == cOptionBase) { if (xt.ValueType == XlTable.BlockType.String) { s.OptionBase = xt.StringValue; } else { rowCorrect = false; } } else if (col == cTrdDateCode) { if (xt.ValueType == XlTable.BlockType.String) { date = xt.StringValue; } else { rowCorrect = false; } } else if (col == cChangetime) // cTime { if (xt.ValueType == XlTable.BlockType.String) { time = xt.StringValue; } else { rowCorrect = false; } } else if (col == cMatDate) { if (xt.ValueType == XlTable.BlockType.String) { matDate = xt.StringValue; } else { rowCorrect = false; } } else if (col == cDaysToMatDate) { if (xt.ValueType == XlTable.BlockType.Float) { s.DaysToMatDate = (int)xt.FloatValue; } else { rowCorrect = false; } } else if (col == cNumbids) { if (xt.ValueType == XlTable.BlockType.Float) { s.Numbids = (int)xt.FloatValue; } else { rowCorrect = false; } } else if (col == cNumoffers) { if (xt.ValueType == XlTable.BlockType.Float) { s.Numoffers = (int)xt.FloatValue; } else { rowCorrect = false; } } else if (col == cBiddeptht) { if (xt.ValueType == XlTable.BlockType.Float) { s.Biddeptht = (int)xt.FloatValue; } else { rowCorrect = false; } } else if (col == cOfferdeptht) { if (xt.ValueType == XlTable.BlockType.Float) { s.Offerdeptht = (int)xt.FloatValue; } else { rowCorrect = false; } } else if (col == cVoltoday) { if (xt.ValueType == XlTable.BlockType.Float) { s.Voltoday = (int)xt.FloatValue; } else { rowCorrect = false; } } else if (col == cValtoday) { if (xt.ValueType == XlTable.BlockType.Float) { s.Valtoday = xt.FloatValue; } else { rowCorrect = false; } } else if (col == cNumtrades) { if (xt.ValueType == XlTable.BlockType.Float) { s.Numtrades = (int)xt.FloatValue; } else { rowCorrect = false; } } else if (col == cNumcontracts) { if (xt.ValueType == XlTable.BlockType.Float) { s.Numcontracts = (int)xt.FloatValue; } else { rowCorrect = false; } } else if (col == cSelldepo) { if (xt.ValueType == XlTable.BlockType.Float) { s.Selldepo = xt.FloatValue; } else if (xt.ValueType == XlTable.BlockType.String) { s.Strike = 0; } else { rowCorrect = false; } } else if (col == cBuydepo) { if (xt.ValueType == XlTable.BlockType.Float) { s.Buydepo = xt.FloatValue; } else { rowCorrect = false; } } else if (col == cOptionStrike) { if (xt.ValueType == XlTable.BlockType.Float) { s.Strike = xt.FloatValue; } else if (xt.ValueType == XlTable.BlockType.String) { s.Strike = 0; } else { rowCorrect = false; } } else if (col == cOptionType) { if (xt.ValueType == XlTable.BlockType.String) { s.OptionType = xt.StringValue; } else { rowCorrect = false; } } else if (col == cVolatility) { if (xt.ValueType == XlTable.BlockType.Float) { s.Volatility = xt.FloatValue; } else if (xt.ValueType == XlTable.BlockType.String) { s.Volatility = 0; } else { rowCorrect = false; } } } // ---------------------------------------------------------- if (rowCorrect) { DateTime sMatDate = s.MatDate; if (DateTime.TryParseExact(matDate, "dd.MM.yyyy", dtFmtInfo, DateTimeStyles.None, out sMatDate)) { s.MatDate = sMatDate; } else { SetError("не распознан формат даты или времени"); return; } DateTime sDateTime = s.DateTime; if (DateTime.TryParseExact(date + time, dtFmt, dtFmtInfo, DateTimeStyles.None, out sDateTime)) { s.DateTime = sDateTime; if (SettingsHandler != null) { SettingsHandler(s); } } else { SetError("не распознан формат даты или времени"); return; } } else { SetError("ошибка в данных"); return; } // ---------------------------------------------------------- } }