コード例 #1
0
ファイル: Quote.cs プロジェクト: blueysnow/cj-at-project
 void tl_gotTick(Tick t)
 {
     try
     {
         _tlt.newTick(t);
         _kt.newTick(t);
         if (spillTick != null)
         {
             spillTick(t);
         }
         RefreshRow(t);
         BarList bl = null;
         if (bardict.TryGetValue(t.symbol, out bl))
         {
             if (SecurityImpl.Parse(t.symbol).Type == SecurityType.CASH)
             {
                 Tick    k = _kt[t.symbol];
                 decimal p = usebidonfx ? k.bid : k.ask;
                 int     s = usebidonfx ? k.bs : k.os;
                 bardict[t.symbol].newPoint(t.symbol, p, k.time, k.date, s);
             }
             else
             {
                 bardict[t.symbol].newTick(t);
             }
         }
     }
     catch (System.Threading.ThreadInterruptedException) { }
 }
コード例 #2
0
ファイル: TikReader.cs プロジェクト: mpvyard/Core
        /// <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;
        }
コード例 #3
0
        public void Parsing()
        {
            // tests to parse and generate user-supplied security specifiers
            SecurityImpl nyse = new SecurityImpl("LVS");
            string       p    = nyse.ToString();

            SecurityImpl t = SecurityImpl.Parse(p);

            Assert.That(t.Symbol == nyse.Symbol, t.Symbol);
            Assert.That(!t.hasDest, t.DestEx);
            Assert.That(t.Type == nyse.Type, t.Type.ToString());

            SecurityImpl crude = SecurityImpl.Parse("CLV8 FUT GLOBEX");

            Assert.That(crude.Symbol == "CLV8", crude.Symbol);
            Assert.That(crude.hasDest, crude.DestEx);
            Assert.That(crude.Type == SecurityType.FUT, crude.Type.ToString());
            SecurityImpl goog = SecurityImpl.Parse("GOOG");

            Assert.AreEqual("GOOG", goog.FullName);

            Security opt = SecurityImpl.Parse("IBM PUT 201004 100.00");

            Assert.That(opt.Type == SecurityType.OPT);
            Assert.AreEqual(100, opt.Strike);
            Assert.AreEqual("PUT", opt.Details);
            Assert.AreEqual(201004, opt.Date);
        }
コード例 #4
0
ファイル: Quote.cs プロジェクト: blueysnow/cj-at-project
        bool addsymbol(string sym, bool dosubscribe)
        {
            Security sec = SecurityImpl.Parse(sym);

            try
            {
                // SYM,LAST,TSIZE,BID,ASK,BSIZE,ASIZE,SIZES,OHLC(YEST),CHANGE
                DataRow r = qt.Rows.Add(sym, "", "", "", "", "", "", "", "", "", "", "");
                qt.Rows[qt.Rows.Count - 1][AVGPRICE] = pt[sym].AvgPrice;
                qt.Rows[qt.Rows.Count - 1][POSSIZE]  = pt[sym].Size;
                qt.Rows[qt.Rows.Count - 1][CLOSEDPL] = pt[sym].ClosedPL;
            }
            catch { }

            if (!bardict.ContainsKey(sec.FullName))
            {
                bardict.Add(sec.FullName, new BarListImpl(sym));
            }
            status("Added " + sym);
            if (!hassym(sym))
            {
                mb.Add(sym);
            }
            symindex();
            if (dosubscribe)
            {
                return(subscribe());
            }
            return(true);
        }
