public static List <string> GetFilesFromDate(string tickfolder, int date) { string[] files = TickUtil.GetFiles(tickfolder, "*.TXT"); List <string> matching = new List <string>(); foreach (string file in files) { Security sec = Util.SecurityFromFileName(file); string symfix = System.IO.Path.GetFileNameWithoutExtension(sec.FullSymbol); //if (sec.Date == date) matching.Add(file); } return(matching); }
public bool newTick(Tick t) { if (_stopped) { return(false); } if ((t.FullSymbol == null) || (t.FullSymbol == "")) { return(false); } TickWriter tw; // prepare last date of tick int lastdate = t.Date; lastdate = _datedict.GetOrAdd(t.FullSymbol, t.Date); // see if we need a new day bool samedate = lastdate == t.Date; // see if we have stream already bool havestream = _filedict.TryGetValue(t.FullSymbol, out tw); // if no changes, just save tick if (samedate && havestream) { try { tw.newTick((Tick)t); return(true); } catch (IOException) { return(false); } } else { try { // if new date, close stream if (!samedate) { try { tw.Close(); } catch (IOException) { } } // ensure file is writable string file = Util.SafeFilename(t.FullSymbol, _folderpath, t.Date); if (TickUtil.IsFileWritetable(file)) { // open new stream tw = new TickWriter(_folderpath, t.FullSymbol, t.Date); // save tick tw.newTick((Tick)t); // save stream if (!havestream) { _filedict.Add(t.FullSymbol, tw); } else { _filedict[t.FullSymbol] = tw; } // save date if changed if (!samedate) { _datedict[t.FullSymbol] = t.Date; } } } catch (IOException) { return(false); } catch (Exception) { return(false); } } return(false); }