Example #1
0
 public void ExecuteDeleteData1(object para)
 {
     try
     {
         List <RStopLossStatus> slsAll = para as List <RStopLossStatus>;
         foreach (RStopLossStatus sls in slsAll)
         {
             if (CommHelper.CFSmvmList.ContainsKey(sls.contract_id + "B"))
             {
                 CommHelper.CFSmvmList[sls.contract_id + "B"].Clear();
                 LogHelper.Info("止盈止损" + sls.contract_id + "B清除数据");
                 PotionDetailModelViewModel temp = PositionViewModel.Instance().PMList.FirstOrDefault(x => x.ContractId == sls.contract_id && x.Direction == "B");
                 if (temp != null)
                 {
                     temp.LossVolume   = null;
                     temp.ProfitVolume = null;
                 }
                 break;
             }
             if (CommHelper.CFSmvmList.ContainsKey(sls.contract_id + "S"))
             {
                 CommHelper.CFSmvmList[sls.contract_id + "S"].Clear();
                 LogHelper.Info("止盈止损" + sls.contract_id + "S清除数据");
                 PotionDetailModelViewModel temp = PositionViewModel.Instance().PMList.FirstOrDefault(x => x.ContractId == sls.contract_id && x.Direction == "S");
                 if (temp != null)
                 {
                     temp.LossVolume   = null;
                     temp.ProfitVolume = null;
                 }
             }
             break;
         }
         if (CheckFullStopViewModel.IsInstance())
         {
             CheckFullStopViewModel.Instance(null).Close();
         }
     }
     catch (Exception ex)
     {
         LogHelper.Info(ex.ToString());
     }
 }
        public void ExecutePositionInfoData(object para)
        {
            try
            {
                PotionModel                rtm       = para as PotionModel;
                PositionAllViewModel       pavm      = PositionAllViewModel.Instance();
                PositionViewModel          pvm       = PositionViewModel.Instance();
                PotionDetailModelViewModel pdmvmtemp = pavm.DetPMList.FirstOrDefault(x => x.PsitionId == rtm.position_id);

                if (rtm.position_volume == 0)
                {
                    if (pdmvmtemp != null)
                    {
                        pavm.DetPMList.Remove(pdmvmtemp);
                        LogHelper.Info("4007  移除 " + rtm.contract_code + ":" + rtm.direction);
                        pavm.PMList.Clear();
                        pvm.PMList.Clear();
                    }

                    int count = SQLiteHelper.ExecuteNonQuery(SQLiteHelper.DBPath, CommandType.Text, "delete from AutoStopLoss where ContractID='" + rtm.contract_id + "' and PostionID='" + rtm.position_id + "';");
                }
                else
                {
                    if (pdmvmtemp != null)
                    {
                        pdmvmtemp.PositionVolume = rtm.position_volume;
                        pdmvmtemp.AbleVolume     = rtm.position_volume;
                        pdmvmtemp.UseMargin      = rtm.use_margin;
                        pdmvmtemp.SysUseMargin   = rtm.sys_margin;
                    }
                    else
                    {
                        PotionDetailModel pdm = new PotionDetailModel();
                        pdm.able_volume       = rtm.position_volume;
                        pdm.contract_code     = rtm.contract_code;
                        pdm.contract_id       = rtm.contract_id;
                        pdm.direction         = rtm.direction;
                        pdm.open_date         = rtm.position_date;
                        pdm.open_price        = rtm.position_price;
                        pdm.open_time         = rtm.position_time;
                        pdm.position_volume   = rtm.position_volume;
                        pdm.position_id       = rtm.position_id;
                        pdm.shadow_orderID    = rtm.shadow_orderID;
                        pdm.shadow_positionid = rtm.shadow_positionid;
                        pdm.shadow_tradeid    = rtm.shadow_tradeid;

                        pdm.trade_id   = "";
                        pdm.user_id    = rtm.user_id;
                        pdm.use_margin = rtm.use_margin;
                        pdm.sys_margin = rtm.sys_margin;
                        VarietyModel vm     = null;
                        string[]     values = pdm.contract_id.Split(' ');
                        if (values.Length == 3)
                        {
                            string varietie = values[1];
                            if (ContractVariety.Varieties.ContainsKey(varietie))
                            {
                                vm = ContractVariety.Varieties[varietie];
                            }
                            if (vm != null)
                            {
                                pdm.precision = vm.precision;
                            }
                        }

                        pdmvmtemp = new PotionDetailModelViewModel(pdm);
                        pavm.DetPMList.Add(pdmvmtemp);
                    }
                }
                if (ContractVariety.ContracPostionID.ContainsKey(rtm.contract_id))
                {
                    AutoStopLossModel aslm = CommParameterSetting.AutoStopLossModel.FirstOrDefault(x => x.Direction == rtm.direction && x.Agreement == rtm.contract_id);
                    if (aslm != null)
                    {
                        if (!ContractVariety.PostionPrice.ContainsKey(rtm.position_id))
                        {
                            ContractVariety.PostionPrice.Add(rtm.position_id, new AutoLossPrice());
                        }
                        string[] VarietiesKey = rtm.contract_id.Split(' ');
                        if (VarietiesKey.Length == 3)
                        {
                            string       varietie = VarietiesKey[1];
                            VarietyModel vm       = null;
                            if (ContractVariety.Varieties.ContainsKey(varietie))
                            {
                                vm = ContractVariety.Varieties[varietie];
                            }
                            if (vm != null)
                            {
                                if (rtm.direction == "B")
                                {
                                    ContractVariety.PostionPrice[rtm.position_id].LossPrice = rtm.position_price - aslm.StopLossPotion * vm.tick_size;
                                }
                                else
                                {
                                    ContractVariety.PostionPrice[rtm.position_id].LossPrice = rtm.position_price + aslm.StopLossPotion * vm.tick_size;
                                }
                                ContractVariety.PostionPrice[rtm.position_id].NewPrice = rtm.position_price;
                                if (!ContractVariety.ContracPostionID.ContainsKey(rtm.contract_id))
                                {
                                    ContractVariety.ContracPostionID.Add(rtm.contract_id, new List <string>());
                                }
                                ContractVariety.ContracPostionID[rtm.contract_id].Add(rtm.position_id);
                                int count = SQLiteHelper.ExecuteNonQuery(SQLiteHelper.DBPath, CommandType.Text, "insert INTO AutoStopLoss VALUES('" + rtm.position_id + "','" + rtm.contract_id + "','" + UserInfoHelper.UserId + "'," + ContractVariety.PostionPrice[rtm.position_id].LossPrice + "," + ContractVariety.PostionPrice[rtm.position_id].NewPrice + ");");
                            }
                        }
                    }
                }
                PotionDetailModelViewModel[] temp = pavm.DetPMList.ToArray();
                //合约名加方向作为K
                Dictionary <string, PotionDetailModelViewModel> dicod = new Dictionary <string, PotionDetailModelViewModel>();

                foreach (PotionDetailModelViewModel item in temp)
                {
                    PotionDetailModelViewModel pm1 = item.Clone(item);
                    if (!dicod.Keys.Contains(pm1.ContractCode + pm1.Direction))
                    {
                        pm1.AllPrice = pm1.OpenPrice * pm1.PositionVolume;
                        dicod.Add(pm1.ContractCode + pm1.Direction, pm1);
                        //MainViewModel.GetInstance().SubscribedStocks.Add(pm1.ContractCode);
                    }
                    else
                    {
                        dicod[item.ContractCode + item.Direction].AbleVolume         = dicod[item.ContractCode + item.Direction].AbleVolume + item.AbleVolume;
                        dicod[item.ContractCode + item.Direction].PositionProfitLoss = dicod[item.ContractCode + item.Direction].PositionProfitLoss + item.PositionProfitLoss;
                        dicod[item.ContractCode + item.Direction].PositionVolume     = dicod[item.ContractCode + item.Direction].PositionVolume + item.PositionVolume;
                        dicod[item.ContractCode + item.Direction].UseMargin          = dicod[item.ContractCode + item.Direction].UseMargin + item.UseMargin;
                        dicod[item.ContractCode + item.Direction].SysUseMargin       = dicod[item.ContractCode + item.Direction].SysUseMargin + item.SysUseMargin;
                        dicod[item.ContractCode + item.Direction].AllPrice          += item.PositionVolume * item.OpenPrice;
                        dicod[item.ContractCode + item.Direction].OpenPrice          = dicod[item.ContractCode + item.Direction].AllPrice / dicod[item.ContractCode + item.Direction].PositionVolume;
                    }
                }
                if (dicod.Keys.Count > 0)
                {
                    pavm.PMList.Clear();
                    pvm.PMList.Clear();
                    foreach (PotionDetailModelViewModel item in dicod.Values)
                    {
                        pavm.PMList.Add(item);
                        pvm.PMList.Add(item);
                    }
                    pvm.SelectedItem = pvm.PMList.FirstOrDefault(x => x.ContractCode == rtm.contract_code && x.Direction == rtm.direction);
                }
                if (!MainViewModel.GetInstance().SubscribedStocks.Contains(rtm.contract_code))
                {
                    MainViewModel.GetInstance().SubscribedStocks.Add(rtm.contract_code);
                    ScoketManager.GetInstance().SendSubscribeInfo(7, rtm.contract_code);
                }

                foreach (string key in CommHelper.CFSmvmList.Keys)
                {
                    PotionDetailModelViewModel temp1 = PositionViewModel.Instance().PMList.FirstOrDefault(x => (x.ContractId + x.Direction) == key);
                    if (temp1 == null)
                    {
                        continue;
                    }
                    double maxprice  = 99999999999;
                    double minprice  = 0;
                    double maxprice1 = 0;
                    double minprice1 = 99999999999;
                    int    maxnum    = 0;
                    int    minnum    = 0;
                    foreach (CheckFullStopModelViewModel item in CommHelper.CFSmvmList[key])
                    {
                        if (item == null)
                        {
                            continue;
                        }
                        if (item.StoplossPrice > 0 || item.StopprofitPrice > 0)
                        {
                            if (item.Direction == "B")
                            {
                                if (item.StopprofitPrice > 0)
                                {
                                    if (item.StopprofitPrice < maxprice)
                                    {
                                        maxprice = item.StopprofitPrice;
                                        maxnum   = item.OrderVolume;
                                    }
                                    else if (item.StopprofitPrice == maxprice)
                                    {
                                        maxnum += item.OrderVolume;
                                    }
                                }
                                if (item.StoplossPrice > 0)
                                {
                                    if (item.StoplossPrice > minprice)
                                    {
                                        minprice = item.StoplossPrice;
                                        minnum   = item.OrderVolume;
                                    }
                                    else if (item.StoplossPrice == minprice)
                                    {
                                        minnum += item.OrderVolume;
                                    }
                                }
                                if (maxprice < 99999999999 && maxnum > 0)
                                {
                                    temp1.ProfitVolume = maxprice + "/" + maxnum;
                                }
                                if (minprice > 0 && minnum > 0)
                                {
                                    temp1.LossVolume = minprice + "/" + minnum;
                                }
                            }
                            else
                            {
                                if (item.StopprofitPrice > 0)
                                {
                                    if (item.StopprofitPrice > maxprice1)
                                    {
                                        maxprice1 = item.StopprofitPrice;
                                        maxnum    = item.OrderVolume;
                                    }
                                    else if (item.StopprofitPrice == maxprice1)
                                    {
                                        maxnum += item.OrderVolume;
                                    }
                                }
                                if (item.StoplossPrice > 0)
                                {
                                    if (item.StoplossPrice < minprice1)
                                    {
                                        minprice1 = item.StoplossPrice;
                                        minnum    = item.OrderVolume;
                                    }
                                    else if (item.StoplossPrice == minprice1)
                                    {
                                        minnum += item.OrderVolume;
                                    }
                                }
                                if (maxprice1 > 0 && maxnum > 0)
                                {
                                    temp1.ProfitVolume = maxprice1 + "/" + maxnum;
                                }
                                if (minprice < 99999999999 && minnum > 0)
                                {
                                    temp1.LossVolume = minprice1 + "/" + minnum;
                                }
                            }
                        }
                    }
                }
                TransactionViewModel.Instance().AgreementChangedExecuteChanged();
                if (pavm.PMList.FirstOrDefault(x => x.ContractCode == rtm.contract_code && x.Direction == rtm.direction) == null)
                {
                    if (CommHelper.CFSmvmList.ContainsKey(rtm.contract_code + rtm.direction))
                    {
                        CommHelper.CFSmvmList[rtm.contract_code + rtm.direction].Clear();
                        LogHelper.Info("4007中移除止盈止损" + rtm.contract_id + rtm.direction + "清除数据");
                    }
                }

                //PositionViewModel.Instance().JSAbleVolume();
                TransactionViewModel.Instance().FigureUpNum(TransactionViewModel.Instance()._futures);
            }
            catch (Exception ex)
            {
                LogHelper.Info(ex.ToString());
            }
        }
 public TransactionPannelViewModel()
 {
     Position    = PositionViewModel.Instance();
     OrderCancel = OrderCancelViewModel.Instance();
 }
