Example #1
0
        //分析融券卖出量
        public decimal SELLQUANTITYrate(string StockCode)
        {
            decimal[]  Remining = new decimal[5];
            D.StockDAL dsd      = new D.StockDAL();
            M.Stock    ms       = new M.Stock();
            DataSet    ds       = new DataSet();

            ds = dsd.Get5List(StockCode);
            for (int i = 0; i < 5; i++)
            {
                Remining[i] = decimal.Parse(ds.Tables[0].Rows[4 - i][10].ToString());
            }

            decimal[] ReminingCha = new decimal[4];

            for (int i = 0; i < 4; i++)
            {
                ReminingCha[i] = (Remining[i + 1] - Remining[i]) / Remining[i];
            }
            decimal dec;

            dec = (ReminingCha[0] + ReminingCha[1] + ReminingCha[2] + ReminingCha[3]) / 4;

            return(dec);
        }
Example #2
0
        //数组获取数据库融券余量
        public int[] GETREMAINQUILITY(string StockCode)
        {
            int[] REMAINQUILITY = new int[20];
            D.StockDAL dsd = new D.StockDAL();
            M.Stock ms = new M.Stock();
            DataSet ds = new DataSet();

            ds = dsd.GetREMAININGList(StockCode);

            for (int i = 0; i < 20; i++)
            {
                REMAINQUILITY[i] = int.Parse(ds.Tables[0].Rows[19 - i][9].ToString());
            }
            return REMAINQUILITY;
        }
Example #3
0
        //数组获取数据库融资余额
        public decimal[] GETREMAINING(string StockCode)
        {
            decimal[] REMAINING = new decimal[20];
            D.StockDAL dsd = new D.StockDAL();
            M.Stock ms = new M.Stock();
            DataSet ds = new DataSet();

            ds = dsd.GetREMAININGList(StockCode);

            for (int i = 0; i < 20; i++)
            {
                REMAINING[i] = decimal.Parse(ds.Tables[0].Rows[19 - i][5].ToString());
            }
            return REMAINING;
        }
Example #4
0
        //数组获取数据库融资买入额
        public decimal[] GETPURCHASES(string StockCode)
        {
            decimal[] PURCHASES = new decimal[20];
            D.StockDAL dsd = new D.StockDAL();
            M.Stock ms = new M.Stock();
            DataSet ds = new DataSet();

            ds = dsd.GetREMAININGList(StockCode);

            for (int i = 0; i < 20; i++)
            {
                PURCHASES[i] = decimal.Parse(ds.Tables[0].Rows[19 - i][6].ToString());
            }
            return PURCHASES;
        }
Example #5
0
        //数组获取数据库日期
        public DateTime[] GETDATE(string StockCode)
        {
            DateTime[] DATE = new DateTime[20];
            D.StockDAL dsd = new D.StockDAL();
            M.Stock ms = new M.Stock();
            DataSet ds = new DataSet();

            ds = dsd.GetREMAININGList(StockCode);

            for (int i = 0; i < 20; i++)
            {
                DATE[i] = DateTime.Parse(ds.Tables[0].Rows[19 - i][2].ToString());
            }
            return DATE;
        }
Example #6
0
        //数组获取数据库日期
        public DateTime[] GETDATE(string StockCode)
        {
            DateTime[] DATE = new DateTime[20];
            D.StockDAL dsd  = new D.StockDAL();
            M.Stock    ms   = new M.Stock();
            DataSet    ds   = new DataSet();

            ds = dsd.GetREMAININGList(StockCode);

            for (int i = 0; i < 20; i++)
            {
                DATE[i] = DateTime.Parse(ds.Tables[0].Rows[19 - i][2].ToString());
            }
            return(DATE);
        }
