コード例 #1
0
        /// <summary>
        /// serialize a tradelink tick file filter
        /// </summary>
        /// <param name="tff"></param>
        /// <returns></returns>
        public static string Serialize(TickFileFilter tff)
        {
            // save everything as xml
            StringWriter fs;

            try
            {
                XmlSerializer xs = new XmlSerializer(typeof(TickFileFilter));
                fs = new StringWriter();
                xs.Serialize(fs, tff);
                fs.Close();
            }
            catch (FileNotFoundException)
            {
                return(string.Empty);
            }
            catch (Exception)
            {
                return(string.Empty);
            }
            if (fs == null)
            {
                return("");
            }
            return(fs.GetStringBuilder().ToString());
        }
コード例 #2
0
        /// <summary>
        /// gets currently selected filter
        /// </summary>
        /// <returns></returns>
        public TickFileFilter GetFilter()
        {
            TickFileFilter tff = new TickFileFilter();
            // prepare date filter
            List<TickFileFilter.TLDateFilter> datefilter = new List<TickFileFilter.TLDateFilter>();
            if (usedates.Checked)
            {
                for (int j = 0; j < yearlist.SelectedIndices.Count; j++)
                    datefilter.Add(new TickFileFilter.TLDateFilter(Convert.ToInt32(yearlist.Items[yearlist.SelectedIndices[j]]) * 10000, DateMatchType.Year));
                for (int j = 0; j < monthlist.SelectedItems.Count; j++)
                    datefilter.Add(new TickFileFilter.TLDateFilter(Convert.ToInt32(monthlist.Items[monthlist.SelectedIndices[j]]) * 100, DateMatchType.Month));
                for (int j = 0; j < daylist.SelectedItems.Count; j++)
                    datefilter.Add(new TickFileFilter.TLDateFilter(Convert.ToInt32(daylist.Items[daylist.SelectedIndices[j]]), DateMatchType.Day));
            }
            // prepare symbol filter
            List<string> symfilter = new List<string>();
            if (usestocks.Checked)
                for (int j = 0; j < stocklist.SelectedItems.Count; j++)
                    symfilter.Add(stocklist.Items[stocklist.SelectedIndices[j]].ToString());

            // build consolidated filter
            if (usestocks.Checked && usedates.Checked)
                tff = new TickFileFilter(symfilter, datefilter);
            else if (usestocks.Checked)
                tff = new TickFileFilter(symfilter);
            else if (usedates.Checked)
                tff = new TickFileFilter(datefilter);
            // set search options
            tff.isDateMatchUnion = _dateor.Checked;
            tff.isSymbolDateMatchUnion = !_symdateand.Checked;
            //return filter
            return tff;

        }
コード例 #3
0
        /// <summary>
        /// save tickfilefilter to a file
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static TickFileFilter FromFile(string filename)
        {
            StreamReader   sr  = new StreamReader(filename);
            string         msg = sr.ReadToEnd();
            TickFileFilter tff = TickFileFilter.Deserialize(msg);

            return(tff);
        }
コード例 #4
0
ファイル: Replay.cs プロジェクト: sopnic/larytet-master
 static TickFileFilter getfilterdate(int date)
 {
     // create a new filter
     TickFileFilter tff = new TickFileFilter();
     // we dont' select any symbols, so just playback whatever we find on this day
     tff.isSymbolDateMatchUnion = true;
     // populate the filter from user's calendar
     tff.DateFilter(date, DateMatchType.Day | DateMatchType.Month | DateMatchType.Year);
     return tff;
 }
コード例 #5
0
ファイル: MultiSimImpl.cs プロジェクト: antonywu/tradelink
 /// <summary>
 /// Create a historical simulator
 /// </summary>
 /// <param name="TickFolder">tick folder to use</param>
 /// <param name="tff">filter to determine what tick files from folder to use</param>
 public MultiSimImpl(string TickFolder, TickFileFilter tff)
 {
     _folder = TickFolder;
     if (tff != null)
         _filter = tff;
     else
     {
         _filter.DefaultDeny = false;
     }
 }