Example #4
0
 public void ExecuteDeleteData(object para)
 {
     try
     {
         double          maxprice  = 99999999999;
         double          minprice  = 0;
         double          maxprice1 = 0;
         double          minprice1 = 99999999999;
         int             maxnum    = 0;
         int             minnum    = 0;
         RStopLossStatus sls       = para as RStopLossStatus;
         LogHelper.Info("5204止盈止损" + sls.contract_id + "开始");
         if (CommHelper.CFSmvmList.ContainsKey(sls.contract_id + "B"))
         {
             CheckFullStopModelViewModel item = CommHelper.CFSmvmList[sls.contract_id + "B"].FirstOrDefault(x => x.StoplossId == sls.stoploss_id);
             if (item != null)
             {
                 CommHelper.CFSmvmList[sls.contract_id + "B"].Remove(item);
                 LogHelper.Info("5204止盈止损" + sls.contract_id + "B清除数据");
             }
             foreach (CheckFullStopModelViewModel temp in CommHelper.CFSmvmList[sls.contract_id + "B"])
             {
                 if (temp == null)
                 {
                     continue;
                 }
                 if (temp.StoplossPrice > 0 || temp.StopprofitPrice > 0)
                 {
                     if (item.StopprofitPrice > 0)
                     {
                         if (temp.StopprofitPrice < maxprice)
                         {
                             maxprice = temp.StopprofitPrice;
                             maxnum   = temp.OrderVolume;
                         }
                         else if (temp.StopprofitPrice == maxprice)
                         {
                             maxnum += temp.OrderVolume;
                         }
                     }
                     if (temp.StoplossPrice > 0)
                     {
                         if (temp.StoplossPrice > minprice)
                         {
                             minprice = temp.StoplossPrice;
                             minnum   = temp.OrderVolume;
                         }
                         else if (temp.StoplossPrice == minprice)
                         {
                             minnum += temp.OrderVolume;
                         }
                     }
                 }
             }
             PotionDetailModelViewModel _PositionModelViewModel1 = PositionViewModel.Instance().PMList.FirstOrDefault(x => x.ContractId == sls.contract_id && x.Direction == "B");
             if (_PositionModelViewModel1 != null)
             {
                 if (maxprice < 99999999999 && maxnum > 0)
                 {
                     _PositionModelViewModel1.ProfitVolume = maxprice + "/" + maxnum;
                 }
                 else
                 {
                     _PositionModelViewModel1.ProfitVolume = "";
                 }
                 if (minprice > 0 && minnum > 0)
                 {
                     _PositionModelViewModel1.LossVolume = minprice + "/" + minnum;
                 }
                 else
                 {
                     _PositionModelViewModel1.LossVolume = "";
                 }
             }
         }
         if (CommHelper.CFSmvmList.ContainsKey(sls.contract_id + "S"))
         {
             CheckFullStopModelViewModel item = CommHelper.CFSmvmList[sls.contract_id + "S"].FirstOrDefault(x => x.StoplossId == sls.stoploss_id);
             if (item != null)
             {
                 CommHelper.CFSmvmList[sls.contract_id + "S"].Remove(item);
                 LogHelper.Info("5204止盈止损" + sls.contract_id + "S清除数据");
             }
             foreach (CheckFullStopModelViewModel temp in CommHelper.CFSmvmList[sls.contract_id + "S"])
             {
                 if (temp == null)
                 {
                     continue;
                 }
                 if (temp.StoplossPrice > 0 || temp.StopprofitPrice > 0)
                 {
                     if (item.StopprofitPrice > 0)
                     {
                         if (item.StopprofitPrice > maxprice1)
                         {
                             maxprice1 = item.StopprofitPrice;
                             maxnum    = item.OrderVolume;
                         }
                         else if (item.StopprofitPrice == maxprice1)
                         {
                             maxnum += item.OrderVolume;
                         }
                     }
                     if (item.StoplossPrice > 0)
                     {
                         if (item.StoplossPrice < minprice1)
                         {
                             minprice1 = item.StoplossPrice;
                             minnum    = item.OrderVolume;
                         }
                         else if (item.StoplossPrice == minprice1)
                         {
                             minnum += item.OrderVolume;
                         }
                     }
                 }
             }
             PotionDetailModelViewModel _PositionModelViewModel = PositionViewModel.Instance().PMList.FirstOrDefault(x => x.ContractId == sls.contract_id && x.Direction == "S");
             if (_PositionModelViewModel != null)
             {
                 if (maxprice1 > 0 && maxnum > 0)
                 {
                     _PositionModelViewModel.ProfitVolume = maxprice1 + "/" + maxnum;
                 }
                 else
                 {
                     _PositionModelViewModel.ProfitVolume = "";
                 }
                 if (minprice1 < 99999999999 && minnum > 0)
                 {
                     _PositionModelViewModel.LossVolume = minprice1 + "/" + minnum;
                 }
                 else
                 {
                     _PositionModelViewModel.LossVolume = "";
                 }
             }
         }
         if (CheckFullStopViewModel.IsInstance())
         {
             CheckFullStopViewModel.Instance(null).Close();
         }
     }
     catch (Exception ex)
     {
         LogHelper.Info(ex.ToString());
     }
 }
