Beispiel #1
0
        /// <summary>
        ///   建立 AbstractProductProperty 淺層覆本
        /// </summary>
        /// <returns>返回值: AbstractProductProperty 類別</returns>
        public AbstractProductProperty Clone()
        {
            AbstractProductProperty cProperty = this.MemberwiseClone() as AbstractProductProperty;

            int iCautionCount             = this.CautionMoneys.Count;
            List <CautionMoney> cCautions = new List <CautionMoney>(iCautionCount + 1);

            cProperty.CautionMoneys = cCautions;

            if (iCautionCount > 0)
            {
                for (int i = 0; i < iCautionCount; i++)
                {
                    cCautions.Add(this.CautionMoneys[i].Clone());
                }
            }

            int iSessionCount = this.Sessions.Count;
            List <SessionObject> cSessions = new List <SessionObject>(iSessionCount + 1);

            cProperty.Sessions = cSessions;

            if (iSessionCount > 0)
            {
                for (int i = 0; i < iSessionCount; i++)
                {
                    cSessions.Add(this.Sessions[i].Clone());
                }
            }
            return(cProperty);
        }
        /// <summary>
        ///   取得商品屬性
        /// </summary>
        /// <param name="symbol">商品來源代號或商品代號</param>
        /// <param name="dataSource">資料來源名稱</param>
        public AbstractProductProperty GetProperty(string symbol, string dataSource = null)
        {
            AbstractProductProperty cProperty = null;

            Product cProduct = GetProduct(symbol);

            if (dataSource != null)
            {
                ProductPropertyList cPropertyList = null;
                if (CustomPropertys.TryGetValue(dataSource, out cPropertyList))
                {
                    if (cProduct == null)
                    {
                        cProperty = cPropertyList.GetProperty(symbol);
                    }
                    else
                    {
                        cProperty = cPropertyList.GetProperty(cProduct);
                    }
                }
            }

            if (cProperty == null)
            {
                if (cProduct == null)
                {
                    cProperty = this.BasePropertys.GetProperty(symbol);
                }
                else
                {
                    cProperty = this.BasePropertys.GetProperty(cProduct);
                }
            }
            return(cProperty);
        }
		internal frmProductRuleSettings(string exchangeName, ERuleType ruleType, AbstractProductProperty property) {
			InitializeComponent();

			__cRuleType = ruleType;
			__cProperty = property;
			
			AbstractExchange cExchange = ProductManager.Manager.GetExchange(exchangeName);
			__cRules = cExchange.GetRuleItems(ruleType);
		}
Beispiel #4
0
		private static _ProductInfo CreateProductInfo(string exchangeName, string dataSource, Product product, AbstractProductProperty property) {
			_ProductInfo cProductInfo = new _ProductInfo() {
				CommodityId = (property == null) ? string.Empty : property.CommodityId,
				Description = (property == null) ? string.Empty : property.Description,
				DataSource = (dataSource == null) ? string.Empty : dataSource,
				ExchangeName = exchangeName,
				ProductId = product.SymbolId,
				ProductName = product.SymbolName
			};
			return cProductInfo;
		}
Beispiel #5
0
        /// <summary>
        ///   取得商品屬性
        /// </summary>
        /// <param name="propertyName">屬性名稱</param>
        /// <returns>返回值:AbstractProductProperty類別</returns>
        public AbstractProductProperty GetProperty(string propertyName)
        {
            AbstractProductProperty cProperty = null;

            if (propertyName != null)
            {
                lock (__cPropertys) {
                    __cPropertys.TryGetValue(propertyName, out cProperty);
                }
            }
            return(cProperty);
        }
        /// <summary>
        ///   新增商品屬性(如果商品已經存在會覆寫之前屬性設定)
        /// </summary>
        /// <param name="property">商品屬性類別</param>
        /// <param name="dataSource">資料來源名稱</param>
        public void AddProperty(AbstractProductProperty property, string dataSource = null)
        {
            if (dataSource == null)
            {
                BasePropertys.AddProperty(property);
            }
            else
            {
                ProductPropertyList cPropertyList = null;

                if (!CustomPropertys.TryGetValue(dataSource, out cPropertyList))
                {
                    cPropertyList = new ProductPropertyList();
                    CustomPropertys.Add(dataSource, cPropertyList);
                }
                cPropertyList.AddProperty(property);
            }
        }
		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;
		}
