/// <inheritdoc/>
        public override void NotifyPacket(IndicatorPacket packet)
        {
            if (string.Compare(packet.Command, IndicatorLink.PacketBar, true) == 0)
            {
                String           security = packet.Args[1];
                long             when     = long.Parse(packet.Args[0]);
                String           key      = security.ToLower();
                InstrumentHolder holder;

                if (_data.ContainsKey(key))
                {
                    holder = _data[key];
                }
                else
                {
                    holder     = new InstrumentHolder();
                    _data[key] = holder;
                }

                if (holder.Record(when, 2, packet.Args))
                {
                    _rowsDownloaded++;
                }
            }
        }
        /// <summary>
        /// Save the file.
        /// </summary>
        public void Save()
        {
            try
            {
                if (_data.Count == 0)
                {
                    return;
                }


                using (var outfile =
                           new StreamWriter(_targetFile.ToString()))
                {
                    // output header
                    outfile.Write("\"INSTRUMENT\",\"WHEN\"");
                    int index = 0;
                    foreach (String str in DataRequested)
                    {
                        String str2;
                        int    ix = str.IndexOf('[');
                        str2 = ix != -1 ? str.Substring(0, ix).Trim() : str;

                        int c = DataCount[index++];
                        if (c <= 1)
                        {
                            outfile.Write(",\"" + str2 + "\"");
                        }
                        else
                        {
                            for (int i = 0; i < c; i++)
                            {
                                outfile.Write(",\"" + str2 + "-b" + i + "\"");
                            }
                        }
                    }
                    outfile.WriteLine();

                    // output data
                    foreach (string ins in _data.Keys)
                    {
                        InstrumentHolder holder = _data[ins];
                        foreach (long key in holder.Sorted)
                        {
                            String str = holder.Data[key];
                            outfile.WriteLine("\"" + ins + "\"," + key + "," + str);
                        }
                    }

                    outfile.Close();
                }
            }
            catch (IOException ex)
            {
                throw new EncogError(ex);
            }
        }
        /// <inheritdoc/>
        public override void NotifyPacket(IndicatorPacket packet)
        {
            if (string.Compare(packet.Command, IndicatorLink.PACKET_BAR, true) == 0)
            {
                String security = packet.Args[1];
                long when = long.Parse(packet.Args[0]);
                String key = security.ToLower();
                InstrumentHolder holder = null;

                if (this.data.ContainsKey(key))
                {
                    holder = this.data[key];
                }
                else
                {
                    holder = new InstrumentHolder();
                    this.data[key] = holder;
                }

                if (holder.Record(when, 2, packet.Args))
                {
                    this.rowsDownloaded++;
                }
            }
        }