Example #1
0
		internal TradeService() {
			__cQueue = new Queue<ResponseEvent>(64);
			__cCloses = new SimpleBoundList<_TradeInfo>(512);
			__cOpens = new TradeBoundList(64);
			__cTrusts = new TradeBoundList(32);

			__cTimer = new Timer();
			__cTimer.Elapsed += Timer_onElapsed;
			__cTimer.AutoReset = false;
			__cTimer.Interval = 500;
		}
        private void LoadProducts(string dataSource)
        {
            List <AbstractExchange> cExchanges = ProductManager.Manager.Exchanges;

            int iCount = cExchanges.Count;

            if (iCount > 0)
            {
                for (int i = 0; i < iCount; i++)
                {
                    AbstractExchange cExchange = cExchanges[i];

                    int               iIndex        = 0;
                    string            sExchangeName = cExchange.ShortName;
                    ESymbolCategory[] cCategorys    = Enum.GetValues(typeof(ESymbolCategory)) as ESymbolCategory[];
                    foreach (ESymbolCategory cCategory in cCategorys)
                    {
                        List <string> cSymbols = cExchange.GetProductClassify(cCategory);
                        if (cSymbols != null && cSymbols.Count > 0)
                        {
                            ++iIndex;
                            tabControl_Products.TabPages.Add(cCategory.ToString());
                            if (iIndex == __cSources.Count)
                            {
                                SimpleBoundList <_ProductInfo> cList = new SimpleBoundList <_ProductInfo>(cSymbols.Count);
                                cList.AllowSort = true;
                                cList.SetComparers(__cComparison);

                                __cSources.Add(cList);
                            }

                            foreach (string sSymbolId in cSymbols)
                            {
                                AbstractProductProperty cProperty = cExchange.GetProperty(sSymbolId, dataSource);
                                if (cProperty != null)
                                {
                                    _ProductInfo cProductInfo = new _ProductInfo()
                                    {
                                        ProductId    = sSymbolId,
                                        Description  = cProperty.Description,
                                        ExchangeName = sExchangeName
                                    };

                                    __cSources[0].Add(cProductInfo);
                                    __cSources[iIndex].Add(cProductInfo);
                                }
                            }
                        }
                    }
                }
            }
        }
        private void comboDataSources_SelectedIndexChanged(object sender, EventArgs e)
        {
            __cSources[0].Clear();              //清除所有商品資訊(0=所有商品資訊)

            int iCount = __cSources.Count;

            for (int i = iCount - 1; i > 0; i--)
            {
                SimpleBoundList <_ProductInfo> cProducts = __cSources[i];
                cProducts.Clear();                        //清除分類商品資訊

                __cSources.RemoveAt(i);                   //移除分類商品
                tabControl_Products.TabPages.RemoveAt(i); //移除分類商品頁籤
            }

            LoadProducts(comboDataSources.Text);
            RefreshGrid();
        }
		internal void SetParameters(string exchangeName, string dataSource, Product product, AbstractProductProperty property) {
			__sExchangeName = exchangeName;
			__sDataSource = dataSource;
			__cProduct = product;
			__cProperty = property;

			//設定保證金資訊
			sourceCautions = new SimpleBoundList<CautionMoney>(__cProperty.CautionMoneys);
			sourceCautions.AllowNew = true;
			sourceCautions.AllowEdit = true;
			sourceCautions.AllowDelete = true;

			//設定開收盤時間
			sourceSessions = new SimpleBoundList<SessionObject>(__cProperty.Sessions);
			sourceSessions.AllowNew = true;
			sourceSessions.AllowEdit = true;
			sourceSessions.AllowDelete = true;
		}
        internal void SetParameters(string exchangeName, string dataSource, Product product, AbstractProductProperty property)
        {
            __sExchangeName = exchangeName;
            __sDataSource   = dataSource;
            __cProduct      = product;
            __cProperty     = property;

            //設定保證金資訊
            sourceCautions             = new SimpleBoundList <CautionMoney>(__cProperty.CautionMoneys);
            sourceCautions.AllowNew    = true;
            sourceCautions.AllowEdit   = true;
            sourceCautions.AllowDelete = true;

            //設定開收盤時間
            sourceSessions             = new SimpleBoundList <SessionObject>(__cProperty.Sessions);
            sourceSessions.AllowNew    = true;
            sourceSessions.AllowEdit   = true;
            sourceSessions.AllowDelete = true;
        }