コード例 #6
0
 public GauntletEngine(TradeLink.API.Response r, TickFileFilter tff)
 {
     _r             = r;
     _r.SendOrder  += new OrderDelegate(_r_SendOrder);
     _r.SendCancel += new UIntDelegate(_r_SendCancel);
     _tff           = tff;
     _h             = new HistSim(_tff);
     _h.GotTick    += new TickDelegate(_h_GotTick);
     _h.SimBroker.GotOrderCancel += new OrderCancelDelegate(SimBroker_GotOrderCancel);
     _h.SimBroker.GotOrder       += new OrderDelegate(_r.GotOrder);
     _h.SimBroker.GotFill        += new FillDelegate(_r.GotFill);
 }
コード例 #7
0
 /// <summary>
 /// restore a filter from a file
 /// </summary>
 /// <param name="tff"></param>
 /// <param name="filename"></param>
 /// <returns></returns>
 public static bool ToFile(TickFileFilter tff, string filename)
 {
     try
     {
         StreamWriter sw = new StreamWriter(filename, false);
         sw.AutoFlush = true;
         sw.WriteLine(TickFileFilter.Serialize(tff));
         sw.Close();
     }
     catch (Exception) { return(false); }
     return(true);
 }
コード例 #8
0
ファイル: GauntletEngine.cs プロジェクト: larytet/JQuant
 public GauntletEngine(TradeLink.API.Response r, TickFileFilter tff)
 {
     _r = r;
     _r.SendOrderEvent  += new OrderSourceDelegate(_r_SendOrder);
     _r.SendCancelEvent += new LongSourceDelegate(_r_SendCancel);
     _tff        = tff;
     _h          = new MultiSimImpl(_tff);
     _h.GotTick += new TickDelegate(_h_GotTick);
     SimBroker.GotOrderCancel += new OrderCancelDelegate(SimBroker_GotOrderCancel);
     SimBroker.GotOrder       += new OrderDelegate(_r.GotOrder);
     SimBroker.GotFill        += new FillDelegate(_r.GotFill);
 }
コード例 #9
0
ファイル: SingleSimImpl.cs プロジェクト: nacht/tradelink
 /// <summary>
 /// Create a historical simulator
 /// </summary>
 /// <param name="TickFolder">tick folder to use</param>
 /// <param name="tff">filter to determine what tick files from folder to use</param>
 public SingleSimImpl(string TickFolder, TickFileFilter tff)
 {
     _folder = TickFolder;
     if (tff != null)
     {
         _filter = tff;
     }
     else
     {
         _filter.DefaultDeny = false;
     }
 }
コード例 #10
0
ファイル: GauntletEngine.cs プロジェクト: antonywu/tradelink
        public GauntletEngine(TradeLink.API.Response r, TickFileFilter tff)
        {
            _r = r;
            _r.SendOrderEvent += new OrderSourceDelegate(_r_SendOrder);
            _r.SendCancelEvent += new LongSourceDelegate(_r_SendCancel);
            _tff = tff;
            _h = new MultiSimImpl(_tff);
            _h.GotTick += new TickDelegate(_h_GotTick);
            SimBroker.GotOrderCancel += new OrderCancelDelegate(SimBroker_GotOrderCancel);
            SimBroker.GotOrder += new OrderDelegate(_r.GotOrder);
            SimBroker.GotFill += new FillDelegate(_r.GotFill);

        }
