public void Basics() { // build a one symbol filter TickFileFilter tff = new TickFileFilter(new[] { "GM" }); // get results from above data files string[] result = tff.Allows(_filenames); // make sure both files for this symbol match Assert.Equal(2, result.Length); // make sure the actual file names are the same Assert.Equal(result[0], _filenames[0]); Assert.Equal(result[1], _filenames[4]); // build a new filter tff = new TickFileFilter(); // request all matching files for a given year tff.DateFilter(20070000, DateMatchType.Year); tff.IsDateMatchUnion = true; tff.IsSymbolDateMatchUnion = true; // do the match result = tff.Allows(_filenames); // make sure we found 3 files from this year Assert.Equal(3, result.Length); // make sure the filename is the same Assert.Equal(_filenames[3], result[2]); }
public void AndTest() { // build a filter with two stocks TickFileFilter tff = new TickFileFilter(new string[] { "GM", "SPX" }); // add date file for year tff.DateFilter(20070000, DateMatchType.Year); // add another date filter for month tff.DateFilter(600, DateMatchType.Month); // set DateFilter to AND/intersection tff.isDateMatchUnion = false; // make sure three stocks match string[] result = tff.Allows(filenames); Assert.AreEqual(3, result.Length); // set more exclusive filter tff.isSymbolDateMatchUnion = false; // make sure two stocks match result = tff.Allows(filenames); Assert.AreEqual(2, result.Length); }
void fupdate(object sender, bool setunions) { // set default search options if (setunions) { // if they have both dates and symbols selected, default // to intersection of both sets if (usedates.Checked && usestocks.Checked) { _symdateand.Checked = true; } else { _symdateand.Checked = false; } // if there are more than one year, more than one month, // or more than one day selected... default to a union of sets if ((yearlist.SelectedIndices.Count > 1) || (monthlist.SelectedIndices.Count > 1) || (daylist.SelectedIndices.Count > 1)) { _dateor.Checked = true; } // otherwise if dates are enabled, default to intersection only else if (yearlist.Enabled) { _dateand.Checked = true; } } // if we're watching files if (_dw.Visible) { // clear window _dw.Clear(); // get current filter TickFileFilter tff = GetFilter(); // get matching files string [] files = tff.Allows(TikUtil.GetFiles()); // display in window foreach (string file in files) { _dw.GotDebug(System.IO.Path.GetFileNameWithoutExtension(file)); } } // notify listeners if (FilterUpdate != null) { FilterUpdate(sender, new EventArgs()); } }
public void Basics() { TickFileFilter tff = new TickFileFilter(new string[] { "GM" }); string[] result = tff.Allows(filenames); Assert.That(result.Length == 1); Assert.That(result[0] == filenames[0]); tff = new TickFileFilter(); tff.DateFilter(20070000, DateMatchType.Year); result = tff.Allows(filenames); Assert.That(result.Length == 3); Assert.That(result[2] == filenames[3]); }
/// <summary> /// Reinitialize the cache /// </summary> public void Initialize() { if (_inited) { return; // only init once } //Clear current data _securityfiles.Clear(); if (_tickfiles.Length == 0) { // get our listings of historical files (idx and epf) string[] files = Directory.GetFiles(_folder, Tickext); _tickfiles = _filter.Allows(files); } _fileInfos = new Dictionary <string, TickFileInfo>(); // get dates for (int i = 0; i < _tickfiles.Length; i++) { _fileInfos.Add(_tickfiles[i], Util.ParseFile(_tickfiles[i])); } // setup our initial index (order all files by dates) _tickfiles = _fileInfos.OrderBy(x => x.Value.Date).Select(x => x.Key).ToArray(); // save index and objects in order _doneindex = _tickfiles.Length - 1; FilesPresent = _tickfiles.Length; FilesProcessed = 0; // initialize initial files (readahead x number of files) InitializeAhead(_cacheahead); // check for event if (GotTick != null) { _hasevent = true; } else { Log.Debug("No GotTick event defined!"); } // read in single tick just to get first time for user Isnexttick(); //Done for now _inited = true; }
/// <summary> /// Reinitialize the cache /// </summary> public void Initialize() { if (_inited) { return; // only init once } //Clear current data _fileInfos.Clear(); if (_tickfiles.Length == 0) { // get our listings of historical files (idx and epf) string[] files = Directory.GetFiles(_folder, Tickext); _tickfiles = _filter.Allows(files); } //Check for cache size if (_tickfiles.Length < _readcache) { _readcache = _tickfiles.Length; } // now we have our list, initialize initial instruments from file for (int i = 0; i < _tickfiles.Length; i++) { _fileInfos.Add(_tickfiles[i], Util.ParseFile(_tickfiles[i])); } // order files according to date _tickfiles = _fileInfos.OrderBy(x => x.Value.Date).Select(x => x.Key).ToArray(); // setup our initial index _currentindex = 0; FilesPresent = _fileInfos.Count; FilesProcessed = 0; // read in single tick just to get first time for user InitializeAhead(_readcache); _inited = true; // set first time as hint for user Setnexttime(); }
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); } }