Beispiel #1
0
        public SecurityItem GetSecurity(string investmentID)
        {
            if (!_securityDatas.ContainsKey(investmentID))
            {
                int    pos      = investmentID.IndexOf('.');
                string secuCode = string.Empty;
                if (pos > 0)
                {
                    secuCode = investmentID.Substring(0, pos);
                }
                else
                {
                    secuCode = investmentID;
                }

                SecurityItem securityItem = new SecurityItem
                {
                    SecuCode = secuCode,
                };

                AddSecurity(investmentID, securityItem);
            }

            return(_securityDatas[investmentID]);
        }
        protected void grdSecurityGroups_OnDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                SecurityItem si = (SecurityItem)e.Row.DataItem;
                RadioButton  rb = (RadioButton)e.Row.FindControl("rdoSecurityOption");
                HiddenField  hf = (HiddenField)e.Row.FindControl("hdnPrivacyCode");
                RadioButton  rdoSecurityOption = (RadioButton)e.Row.FindControl("rdoSecurityOption");
                Literal      l  = (Literal)e.Row.FindControl("rdoSecurityOptionLabel");
                HiddenField  hl = (HiddenField)e.Row.FindControl("hdnLabel");

                rdoSecurityOption.GroupName = "SecurityOption";

                hf.Value = si.PrivacyCode.ToString();
                l.Text   = "<label for=\"" + rb.UniqueID.Replace("$", "_") + "\">" + si.Label + "</label>";
                hl.Value = si.Label;

                if (si.PrivacyCode == this.PrivacyCode)
                {
                    rb.Checked         = true;
                    litVisibility.Text = "(" + si.Label + ")";
                }
                else
                {
                    rb.Checked = false;
                }
            }
        }
Beispiel #3
0
        protected void grdSecurityGroups_OnDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                SecurityItem si = (SecurityItem)e.Row.DataItem;
                RadioButton  rb = (RadioButton)e.Row.FindControl("rdoSecurityOption");
                HiddenField  hf = (HiddenField)e.Row.FindControl("hdnPrivacyCode");
                RadioButton  rdoSecurityOption = (RadioButton)e.Row.FindControl("rdoSecurityOption");

                rdoSecurityOption.GroupName = "SecurityOption";

                hf.Value = si.PrivacyCode.ToString();

                if (si.PrivacyCode == this.PrivacyCode)
                {
                    if (this.PrivacyCode == 0)
                    {
                        si.Label = "<b>" + si.Label + "</b>";
                    }

                    rb.Checked = true;
                    imbSecurityOptions.Text = "Edit Visibility (" + si.Label + ")";
                }
                else
                {
                    rb.Checked = false;
                }
            }
        }
        private void SetItemPrice(CancelRedoItem item, SecurityItem secuItem, PriceType priceType)
        {
            var marketData = QuoteCenter2.Instance.GetMarketData(secuItem);

            item.EntrustPrice   = QuotePriceHelper.GetPrice(priceType, marketData);
            item.LastPrice      = marketData.CurrentPrice;
            item.LimitDownPrice = marketData.LowLimitPrice;
            item.LimitUpPrice   = marketData.HighLimitPrice;
        }
Beispiel #5
0
 public void AddSecurity(string investmentID, SecurityItem securityItem)
 {
     if (!_securityDatas.ContainsKey(investmentID))
     {
         _securityDatas.Add(investmentID, securityItem);
     }
     else
     {
         _securityDatas[investmentID] = securityItem;
     }
 }
        private SecurityItem CreateItem(Security security)
        {
            var data = new SecurityItem(security);

            if (MarketDataProvider != null)
            {
                UpdateData(security, data);
            }

            return(data);
        }
        private void UpdateData(Security security, SecurityItem data)
        {
            var changes = MarketDataProvider.GetSecurityValues(security);

            if (changes == null)
            {
                return;
            }

            data.ApplyChanges(changes, TimeHelper.NowWithOffset, TimeHelper.Now);
            data.RefreshLastTradeDirection();
        }
