Пример #1
0
        /// <summary>
        /// Read file header for TIK file information
        /// </summary>
        private void ReadHeader()
        {
            // get version id
            ReadByte();

            // get version
            _fileversion = ReadInt32();
            if (_fileversion != TikConst.Filecurrentversion)
            {
                throw new BadTikFile("version: " + _fileversion + " expected: " + TikConst.Filecurrentversion);
            }

            // get real symbol
            _realsymbol = ReadString();

            // get security from symbol
            _sec      = SecurityImpl.Parse(_realsymbol);
            _sec.Date = SecurityImpl.SecurityFromFileName(_path).Date;

            // get short symbol
            _sym = _sec.Name;

            // get end of header
            ReadByte();

            // make sure we read something
            if (_realsymbol.Length <= 0)
            {
                throw new BadTikFile("no symbol defined in tickfile");
            }

            // flag header as read
            _haveheader = true;
        }
Пример #2
0
        public void TickIndex()
        {
            string[,] idx = Util.TickFileIndex(Environment.CurrentDirectory + "\\", TikConst.WILDCARD_EXT);
            string[] syma     = new string[] { "ABN", "$SPX", "FTI" };
            string   syms     = string.Join(",", syma);
            bool     foundsym = true;

            for (int i = 0; i < idx.GetLength(0); i++)
            {
                Security s = SecurityImpl.SecurityFromFileName(idx[i, 0]);
                foundsym &= syms.Contains(s.Symbol);
            }
            Assert.IsTrue(foundsym);
            Assert.AreEqual(syma.Length, idx.GetLength(0));
            Assert.AreEqual(2, idx.GetLength(1));
        }
Пример #3
0
        private bool loadfile(string path)
        {
            string f       = path;
            bool   success = false;

            if (isResponse(f))
            {
                responsedll = f;
                List <string> l = Util.GetResponseList(responsedll);
                if (System.IO.File.Exists(f) && (l.Count > 0))
                {
                    if (!isRecentResLib(f))
                    {
                        reslist.DropDownItems.Add(f);
                    }
                }
                status("Found " + l.Count + " responses.  ");
                _rl = new ResponseList(l);
                _rl.ResponseSelected += new DebugDelegate(loadboxname);
                if (_rl.ShowDialog() != DialogResult.OK)
                {
                    status("no response was selected.");
                }

                success = true;
            }
            else if (isTIK(f))
            {
                if (System.IO.File.Exists(f))
                {
                    if (!isRecentTickfile(f) && SecurityImpl.SecurityFromFileName(f).isValid)
                    {
                        recent.DropDownItems.Add(f);
                    }
                }
                epffiles.Add(f);
                success = loadsim();
            }
            else if (isSkin(f))
            {
                loadskin(f);
            }
            hasprereq();

            return(success);
        }
        /// <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);
        }
Пример #5
0
 private void loadTickData(List <string> paths)
 {
     _historicalDataFiles.Clear();
     foreach (var path in paths)
     {
         string f = path;
         if (isTIK(f))
         {
             if (System.IO.File.Exists(f))
             {
                 if (SecurityImpl.SecurityFromFileName(f).isValid)
                 {
                     _historicalDataFiles.Add(f);
                 }
             }
         }
     }
 }
Пример #6
0
        public void TickIndex()
        {
            string[,] idx = Util.TickFileIndex(Environment.CurrentDirectory + @"\\Common" + "\\", TikConst.WildcardExt);
            string[]      syma     = new string[] { "ABN", "$SPX", "FTI", "TPX", "EURUSD" };
            string        syms     = string.Join(",", syma);
            bool          foundsym = true;
            List <string> missing  = new List <string>();

            for (int i = 0; i < idx.GetLength(0); i++)
            {
                ISecurity s     = SecurityImpl.SecurityFromFileName(idx[i, 0]);
                var       found = syms.Contains(s.Name);
                if (!found)
                {
                    missing.Add(s.Name);
                }
                foundsym &= found;
            }
            Assert.True(foundsym, "missing symbols: " + string.Join(" ", missing.ToArray()));
            Assert.Equal(syma.Length, idx.GetLength(0));
            Assert.Equal(2, idx.GetLength(1));
        }
Пример #7
0
        public void TickIndex()
        {
            string[,] idx = Util.TickFileIndex(Environment.CurrentDirectory + "\\", TikConst.WILDCARD_EXT);
            string[]      syma     = new string[] { "ABN", "$SPX", "FTI", "TPX" };
            string        syms     = string.Join(",", syma);
            bool          foundsym = true;
            List <string> missing  = new List <string>();

            for (int i = 0; i < idx.GetLength(0); i++)
            {
                Security s     = SecurityImpl.SecurityFromFileName(idx[i, 0]);
                var      found = syms.Contains(s.symbol);
                if (!found)
                {
                    missing.Add(s.symbol);
                }
                foundsym &= found;
            }
            Assert.IsTrue(foundsym, "missing symbols: " + string.Join(" ", missing.ToArray()));
            Assert.AreEqual(syma.Length, idx.GetLength(0), "unexpected number of symbols");
            Assert.AreEqual(2, idx.GetLength(1), "tick file sizes were not as expected");
        }
        public bool LoadTickData(List <string> paths)
        {
            bool success = false;

            _historicalDataFiles.Clear();
            foreach (var path in paths)
            {
                string f = path;
                if (isTIK(f))
                {
                    if (System.IO.File.Exists(f))
                    {
                        if (SecurityImpl.SecurityFromFileName(f).isValid)
                        {
                            _historicalDataFiles.Add(f);
                        }
                    }
                }
            }
            success = loadsim();
            success = success && hasprereq();
            return(success);
        }
Пример #9
0
 bool getsimhints(string folder, TickFileFilter tff, ref int date, ref string[] syms)
 {
     date = 0;
     syms = new string[0];
     try
     {
         string[]      files    = Directory.GetFiles(folder, TikConst.WILDCARD_EXT);
         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 = 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);
     }
 }