コード例 #5
0
ファイル: HistorySimImpl.cs プロジェクト: w1r2p1/Core-1
        private SecurityImpl getsec(string file)
        {
            try
            {
                //Check if file contains a zip definition
                if (file.ToLower().Contains("zip"))
                {
                    //Get zip file and tik file from filename
                    string[] parts    = file.ToLower().Split('\\');
                    string   tickfile = parts.Skip(parts.Length - 1).First();
                    string   zipfile  = string.Join(@"\", parts.Take(parts.Length - 1));

                    return(SecurityImpl.FromZIP(zipfile, tickfile));
                }
                else
                {
                    return(SecurityImpl.FromTIK(file));
                }
            }
            catch (Exception ex)
            {
                debug("error reading TIK file: " + file + " err: " + ex.Message + ex.StackTrace);
                return(null);
            }
        }
コード例 #6
0
ファイル: SingleSimImpl.cs プロジェクト: w1r2p1/Core-1
        private void InitializeAhead(int files)
        {
            if (_currentindex + files > _doneindex)
            {
                files = _doneindex - _currentindex + 1;
            }

            // now we have our list, initialize instruments from files
            for (int i = _currentindex; i < files + _currentindex; i++)
            {
                SecurityImpl s = getsec(i);
                if ((s != null) && s.IsValid && s.HistSource.IsValid)
                {
                    s.HistSource.GotTick += HistSource_gotTick;
                    _securityfiles.Add(s);
                }
            }

            // log currently read files
            int ticksfound = _securityfiles.Skip(_securityfiles.Count - files).Sum(x => x.ApproxTicks);

            _availticks += ticksfound;

            //Dispose and clear memory by removing old and unused files
            if (_currentindex > 0)
            {
                CloseUnusedReaders(_currentindex - files, _currentindex - 1);
            }
        }
コード例 #7
0
ファイル: Quote.cs プロジェクト: blueysnow/cj-at-project
 void symindex()
 {
     for (int i = 0; i < qt.Rows.Count; i++)
     {
         if (qt.Rows[i].RowState == DataRowState.Deleted)
         {
             continue;
         }
         Security sec = SecurityImpl.Parse(qt.Rows[i]["Symbol"].ToString());
         string   sym = sec.Symbol;
         if (!symidx.ContainsKey(sec.FullName)) // if we've not seen this symbol add it's index
         {
             symidx.Add(sec.FullName, new int[] { i });
         }
         else
         {
             // otherwise create a new array with an extra spot
             int[] newidx = new int[symidx[sec.FullName].Length + 1];
             // copy the old indicies in
             symidx[sec.FullName].CopyTo(newidx, 0);
             // save this latest index
             newidx[symidx[sec.FullName].Length] = i;
             // replace the old with the new
             symidx[sec.FullName] = newidx;
         }
     }
 }
コード例 #8
0
ファイル: Quote.cs プロジェクト: blueysnow/cj-at-project
        int[] GetSymbolRows(string sym)
        {
            int[] res = new int[0];
            if (symidx.TryGetValue(sym, out res))
            {
                return(res);
            }
            List <int> rows = new List <int>();

            for (int i = 0; i < qt.Rows.Count; i++)
            {
                if (qt.Rows[i].RowState == DataRowState.Deleted)
                {
                    continue;
                }
                Security sec  = SecurityImpl.Parse(qt.Rows[i]["Symbol"].ToString());
                Security csec = SecurityImpl.Parse(sym);
                if (sec.Symbol == csec.Symbol)
                {
                    rows.Add(i);
                }
            }

            return(rows.ToArray());
        }
コード例 #9
0
ファイル: TnS.cs プロジェクト: rebider/TradeLinkProj
        void LoadEPF(string file)
        {
            SecurityImpl s;

            try
            {
                _dt.Clear();
                s = SecurityImpl.FromTIK(file);
                if (s.Type == SecurityType.CASH)
                {
                    _dp = 5;
                }
                total  = s.ApproxTicks;
                symbol = s.symbol;
                date   = s.Date;
            }
            catch (Exception ex)
            {
                debug("error opening: " + file + " err: " + ex.Message + ex.StackTrace);
                status("Error.  Is file closed?");
                return;
            }
            if (!bw.IsBusy)
            {
                bw.RunWorkerAsync(s);
            }
            else
            {
                status("try again.");
            }
        }
コード例 #10
0
ファイル: TestStock.cs プロジェクト: michaelwills/tradelink
        public void Basics()
        {
            SecurityImpl s = new SecurityImpl("");

            Assert.That(s != null);
            Assert.That(!s.isValid);
            s = new SecurityImpl("TST");
            Assert.That(s.isValid);
        }
コード例 #11
0
        private void UpdateSecurity(Tick t, SecurityImpl sec)
        {
            if (sec == null || !t.IsValid)
            {
                return;
            }

            //Set bid ask
            sec.Bid = t.Bid;
            sec.Ask = t.Ask;

            //Set spread information
            if (t.IsFullQuote)
            {
                sec.Spread = (int)((double)(t.Ask - t.Bid) * Math.Pow(10, sec.Digits));
            }

            //Set pip value
            string conversionsymbol = Util.GetPipValueSymbolCrosses(CurrencyType.USD, sec);

            if (_priceinformation.ContainsKey(conversionsymbol) && sec.Type == SecurityType.Forex)
            {
                //get current price based on tick received
                decimal price = _priceinformation[conversionsymbol].IsFullQuote ? _priceinformation[conversionsymbol].Bid : _priceinformation[conversionsymbol].Trade;

                //convert to pip value
                sec.PipValue = sec.PipSize / price * sec.ContractSize;
            }
            else if (sec.Type == SecurityType.CFD)
            {
                //get current price based on tick received
                decimal price = 1;
                if (conversionsymbol != "USDUSD")
                {
                    price = _priceinformation[conversionsymbol].IsFullQuote ? _priceinformation[conversionsymbol].Bid : _priceinformation[conversionsymbol].Trade;
                }

                //convert to pip value (depending on the info that we have of this security)
                if (sec.ContractSize > 1 && sec.TickValue > 0) //CFD has a tickvalue and a contract size
                {
                    sec.PipValue = (1M / sec.TickSize) * sec.TickValue;
                }
                else if (sec.ContractSize > 1 || sec.TickValue == 0) //CFD has no tickvalue
                {
                    sec.PipValue = (1M / sec.TickSize) * price * (sec.ContractSize * sec.TickSize);
                }
                else
                {
                    sec.PipValue = ((1M / sec.TickSize) * sec.TickValue) / price;
                }
            }
            else if (conversionsymbol == "USDUSD")
            {
                sec.PipValue = 10 * (sec.LotSize / 100000M);
            }
        }
コード例 #12
0
ファイル: Quote.cs プロジェクト: blueysnow/cj-at-project
        Security GetVisibleSecurity(int row)
        {
            if ((row < 0) || (row >= qg.Rows.Count))
            {
                return(new SecurityImpl());
            }
            Security s = SecurityImpl.Parse(qt.Rows[row]["Symbol"].ToString());

            return(s);
        }
コード例 #13
0
ファイル: RecordMain.cs プロジェクト: michaelwills/tradelink
        private void recordbut_Click(object sender, EventArgs e)
        {
            int          size = mb.Count;
            SecurityImpl sec  = SecurityImpl.Parse(symbox.Text);

            if (sec.isValid)
            {
                mb.Add(sec);
            }
            refreshlist(size);
        }
コード例 #14
0
        public void OptionOSIParse()
        {
            string   osi = "YHOO100416C00020000";
            Security sec = new SecurityImpl();

            Assert
            .IsTrue(SecurityImpl.ParseOptionOSI(osi, ref sec, rt.d), "parsing osi had an error");
            Assert.AreEqual("YHOO", sec.Symbol, "symbol incorrect");
            Assert.AreEqual(20100416, sec.Date, "date incorrect");
            Assert.AreEqual(20, sec.Strike, "strike incorrect");
            Assert.IsTrue(sec.isCall, "not a call");
        }
コード例 #15
0
        void workingres_SendOrder(Order o)
        {
            // process order coming from a response

            // set account on order
            if (o.Account == string.Empty)
            {
                o.Account = _ao._account.Text;
            }
            try
            {
                // set the security
                if (o.Security == SecurityType.NIL)
                {
                    o.Security = _seclist[o.symbol].Type;
                }
                // set the exchange
                if (o.Exchange == string.Empty)
                {
                    o.Exchange = _seclist[o.symbol].DestEx;
                }
            }
            catch (KeyNotFoundException)
            {
                string       sym = SecurityImpl.Parse(o.symbol).Symbol;
                SecurityImpl sec = null;
                if (_seclist.TryGetValue(sym, out sec))
                {
                    o.Security = sec.Type;
                    o.Exchange = sec.DestEx;
                }
                else
                {
                    debug("security and exchange missing on: " + o.symbol);
                }
            }
            // set the local symbol
            if (o.LocalSymbol == string.Empty)
            {
                o.LocalSymbol = o.symbol;
            }
            // assign master order if necessary
            assignmasterorderid(ref o);
            // send order and get error message
            int res = tl.SendOrder(o);

            // if error, display it
            if (res != (int)MessageTypes.OK)
            {
                debug(Util.PrettyError(tl.BrokerName, res) + " " + o.ToString());
            }
        }
コード例 #16
0
ファイル: HistorySimImpl.cs プロジェクト: w1r2p1/Core-1
        /// <summary>
        /// Reinitialize the cache
        /// </summary>
        public void Initialize()
        {
            if (initialized)
            {
                return;              // only init once
            }
            // now we have our list, initialize instruments from files
            if (this.datafiles.Length == 0)
            {
                for (int i = 0; i < _tickfiles.Length; i++)
                {
                    try
                    {
                        SecurityImpl s = getsec(i);
                        if ((s != null) && s.isValid && s.HistSource.isValid)
                        {
                            Workers.Add(new SimWorker(s));
                        }
                    }
                    catch (Exception ex)
                    {
                        debug("Unable to initialize: " + _tickfiles[i] + " error: " + ex.Message + ex.StackTrace);
                        continue;
                    }
                }
            }

            // setup our initial index
            idx  = genidx(Workers.Count);
            cidx = new int[Workers.Count];

            debug("Initialized " + (_tickfiles.Length) + " instruments.");
            debug(string.Join(Environment.NewLine.ToString(), _tickfiles));
            // read in single tick just to get first time for user
            FillCache(1);

            // get total ticks represented by files
            _availticks = 0;
            for (int i = 0; i < Workers.Count; i++)
            {
                if (Workers[i].workersec != null)
                {
                    _availticks += Workers[i].workersec.ApproxTicks;
                }
            }

            debug("Approximately " + TicksPresent + " ticks to process...");
            _inited = true;
            // set first time as hint for user
            setnexttime();
        }
コード例 #17
0
ファイル: TikUtil.cs プロジェクト: w1r2p1/Core-1
 /// <summary>
 /// converts EPF files to tick files in current directory
 /// </summary>
 /// <param name="args"></param>
 public static void Epf2Tik(string[] args)
 {
     // get a list of epf files
     foreach (string file in args)
     {
         SecurityImpl sec = SecurityImpl.FromTik(file);
         sec.HistSource.GotTick += HistSource_gotTick;
         _tw = new TikWriter(sec.Name);
         while (sec.NextTick())
         {
             _tw.Close();
         }
     }
 }
コード例 #18
0
        public void OptionSec2OSI()
        {
            string   osi1 = "YHOO100416C00020000";
            string   osi2 = "AAPL 111022P420000";
            Security sec  = new SecurityImpl();

            Assert
            .IsTrue(SecurityImpl.ParseOptionOSI(osi1, ref sec, rt.d), "parsing osi1 had an error");
            Assert.AreEqual("YHOO 100416C20000", SecurityImpl.ToOSISymbol(sec), "converting to osi1 failed");

            Assert
            .IsTrue(SecurityImpl.ParseOptionOSI(osi2, ref sec, rt.d), "parsing osi2 had an error");
            Assert.AreEqual("AAPL 111022P420000", SecurityImpl.ToOSISymbol(sec), "converting to osi2 failed");
        }
コード例 #19
0
ファイル: BarListImpl.cs プロジェクト: w1r2p1/Core-1
        /// <summary>
        /// create barlist from a tik file using given intervals/types
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="uselast"></param>
        /// <param name="usebid"></param>
        /// <param name="intervals"></param>
        /// <param name="types"></param>
        /// <returns></returns>
        public static BarList FromTIK(string filename, bool uselast, bool usebid, int[] intervals, BarInterval[] types)
        {
            _uselast = uselast;
            _usebid  = usebid;
            SecurityImpl s = SecurityImpl.FromTik(filename);

            s.HistSource.GotTick += HistSource_gotTick;
            _fromepf              = new BarListImpl(s.Name, intervals, types);
            while (s.HistSource.NextTick())
            {
                ;
            }
            return(_fromepf);
        }
コード例 #20
0
        public bool Start(HostControl hostControl)
        {
            var runtime = _config.GetConfigSection("HareShowRuntimeSettings/EventTrigger");

            // TODO: get start datetime from app.config
            DateTime startDateTime;

            if (string.IsNullOrWhiteSpace(runtime.Get("startDateTime")))
            {
                startDateTime = DateTime.Now;
            }
            else
            {
                if (!DateTime.TryParse(runtime.Get("startDateTime"), out startDateTime))
                {
                    // TODO: if the start datetime is bad then throw an exception here
                }
            }

            // TODO: get interval from app.config
            TimeSpan interval;

            if (!TimeSpan.TryParse(runtime.Get("runInterval"), out interval))
            {
                // TODO: if the interval time is bad then throw an exception here
            }

            // TODO: get username and password from app.config
            var hareDuCredentials = _config.GetConfigSection("HareDuSettings/Login");

            if (string.IsNullOrWhiteSpace(hareDuCredentials.Get("username")) ||
                string.IsNullOrWhiteSpace(hareDuCredentials.Get("password")))
            {
                throw new UserCredentialsInvalidException(
                          "Not able to connect to RabbitMQ because username or password is invalid.");
            }

            string username = hareDuCredentials.Get("username");
            string password = hareDuCredentials.Get("password");

            _scheduler.Schedule <QueueMonitorJob>(Guid.NewGuid(), new DateTimeOffset(startDateTime), interval, username, password);
            var monitor  = new QueueMonitor(_client);
            var security = new SecurityImpl();

            _scheduler.JobFactory = new HareShowJobFactory <IQueueMonitor, ISecurity, QueueMonitorJob>(monitor, security);
            _scheduler.Start();

            return(true);
        }
コード例 #21
0
ファイル: BarListImpl.cs プロジェクト: w1r2p1/Core-1
        /// <summary>
        /// get a barlist from tick data and optionally use bid/ask data to construct bars
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="uselast"></param>
        /// <param name="usebid"></param>
        /// <returns></returns>
        public static BarList FromTIK(string filename, bool uselast, bool usebid)
        {
            _uselast = uselast;
            _usebid  = usebid;
            SecurityImpl s = SecurityImpl.FromTik(filename);

            s.HistSource.GotTick += HistSource_gotTick;
            _fromepf              = new BarListImpl(s.Name);
            while (s.HistSource.NextTick())
            {
                ;
            }
            s.HistSource.Close();
            return(_fromepf);
        }
コード例 #22
0
ファイル: TnS.cs プロジェクト: zli69/tradelink
        void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            SafeBindingSource.refreshgrid(_dg, _bs, false);
            SecurityImpl s = (SecurityImpl)e.Argument;

            s.HistSource.gotTick += new TickDelegate(HistSource_gotTick);
            line = 0;
            while (s.HistSource.NextTick() && !bw.CancellationPending)
            {
                ;
            }

            status(headline + " (cleaning up)");
            s.HistSource.Close();
        }