Beispiel #8
0
        /// <summary>
        ///   取得商品屬性
        /// </summary>
        /// <param name="product">商品類別</param>
        /// <returns>返回值:AbstractProductProperty類別</returns>
        public AbstractProductProperty GetProperty(Product product)
        {
            AbstractProductProperty cProperty = null;

            if (product != null)
            {
                lock (__cPropertys) {
                    __cPropertys.TryGetValue(product.SymbolId, out cProperty);
                    if (cProperty == null)
                    {
                        string sCommodity = product.CommodityId;
                        if (sCommodity != null)
                        {
                            __cPropertys.TryGetValue(sCommodity, out cProperty);
                        }
                    }
                }
            }
            return(cProperty);
        }
		/// <summary>
		///   新增或修改商品屬性(如果商品已經存在會覆寫原本的設定值)
		/// </summary>
		/// <param name="property">商品屬性類別</param>
		public void AddProperty(AbstractProductProperty property) {
			AbstractProductProperty cProperty = null;
			string sCommodityId = property.CommodityId;
			
			lock (__cPropertys) {
				if (__cPropertys.TryGetValue(sCommodityId, out cProperty)) {
					cProperty.BigPointValue = property.BigPointValue;
					cProperty.CautionMoneys = property.CautionMoneys;
					cProperty.CommodityId = property.CommodityId;
					cProperty.ContractRule = property.ContractRule;
					cProperty.DailyLimit = property.DailyLimit;
					cProperty.Description = property.Description;
					cProperty.PriceScaleRule = property.PriceScaleRule;
					cProperty.Sessions = property.Sessions;
					cProperty.TaxRule = property.TaxRule;
				} else {
					__cPropertys.Add(sCommodityId, property);
				}
			}
		}
		/// <summary>
		///   建構子
		/// </summary>
		/// <param name="request">InstrumentDataRequest類別</param>
		public InstrumentSettings(ref InstrumentDataRequest request) {
			AbstractExchange cExchange = ProductManager.Manager.GetExchange(request.Exchange);

			__sSymbolId = request.Symbol;
			__sExchange = request.Exchange;
			__sDataSource = request.DataFeed;
			
			__dTimeZone = cExchange.TimeZone;
			__cProduct = cExchange.GetProduct(__sSymbolId);
			__cProperty = cExchange.GetProperty(__sSymbolId, __sDataSource);

			//如果沒有商品資訊就使用 request.Symbol 第一個字元當作搜尋條件來取代
			if (__cProduct == null) {
				List<Product> cProducts = cExchange.SearchProducts(new string(__sSymbolId[0], 1), false);
				foreach (Product cProduct in cProducts) {
					AbstractProductProperty cProperty = cExchange.GetProperty(cProduct.SymbolId);
					if (cProperty != null) {
						__cProduct = cProduct;
						__cProperty = cProperty;
						break;
					}
				}
			}

			__cOptionType = __cProperty.GetCallOrPut(__cProduct);     //取得選擇權 Call or Put 類型
			__dStrikePrice = __cProperty.GetStrikePrice(__cProduct);  //取得選擇權履約價格
				
			//取得合約到期日索引值
			IContractTime cContractTime = __cProperty.ContractRule as IContractTime;
			if (cContractTime != null) {
				__iContractIndex = cContractTime.GetContractIndex(__sSymbolId);
			}

			this.Create(ref request);
			__cResolution = request.Resolution;
		}
Beispiel #11
0
        /// <summary>
        ///   新增或修改商品屬性(如果商品已經存在會覆寫原本的設定值)
        /// </summary>
        /// <param name="property">商品屬性類別</param>
        public void AddProperty(AbstractProductProperty property)
        {
            AbstractProductProperty cProperty = null;
            string sCommodityId = property.CommodityId;

            lock (__cPropertys) {
                if (__cPropertys.TryGetValue(sCommodityId, out cProperty))
                {
                    cProperty.BigPointValue  = property.BigPointValue;
                    cProperty.CautionMoneys  = property.CautionMoneys;
                    cProperty.CommodityId    = property.CommodityId;
                    cProperty.ContractRule   = property.ContractRule;
                    cProperty.DailyLimit     = property.DailyLimit;
                    cProperty.Description    = property.Description;
                    cProperty.PriceScaleRule = property.PriceScaleRule;
                    cProperty.Sessions       = property.Sessions;
                    cProperty.TaxRule        = property.TaxRule;
                }
                else
                {
                    __cPropertys.Add(sCommodityId, property);
                }
            }
        }