コード例 #11
0
 public GauntletEngine(TradeLink.API.Response r, TickFileFilter inittff)
 {
     responseengine = r;
     responseengine.SendOrderEvent  += new OrderSourceDelegate(_r_SendOrder);
     responseengine.SendCancelEvent += new LongSourceDelegate(_r_SendCancel);
     responseengine.SendDebugEvent  += new DebugDelegate(_r_SendDebugEvent);
     tff                       = inittff;
     myhistsim                 = new MultiSimImpl(tff);
     myhistsim.GotTick        += new TickDelegate(_h_GotTick);
     SimBroker.GotOrderCancel += new OrderCancelDelegate(SimBroker_GotOrderCancel);
     SimBroker.GotOrder       += new OrderDelegate(responseengine.GotOrder);
     SimBroker.GotFill        += new FillDelegate(responseengine.GotFill);
 }
コード例 #12
0
ファイル: GauntletEngine.cs プロジェクト: antonywu/tradelink
        public GauntletEngine(TradeLink.API.Response r, TickFileFilter tff)
        {
            _r = r;
            _r.SendOrder += new OrderDelegate(_r_SendOrder);
            _r.SendCancel += new UIntDelegate(_r_SendCancel);
            _tff = tff;
            _h = new HistSim(_tff);
            _h.GotTick += new TickDelegate(_h_GotTick);
            _h.SimBroker.GotOrderCancel += new OrderCancelDelegate(SimBroker_GotOrderCancel);
            _h.SimBroker.GotOrder += new OrderDelegate(_r.GotOrder);
            _h.SimBroker.GotFill += new FillDelegate(_r.GotFill);

        }
コード例 #13
0
 public static bool BuildIndex(string folder, TickFileFilter tff, out HistSimIndex hsi, bool start, bool saveidx, int interval, DebugDelegate debug)
 {
     if (debug != null)
     {
         debug("getting tickfiles available, please wait...");
     }
     string[,] allows = Util.TickFileIndex(folder, TikConst.WILDCARD_EXT);
     if (debug != null)
     {
         debug("found " + allows.Length + " tickfiles.");
     }
     return(BuildIndex(folder, allows, tff, out hsi, start, saveidx, interval, debug));
 }
コード例 #14
0
 public static bool BuildIndex(string folder, string[,] tickfiles, TickFileFilter tff, out HistSimIndex hsi, bool start, bool saveidx, int interval, DebugDelegate debug)
 {
     if (debug != null)
     {
         debug("filtering tickfiles...");
     }
     string[,] allows = tff.AllowsIndexAndSize(tickfiles);
     if (debug != null)
     {
         debug("using " + allows.Length + " tickfiles post-filter.");
     }
     return(BuildIndex(folder, allows, out hsi, start, saveidx, interval, debug));
 }
コード例 #15
0
        public void SerializeDeserialize()
        {
            TickFileFilter tff = new TickFileFilter(new string[] { "IBM", "MHS", "T" });
            tff.DateFilter(20070000, DateMatchType.Year);
            tff.isDateMatchUnion = false;
            tff.isSymbolDateMatchUnion = false;
            string msg = TickFileFilter.Serialize(tff);

            TickFileFilter f2 = TickFileFilter.Deserialize(msg);

            string msg2 = TickFileFilter.Serialize(f2);

            Assert.AreEqual(msg, msg2);
            Assert.AreEqual(tff.isDateMatchUnion, f2.isDateMatchUnion);
            Assert.AreEqual(tff.isSymbolDateMatchUnion, f2.isDateMatchUnion);

        }
コード例 #16
0
        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();
        }
コード例 #17
0
 public static bool HaveIndex(string folder, TickFileFilter tff, out string file, DebugDelegate debug)
 {
     if (debug != null)
     {
         debug("getting tickfiles present: " + folder);
     }
     string[,] files = Util.TickFileIndex(folder, TikConst.WILDCARD_EXT);
     if (debug != null)
     {
         debug("got " + files.Length.ToString("N0") + " tickfiles");
     }
     string[,] filtered = tff.AllowsIndexAndSize(files);
     if (debug != null)
     {
         debug("found " + filtered.GetLength(0).ToString("N0") + " files post-filter.");
     }
     return(HaveIndex(folder, filtered, out file, debug));
 }
