private void LoadTemplateStock(int archiveId)
        {
            if (archiveId < 0)
            {
                return;
            }

            _secuDataSource.Clear();
            var stocks = _templateBLL.GetStocks(archiveId);

            if (stocks != null)
            {
                foreach (var stock in stocks)
                {
                    var secuInfo = SecurityInfoManager.Instance.Get(stock.SecuCode, Model.SecurityInfo.SecurityType.Stock);
                    if (secuInfo != null)
                    {
                        stock.SecuName = secuInfo.SecuName;
                        stock.Exchange = SecurityItemHelper.GetExchange(secuInfo.ExchangeCode);
                    }

                    _secuDataSource.Add(stock);
                }
            }
        }
        public void Test_GetExchange()
        {
            var actual = SecurityItemHelper.GetExchange(Exchange.SHSE);

            Assert.AreEqual("上交所", actual);

            actual = SecurityItemHelper.GetExchange(Exchange.SZSE);

            Assert.AreEqual("深交所", actual);

            actual = SecurityItemHelper.GetExchange(Exchange.CFFEX);

            Assert.AreEqual("中金所", actual);
        }
Exemple #3
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);
        }
        public void Test_GetSecurityType()
        {
            var actual = SecurityItemHelper.GetSecurityType("000001", Exchange.SHSE);

            Assert.AreEqual(SecurityType.Index, actual);

            actual = SecurityItemHelper.GetSecurityType("000001", Exchange.SZSE);
            Assert.AreEqual(SecurityType.Stock, actual);

            actual = SecurityItemHelper.GetSecurityType("002415", Exchange.SZSE);
            Assert.AreEqual(SecurityType.Stock, actual);

            actual = SecurityItemHelper.GetSecurityType("300001", Exchange.SZSE);
            Assert.AreEqual(SecurityType.Stock, actual);

            actual = SecurityItemHelper.GetSecurityType("600000", Exchange.SHSE);
            Assert.AreEqual(SecurityType.Stock, actual);

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

            actual = SecurityItemHelper.GetSecurityType("399998", Exchange.SZSE);
            Assert.AreEqual(SecurityType.Index, actual);

            actual = SecurityItemHelper.GetSecurityType("399999", Exchange.SZSE);
            Assert.AreEqual(SecurityType.All, actual);

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

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

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

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

            actual = SecurityItemHelper.GetSecurityType("IC1612", Exchange.CFFEX);
            Assert.AreEqual(SecurityType.Futures, actual);
        }
Exemple #5
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);
        }
        public List <TemplateStock> GetStocks(int templateId)
        {
            int loginUserId = LoginManager.Instance.GetUserId();

            _userActionTrackingBLL.Create(loginUserId, Model.UsageTracking.ActionType.Get, ResourceType.SpotTemplate, templateId, 1, Model.UsageTracking.ActionStatus.Normal, "stocks");

            var stocks = _stockdbdao.Get(templateId);

            if (stocks != null)
            {
                stocks.ForEach(p => {
                    var secuInfo = SecurityInfoManager.Instance.Get(p.SecuCode, Model.SecurityInfo.SecurityType.Stock);
                    if (secuInfo != null)
                    {
                        p.SecuName = secuInfo.SecuName;
                        p.Exchange = SecurityItemHelper.GetExchange(secuInfo.ExchangeCode);
                    }
                });
            }

            return(stocks);
        }
Exemple #7
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);
        }
Exemple #8
0
        public SecurityItem Get(string secuCode, string exchangeCode)
        {
            var allSecuItems = Get();
            //var secuItem = allSecuItems.Find(p => p.SecuCode.Equals(secuCode) && (p.SecuType == SecurityType.Stock || p.SecuType == SecurityType.Futures));
            var secuItem = allSecuItems.Find(p => p.SecuCode.Equals(secuCode) && p.ExchangeCode.Equals(exchangeCode));

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

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

            return(secuItem);
        }
        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);
        }