Beispiel #12
0
		private void btnOk_Click(object sender, EventArgs e) {
			string sSymbolId = txtProductId.Text;
			if (sSymbolId.Length == 0) {  //如果沒有輸入商品代號就離開
				return;
			}

			__sExchangeName = comboExchange.Text;
			string sCommodityId = txtCommodity.Text;

			AbstractExchange cExchange = ProductManager.Manager.GetExchange(__sExchangeName);
			__cProduct = cExchange.GetProduct(sSymbolId);
			if (__cProduct == null) {
				string sProductName = txtProductName.Text;
				ESymbolCategory cCategory = (ESymbolCategory) Enum.Parse(typeof(ESymbolCategory), comboCategory.Text);

				__cProduct = new Product();
				__cProduct.SymbolId = sSymbolId;
				__cProduct.SymbolName = sProductName;
				__cProduct.Category = cCategory;
				if(sCommodityId.Length > 0) {
					__cProduct.CommodityId = sCommodityId;
				}

				cExchange.AddProduct(__cProduct);
			}

			sSymbolId = __cProduct.SymbolId;
			__sDataSource = comboDataSource.Text;
			__sDataSource = (__sDataSource.Length == 0) ? null : __sDataSource;
	
			string sCommodity = (sCommodityId.Length == 0) ? sSymbolId : sCommodityId;
			cExchange.AddProperty(sCommodity, __sDataSource);
			__cProperty = cExchange.GetProperty(sSymbolId, __sDataSource);

			this.DialogResult = DialogResult.OK;
		}
Beispiel #13
0
		/// <summary>
		///   建構子
		/// </summary>
		/// <param name="request">InstrumentDataRequest類別</param>
		public InstrumentSettings(ref InstrumentDataRequest request) {
			AbstractExchange cExchange = ProductManager.Manager.GetExchange(request.Exchange);

			__sSymbolId = request.Symbol;
			__sExchange = request.Exchange;
			__sDataSource = request.DataFeed;
			
			__dTimeZone = cExchange.TimeZone;
			__cProduct = cExchange.GetProduct(__sSymbolId);
			__cProperty = cExchange.GetProperty(__sSymbolId, __sDataSource);

			if (__cProperty != null) {
				__cOptionType = __cProperty.GetCallOrPut(__cProduct);     //取得選擇權 Call or Put 類型
				__dStrikePrice = __cProperty.GetStrikePrice(__cProduct);  //取得選擇權履約價格
				
				//取得合約到期日索引值
				IContractTime cContractTime = __cProperty.ContractRule as IContractTime;
				if (cContractTime != null) {
					__iContractIndex = cContractTime.GetContractIndex(__sSymbolId);
				}
			}

			this.Create(ref request);
			__cResolution = request.Resolution;
		}
		/// <summary>
		///   設定 Instrument 資訊
		/// </summary>
		/// <param name="bars">Instrument 類別</param>
		public override void SetInstrument(Instrument bars) {
			base.SetInstrument(bars);
			
			__cProperty = (Bars.Info as InstrumentSettings).Property;  //取得商品屬性
			__cCurrentPosition.SetBigPointValue(__cProperty.BigPointValue);  //設定每一大點的交易金額
		}
Beispiel #15
0
		/// <summary>
		///   新增商品屬性(如果商品已經存在會覆寫之前屬性設定)
		/// </summary>
		/// <param name="property">商品屬性類別</param>
		/// <param name="dataSource">資料來源名稱</param>
		public void AddProperty(AbstractProductProperty property, string dataSource = null) {
			if (dataSource == null) {
				BasePropertys.AddProperty(property);
			} else {
				ProductPropertyList cPropertyList = null;
				
				if (!CustomPropertys.TryGetValue(dataSource, out cPropertyList)) {
					cPropertyList = new ProductPropertyList();
					CustomPropertys.Add(dataSource, cPropertyList);
				}
				cPropertyList.AddProperty(property);
			}
		}