コード例 #18
0
 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);
 }
コード例 #19
0
        /// <summary>
        /// take a serialized tickfilefilter and convert back to an object
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static TickFileFilter Deserialize(string msg)
        {
            StringReader   fs;
            TickFileFilter tf = null;

            try
            {
                // prepare serializer
                XmlSerializer xs = new XmlSerializer(typeof(TickFileFilter));
                // read in message
                fs = new StringReader(msg);
                // deserialize message
                tf = (TickFileFilter)xs.Deserialize(fs);
                // close serializer
                fs.Close();
            }
            catch (FileNotFoundException) { }
            catch (Exception) { }
            return(tf);
        }
コード例 #20
0
        /// <summary>
        /// gets currently selected filter
        /// </summary>
        /// <returns></returns>
        public TickFileFilter GetFilter()
        {
            // prepare date filter
            List <TickFileFilter.TLDateFilter> datefilter = new List <TickFileFilter.TLDateFilter>();

            if (usedates.Checked)
            {
                for (int j = 0; j < yearlist.SelectedIndices.Count; j++)
                {
                    datefilter.Add(new TickFileFilter.TLDateFilter(Convert.ToInt32(yearlist.Items[yearlist.SelectedIndices[j]]) * 10000, DateMatchType.Year));
                }
                for (int j = 0; j < monthlist.SelectedItems.Count; j++)
                {
                    datefilter.Add(new TickFileFilter.TLDateFilter(Convert.ToInt32(monthlist.Items[monthlist.SelectedIndices[j]]) * 100, DateMatchType.Month));
                }
                for (int j = 0; j < daylist.SelectedItems.Count; j++)
                {
                    datefilter.Add(new TickFileFilter.TLDateFilter(Convert.ToInt32(daylist.Items[daylist.SelectedIndices[j]]), DateMatchType.Day));
                }
            }
            // prepare symbol filter
            List <string> symfilter = new List <string>();

            if (usestocks.Checked)
            {
                for (int j = 0; j < stocklist.SelectedItems.Count; j++)
                {
                    symfilter.Add(stocklist.Items[stocklist.SelectedIndices[j]].ToString());
                }
            }

            // build consolidated filter
            TickFileFilter tff = new TickFileFilter(symfilter, datefilter);

            // set search options
            tff.isDateMatchUnion       = _dateor.Checked;
            tff.isSymbolDateMatchUnion = !_symdateand.Checked;
            //return filter
            return(tff);
        }
コード例 #21
0
 public void Basics()
 {
     // build a one symbol filter
     TickFileFilter tff = new TickFileFilter(new string[] { "GM" });
     // get results from above data files
     string[] result = tff.Allows(filenames);
     // make sure both files for this symbol match
     Assert.AreEqual(2,result.Length);
     // make sure the actual file names are the same
     Assert.AreEqual(result[0],filenames[0]);
     Assert.AreEqual(result[1], filenames[4]);
     // build a new filter
     tff = new TickFileFilter();
     // request all matching files for a given year
     tff.DateFilter(20070000, DateMatchType.Year);
     // do the match
     result = tff.Allows(filenames);
     // make sure we found 3 files from this year
     Assert.AreEqual(3, result.Length);
     // make sure the filename is the same
     Assert.AreEqual(filenames[3], result[2]);
 }
コード例 #22
0
ファイル: HistSim.cs プロジェクト: antonywu/tradelink
 /// <summary>
 /// Create a historical simulator
 /// </summary>
 /// <param name="tff"></param>
 public HistSim(TickFileFilter tff) : this(Util.TLTickDir, tff) { }
コード例 #23
0
ファイル: Gauntlet.cs プロジェクト: antonywu/tradelink
        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;
            }

            
        }
コード例 #24
0
 /// <summary>
 /// checks whether we already have an index built for a given pre-filtered data set
 /// </summary>
 /// <param name="folder"></param>
 /// <param name="tff"></param>
 /// <param name="file"></param>
 /// <returns></returns>
 public static bool HaveIndex(string folder, TickFileFilter tff, out string file)
 {
     return(HaveIndex(folder, tff, out file, null));
 }