Example #5
0
 public void ExecuteSelectData(object para)
 {
     try
     {
         CheckFullStopModel cfsm = para as CheckFullStopModel;
         if (cfsm.blast)
         {
             // CheckFullStopViewModel.Instance(null).AddData();
             foreach (string key in CommHelper.CFSmvmList.Keys)
             {
                 PotionDetailModelViewModel temp = PositionViewModel.Instance().PMList.FirstOrDefault(x => (x.ContractId + x.Direction) == key);
                 if (temp == null)
                 {
                     continue;
                 }
                 double maxprice  = 99999999999;
                 double minprice  = 0;
                 double maxprice1 = 0;
                 double minprice1 = 99999999999;
                 int    maxnum    = 0;
                 int    minnum    = 0;
                 foreach (CheckFullStopModelViewModel item in CommHelper.CFSmvmList[key])
                 {
                     if (item == null)
                     {
                         continue;
                     }
                     if (item.StoplossPrice > 0 || item.StopprofitPrice > 0)
                     {
                         if (item.Direction == "B")
                         {
                             if (item.StopprofitPrice > 0)
                             {
                                 if (item.StopprofitPrice < maxprice)
                                 {
                                     maxprice = item.StopprofitPrice;
                                     maxnum   = item.OrderVolume;
                                 }
                                 else if (item.StopprofitPrice == maxprice)
                                 {
                                     maxnum += item.OrderVolume;
                                 }
                             }
                             if (item.StoplossPrice > 0)
                             {
                                 if (item.StoplossPrice > minprice)
                                 {
                                     minprice = item.StoplossPrice;
                                     minnum   = item.OrderVolume;
                                 }
                                 else if (item.StoplossPrice == minprice)
                                 {
                                     minnum += item.OrderVolume;
                                 }
                             }
                             if (maxprice < 99999999999 && maxnum > 0)
                             {
                                 temp.ProfitVolume = maxprice + "/" + maxnum;
                             }
                             if (minprice > 0 && minnum > 0)
                             {
                                 temp.LossVolume = minprice + "/" + minnum;
                             }
                         }
                         else
                         {
                             if (item.StopprofitPrice > 0)
                             {
                                 if (item.StopprofitPrice > maxprice1)
                                 {
                                     maxprice1 = item.StopprofitPrice;
                                     maxnum    = item.OrderVolume;
                                 }
                                 else if (item.StopprofitPrice == maxprice1)
                                 {
                                     maxnum += item.OrderVolume;
                                 }
                             }
                             if (item.StoplossPrice > 0)
                             {
                                 if (item.StoplossPrice < minprice1)
                                 {
                                     minprice1 = item.StoplossPrice;
                                     minnum    = item.OrderVolume;
                                 }
                                 else if (item.StoplossPrice == minprice1)
                                 {
                                     minnum += item.OrderVolume;
                                 }
                             }
                             if (maxprice1 > 0 && maxnum > 0)
                             {
                                 temp.ProfitVolume = maxprice1 + "/" + maxnum;
                             }
                             if (minprice < 99999999999 && minnum > 0)
                             {
                                 temp.LossVolume = minprice1 + "/" + minnum;
                             }
                         }
                     }
                 }
             }
             //  PositionViewModel.Instance().PMList.Add(item);
             return;
         }
         if (string.IsNullOrEmpty(cfsm.contract_id + cfsm.direction))
         {
             return;
         }
         if (CommHelper.CFSmvmList.ContainsKey(cfsm.contract_id + cfsm.direction))
         {
             if (CommHelper.CFSmvmList[cfsm.contract_id + cfsm.direction].FirstOrDefault(x => x.StoplossId == cfsm.stoploss_id) == null)
             {
                 CommHelper.CFSmvmList[cfsm.contract_id + cfsm.direction].Add(new CheckFullStopModelViewModel(cfsm));
             }
         }
         else
         {
             CommHelper.CFSmvmList.Add(cfsm.contract_id + cfsm.direction, new List <CheckFullStopModelViewModel>());
             CommHelper.CFSmvmList[cfsm.contract_id + cfsm.direction].Add(new CheckFullStopModelViewModel(cfsm));
         }
     }
     catch (Exception ex)
     {
         LogHelper.Info(ex.ToString());
     }
     //CheckFullStopViewModel.Instance(null).CFSMVMList.Add(new CheckFullStopModelViewModel(cfsm));
     //CheckFullStopViewModel.Instance(null).IsHaveData = true;
 }