コード例 #23
0
 public SimWorker(SecurityImpl sec)
 {
     Workersec = sec;
     WorkerSupportsCancellation = true;
     RunWorkerCompleted        += simworker_RunWorkerCompleted;
     // if we're multi-core prepare to start I/O thread for this security
     if (Environment.ProcessorCount > 1)
     {
         DoWork += simworker_DoWork;
         Workersec.HistSource.GotTick += HistSource_gotTick2;
     }
     else
     {
         Workersec.HistSource.GotTick += HistSource_gotTick;
     }
 }
コード例 #24
0
ファイル: TestUtil.cs プロジェクト: michaelwills/tradelink
        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));
        }
コード例 #25
0
ファイル: KadinaMain.cs プロジェクト: larytet/JQuant
        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);
        }
コード例 #26
0
        public void Parsing()
        {
            // tests to parse and generate user-supplied security specifiers
            SecurityImpl nyse = new SecurityImpl("LVS");
            string p = nyse.ToString();

            SecurityImpl t = SecurityImpl.Parse(p);
            Assert.True(t.Name == nyse.Name, t.Name);
            Assert.True(t.Type == nyse.Type, t.Type.ToString());

            SecurityImpl crude = SecurityImpl.Parse("CLV8 FUT GLOBEX");
            Assert.True(crude.Name == "CLV8", crude.Name);
            Assert.True(crude.HasDest, crude.DestEx);
            Assert.True(crude.Type == SecurityType.Future, crude.Type.ToString());
            SecurityImpl goog = SecurityImpl.Parse("GOOG");
            Assert.Equal("GOOG", goog.Name);
        }