コード例 #25
0
ファイル: HistSimIndex.cs プロジェクト: bluejack2000/core
        public static bool HaveIndex(string folder, TickFileFilter tff, out string file, DebugDelegate debug)
        {
            if (debug != null)
                debug("getting tickfiles present: " + folder);
            string[,] files = Util.TickFileIndex(folder, TikConst.WILDCARD_EXT);
            if (debug!=null)
                debug("got "+files.Length.ToString("N0")+" tickfiles");
            string[,] filtered = tff.AllowsIndexAndSize(files);
            if (debug != null)
                debug("found " + filtered.GetLength(0).ToString("N0") + " files post-filter.");
            return HaveIndex(folder, filtered, out file, debug);

        }
コード例 #26
0
ファイル: Replay.cs プロジェクト: bluejack2000/core
 private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
 {
     // set the filter on the simulator
     FileFilter = getfilterdate(Util.ToTLDate(monthCalendar1.SelectionEnd));
 }
コード例 #27
0
ファイル: HistSimMemory.cs プロジェクト: bluejack2000/core
 public HistSimMemory(string folder, TickFileFilter tff)
     : base(folder, tff,0, null)
 { }
コード例 #28
0
ファイル: GauntletEngine.cs プロジェクト: bluejack2000/core
        public GauntletEngine(TradeLink.API.Response r, TickFileFilter inittff)
        {
            responseengine = r;
            responseengine.SendOrderEvent += new OrderSourceDelegate(_r_SendOrder);
            responseengine.SendCancelEvent += new LongSourceDelegate(_r_SendCancel);
            responseengine.SendDebugEvent += new DebugDelegate(_r_SendDebugEvent);
            tff = inittff;
            myhistsim = new MultiSimImpl(tff);
            myhistsim.GotTick += new TickDelegate(_h_GotTick);
            SimBroker.GotOrderCancel += new OrderCancelDelegate(SimBroker_GotOrderCancel);
            SimBroker.GotOrder += new OrderDelegate(responseengine.GotOrder);
            SimBroker.GotFill += new FillDelegate(responseengine.GotFill);

        }
コード例 #29
0
ファイル: HistSimIndex.cs プロジェクト: bluejack2000/core
 /// <summary>
 /// get index from a set of tick files given a filter and starts indexing
 /// </summary>
 /// <param name="folder"></param>
 /// <param name="tff"></param>
 /// <param name="hsi"></param>
 /// <returns></returns>
 public static bool BuildIndex(string folder, TickFileFilter tff, out HistSimIndex hsi) { return BuildIndex(folder, tff, out hsi, true, true, 0,null); }
コード例 #30
0
ファイル: HistSimIndex.cs プロジェクト: bluejack2000/core
        public static bool BuildIndex(string folder, TickFileFilter tff, out HistSimIndex hsi,int interval,DebugDelegate debug)
        {
            if (debug != null)
                debug("getting tickfiles available, please wait...");
            string[,] allows = Util.TickFileIndex(folder, TikConst.WILDCARD_EXT);
            if (debug != null)
                debug("found " + allows.Length + " tickfiles.");

            return BuildIndex(folder,allows, tff,out hsi, true,true,interval,debug);
        }
コード例 #31
0
ファイル: HistSimIndex.cs プロジェクト: bluejack2000/core
 /// <summary>
 /// gets index from set of tick files and starts indexing
 /// </summary>
 /// <param name="tickfiles"></param>
 /// <param name="tff"></param>
 /// <param name="hsi"></param>
 /// <param name="start"></param>
 /// <returns></returns>
 public static bool BuildIndex(string folder, string[,] tickfiles, TickFileFilter tff, out HistSimIndex hsi) { return BuildIndex(folder, tickfiles, tff,out hsi,0, null); }
