Exemplo n.º 1
0
        private CancelRedoItem Convert(EntrustSecurity p, Model.Database.TradeCommand tradeCommand)
        {
            CancelRedoItem cancelRedoItem = new CancelRedoItem
            {
                Selection        = true,
                CommandId        = tradeCommand.CommandId,
                EDirection       = p.EntrustDirection,
                EntrustPrice     = p.EntrustPrice,
                SecuCode         = p.SecuCode,
                SecuType         = p.SecuType,
                EntrustNo        = p.EntrustNo,
                ECommandPrice    = p.PriceType,
                ReportPrice      = p.EntrustPrice,
                EOriginPriceType = p.EntrustPriceType,
                LeftAmount       = p.EntrustAmount - p.TotalDealAmount,
                ReportAmount     = p.EntrustAmount,
                DealAmount       = p.TotalDealAmount,
                EntrustDate      = p.EntrustDate,
                SubmitId         = p.SubmitId,
                EntrustBatchNo   = p.BatchNo,
                PortfolioName    = tradeCommand.PortfolioName,
                FundName         = tradeCommand.AccountName,
            };

            cancelRedoItem.EntrustAmount = cancelRedoItem.LeftAmount;
            if (cancelRedoItem.SecuType == Model.SecurityInfo.SecurityType.Stock && cancelRedoItem.EDirection == EntrustDirection.BuySpot)
            {
                if (cancelRedoItem.LeftAmount % 100 > 0)
                {
                    cancelRedoItem.EntrustAmount = AmountRoundUtil.Round(cancelRedoItem.LeftAmount);
                }
            }

            var secuInfo = SecurityInfoManager.Instance.Get(p.SecuCode, p.SecuType);

            if (secuInfo != null)
            {
                cancelRedoItem.SecuName     = secuInfo.SecuName;
                cancelRedoItem.ExchangeCode = secuInfo.ExchangeCode;
            }
            else
            {
                cancelRedoItem.ExchangeCode = SecurityItemHelper.GetExchangeCode(p.SecuCode, p.SecuType);
            }

            return(cancelRedoItem);
        }
Exemplo n.º 2
0
        public SecurityItem Get(string secuCode, SecurityType secuType)
        {
            var allSecuItems = Get();
            var secuItem     = allSecuItems.Find(p => p.SecuCode.Equals(secuCode) && p.SecuType == secuType);

            if (secuItem == null)
            {
                secuItem = new SecurityItem
                {
                    SecuCode     = secuCode,
                    SecuType     = secuType,
                    ExchangeCode = SecurityItemHelper.GetExchangeCode(secuCode, secuType),
                };

                string investmentID = CodeHelper.GetWindCode(secuItem);
                Add(investmentID, secuItem);
            }

            return(secuItem);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get the wind code from SecurityItem. The SecurityItem includes secucode, exchange, security type.
        /// The final wind code will end with the point+exchangecode, such as 000001.SZ, 600000.SH, IF1612.CF
        /// </summary>
        /// <param name="secuItem">The SecurityItem, which include secucode, security type, exchange information.</param>
        /// <returns>A wind code consist of wind internal code, point, and exchange code.</returns>
        public static string GetWindCode(SecurityItem secuItem)
        {
            string secuCode = secuItem.SecuCode.Trim();
            string windCode = secuCode;

            if (secuItem.SecuType == SecurityType.Index)
            {
                windCode = CodeHelper.GetIndexWindCode(secuCode);
            }

            string exchangeCode = secuItem.ExchangeCode;

            if (string.IsNullOrEmpty(exchangeCode))
            {
                exchangeCode = SecurityItemHelper.GetExchangeCode(secuItem.SecuCode, secuItem.SecuType);
            }

            if (!string.IsNullOrEmpty(exchangeCode))
            {
                if (exchangeCode.Equals(Exchange.SHSE, StringComparison.OrdinalIgnoreCase))
                {
                    windCode += ".SH";
                }
                else if (exchangeCode.Equals(Exchange.SZSE, StringComparison.OrdinalIgnoreCase))
                {
                    windCode += ".SZ";
                }
                else if (exchangeCode.Equals(Exchange.CFFEX, StringComparison.OrdinalIgnoreCase))
                {
                    windCode += ".CF";
                }
            }
            else
            {
                //do nothing
            }

            return(windCode);
        }
        public void Test_GetExchangeCode()
        {
            var actual = SecurityItemHelper.GetExchangeCode("000001", SecurityType.Stock);

            Assert.AreEqual(Exchange.SZSE, actual);

            actual = SecurityItemHelper.GetExchangeCode("002001", SecurityType.Stock);
            Assert.AreEqual(Exchange.SZSE, actual);

            actual = SecurityItemHelper.GetExchangeCode("300024", SecurityType.Stock);
            Assert.AreEqual(Exchange.SZSE, actual);

            actual = SecurityItemHelper.GetExchangeCode("600110", SecurityType.Stock);
            Assert.AreEqual(Exchange.SHSE, actual);

            actual = SecurityItemHelper.GetExchangeCode("000001", SecurityType.Index);
            Assert.AreEqual(Exchange.SHSE, actual);

            actual = SecurityItemHelper.GetExchangeCode("399001", SecurityType.Index);
            Assert.AreEqual(Exchange.SZSE, actual);

            actual = SecurityItemHelper.GetExchangeCode("930901", SecurityType.Index);
            Assert.AreEqual(Exchange.SHSE, actual);

            actual = SecurityItemHelper.GetExchangeCode("950110", SecurityType.Index);
            Assert.AreEqual(Exchange.SHSE, actual);

            actual = SecurityItemHelper.GetExchangeCode("IF1612", SecurityType.Futures);
            Assert.AreEqual(Exchange.CFFEX, actual);

            actual = SecurityItemHelper.GetExchangeCode("IC1612", SecurityType.Futures);
            Assert.AreEqual(Exchange.CFFEX, actual);

            actual = SecurityItemHelper.GetExchangeCode("IH1612", SecurityType.Futures);
            Assert.AreEqual(Exchange.CFFEX, actual);
        }