前复权后复权程序C# .net

if (win32apitest.MDIMain.SFSDA.FuQuan == "前复权")
                    {
                        if (mytime == DateTime.Parse("2009-04-29"))
                        {
                            //if (svalue == 34.89)
                            //{
                            //}
                        }
                        if (mytime == DateTime.Parse("2009-04-30"))
                        {
                            //if (svalue == 34.89)
                            //{
                            //}
                        }
                        for (int i = QuanXiList.Rows.Count - 1; i >= 0; i--)
                        {
                            // 前复权:复权后价格=[(复权前价格-现金红利)+配(新)股价格×流通股份变动比例]÷(1+流通股份变动比例)
                            //  权后价格=(价格-红利/10)/(1+送股数/10)
                            DateTime ctime = DateTime.Parse(QuanXiList.Rows[i]["时间"].ToString());
                            if (mytime < ctime)
                            {
                                double hongli = double.Parse(QuanXiList.Rows[i]["红利"].ToString());
                                double songgu = double.Parse(QuanXiList.Rows[i]["送股数"].ToString())/10;
                                double liutongbdbl = double.Parse(QuanXiList.Rows[i]["转增数"].ToString()) / 10 + songgu;
                                double peigujia = double.Parse(QuanXiList.Rows[i]["配股价"].ToString())/1000;
                             
                                    tvalue = (tvalue - hongli + peigujia * liutongbdbl) / (1 + liutongbdbl);
                           
                            }
                        }
                    }
                    if (win32apitest.MDIMain.SFSDA.FuQuan == "后复权")
                    {

     
                        for (int i = 0; i < QuanXiList.Rows.Count; i++)
                     //  for (int i = QuanXiList.Rows.Count - 1; i >= 0; i--)
                        {
                            //  权后价格=价格*(1+送股数/10)+红利/10 
                            //  后复权:复权后价格=复权前价格×(1+流通股份变动比例)-配(新)股价格×流通股份变动比例+现金红利
                            DateTime ctime = DateTime.Parse(QuanXiList.Rows[i]["时间"].ToString());
                            if (mytime >= ctime)
                            {
                                double hongli = double.Parse(QuanXiList.Rows[i]["红利"].ToString());
                                double songgu = double.Parse(QuanXiList.Rows[i]["送股数"].ToString()) / 10;
                                double liutongbdbl = double.Parse(QuanXiList.Rows[i]["转增数"].ToString()) / 10 + songgu;
                                double peigujia = double.Parse(QuanXiList.Rows[i]["配股价"].ToString()) / 1000;
                                if (liutongbdbl != 0)
                                {
                                    tvalue = tvalue * (1 + liutongbdbl) - peigujia * liutongbdbl + hongli;
                                }
                            }
                        }
                    }

展开阅读全文

没有更多推荐了,返回首页