Exemple #1
0
        public static string GetEntrustPriceType(EntrustPriceType entrustPriceType)
        {
            string entrustPriceTypeName = string.Empty;

            switch (entrustPriceType)
            {
            case EntrustPriceType.FixedPrice:
                entrustPriceTypeName = "限价";
                break;

            case EntrustPriceType.FifthIsLeftOffSH:
                entrustPriceTypeName = "五档即成剩撤";
                break;

            case EntrustPriceType.FifthIsLeftOffSZ:
                entrustPriceTypeName = "五档即成剩撤";
                break;

            case EntrustPriceType.FifthIsLeftTurnSH:
                entrustPriceTypeName = "五档即成剩转";
                break;

            case EntrustPriceType.LeftTurnSZ:
                entrustPriceTypeName = "五档即成剩转";
                break;

            case EntrustPriceType.OppSideOptSZ:
                entrustPriceTypeName = "对手方最优";
                break;

            case EntrustPriceType.BestBestSZ:
                entrustPriceTypeName = "本方最优";
                break;

            case EntrustPriceType.FOKMarketSZ:
                entrustPriceTypeName = "全额成或撤";
                break;

            case EntrustPriceType.FifthIsLeftOffCFX:
                entrustPriceTypeName = "五档即成剩撤";
                break;

            case EntrustPriceType.FifthIsLeftTurnCFX:
                entrustPriceTypeName = "五档即成剩转";
                break;

            case EntrustPriceType.BestOneLeftOff:
                entrustPriceTypeName = "最优一档即成剩撤";
                break;

            case EntrustPriceType.BestOneLeftTurn:
                entrustPriceTypeName = "最优一档即成剩转";
                break;

            default:
                break;
            }

            return(entrustPriceTypeName);
        }
        public static string GetEntrustPriceType(EntrustPriceType eEntrustPriceType)
        {
            string entrustpricetype = string.Empty;

            StringBuilder sb = new StringBuilder();

            sb.Append((char)eEntrustPriceType);
            entrustpricetype = sb.ToString();

            return(entrustpricetype);
        }
        private bool Form_LoadData(object sender, object data)
        {
            if (data == null)
            {
                return(false);
            }

            if (!(data is List <CancelRedoItem>))
            {
                return(false);
            }

            //Get the price type
            PriceType        spotBuyPrice    = PriceTypeHelper.GetPriceType(this.cbSpotBuyPrice);
            PriceType        spotSellPrice   = PriceTypeHelper.GetPriceType(this.cbSpotSellPrice);
            PriceType        futureBuyPrice  = PriceTypeHelper.GetPriceType(this.cbFuturesBuyPrice);
            PriceType        futureSellPrice = PriceTypeHelper.GetPriceType(this.cbFuturesSellPrice);
            EntrustPriceType shPriceType     = EntrustPriceTypeHelper.GetPriceType(this.cbSHExchangePrice);
            EntrustPriceType szPriceType     = EntrustPriceTypeHelper.GetPriceType(this.cbSZExchangePrice);

            _secuDataSource.Clear();
            var cancelSecuItems = data as List <CancelRedoItem>;

            foreach (var cancelRedoItem in cancelSecuItems)
            {
                if (cancelRedoItem.SecuType == SecurityType.Stock && cancelRedoItem.EDirection == EntrustDirection.BuySpot)
                {
                    cancelRedoItem.EPriceSetting = spotBuyPrice;
                }
                else if (cancelRedoItem.SecuType == SecurityType.Stock && cancelRedoItem.EDirection == EntrustDirection.BuySpot)
                {
                    cancelRedoItem.EPriceSetting = spotSellPrice;
                }
                else if (cancelRedoItem.SecuType == SecurityType.Futures && cancelRedoItem.EDirection == EntrustDirection.SellOpen)
                {
                    cancelRedoItem.EPriceSetting = futureSellPrice;
                }
                else if (cancelRedoItem.SecuType == SecurityType.Futures && cancelRedoItem.EDirection == EntrustDirection.BuyClose)
                {
                    cancelRedoItem.EPriceSetting = futureBuyPrice;
                }

                SetEntrustPriceType(cancelRedoItem, shPriceType, szPriceType);

                _secuDataSource.Add(cancelRedoItem);
            }

            //update the quote
            QueryQuote();

            return(true);
        }
        private void ComboBox_SZExchangePrice_SelectedIndexChanged(object sender, EventArgs e)
        {
            EntrustPriceType priceType = EntrustPriceTypeHelper.GetPriceType(this.cbSZExchangePrice);

            _secuDataSource.Where(p => p.SecuType == SecurityType.Stock &&
                                  Exchange.SZSE.Equals(p.ExchangeCode) &&
                                  p.EPriceSetting == PriceType.Market
                                  )
            .ToList()
            .ForEach(o => o.EEntrustPriceType = priceType);

            this.secuGridView.Invalidate();
        }
        /// <summary>
        /// Convert the single char string into EntrustPriceType, such as "0", "1", "a".
        /// NOTE: the type is from UFX interface dictionary.
        /// </summary>
        /// <param name="priceTypeCode">A given string code for the EntrustPriceType.</param>
        /// <returns>A EntrustPriceType for the code standby.</returns>
        public static EntrustPriceType GetPriceType(string priceTypeCode)
        {
            if (priceTypeCode == null || string.IsNullOrEmpty(priceTypeCode) || priceTypeCode.Length != 1)
            {
                string msg = string.Format("The EntrustPriceType [{0}] is not supported!", priceTypeCode);
                throw new NotSupportedException(msg);
            }

            var bytes    = Encoding.UTF8.GetBytes(priceTypeCode);
            int charCode = (int)bytes[0];

            if (!Enum.IsDefined(typeof(EntrustPriceType), charCode))
            {
                string msg = string.Format("The EntrustPriceType [{0}] is not supported!", priceTypeCode);
                throw new NotSupportedException(msg);
            }

            EntrustPriceType priceType = (EntrustPriceType)Enum.ToObject(typeof(EntrustPriceType), charCode);

            return(priceType);
        }
 private void SetEntrustPriceType(CancelRedoItem cancelRedoItem, EntrustPriceType shPriceType, EntrustPriceType szPriceType)
 {
     //只有选择市价时设置市价委托方式
     if (cancelRedoItem.SecuType == SecurityType.Stock && cancelRedoItem.EPriceSetting == PriceType.Market)
     {
         if (Exchange.SHSE.Equals(cancelRedoItem.ExchangeCode))
         {
             cancelRedoItem.EEntrustPriceType = shPriceType;
         }
         else if (Exchange.SZSE.Equals(cancelRedoItem.ExchangeCode))
         {
             cancelRedoItem.EEntrustPriceType = szPriceType;
         }
         else
         {
             //do nothing
         }
     }
     else
     {
         cancelRedoItem.EEntrustPriceType = EntrustPriceType.FixedPrice;
     }
 }
        public void TestEntrustPriceType()
        {
            string priceTypeId = "A";

            if (priceTypeId == null || string.IsNullOrEmpty(priceTypeId) || priceTypeId.Length != 1)
            {
                string msg = string.Format("The EntrustPriceType [{0}] is not supported!", priceTypeId);
                throw new NotSupportedException(msg);
            }

            var bytes    = Encoding.UTF8.GetBytes(priceTypeId);
            int charCode = (int)bytes[0];

            if (!Enum.IsDefined(typeof(EntrustPriceType), charCode))
            {
                string msg = string.Format("The EntrustPriceType [{0}] is not supported!", priceTypeId);
                throw new NotSupportedException(msg);
            }

            EntrustPriceType priceType = (EntrustPriceType)Enum.ToObject(typeof(EntrustPriceType), charCode);

            Assert.AreEqual(EntrustPriceType.FifthIsLeftOffSZ, priceType);
        }
        private void ComboBox_PriceType_SelectedIndexChange(object sender, EventArgs e)
        {
            if (sender == null || !(sender is ComboBox))
            {
                return;
            }
            ComboBox cb = sender as ComboBox;

            PriceType        priceType   = PriceTypeHelper.GetPriceType(cb);
            EntrustDirection direction   = EntrustDirection.BuySpot;
            SecurityType     secuType    = SecurityType.All;
            EntrustPriceType shPriceType = EntrustPriceTypeHelper.GetPriceType(this.cbSHExchangePrice);
            EntrustPriceType szPriceType = EntrustPriceTypeHelper.GetPriceType(this.cbSZExchangePrice);

            switch (cb.Name)
            {
            case "cbSpotBuyPrice":
            {
                direction = EntrustDirection.BuySpot;
                secuType  = SecurityType.Stock;
            }
            break;

            case "cbSpotSellPrice":
            {
                direction = EntrustDirection.SellSpot;
                secuType  = SecurityType.Stock;
            }
            break;

            case "cbFuturesBuyPrice":
            {
                direction = EntrustDirection.BuyClose;
                secuType  = SecurityType.Futures;
            }
            break;

            case "cbFuturesSellPrice":
            {
                direction = EntrustDirection.SellOpen;
                secuType  = SecurityType.Futures;
            }
            break;

            default:
                break;
            }

            var stockItems = _secuDataSource.Where(p => p.EDirection == direction && p.SecuType == secuType).ToList();

            if (stockItems.Count > 0)
            {
                stockItems.ForEach(p =>
                {
                    p.EPriceSetting = priceType;
                    SetEntrustPriceType(p, shPriceType, szPriceType);
                });
            }

            //update the quote
            QueryQuote();

            this.secuGridView.Invalidate();
        }
 /// <summary>
 /// Get the string type of name for the specified EntrustPriceType
 /// </summary>
 /// <param name="priceType">A given EntrustPriceType.</param>
 /// <returns>A string type of the name.</returns>
 public static string GetPriceTypeName(EntrustPriceType priceType)
 {
     return(EnumAttributeHelper.GetEnumDescription <EntrustPriceType>(priceType));
 }