Example #7
0
        //数组获取数据库融券卖出量
        public int[] GETSELLQUANTITY(string StockCode)
        {
            int[]      SELLQUANTITY = new int[20];
            D.StockDAL dsd          = new D.StockDAL();
            M.Stock    ms           = new M.Stock();
            DataSet    ds           = new DataSet();

            ds = dsd.GetREMAININGList(StockCode);

            for (int i = 0; i < 20; i++)
            {
                SELLQUANTITY[i] = int.Parse(ds.Tables[0].Rows[19 - i][10].ToString());
            }
            return(SELLQUANTITY);
        }
Example #8
0
        //数组获取数据库融资买入额
        public decimal[] GETPURCHASES(string StockCode)
        {
            decimal[]  PURCHASES = new decimal[20];
            D.StockDAL dsd       = new D.StockDAL();
            M.Stock    ms        = new M.Stock();
            DataSet    ds        = new DataSet();

            ds = dsd.GetREMAININGList(StockCode);

            for (int i = 0; i < 20; i++)
            {
                PURCHASES[i] = decimal.Parse(ds.Tables[0].Rows[19 - i][6].ToString());
            }
            return(PURCHASES);
        }
Example #9
0
        //分析融券余量
        public decimal REAMINQUANTITYrate(string StockCode)
        {
            decimal[] Remining = new decimal[5];
               D.StockDAL dsd = new D.StockDAL();
               M.Stock ms = new M.Stock();
               DataSet ds = new DataSet();

               ds = dsd.Get5List(StockCode);
               for (int i = 0; i < 5; i++)
               {
               Remining[i] = decimal.Parse(ds.Tables[0].Rows[4 - i][9].ToString());
               }

               decimal[] ReminingCha = new decimal[4];

               for (int i = 0; i < 4; i++)
               {
               ReminingCha[i] = (Remining[i + 1] - Remining[i]) / Remining[i];
               }
               decimal dec;
               dec = (ReminingCha[0] + ReminingCha[1] + ReminingCha[2] + ReminingCha[3]) / 4;

               return dec;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    string StockCode;
                    StockCode = Request.QueryString["STOCK_CODE"].ToString();
                    //定义一个数组
                    ShowChart(StockCode);
                    D.StockDAL dsd = new D.StockDAL();
                    M.Stock    MS  = new M.Stock();
                    MS = dsd.GetModelName(StockCode);
                    string StockName = MS.STOCK_NAME;

                    B.StockAnalyse bsa                = new B.StockAnalyse();
                    decimal        REMININGrate       = bsa.REMININGrate(StockCode);
                    decimal        URCHASESrate       = bsa.PURCHASESrate(StockCode);
                    decimal        REAMINQUANTITYrate = bsa.REAMINQUANTITYrate(StockCode);
                    decimal        SELLQUANTITYrate   = bsa.SELLQUANTITYrate(StockCode);
                    decimal        Conclusion         = bsa.Conclusion(StockCode);

                    lbl1.Text = (REMININGrate * 100).ToString("0.00") + "%";
                    lbl2.Text = (URCHASESrate * 100).ToString("0.00") + "%";
                    lbl3.Text = (REAMINQUANTITYrate * 100).ToString("0.00") + "%";
                    lbl4.Text = (SELLQUANTITYrate * 100).ToString("0.00") + "%";
                    lbl5.Text = (Conclusion * 100).ToString("0.00") + "%";
                    #region//分析数据
                    StringBuilder strconclusion = new StringBuilder();
                    strconclusion.Append(StockName);
                    if (REMININGrate > 0)
                    {
                        strconclusion.Append("股票的融资余额在一周内同比增长了" + lbl1.Text + ",");
                    }
                    else
                    {
                        strconclusion.Append("股票的融资余额在一周内同比减少了" + lbl1.Text + ",");
                    }
                    if (URCHASESrate > 0)
                    {
                        strconclusion.Append("融资买入额在一周内同比增长了" + lbl2.Text + ",");
                    }
                    else
                    {
                        strconclusion.Append("融资买入额在一周内同比减少了" + lbl2.Text + ",");
                    }
                    if (REAMINQUANTITYrate > 0)
                    {
                        strconclusion.Append("融券余量在一周内同比增长了" + lbl3.Text + ",");
                    }
                    else
                    {
                        strconclusion.Append("融券余量在一周内同比减少了" + lbl3.Text + ",");
                    }
                    if (SELLQUANTITYrate > 0)
                    {
                        strconclusion.Append("融券卖出量在一周内同比增长了" + lbl4.Text + ",");
                    }
                    else
                    {
                        strconclusion.Append("融券卖出量在一周内同比减少了" + lbl4.Text + ",");
                    }
                    if (Conclusion > 0)
                    {
                        strconclusion.Append("平均在一周内同比增长了" + lbl5.Text + ",");
                    }
                    else
                    {
                        strconclusion.Append("平均在一周内同比减少了" + lbl5.Text + ",");
                    }

                    if (Conclusion < 0.05M)
                    {
                        strconclusion.Append("变现低落,建议持股即可,必要时可适当卖出.");
                    }
                    else
                    {
                        if (0.05M <= Conclusion || Conclusion < 0.1M)
                        {
                            strconclusion.Append("低开高走,表现平淡,投资者对未来本股的行情出现分歧、结合其一周以来的涨幅,走强势头尚未结束,建议继续持股.");
                        }
                        else
                        {
                            if (0.1M <= Conclusion || Conclusion < 0.12M)
                            {
                                strconclusion.Append("表现强势,相应股票表现不俗,适当关注这一现象.");
                            }
                            else
                            {
                                if (0.12M <= Conclusion || Conclusion < 0.15M)
                                {
                                    strconclusion.Append("强势整理,强支撑,而且成交量也保持良好水平,技术指标亦多有配合。建议密切关注.");
                                }
                                else
                                {
                                    strconclusion.Append("表现强势,属于强力股,资金大头,个人可适当跟盘操作,公司可考虑强力入股.");
                                }
                            }
                        }
                    }
                    #endregion
                    string strconclusion2 = strconclusion.ToString();
                    lbl6.Text = strconclusion2;
                }
                catch
                {
                    Server.Transfer("404error.aspx", true);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    string StockCode;
                    StockCode = Request.QueryString["STOCK_CODE"].ToString();
                    //定义一个数组
                    ShowChart(StockCode);
                    D.StockDAL dsd=new D.StockDAL ();
                    M.Stock MS=new M.Stock ();
                    MS=dsd.GetModelName(StockCode);
                    string StockName=MS.STOCK_NAME;

                     B.StockAnalyse bsa = new B.StockAnalyse();
                    decimal REMININGrate=bsa.REMININGrate(StockCode);
                    decimal URCHASESrate=bsa.PURCHASESrate(StockCode);
                    decimal REAMINQUANTITYrate=bsa.REAMINQUANTITYrate(StockCode);
                    decimal SELLQUANTITYrate=bsa.SELLQUANTITYrate(StockCode);
                    decimal Conclusion=bsa.Conclusion(StockCode);

                    lbl1.Text = ( REMININGrate* 100).ToString("0.00") + "%";
                    lbl2.Text = (URCHASESrate * 100).ToString("0.00") + "%";
                    lbl3.Text = (REAMINQUANTITYrate * 100).ToString("0.00") + "%";
                    lbl4.Text = (SELLQUANTITYrate * 100).ToString("0.00") + "%";
                    lbl5.Text = ( Conclusion* 100).ToString("0.00") + "%";
                    #region//分析数据
                    StringBuilder strconclusion = new StringBuilder();
                    strconclusion.Append(StockName);
                    if (REMININGrate > 0)
                    {
                        strconclusion.Append("股票的融资余额在一周内同比增长了" + lbl1.Text+",");
                    }
                    else
                    {
                        strconclusion.Append("股票的融资余额在一周内同比减少了" + lbl1.Text + ",");
                    }
                    if (URCHASESrate > 0)
                    {
                        strconclusion.Append("融资买入额在一周内同比增长了" + lbl2.Text + ",");
                    }
                    else
                    {
                        strconclusion.Append("融资买入额在一周内同比减少了" + lbl2.Text + ",");
                    }
                    if (REAMINQUANTITYrate > 0)
                    {
                        strconclusion.Append("融券余量在一周内同比增长了" + lbl3.Text + ",");
                    }
                    else
                    {
                        strconclusion.Append("融券余量在一周内同比减少了" + lbl3.Text + ",");
                    }
                    if (SELLQUANTITYrate > 0)
                    {
                        strconclusion.Append("融券卖出量在一周内同比增长了" + lbl4.Text + ",");
                    }
                    else
                    {
                        strconclusion.Append("融券卖出量在一周内同比减少了" + lbl4.Text + ",");
                    }
                    if (Conclusion > 0)
                    {
                        strconclusion.Append("平均在一周内同比增长了" + lbl5.Text + ",");
                    }
                    else
                    {
                        strconclusion.Append("平均在一周内同比减少了" + lbl5.Text + ",");
                    }

                    if (Conclusion < 0.05M)
                    {
                        strconclusion.Append("变现低落,建议持股即可,必要时可适当卖出.");
                    }
                    else
                    {
                        if (0.05M <= Conclusion || Conclusion <0.1M)
                        {
                            strconclusion.Append("低开高走,表现平淡,投资者对未来本股的行情出现分歧、结合其一周以来的涨幅,走强势头尚未结束,建议继续持股.");
                        }
                        else
                        {
                            if (0.1M <= Conclusion || Conclusion <0.12M)
                            {
                                strconclusion.Append("表现强势,相应股票表现不俗,适当关注这一现象.");
                            }
                            else
                            {
                                if (0.12M <= Conclusion || Conclusion < 0.15M)
                                {
                                    strconclusion.Append("强势整理,强支撑,而且成交量也保持良好水平,技术指标亦多有配合。建议密切关注.");
                                }
                                else
                                {
                                    strconclusion.Append("表现强势,属于强力股,资金大头,个人可适当跟盘操作,公司可考虑强力入股.");
                                }
                            }
                        }
                    }
            #endregion
                    string strconclusion2 = strconclusion.ToString();
                    lbl6.Text = strconclusion2;
                }
                catch
                {
                    Server.Transfer("404error.aspx", true);
                }

             }
        }
