コード例 #1
0
ファイル: TTDriver.cs プロジェクト: akamatht/trader_curves
        public IReadOnlyCollection <Instrument> Query(MarketId mktId, ProductType pdtType, string group)
        {
            var qry = new InstrumentCatalog(mktId, pdtType, group, this._dispatcher);
            var evt = qry.Get();

            if (evt != ProductDataEvent.Found)
            {
                throw new Exception("ERROR");
            }
            return(qry.InstrumentList);
        }
コード例 #2
0
        /// <summary>
        /// Subscribe to the instrument catalog for a given product.
        /// </summary>
        /// <param name="product">Product to subscribe to.</param>
        private void subscribeToInstrumentCatalog(Product product)
        {
            if (!m_instrumentCatalogList.ContainsKey(product))
            {
                // Create and start an instrument catalog subscription.
                InstrumentCatalog instrumentCatalog = new InstrumentCatalog(product, Dispatcher.Current);
                instrumentCatalog.OnData += new EventHandler <InstrumentCatalogEventArgs>(instrumentsUpdated);
                instrumentCatalog.GetAsync();

                m_instrumentCatalogList.Add(product, instrumentCatalog);
            }
            else
            {
                updateInstrumentTreeViewNodes(m_instrumentCatalogList[product]);
            }
        }
コード例 #3
0
        IEnumerable <Instrument> GetContracts(MarketId market, ProductType productType, string productCode)
        {
            InstrumentCatalog instruments = new InstrumentCatalog(market, productType, productCode, _dispatcher);
            ProductDataEvent  e           = instruments.Get();

            var subscriptionDetails = $"{market.ToString()} : {productType.ToString()} : {productCode}";

            if (e == ProductDataEvent.Found)
            {
                _log.Info($"Fetched instrument count for '{productCode}': {subscriptionDetails} : {instruments.InstrumentList.Count()}");
                return(instruments.InstrumentList);
            }
            else
            {
                _log.Error($"Failed to fetch intruments for: {subscriptionDetails}");
                return(Enumerable.Empty <Instrument>());
            }
        }
コード例 #4
0
        private void updateInstrumentTreeViewNodes(InstrumentCatalog instrumentCatalog)
        {
            treeViewProductList.BeginUpdate();

            TreeNode updatedNode = null;

            // Find the product in the tree view for the selected product tree view node.
            foreach (TreeNode node in treeViewProductList.Nodes)
            {
                if (String.Equals((node.Tag as Product).Alias, instrumentCatalog.Product.Alias))
                {
                    updatedNode = node;
                    break;
                }
            }

            // updatedNode should never be null.
            if (updatedNode == null)
            {
                return;
            }

            updatedNode.Nodes.Clear();

            // Insert the instruments as child nodes within the product tree view node.
            foreach (Instrument instr in instrumentCatalog.InstrumentList)
            {
                TreeNode node = updatedNode.Nodes.Add(instr.GetFormattedName(InstrumentNameFormat.Normal));

                // Add tooltip text from the Definition
                node.ToolTipText = instr.Name + "\r\n"
                                   + instr.InstrumentDetails.Currency + "\r\n" + instr.InstrumentDetails.TickSize.ToString()
                                   + " / " + instr.InstrumentDetails.TickSize.ToString();

                node.Tag = instr;
            }

            Cursor = Cursors.Default;
            treeViewProductList.EndUpdate();
        }
コード例 #5
0
        private void instrumentsUpdated(object sender, InstrumentCatalogEventArgs e)
        {
            InstrumentCatalog instrumentCatalog = sender as InstrumentCatalog;

            updateInstrumentTreeViewNodes(instrumentCatalog);
        }