コード例 #32
0
ファイル: SingleSimImpl.cs プロジェクト: nacht/tradelink
 /// <summary>
 /// Create a historical simulator
 /// </summary>
 /// <param name="tff"></param>
 public SingleSimImpl(TickFileFilter tff) : this(Util.TLTickDir, tff)
 {
 }
コード例 #33
0
ファイル: Replay.cs プロジェクト: antonywu/tradelink
 private void monthCalendar1_DateSelected(object sender, DateRangeEventArgs e)
 {
     // create a new filter
     TickFileFilter tff = new TickFileFilter();
     // populate the filter from user's calendar
     tff.DateFilter(Util.ToTLDate(monthCalendar1.SelectionEnd), DateMatchType.Day | DateMatchType.Month | DateMatchType.Year);
     // set the filter on the simulator
     h.FileFilter = tff;
 }
コード例 #34
0
 /// <summary>
 /// get index from a set of tick files given a filter
 /// </summary>
 /// <param name="folder"></param>
 /// <param name="tff"></param>
 /// <param name="hsi"></param>
 /// <returns></returns>
 public static bool BuildIndex(string folder, TickFileFilter tff, out HistSimIndex hsi, bool start)
 {
     return(BuildIndex(folder, tff, out hsi, start, true, 0, null));
 }
コード例 #35
0
ファイル: HistSim.cs プロジェクト: michaelwills/tradelink
 /// <summary>
 /// Create a historical simulator
 /// </summary>
 /// <param name="tff"></param>
 public HistSim(TickFileFilter tff) : this(Util.TLTickDir, tff)
 {
 }
コード例 #36
0
 /// <summary>
 /// create a player from some tickdata, attempt to create index if not present
 /// </summary>
 /// <param name="folder"></param>
 /// <param name="tff"></param>
 public HistSimIndexPlay(string folder, TickFileFilter tff) : this(folder, tff, 0, null)
 {
 }
コード例 #37
0
ファイル: HistSimIndexPlay.cs プロジェクト: bluejack2000/core
        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 = 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))
            {
                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))
            {
                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();

        }
コード例 #38
0
ファイル: HistSimMemory.cs プロジェクト: bluejack2000/core
 public HistSimMemory(string folder, TickFileFilter tff,DebugDelegate deb)
     : base(folder, tff,0,deb)
 {
 }
コード例 #39
0
ファイル: HistSimIndex.cs プロジェクト: bluejack2000/core
 /// <summary>
 /// checks whether we already have an index built for a given pre-filtered data set
 /// </summary>
 /// <param name="folder"></param>
 /// <param name="tff"></param>
 /// <param name="file"></param>
 /// <returns></returns>
 public static bool HaveIndex(string folder, TickFileFilter tff, out string file) { return HaveIndex(folder, tff, out file, null); }
コード例 #40
0
ファイル: SingleSimImpl.cs プロジェクト: antonywu/tradelink
 /// <summary>
 /// Create a historical simulator
 /// </summary>
 /// <param name="tff"></param>
 public SingleSimImpl(TickFileFilter tff) : this(Util.TLTickDir, tff) { }
コード例 #41
0
 public HistSimMemory(string folder, TickFileFilter tff)
     : base(folder, tff, 0, null)
 {
 }
コード例 #42
0
ファイル: HistSimIndex.cs プロジェクト: rebider/TradeLinkProj
 /// <summary>
 /// get index from set of tick files given a filter
 /// </summary>
 /// <param name="tickfiles"></param>
 /// <param name="tff"></param>
 /// <param name="hsi"></param>
 /// <returns></returns>
 public static bool BuildIndex(string folder, string[,] tickfiles, TickFileFilter tff, out HistSimIndex hsi, bool start, bool bUseCSV)
 {
     return(BuildIndex(folder, tickfiles, out hsi, start, true, 0, null, bUseCSV));
 }