Example #12
0
        /// <summary>
        /// 爬取新浪融资融券网当天的交易信息,并存储到数据库里
        /// </summary>
        /// <param name="tradeDate"></param>
        /// <returns></returns>
        public static int BeginFunction(DateTime tradeDate)
        {
            int flat = 0;
            string url = "http://vip.stock.finance.sina.com.cn/q/go.php/vInvestConsult/kind/rzrq/index.phtml?tradedate=" + tradeDate.Date.ToString("yyyy-MM-dd");
            //得到指定Url的源码
            string strWebContent = GetWebContent(url);

                #region//取出和数据有关的那段源码
                int iStart = strWebContent.IndexOf("融资融券交易明细");
                if (iStart > 0)
                {
                    string strTableStart = strWebContent.Substring(0, iStart);
                    string strTableEnd = strWebContent.Substring(iStart);
                    strTableStart = strTableStart.Substring(strTableStart.LastIndexOf("<table"));
                    strTableEnd = strTableEnd.Substring(0, strTableEnd.IndexOf("</table>") + 8);
                    string strWeb = strTableStart + strTableEnd;
                    string[] trArray = Regex.Split(strWeb, @"<tr class=""head"">", RegexOptions.IgnoreCase);
                    for (int i = 0; i < trArray.Length; i++)
                    {
                        string[] tdArray = Regex.Split(trArray[i], @"<td style=""background-color:#ffffff"">", RegexOptions.IgnoreCase);
                        if (tdArray.Length == 12)
                        {
                            string stockCode = string.Empty;
                            string stockName = string.Empty;
                            decimal remaining = 0;
                            decimal purchases = 0;
                            decimal payments = 0;
                            decimal remainSum = 0;
                            int remainQuantity = 0;
                            int sellQuantity = 0;
                            int reimbursedFloat = 0;
                            decimal securitiesBalances = 0;

                            stockCode = tdArray[2];
                            stockCode = stockCode.Substring(0, stockCode.IndexOf("</a>"));
                            stockCode = stockCode.Substring(stockCode.LastIndexOf(">") + 1);

                            stockName = tdArray[3];
                            stockName = stockName.Substring(0, stockName.IndexOf("</a>"));
                            stockName = stockName.Substring(stockName.LastIndexOf(">") + 1);

                            string strRemaining = tdArray[4].Replace("</td>", "").Replace("\n>", "").Replace("--", "").Trim();
                            if (strRemaining != string.Empty)
                                remaining = decimal.Parse(strRemaining);

                            string strPurchases = tdArray[5].Replace("</td>", "").Replace("\n>", "").Replace("--", "").Trim();
                            if (strPurchases != string.Empty)
                                purchases = decimal.Parse(strPurchases);

                            string strPayments = tdArray[6].Replace("</td>", "").Replace("\n>", "").Replace("--", "").Trim();
                            if (strPayments != string.Empty)
                                payments = decimal.Parse(strPayments);

                            string strRemainSum = tdArray[7].Replace("</td>", "").Replace("\n>", "").Replace("--", "").Trim();
                            if (strRemainSum != string.Empty)
                                remainSum = decimal.Parse(strRemainSum);

                            string strRemainQuantity = tdArray[8].Replace("</td>", "").Replace("\n>", "").Replace("--", "").Replace(",", "").Trim();
                            if (strRemainQuantity != string.Empty)
                                remainQuantity = int.Parse(strRemainQuantity);

                            string strSellQuantity = tdArray[9].Replace("</td>", "").Replace("\n>", "").Replace("--", "").Replace(",", "").Trim();
                            if (strSellQuantity != string.Empty)
                                sellQuantity = int.Parse(strSellQuantity);

                            string strReimbursedFloat = tdArray[10].Replace("</td>", "").Replace("\n>", "").Replace("--", "").Replace(",", "").Trim();
                            if (strReimbursedFloat != string.Empty)
                                reimbursedFloat = int.Parse(strReimbursedFloat);

                            try
                            {
                                string strSecuritiesBalances = tdArray[11].Replace("</td>", "").Replace("</tr>", "").Replace("</table>", "").Replace("\n>", "").Replace("--", "").Trim();
                                if (strSecuritiesBalances != string.Empty)
                                    securitiesBalances = decimal.Parse(strSecuritiesBalances);
                            }
                            catch (Exception e)
                            {
                                string message = e.Message;
                            }

                            StockWebApp.Model.Stock swm = new Stock();
                            StockWebApp.DAL.StockDAL swd = new StockDAL();

                            swm.STOCK_CODE = stockCode;
                            swm.STOCK_NAME = stockName;
                            swm.REMAINING = remaining;
                            swm.PURCHASES = purchases;
                            swm.PAYMENTS = payments;
                            swm.REMAIN_SUM = remainSum;
                            swm.REMAIN_QUANTITY = remainQuantity;
                            swm.SELL_QUANTITY = sellQuantity;
                            swm.REIMBURSED_FLOAT = reimbursedFloat;
                            swm.SECURITIES_BALANCES = securitiesBalances;
                            swm.TRADE_DATE = tradeDate;
                            swm.CREATED = DateTime.Now;
                            flat = swd.Add(swm);
                        }
                    }
                }
                if (flat != 0)
                {
                    return 1;//爬取成功
                }
                else return 0;//爬取失败
                #endregion
        }