Beispiel #8
0
        public MarketData GetMarketData(SecurityItem secuItem)
        {
            string windCode = CodeHelper.GetWindCode(secuItem);

            MarketData marketData = new MarketData
            {
                InstrumentID = windCode
            };


            return(_quote.Get(windCode));
        }
        public int Update(SecurityItem securityItem)
        {
            var dbCommand = _dbHelper.GetStoredProcCommand(SP_Modify);

            _dbHelper.AddInParameter(dbCommand, "@SecuCode", System.Data.DbType.String, securityItem.SecuCode);
            _dbHelper.AddInParameter(dbCommand, "@SecuName", System.Data.DbType.String, securityItem.SecuName);
            _dbHelper.AddInParameter(dbCommand, "@ExchangeCode", System.Data.DbType.String, securityItem.ExchangeCode);
            _dbHelper.AddInParameter(dbCommand, "@SecuType", System.Data.DbType.Int32, (int)securityItem.SecuType);

            int ret = _dbHelper.ExecuteNonQuery(dbCommand);

            return(ret);
        }
        private List <SecurityItem> Select(string secuCode, SecurityType secuType)
        {
            var dbCommand = _dbHelper.GetStoredProcCommand(SP_Get);

            if (!string.IsNullOrEmpty(secuCode))
            {
                _dbHelper.AddInParameter(dbCommand, "@SecuCode", System.Data.DbType.String, secuCode);
            }

            if (secuType == SecurityType.All)
            {
                _dbHelper.AddInParameter(dbCommand, "@SecuType", System.Data.DbType.Int32, null);
            }
            else
            {
                _dbHelper.AddInParameter(dbCommand, "@SecuType", System.Data.DbType.Int32, (int)secuType);
            }

            List <SecurityItem> items = new List <SecurityItem>();
            var reader = _dbHelper.ExecuteReader(dbCommand);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    SecurityItem item = new SecurityItem();
                    item.SecuCode     = (string)reader["SecuCode"];
                    item.SecuName     = (string)reader["SecuName"];
                    item.ExchangeCode = (string)reader["ExchangeCode"];
                    item.SecuType     = (SecurityType)reader["SecuType"];
                    if (reader["ListDate"] != null && reader["ListDate"] != DBNull.Value)
                    {
                        item.ListDate = (string)reader["ListDate"];
                    }

                    items.Add(item);
                }
            }
            reader.Close();
            _dbHelper.Close(dbCommand);

            return(items);
        }
Beispiel #11
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);
        }
Beispiel #12
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);
        }
Beispiel #13
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);
        }
Beispiel #14
0
        public List <SecurityItem> GetAll()
        {
            if (_futuresItems == null)
            {
                _futuresItems = new List <SecurityItem>();
            }

            if (_futuresItems.Count == 0)
            {
                var quoteItems = _quote.GetFuturesContract();
                if (quoteItems != null && quoteItems.Count > 0)
                {
                    _futuresItems.AddRange(quoteItems);
                }

                var dbItems = _futurescontractdao.GetAll();
                if (dbItems != null && dbItems.Count > 0)
                {
                    foreach (var dbItem in dbItems)
                    {
                        var findItem = _futuresItems.Find(p => p.SecuCode.Equals(dbItem.Code));
                        if (findItem == null)
                        {
                            SecurityItem newItem = new SecurityItem
                            {
                                SecuCode     = dbItem.Code,
                                SecuName     = dbItem.Name,
                                SecuType     = SecurityType.Futures,
                                ExchangeCode = dbItem.Exchange,
                            };

                            _futuresItems.Add(newItem);
                        }
                    }
                }
            }

            return(_futuresItems);
        }
Beispiel #15
0
 public void Add(string investmentID, SecurityItem secuItem)
 {
     _quote.AddSecurity(investmentID, secuItem);
 }
Beispiel #16
0
        private void AddSecurity(TDFCode[] codeArr)
        {
            for (int i = 0; i < codeArr.Length; i++)
            {
                if (codeArr[i].Type >= 0x10 && codeArr[i].Type <= 0x16)
                {
                    //股票代码
                    //TDFOptionCode code = new TDFOptionCode();
                    //var ret = _tdfImp.GetOptionCodeInfo(codeArr[i].WindCode, ref code);
                    SecurityItem securityItem = new SecurityItem();
                    securityItem.SecuCode = codeArr[i].Code;
                    securityItem.SecuName = codeArr[i].CNName;
                    securityItem.SecuType = SecurityType.Stock;

                    //if (codeArr[i].WindCode.Equals("002109.SZ", StringComparison.InvariantCultureIgnoreCase))
                    //{
                    //    Console.WriteLine(codeArr[i].WindCode);
                    //}

                    if (codeArr[i].Market.Equals("SZ", System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        securityItem.ExchangeCode = Exchange.SZSE;
                    }
                    else if (codeArr[i].Market.Equals("SH", System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        securityItem.ExchangeCode = Exchange.SHSE;
                    }
                    else
                    {
                        //Fail;
                    }

                    _quote.AddSecurity(codeArr[i].WindCode, securityItem);
                }
                else if (codeArr[i].Type == 0x70)
                {
                    //股指期货
                    SecurityItem securityItem = new SecurityItem();
                    securityItem.SecuCode     = codeArr[i].Code;
                    securityItem.SecuName     = codeArr[i].CNName;
                    securityItem.SecuType     = SecurityType.Futures;
                    securityItem.ExchangeCode = Exchange.CFFEX;
                    _quote.AddSecurity(codeArr[i].WindCode, securityItem);
                }
                else if (codeArr[i].Type == 0x01)
                {
                    //指数
                    SecurityItem securityItem = new SecurityItem();
                    securityItem.SecuCode = CodeHelper.GetIndexSecuCode(codeArr[i].Code);
                    securityItem.SecuName = codeArr[i].CNName;
                    securityItem.SecuType = SecurityType.Index;

                    if (codeArr[i].Market.Equals("SZ", System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        securityItem.ExchangeCode = Exchange.SZSE;
                    }
                    else if (codeArr[i].Market.Equals("SH", System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        securityItem.ExchangeCode = Exchange.SHSE;
                    }
                    else
                    {
                        //Fail;
                    }

                    _quote.AddSecurity(codeArr[i].WindCode, securityItem);
                }
                else
                {
                    //do nothing
                }
            }
        }