コード例 #43
0
 public HistSimMemory(string folder, TickFileFilter tff, DebugDelegate deb)
     : base(folder, tff, 0, deb)
 {
 }
コード例 #44
0
ファイル: HistSimIndexPlay.cs プロジェクト: bluejack2000/core
 /// <summary>
 /// create a player from some tickdata, attempt to create index if not present
 /// </summary>
 /// <param name="folder"></param>
 /// <param name="tff"></param>
 public HistSimIndexPlay(string folder, TickFileFilter tff) : this(folder, tff, 0,null) { }
コード例 #45
0
 /// <summary>
 /// gets index from set of tick files and starts indexing
 /// </summary>
 /// <param name="tickfiles"></param>
 /// <param name="tff"></param>
 /// <param name="hsi"></param>
 /// <param name="start"></param>
 /// <returns></returns>
 public static bool BuildIndex(string folder, string[,] tickfiles, TickFileFilter tff, out HistSimIndex hsi)
 {
     return(BuildIndex(folder, tickfiles, tff, out hsi, 0, null));
 }
コード例 #46
0
ファイル: TickFileFilter.cs プロジェクト: bluejack2000/core
        /// <summary>
        /// serialize a tradelink tick file filter
        /// </summary>
        /// <param name="tff"></param>
        /// <returns></returns>
        public static string Serialize(TickFileFilter tff)
        {
            // save everything as xml
            StringWriter fs;
            try
            {
                XmlSerializer xs = new XmlSerializer(typeof(TickFileFilter));
                fs = new StringWriter();
                xs.Serialize(fs, tff);
                fs.Close();
            }
            catch (FileNotFoundException)
            {
                return string.Empty;
            }
            catch (Exception)
            {
                return string.Empty;
            }
            if (fs == null) return "";
            return fs.GetStringBuilder().ToString();

        }
コード例 #47
0
ファイル: HistSimIndex.cs プロジェクト: bluejack2000/core
        public static bool BuildIndex(string folder, string[,] tickfiles, TickFileFilter tff, out HistSimIndex hsi, int interval, DebugDelegate debug)
        {
            if (debug != null)
                debug("filtering tickfiles...");
            string[,] allows = tff.AllowsIndexAndSize(tickfiles);
            if (debug != null)
                debug("using " + allows.Length + " tickfiles post-filter.");

            return BuildIndex(folder,allows, out hsi, true,true,interval,debug);
        }
コード例 #48
0
ファイル: MultiSimImpl.cs プロジェクト: antonywu/tradelink
 /// <summary>
 /// Create a historical simulator
 /// </summary>
 /// <param name="tff"></param>
 public MultiSimImpl(TickFileFilter tff) : this(Util.TLTickDir, tff) { }
コード例 #49
0
ファイル: TickFileFilter.cs プロジェクト: bluejack2000/core
 /// <summary>
 /// restore a filter from a file
 /// </summary>
 /// <param name="tff"></param>
 /// <param name="filename"></param>
 /// <returns></returns>
 public static bool ToFile(TickFileFilter tff, string filename)
 {
     try
     {
         StreamWriter sw = new StreamWriter(filename, false);
         sw.AutoFlush = true;
         sw.WriteLine(TickFileFilter.Serialize(tff));
         sw.Close();
     }
     catch (Exception) { return false; }
     return true;
 }
コード例 #50
0
ファイル: Gauntlet.cs プロジェクト: antonywu/tradelink
 bool SetFilter(string file)
 {
     if (File.Exists(file))
     {
         _filterloc = file;
         _filter = TickFileFilter.FromFile(file);
         D("found filter: " + file);
         return true;
     }
     else D("no filter found: " + file);
     return false;
 }
コード例 #51
0
 /// <summary>
 /// Create a historical simulator
 /// </summary>
 /// <param name="tff"></param>
 public MultiSimImpl(TickFileFilter tff) : this(Util.TLTickDir, tff)
 {
 }