/// <summary>
        /// sets available symbols from an index
        /// </summary>
        /// <param name="index"></param>
        public void SetSymbols(string[,] index)
        {
            List <string> tmpstk = new List <string>();

            int[] years  = new int[200];
            int[] days   = new int[31];
            int[] months = new int[12];
            int   yc     = 0;
            int   dc     = 0;
            int   mc     = 0;
            int   count  = index.GetLength(0);

            for (int i = 0; i < count; i++)
            {
                SecurityImpl s = bUseCSV ? ChimeraDataUtils.SecurityFromFileName(index[i, 0]) :
                                 SecurityImpl.SecurityFromFileName(index[i, 0]);

                if (!s.isValid)
                {
                    continue;
                }
                DateTime d = Util.ToDateTime(s.Date, 0);
                if (!tmpstk.Contains(s.symbol))
                {
                    tmpstk.Add(s.symbol);
                }
                if (!contains(d.Year, years))
                {
                    years[yc++] = d.Year;
                }
                if (!contains(d.Month, months))
                {
                    months[mc++] = d.Month;
                }
                if (!contains(d.Day, days))
                {
                    days[dc++] = d.Day;
                }
            }
            Array.Sort(years);
            Array.Sort(days);
            Array.Sort(months);
            tmpstk.Sort();
            updateGUI(tmpstk.ToArray(), days, years, months, index);
        }
Exemple #2
0
        bool getsimhints(string folder, TickFileFilter tff, ref int date, ref string[] syms)
        {
            date = 0;
            syms = new string[0];
            try
            {
                string   wild_ext = _useCsvTicks.Checked ? "*_trades.csv" : TikConst.WILDCARD_EXT;
                var      searOpts = _useCsvTicks.Checked ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
                string[] files    = Directory.GetFiles(folder, wild_ext, searOpts);

                var           simfiles = tff.Allows(files);
                List <string> simsyms  = new List <string>(simfiles.Length);
                Array.Sort(simfiles);
                // get earliest date
                var min = int.MaxValue;
                foreach (var sf in simfiles)
                {
                    var sec = _useCsvTicks.Checked ? ChimeraDataUtils.SecurityFromFileName(sf) : SecurityImpl.SecurityFromFileName(sf);
                    if (!string.IsNullOrWhiteSpace(sec.symbol) && !simsyms.Contains(sec.symbol))
                    {
                        simsyms.Add(sec.symbol);
                    }
                    if ((sec.Date > 0) && (sec.Date < min))
                    {
                        min = sec.Date;
                    }
                }
                if (min != int.MaxValue)
                {
                    date = min;
                }
                syms = simsyms.ToArray();
                return(true);
            }
            catch (Exception ex)
            {
                debug("error getting sim hints: " + ex.Message + ex.StackTrace);
                return(false);
            }
        }