예제 #1
0
        /// <summary>
        /// build index for an entire folder
        /// </summary>
        /// <param name="folder"></param>
        public HistSimIndexPlay(string folder, int interval)
        {
            _folder       = folder + "\\";
            string[,] tfi = Util.TickFileIndex(folder, TikConst.WILDCARD_EXT);
            // see if we have index
            string       fn;
            HistSimIndex hsi;

            _extdebug = tfi.GetLength(0) > 500;
            edebug("checking for index for: " + tfi.GetLength(0) + "-sized simulation.");
            if (HistSimIndex.HaveIndex(folder, tfi, interval, out fn))
            {
                edebug("index found.");
                hsi           = HistSimIndex.FromFile(fn);
                hsi.GotDebug += new DebugDelegate(debug);
            }
            else if (HistSimIndex.BuildIndex(folder, tfi, out hsi, true, true, interval, debug))
            {
                edebug("Index built successfully. ");
            }
            else
            {
                debug("Error building index.");
                return;
            }
            myhsi           = hsi;
            _reader.DoWork += new DoWorkEventHandler(_reader_DoWork);
            _reader.WorkerSupportsCancellation = true;

            hsip_avail = hsi.Playindex.Length;
            checkindex();
        }
예제 #2
0
        public HistSimIndexPlay(string folder, TickFileFilter tff, int interval, DebugDelegate deb)
        {
            if (deb != null)
            {
                GotDebug += deb;
            }
            _folder = folder + "\\";
            // see if we have index
            string       fn;
            HistSimIndex hsi;

            debug("getting tickfiles, please wait...");

            string[,] total = tff.bUseCSV ? ChimeraDataUtils.TickFileIndex(folder, "*_trades.csv", true)
                                : Util.TickFileIndex(folder, TikConst.WILDCARD_EXT, false);
            debug("found " + total.GetLength(0).ToString("N0") + " tickfiles");
            string[,] filtered = tff.AllowsIndexAndSize(total);
            debug("post-filter: " + filtered.GetLength(0).ToString("N0") + ", checking for index...");

            if (HistSimIndex.HaveIndex(folder, filtered, out fn, deb, tff.bUseCSV))
            {
                debug("index found, starting load: " + fn);
                hsi = HistSimIndex.FromFile(fn, debug);
                if (hsi == null)
                {
                    debug("unable to load index.");
                    return;
                }
                hsi.GotDebug += new DebugDelegate(debug);
            }
            else if (HistSimIndex.BuildIndex(folder, filtered, out hsi, true, true, interval, debug, tff.bUseCSV))
            {
                debug("Index built successfully, ready to play.");
            }
            else
            {
                debug("Error building index...");
                return;
            }
            _reader.DoWork += new DoWorkEventHandler(_reader_DoWork);
            _reader.WorkerSupportsCancellation = true;
            myhsi      = hsi;
            hsip_avail = hsi.Playindex.Length;
            checkindex();
        }
예제 #3
0
        public HistSimIndexPlay(string[] dataset, string folder, int interval, DebugDelegate deb)
        {
            if (deb != null)
            {
                GotDebug += deb;
            }
            if (dataset.Length < 1)
            {
                debug("Empty data set, quitting...");
                return;
            }
            _folder = folder;
            // get index of set
            string[,] tfi = GetTickIndex(dataset, false, folder);
            _extdebug     = tfi.GetLength(0) > 500;
            // see if we have index
            string       fn;
            HistSimIndex hsi;

            edebug("checking for index");
            if (HistSimIndex.HaveIndex(folder, tfi, interval, out fn))
            {
                edebug("index found.");
                hsi           = HistSimIndex.FromFile(fn);
                hsi.GotDebug += new DebugDelegate(debug);
            }
            else if (HistSimIndex.BuildIndex(folder, tfi, out hsi, true, true, interval, debug))
            {
                edebug("Index built successfully");
            }
            else
            {
                debug("Error building index...");
                return;
            }
            myhsi           = hsi;
            _reader.DoWork += new DoWorkEventHandler(_reader_DoWork);
            _reader.WorkerSupportsCancellation = true;

            hsip_avail = hsi.Playindex.Length;
            checkindex();
        }