bool ReadNewQuote() { try { nextQuote = ChimeraDataUtils.GetQuoteTick(quotesReader.ReadLine()); } catch (EndOfStreamException) { _endOfQuoteStream = true; _haveQuote = false; quotesReader.Close(); return(false); } catch (ObjectDisposedException) { _endOfQuoteStream = true; _haveQuote = false; return(false); } catch (System.Exception ex) { _endOfQuoteStream = true; _haveQuote = false; return(false); } _haveQuote = true; return(true); }
bool ReadNewTrade() { try { nextTrade = ChimeraDataUtils.GetTradeTick(this.ReadLine()); } catch (EndOfStreamException) { _endOfTradeStream = true; _haveTrade = false; this.Close(); return(false); } catch (ObjectDisposedException) { _endOfTradeStream = true; _haveTrade = false; return(false); } catch (System.Exception ex) { _endOfTradeStream = true; _haveTrade = false; return(false); } _haveTrade = true; return(true); }
internal void InitCSVReader(int Index, string filepath, bool saveticks, int interval) { var s = ChimeraDataUtils.SecurityFromFileName(filepath); string strQuote = ChimeraDataUtils.QuotePathFromTradePath(filepath); string strNBBO = ChimeraDataUtils.NBBOPathFromTradePath(filepath); trCSV = new CSVtoTikReader(filepath, strQuote, strNBBO, s.symbol, s.Date); if (_saveticks) { ticks = new List <Tick>(trCSV.ApproxTicks); } else { ticks = new List <Tick>(); } _saveticks = saveticks; idx = Index; if (interval == 0) { trCSV.gotTick += new TickDelegate(tr_gotTick); } else { bl = new BarListImpl(trCSV.Symbol, interval, BarInterval.CustomTime); bl.GotNewBar += new SymBarIntervalDelegate(bl_GotNewBar); trCSV.gotTick += new TickDelegate(tr_gotTick2); } }
public CSVtoTikReader(string strTradesPath, string strQuotesPath, string strNbboPath, string sym, int date) : base(new FileStream(strTradesPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { quotesReader = new StreamReader(new FileStream(strQuotesPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); nbboReader = new StreamReader(new FileStream(strNbboPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)); _path = strTradesPath; FileInfo fi = new FileInfo(strTradesPath); ApproxTicks = (int)((double)fi.Length / 39); _realsymbol = sym; _sec = TradeLink.Common.SecurityImpl.Parse(_realsymbol); _sec.Date = ChimeraDataUtils.SecurityFromFileName(_path).Date; // get short symbol _sym = _sec.symbol; ReadHeader(); }
public HistSimIndexPlay(string folder, TickFileFilter tff, int interval, DebugDelegate deb) { if (deb != null) { GotDebug += deb; } _folder = folder + "\\"; // see if we have index string fn; HistSimIndex hsi; debug("getting tickfiles, please wait..."); string[,] total = tff.bUseCSV ? ChimeraDataUtils.TickFileIndex(folder, "*_trades.csv", true) : Util.TickFileIndex(folder, TikConst.WILDCARD_EXT, false); debug("found " + total.GetLength(0).ToString("N0") + " tickfiles"); string[,] filtered = tff.AllowsIndexAndSize(total); debug("post-filter: " + filtered.GetLength(0).ToString("N0") + ", checking for index..."); if (HistSimIndex.HaveIndex(folder, filtered, out fn, deb, tff.bUseCSV)) { debug("index found, starting load: " + fn); hsi = HistSimIndex.FromFile(fn, debug); if (hsi == null) { debug("unable to load index."); return; } hsi.GotDebug += new DebugDelegate(debug); } else if (HistSimIndex.BuildIndex(folder, filtered, out hsi, true, true, interval, debug, tff.bUseCSV)) { debug("Index built successfully, ready to play."); } else { debug("Error building index..."); return; } _reader.DoWork += new DoWorkEventHandler(_reader_DoWork); _reader.WorkerSupportsCancellation = true; myhsi = hsi; hsip_avail = hsi.Playindex.Length; checkindex(); }
/// <summary> /// Allows the specified filepath, if instructed by the filter. /// </summary> /// <param name="filepath">The filepath.</param> /// <returns>true if allowed, false otherwise</returns> public bool Allow(string filepath) { TickFileInfo tfi = bUseCSV ? ChimeraDataUtils.ParseFile(filepath) : Util.ParseFile(filepath); if (tfi.type == TickFileType.Invalid) { return(_allowedinvalid); } // make sure the default is consistent with the set intersection requested bool symallowed = _defallowed; // see if symbols match for (int i = 0; i < namelist.Count; i++) { symallowed |= (tfi.symbol == namelist[i]); } // make sure the default is consistent with the set intersection requested bool dateallowed = _isDateMatchUnion ? _defallowed : !_defallowed; if (_isDateMatchUnion) { for (int i = 0; i < datelist.Count; i++) { dateallowed |= Util.TLDateMatch(Util.ToTLDate(tfi.date), datelist[i].date, datelist[i].type); } } else { for (int i = 0; i < datelist.Count; i++) { dateallowed &= Util.TLDateMatch(Util.ToTLDate(tfi.date), datelist[i].date, datelist[i].type); } } // make sure intersection between dates and symbols is what is desired bool allowed = _isSymDateMatchUnion ? symallowed || dateallowed : symallowed && dateallowed; return(allowed); }