Example #1
0
        private void weituoXingwei(weimai4Shuju wt)
        {
            //调整价格和纠错
            if (wt.jiage <= 0)
            {
                throw new ArgumentOutOfRangeException("委托价不应小于或等于0");
            }
            if (wt.jiage > zhangtingjia)
            {
                wt.jiage = zhangtingjia;
            }
            if (wt.jiage < dietingjia)
            {
                wt.jiage = dietingjia;
            }
            wt.jiage = Math.Round(wt.jiage, 2);

            //调整可用数量
            moniqunti.Getishuzu[wt.bianhao].chigushuju.keyongshuliang -= wt.shuliang;
            //根据判断来确定行为

            while (weimai3jihe.Count > 0 && wt.shuliang > 0 && weimai3jihe.First().jiage >= wt.jiage)
            {
                chengjiao(ref wt, weimai3jihe.First());
                if (weimai3jihe.First().shuliang == 0)
                {
                    chudui(maimaileixingMj.mai3);
                }
            }
            if (wt.shuliang > 0)//不成交,即委买为0或委买价小于委卖价
            {
                rudui(wt);
            }
        }
Example #2
0
        public int CompareTo(object obj)
        {
            weimai4Shuju qita   = obj as weimai4Shuju;
            int          result = this.jiage.CompareTo(qita.jiage);

            if (result == 0)
            {
                result = 1;
            }
            return(result);
        }
Example #3
0
 private void rudui(weimai4Shuju wt)   //委卖数据入队
 {
     weimai4jihe.Add(wt);
     if (weimai4duilie.ContainsKey(wt.jiage))
     {
         weimai4duilie[wt.jiage] += wt.shuliang;
     }
     else
     {
         weimai4duilie.Add(wt.jiage, wt.shuliang);
     }
 }
Example #4
0
        private void chengjiao(ref weimai3Shuju zhudongdan, weimai4Shuju weituodan)
        {
            if (zhudongdan.jiage < weituodan.jiage)
            {
                throw new ArgumentOutOfRangeException("成交的委买价格小于委卖价格");
            }

            uint zdbianhao = zhudongdan.bianhao;
            uint wtbianhao = weituodan.bianhao;

            geti.chigushujuJg zhudongchigushuju =
                moniqunti.Getishuzu[zdbianhao].chigushuju;
            geti.chigushujuJg weituochigushuju =
                moniqunti.Getishuzu[zdbianhao].chigushuju;
            //确定数量和价格
            uint   chengjiaoliang;
            double chengjiaojia;

            chengjiaojia = weituodan.jiage;
            if (zhudongdan.shuliang < weituodan.shuliang)
            {
                chengjiaoliang = zhudongdan.shuliang;
            }
            else
            {
                chengjiaoliang = weituodan.shuliang;
            }
            //主动数据修改
            zhudongdan.shuliang -= chengjiaoliang;

            zhudongchigushuju.Chengbenjia = (zhudongchigushuju.Chengbenjia * zhudongchigushuju.chigushu +
                                             chengjiaoliang * chengjiaojia) / (zhudongchigushuju.chigushu + chengjiaoliang);
            zhudongchigushuju.chigushu    += chengjiaoliang;
            zhudongchigushuju.Zijin       -= chengjiaojia * chengjiaoliang;
            zhudongchigushuju.Cangwei      = zhudongchigushuju.chigushu * chengjiaojia / (zhudongchigushuju.chigushu * chengjiaojia + zhudongchigushuju.Zijin);
            zhudongchigushuju.Keyongzijin += (chengjiaojia - zhudongdan.jiage) * chengjiaoliang;


            //委托数据修改
            weituodan.shuliang -= chengjiaoliang;

            weituochigushuju.Chengbenjia = (weituochigushuju.Chengbenjia * weituochigushuju.chigushu -
                                            chengjiaoliang * chengjiaojia) / (weituochigushuju.chigushu - chengjiaoliang);
            weituochigushuju.chigushu    -= chengjiaoliang;
            weituochigushuju.Zijin       += chengjiaojia * chengjiaoliang;
            weituochigushuju.Cangwei      = weituochigushuju.chigushu * chengjiaojia / (weituochigushuju.chigushu * chengjiaojia + weituochigushuju.Zijin);
            weituochigushuju.Keyongzijin += chengjiaoliang * chengjiaojia;
        }