Esempio n. 1
0
        /// <summary>
        /// Reinitialize the cache
        /// </summary>
        public void Initialize()
        {
            if (_inited)
            {
                return;          // only init once
            }
            if (_tickfiles.Length == 0)
            {
                return;                             // no tick files
            }
            List <long>       ds  = new List <long>(_tickfiles.Length);
            List <TickReader> trs = new List <TickReader>(_tickfiles.Length);

            // now we have our list, initialize instruments from files
            for (int i = 0; i < _tickfiles.Length; i++)
            {
                long       d  = Util.DateFromFileName(_tickfiles[i]);
                TickReader tr = new TickReader(_tickfiles[i]);

                ds.Add(d);
                trs.Add(tr);
            }
            // setup our initial index
            long[]       didx  = ds.ToArray();
            TickReader[] tridx = trs.ToArray();
            Array.Sort(didx, tridx);
            // save index and objects in order
            _secreaders.Clear();
            _dates.Clear();
            _secreaders.AddRange(tridx);
            _dates.AddRange(didx);
            totaltickfiles = _tickfiles.Length - 1;

            OnDebug("Initialized " + (_tickfiles.Length) + " instruments.");
            OnDebug(string.Join(Environment.NewLine.ToString(), _tickfiles));
            // check for event
            if (GotTickHandler != null)
            {
                hasevent = true;
            }
            else
            {
                OnDebug("No GotTick event handler defined!");
            }
            // read in single tick just to get first time for user
            isnexttick();

            // count total ticks represented by files
            // get total ticks represented by files
            _availticks = 0;
            for (int i = 0; i < trs[i].Count; i++)
            {
                if (trs[i] != null)
                {
                    _availticks += trs[i].TotalCount;
                }
            }

            _inited = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Reinitialize the cache
        /// </summary>
        public void Initialize()
        {
            if (_inited)
            {
                return;          // only init once
            }
            if (_tickfiles.Length == 0)
            {
                return;                             // no tick files
            }
            // now we have our list, initialize instruments from files
            for (int i = 0; i < _tickfiles.Length; i++)
            {
                try
                {
                    TickReader tr = new TickReader(_tickfiles[i]);
                    if (tr.IsValid)
                    {
                        Workers.Add(new simworker(tr));
                    }
                }
                catch (Exception ex)
                {
                    Debug("Unable to initialize: " + _tickfiles[i] + " error: " + ex.Message + ex.StackTrace);
                    continue;
                }
            }
            // setup our initial index
            idx  = genidx(Workers.Count);
            cidx = new int[Workers.Count];

            Debug("Initialized " + (_tickfiles.Length) + " instruments.");
            Debug(string.Join(Environment.NewLine.ToString(), _tickfiles));
            // read in single tick just to get first time for user
            FillCache(1);

            // get total ticks represented by files
            _availticks = 0;
            for (int i = 0; i < Workers.Count; i++)
            {
                if (Workers[i].workersec != null)
                {
                    _availticks += Workers[i].workersec.TotalCount;
                }
            }

            Debug("Approximately " + TicksPresent + " ticks to process...");
            _inited = true;
            // set first time as hint for user
            setnexttime();
        }
Esempio n. 3
0
 public simworker(TickReader sec)
 {
     workersec = sec;
     WorkerSupportsCancellation = true;
     RunWorkerCompleted        += new RunWorkerCompletedEventHandler(simworker_RunWorkerCompleted);
     // if we're multi-core prepare to start I/O thread for this security
     if (Environment.ProcessorCount > 1)
     {
         DoWork += new DoWorkEventHandler(simworker_DoWork);
         workersec.GotTickHanlder += new Action <Tick>(HistSource_gotTick2);
     }
     else
     {
         workersec.GotTickHanlder += new Action <Tick>(HistSource_gotTick);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Reinitialize the cache
        /// </summary>
        public void Initialize()
        {
            if (_inited) return; // only init once
            if (_tickfiles.Length == 0) return;     // no tick files

            List<long> ds = new List<long>(_tickfiles.Length);
            List<TickReader> trs = new List<TickReader>(_tickfiles.Length);
            // now we have our list, initialize instruments from files
            for (int i = 0; i < _tickfiles.Length; i++)
            {
                long d = Util.DateFromFileName(_tickfiles[i]);
                TickReader tr = new TickReader(_tickfiles[i]);

                ds.Add(d);
                trs.Add(tr);
            }
            // setup our initial index
            long[] didx = ds.ToArray();
            TickReader[] tridx = trs.ToArray();
            Array.Sort(didx, tridx);
            // save index and objects in order
            _secreaders.Clear();
            _dates.Clear();
            _secreaders.AddRange(tridx);
            _dates.AddRange(didx);
            totaltickfiles = _tickfiles.Length - 1;

            OnDebug("Initialized " + (_tickfiles.Length) + " instruments.");
            OnDebug(string.Join(Environment.NewLine.ToString(), _tickfiles));
            // check for event
            if (GotTickHandler != null)
                hasevent = true;
            else
                OnDebug("No GotTick event handler defined!");
            // read in single tick just to get first time for user
            isnexttick();

            // count total ticks represented by files
            // get total ticks represented by files
            _availticks = 0;
            for (int i = 0; i < trs[i].Count; i++)
                if (trs[i] != null)
                    _availticks += trs[i].TotalCount;

            _inited = true;
        }
Esempio n. 5
0
 public simworker(TickReader sec)
 {
     workersec = sec;
     WorkerSupportsCancellation = true;
     RunWorkerCompleted += new RunWorkerCompletedEventHandler(simworker_RunWorkerCompleted);
     // if we're multi-core prepare to start I/O thread for this security
     if (Environment.ProcessorCount > 1)
     {
         DoWork += new DoWorkEventHandler(simworker_DoWork);
         workersec.GotTickHanlder += new Action<Tick>(HistSource_gotTick2);
     }
     else
     {
         workersec.GotTickHanlder += new Action<Tick>(HistSource_gotTick);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Reinitialize the cache
        /// </summary>
        public void Initialize()
        {
            if (_inited) return; // only init once
            if (_tickfiles.Length == 0) return;     // no tick files

            // now we have our list, initialize instruments from files
            for (int i = 0; i < _tickfiles.Length; i++)
            {
                try
                {
                    TickReader tr = new TickReader(_tickfiles[i]);
                    if (tr.IsValid)
                        Workers.Add(new simworker(tr));
                }
                catch (Exception ex)
                {
                    Debug("Unable to initialize: " + _tickfiles[i] + " error: " + ex.Message + ex.StackTrace);
                    continue;
                }
            }
            // setup our initial index
            idx = genidx(Workers.Count);
            cidx = new int[Workers.Count];

            Debug("Initialized " + (_tickfiles.Length) + " instruments.");
            Debug(string.Join(Environment.NewLine.ToString(), _tickfiles));
            // read in single tick just to get first time for user
            FillCache(1);

            // get total ticks represented by files
            _availticks = 0;
            for (int i = 0; i < Workers.Count; i++)
                if (Workers[i].workersec != null)
                    _availticks += Workers[i].workersec.TotalCount;

            Debug("Approximately " + TicksPresent + " ticks to process...");
            _inited = true;
            // set first time as hint for user
            setnexttime();
        }