Example #6
0
        public void Result(List <CheckFullStopModel> cfsms)
        {
            List <CheckFullStopModel> temps = cfsms;
            double maxprice  = 99999999999;
            double minprice  = 0;
            double maxprice1 = 0;
            double minprice1 = 99999999999;
            int    maxnum    = 0;
            int    minnum    = 0;

            if (CommHelper.CFSmvmList.ContainsKey(temps[0].contract_id + temps[0].direction))
            {
                CommHelper.CFSmvmList[temps[0].contract_id + temps[0].direction].Clear();
            }
            else
            {
                CommHelper.CFSmvmList.Add(temps[0].contract_id + temps[0].direction, new List <CheckFullStopModelViewModel>());
            }
            CommHelper.CFSmvmList[temps[0].contract_id + temps[0].direction].Clear();

            foreach (CheckFullStopModel item in temps)
            {
                if (item.stoploss_price > 0 || item.stopprofit_price > 0)
                {
                    if (item.direction == "B")
                    {
                        if (item.stopprofit_price > 0)
                        {
                            if (item.stopprofit_price < maxprice)
                            {
                                maxprice = item.stopprofit_price;
                                maxnum   = item.order_volume;
                            }
                            else if (item.stopprofit_price == maxprice)
                            {
                                maxnum += item.order_volume;
                            }
                        }
                        if (item.stoploss_price > 0)
                        {
                            if (item.stoploss_price > minprice)
                            {
                                minprice = item.stoploss_price;
                                minnum   = item.order_volume;
                            }
                            else if (item.stoploss_price == minprice)
                            {
                                minnum += item.order_volume;
                            }
                        }
                    }
                    else
                    {
                        if (item.stopprofit_price > 0)
                        {
                            if (item.stopprofit_price > maxprice1)
                            {
                                maxprice1 = item.stopprofit_price;
                                maxnum    = item.order_volume;
                            }
                            else if (item.stopprofit_price == maxprice1)
                            {
                                maxnum += item.order_volume;
                            }
                        }
                        if (item.stoploss_price > 0)
                        {
                            if (item.stoploss_price < minprice1)
                            {
                                minprice1 = item.stoploss_price;
                                minnum    = item.order_volume;
                            }
                            else if (item.stoploss_price == minprice1)
                            {
                                minnum += item.order_volume;
                            }
                        }
                    }
                    CheckFullStopModel cfsm = new CheckFullStopModel();
                    cfsm.user_id          = item.user_id;
                    cfsm.contract_id      = item.contract_id;
                    cfsm.direction        = item.direction;
                    cfsm.open_offset      = (int)OffsetType.OFFSET_COVER;
                    cfsm.order_volume     = item.order_volume;
                    cfsm.stoploss_price   = item.stoploss_price;
                    cfsm.stopprofit_price = item.stopprofit_price;
                    cfsm.float_loss       = item.float_loss;
                    cfsm.stoploss_id      = item.stoploss_id;
                    cfsm.float_loss_flag  = (int)FloatLossFlag.FLF_FloatLoss;
                    if (CommParameterSetting.StopLossModel.StopLossPrice == "最新价")
                    {
                        cfsm.trriger_price_type = (int)YunTrrigerStyle.Y_LASTPRICE;
                    }
                    else
                    {
                        if (item.direction == "S")
                        {
                            cfsm.trriger_price_type = (int)YunTrrigerStyle.Y_BUYONEPRICE;
                            cfsm.order_add_price    = CommParameterSetting.StopLossModel.BuyNum;
                        }
                        else
                        {
                            cfsm.order_add_price    = CommParameterSetting.StopLossModel.SellNum;
                            cfsm.trriger_price_type = (int)YunTrrigerStyle.Y_SELLONEPRICE;
                        }
                    }
                    if (CommParameterSetting.StopLossModel.StopProfitDelegation == "市价")
                    {
                        cfsm.price_type = "M";
                    }
                    else
                    {
                        cfsm.price_type = "L";
                    }
                    cfsm.create_date = DateTime.Now.ToString("yyyy-MM-dd");
                    cfsm.create_time = DateTime.Now.ToString("HH:mm:ss");

                    CheckFullStopModelViewModel cfsmvm = new CheckFullStopModelViewModel(cfsm);
                    if (CommHelper.CFSmvmList[item.contract_id + item.direction].FirstOrDefault(x => x.StoplossId == cfsm.stoploss_id) == null)
                    {
                        CommHelper.CFSmvmList[item.contract_id + item.direction].Add(cfsmvm);
                        LogHelper.Info("止盈止损添加 " + cfsm.contract_code + ":" + cfsm.direction + ";" + cfsm.create_time);
                    }
                }
            }
            PotionDetailModelViewModel _PositionModelViewModel = PositionViewModel.Instance().PMList.FirstOrDefault(x => x.ContractId == temps[0].contract_id && x.Direction == temps[0].direction);

            if (_PositionModelViewModel == null)
            {
                return;
            }
            if (_PositionModelViewModel.Direction == "B")
            {
                if (maxprice < 99999999999 && maxnum > 0)
                {
                    _PositionModelViewModel.ProfitVolume = maxprice + "/" + maxnum;
                }
                if (minprice > 0 && minnum > 0)
                {
                    _PositionModelViewModel.LossVolume = minprice + "/" + minnum;
                }
            }
            else
            {
                if (maxprice1 > 0 && maxnum > 0)
                {
                    _PositionModelViewModel.ProfitVolume = maxprice1 + "/" + maxnum;
                }
                if (minprice1 < 99999999999 && minnum > 0)
                {
                    _PositionModelViewModel.LossVolume = minprice1 + "/" + minnum;
                }
            }
        }
        public void ExecutePositionDetialData(object para)
        {
            try
            {
                PotionDetailModel    pm   = para as PotionDetailModel;
                PositionAllViewModel pavm = PositionAllViewModel.Instance();
                if (pavm.DetPMList.FirstOrDefault(x => x.PsitionId == pm.position_id) != null)
                {
                    return;
                }
                if (pm.bLast)
                {
                    PotionDetailModelViewModel[] temp = pavm.DetPMList.ToArray();
                    //合约名加方向作为K
                    Dictionary <string, PotionDetailModelViewModel> dicod = new Dictionary <string, PotionDetailModelViewModel>();
                    foreach (PotionDetailModelViewModel item in temp)
                    {
                        PotionDetailModelViewModel pm1 = item.Clone(item);
                        if (!dicod.Keys.Contains(pm1.ContractCode + pm1.Direction))
                        {
                            pm1.AllPrice = pm1.OpenPrice * pm1.PositionVolume;
                            dicod.Add(pm1.ContractCode + pm1.Direction, pm1);
                            MainViewModel.GetInstance().SubscribedStocks.Add(pm1.ContractCode);
                        }
                        else
                        {
                            dicod[item.ContractCode + item.Direction].AbleVolume         = dicod[item.ContractCode + item.Direction].AbleVolume + item.AbleVolume;
                            dicod[item.ContractCode + item.Direction].PositionProfitLoss = dicod[item.ContractCode + item.Direction].PositionProfitLoss + item.PositionProfitLoss;
                            dicod[item.ContractCode + item.Direction].PositionVolume     = dicod[item.ContractCode + item.Direction].PositionVolume + item.PositionVolume;
                            dicod[item.ContractCode + item.Direction].UseMargin          = dicod[item.ContractCode + item.Direction].UseMargin + item.UseMargin;
                            dicod[item.ContractCode + item.Direction].SysUseMargin       = dicod[item.ContractCode + item.Direction].SysUseMargin + item.SysUseMargin;
                            dicod[item.ContractCode + item.Direction].AllPrice          += item.PositionVolume * item.OpenPrice;
                            dicod[item.ContractCode + item.Direction].OpenPrice          = dicod[item.ContractCode + item.Direction].AllPrice / dicod[item.ContractCode + item.Direction].PositionVolume;
                        }
                    }
                    if (dicod.Keys.Count > 0)
                    {
                        foreach (PotionDetailModelViewModel item in dicod.Values)
                        {
                            pavm.PMList.Add(item);
                            PositionViewModel.Instance().PMList.Add(item);
                        }
                    }
                    ScoketManager.GetInstance().SendSubscribeInfo(7, MainViewModel.GetInstance().SubscribedStocks);
                    //发送命令
                    ReqPotion rp = new ReqPotion();
                    rp.cmdcode = RequestCmdCode.SelectStopLoss;
                    rp.content = new ReqLoginName()
                    {
                        user_id = UserInfoHelper.UserId
                    };
                    ScoketManager.GetInstance().SendTradeWSInfo(JsonConvert.SerializeObject(rp));
                    //PositionViewModel.Instance().JSAbleVolume();
                    TransactionViewModel.Instance().FigureUpNum(TransactionViewModel.Instance()._futures);
                    return;
                }

                VarietyModel vm     = null;
                string[]     values = pm.contract_id.Split(' ');
                if (values.Length == 3)
                {
                    string varietie = values[1];
                    if (ContractVariety.Varieties.ContainsKey(varietie))
                    {
                        vm = ContractVariety.Varieties[varietie];
                    }
                    if (vm != null)
                    {
                        pm.precision = vm.precision;
                    }
                }

                PotionDetailModelViewModel pvm = new PotionDetailModelViewModel(pm);
                pavm.DetPMList.Add(pvm);
            }
            catch (Exception ex)
            {
                LogHelper.Info(ex.ToString());
            }
        }