コード例 #27
0
        /// <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);
        }
コード例 #28
0
        void tl_newRegisterSymbols(string client, string symbols)
        {
            if (VerboseDebugging)
            {
                debug("client subscribe request received: " + symbols);
            }

            Basket rem = new BasketImpl();

            // if we had something before, check if something was removed
            if (org.Count > 0)
            {
                rem = BasketImpl.Subtract(org, tl.AllClientBasket);
            }

            SubscriptionFlags flags = SubscriptionFlags.Prints;

            flags |= SubscriptionFlags.Quotes;
            flags |= SubscriptionFlags.Best;

            List <string> syms = new List <string>();

            syms.AddRange(tl.AllClientBasket.ToSymArray());

            List <string> orgs = new List <string>(org.ToSymArray());

            // add current
            foreach (string sym in tl.AllClientBasket.ToSymArray())
            {
                // subscribe what we don't have
                if (!orgs.Contains(sym))
                {
                    // get the security
                    Security sec = SecurityImpl.Parse(sym);
                    string   ex  = sec.hasDest ? sec.DestEx : "NYSE";
                    oEngine.subscribe(ex, sec.Symbol, flags, null);
                }
            }

            // remove old
            foreach (Security s in rem)
            {
                oEngine.unsubscribe(string.Empty, s.Symbol);
            }
        }
コード例 #29
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);
                 }
             }
         }
     }
 }
コード例 #30
0
ファイル: TestBasket.cs プロジェクト: michaelwills/tradelink
        public void Serialization()
        {
            BasketImpl mb = new BasketImpl();

            mb.Add(new SecurityImpl("IBM"));
            BasketImpl compare = BasketImpl.Deserialize(mb.ToString());

            Assert.That(compare.Count == 1);
            mb.Clear();
            compare = BasketImpl.Deserialize(mb.ToString());
            Assert.That(compare.Count == 0);

            mb.Clear();
            SecurityImpl longform = SecurityImpl.Parse("CLZ8 FUT NYMEX");

            mb.Add(longform);
            compare = BasketImpl.Deserialize(mb.ToString());
            Assert.AreEqual(longform.ToString(), compare[0].ToString());
        }
コード例 #31
0
ファイル: ActorTest.cs プロジェクト: mmitkevich/Snail
		public static void Run()
		{
			//a1();
			//a2();
			//return;

			MicroLog.Writers.Add(new StreamWriter("ActorTest.mlog"));
			//MicroLog.Writers.Clear();
			MicroLog.WhenFull = MicroLog.WhenFullAction.NoCaching;
			var abook = new AddressBook();
			
			var net = new Network();
			
			var implHost = new Host(net, Scheduler.Current);

			var callerHost = new Host(net, Scheduler.Current);
			var delay = new Delay(JOB/2);

			for (int k = 0; k < 4; k++)
			{
				var implBox = new Mailbox(implHost);


				var impl = new SecurityImpl(delay);
				var callerBox = new Mailbox(callerHost);
				var callerImpl = new Caller(callerBox, impl, delay);

				Run("P0C0", callerImpl);

				implBox = new Mailbox(implHost);

				var sec = new Security(implBox, delay);
				var proxy = SecurityProxyFactory.CreateSecurityProxy(sec);
				var callerProxy = new Caller(callerBox, proxy, delay);

				Run("P1C1", callerProxy);
				MicroLog.Info("HaveWorks:{0}", sec.Mailbox.HaveWorks);
//				var q = proxy.Queue;
//				MicroLog.Info("Backtracks {0} {1:F4}% EnqFulls {2} {3:F4}", q.Msgs.Backtrackings,
//								  (double)100 * q.Msgs.Backtrackings / q.Msgs.Tail, q.Msgs.EnqueueFulls, (double)100 * q.Msgs.EnqueueFulls / q.Msgs.Tail);

				Console.ReadKey();
			}
		}