public void ExecuteSendPlaceOrderData1(object para)
        {
            try
            {
                DelegationModel rtm = para as DelegationModel;

                DelegationModelViewModel dmvm = OrderCancelViewModel.Instance().Delegations.FirstOrDefault(x => x.OrderId == rtm.order_id && rtm.user_id == UserInfoHelper.UserId);
                if (dmvm == null)
                {
                    OrderCancelViewModel.Instance().Delegations.Add(new DelegationModelViewModel(rtm));
                }
                else
                {
                    dmvm.OrderStatus = rtm.order_status;
                    //详细状态
                    dmvm.FailMsg = rtm.fail_msg;
                }
                DelegationModelViewModel dmvm1 = OrderCancelViewModel.Instance().KCDelegations.FirstOrDefault(x => x.OrderId == rtm.order_id && rtm.user_id == UserInfoHelper.UserId);
                if (dmvm1 != null)
                {
                    OrderCancelViewModel.Instance().KCDelegations.Remove(dmvm1);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Info(ex.ToString());
            }
        }
Exemple #2
0
        public void QuickBackhandExecuteChanged()
        {
            if (SelectedItem == null)
            {
                MessageBox.Show("请选择快捷反手项", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            IsReadOnly = false;
            Action RefreshHandel = Refresh;

            RefreshHandel.BeginInvoke(null, RefreshHandel);
            List <DelegationModelViewModel> ckitem = OrderCancelViewModel.Instance().KCDelegations.Where(x => x.ContractCode == SelectedItem.ContractId && x.Direction != SelectedItem.Direction && x.OpenOffset == (int)OffsetType.OFFSET_COVER).ToList();
            int ckNum = 0;

            if (ckitem != null && ckitem.Count > 0)
            {
                ckNum = ckitem.Sum(x => x.OrderVolume);
            }
            if (SelectedItem.PositionVolume - ckNum <= 0)
            {
                MessageBox.Show("可平手数不足!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            AutoStopLossComm.OpenCloseing(SelectedItem, ckNum);
            AutoStopLossComm.OpenCloseing(SelectedItem, ckNum, false);
        }
Exemple #3
0
        public void CloseingExecuteChanged()
        {
            if (SelectedItem == null)
            {
                MessageBox.Show("请选择平仓项", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (CommParameterSetting.OrderVersion != null && CommParameterSetting.OrderVersion.BeforeOrderEnter)
            {
                if (MessageBox.Show("确定平仓合约" + SelectedItem.ContractId + "吗?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
                {
                    return;
                }
            }
            List <DelegationModelViewModel> ckitem = OrderCancelViewModel.Instance().KCDelegations.Where(x => x.ContractID == SelectedItem.ContractId && x.Direction != SelectedItem.Direction && x.OpenOffset == (int)OffsetType.OFFSET_COVER).ToList();
            int ckNum = 0;

            if (ckitem != null && ckitem.Count > 0)
            {
                ckNum = ckitem.Sum(x => x.OrderVolume);
            }
            if (SelectedItem.PositionVolume - ckNum <= 0)
            {
                MessageBox.Show("可平手数不足!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            AutoStopLossComm.OpenCloseing(SelectedItem, ckNum);
        }
Exemple #4
0
        public void TradeAllExecuteChanged()
        {
            if (PMList.Count > 0)
            {
                if (MessageBox.Show("对所有持仓执行平仓操作,是否确认?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
                {
                    return;
                }

                bool isUns = false;

                foreach (PotionDetailModelViewModel item in PMList)
                {
                    List <DelegationModelViewModel> ckitem = null;
                    ckitem = OrderCancelViewModel.Instance().KCDelegations.Where(x => x.ContractCode == item.ContractId && x.Direction != item.Direction && x.OpenOffset == (int)OffsetType.OFFSET_COVER).ToList();
                    int ckNum = 0;
                    if (ckitem != null && ckitem.Count > 0)
                    {
                        ckNum = ckitem.Sum(x => x.OrderVolume);
                    }
                    if (item.PositionVolume - ckNum <= 0)
                    {
                        isUns = true;
                        continue;
                    }
                    AutoStopLossComm.OpenCloseing(item, ckNum);
                    // LogHelper.Info(item.ContractCode + " " + (item.PositionVolume - ckNum) + ":总持仓:" + item.PositionVolume + " 挂单数量:" + ckNum);
                }
                if (isUns)
                {
                    MessageBox.Show("持仓中部分合约可平手数不足!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
        }
Exemple #5
0
 public static OrderCancelViewModel Instance()
 {
     if (_OrderCancelViewModel == null)
     {
         _OrderCancelViewModel = new OrderCancelViewModel();
     }
     return(_OrderCancelViewModel);
 }
Exemple #6
0
        public void GotFocusExecuteChanged()
        {
            if (SelectedItem == null)
            {
                return;
            }
            List <DelegationModelViewModel> ckitem = OrderCancelViewModel.Instance().KCDelegations.Where(x => x.ContractCode == SelectedItem.ContractId && x.Direction != SelectedItem.Direction && x.OpenOffset == (int)OffsetType.OFFSET_COVER).ToList();
            int ckNum = 0;

            if (ckitem != null && ckitem.Count > 0)
            {
                ckNum = ckitem.Sum(x => x.OrderVolume);
            }
            TransactionViewModel.Instance().dic = SelectedItem.Direction;
            TransactionViewModel.Instance().SelectFutures(SelectedItem.ContractId, SelectedItem.PositionVolume - ckNum);
            TransactionViewModel.Instance().IsEnabled = true;
        }
        public void ExecuteDelegationData(object para)
        {
            try
            {
                DelegationModel      rtm  = para as DelegationModel;
                OrderCancelViewModel ocvm = OrderCancelViewModel.Instance();
                if (ocvm.Delegations.FirstOrDefault(x => x.OrderId == rtm.order_id) != null)
                {
                    return;
                }
                if (rtm.bLast)
                {
                    //PositionViewModel.Instance().JSAbleVolume();
                    TransactionViewModel.Instance().FigureUpNum(TransactionViewModel.Instance()._futures);
                    return;
                }
                VarietyModel vm     = null;
                string[]     values = rtm.contract_code.Split(' ');
                if (values.Length == 3)
                {
                    string varietie = values[1];
                    if (ContractVariety.Varieties.ContainsKey(varietie))
                    {
                        vm = ContractVariety.Varieties[varietie];
                    }
                    if (vm != null)
                    {
                        rtm.precision = vm.precision;
                    }
                }


                DelegationModelViewModel dmvm = new DelegationModelViewModel(rtm);

                ocvm.Delegations.Add(dmvm);
                if (rtm.order_status == (int)DeleteType.CreateSuccess || rtm.order_status == (int)DeleteType.PortionTakeEffect)
                {
                    ocvm.KCDelegations.Add(dmvm);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Info(ex.ToString());
            }
        }
        public void ExecutePlaceOrderData(object para)
        {
            try
            {
                DelegationModel rtm = para as DelegationModel;
                //添加持仓集合
                if (!rtm.bLast)
                {
                    VarietyModel vm     = null;
                    string[]     values = rtm.contract_id.Split(' ');
                    if (values.Length == 3)
                    {
                        string varietie = values[1];
                        if (ContractVariety.Varieties.ContainsKey(varietie))
                        {
                            vm = ContractVariety.Varieties[varietie];
                        }
                        if (vm != null)
                        {
                            rtm.precision = vm.precision;
                        }
                    }
                }
                if (OrderCancelViewModel.Instance().Delegations.FirstOrDefault(x => x.OrderId == rtm.order_id) == null)
                {
                    OrderCancelViewModel.Instance().Delegations.Add(new DelegationModelViewModel(rtm));
                    LogHelper.Info("4002 增加" + rtm.contract_code + ":" + rtm.direction + ":" + rtm.open_offset + ":" + rtm.order_status);
                }

                if (CommParameterSetting.MessageAlert.OrderAlert == "窗口提示")
                {
                    MessageBox.Show(rtm.contract_id + " 委托创建成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (CommParameterSetting.MessageAlert.OrderAlert == "声音提示")
                {
                    SoundPlayerHelper.Play();
                }
            }
            catch (Exception ex)
            {
                LogHelper.Info(ex.ToString());
            }
        }
Exemple #9
0
 public void JSAbleVolume()
 {
     try
     {
         foreach (PotionDetailModelViewModel item in PMList)
         {
             List <DelegationModelViewModel> pdmvm1 = OrderCancelViewModel.Instance().KCDelegations.Where(x => x.ContractCode == item.ContractCode && x.Direction != item.Direction && x.OpenOffset == (int)OffsetType.OFFSET_COVER).ToList();
             int cknum0 = 0;
             if (pdmvm1 != null && pdmvm1.Count > 0)
             {
                 cknum0 = pdmvm1.Sum(x => x.OrderVolume);
             }
             item.BDAbleVolume = item.PositionVolume - cknum0;
         }
     }
     catch (Exception ex)
     {
         LogHelper.Info(ex.Message);
     }
 }
        public void CheckFullStopExecuteChanged()
        {
            if (SelectedItem == null)
            {
                MessageBox.Show("请选择持仓项!");
                return;
            }
            List <DelegationModelViewModel> ckitem = OrderCancelViewModel.Instance().KCDelegations.Where(x => x.ContractCode == SelectedItem.ContractId && x.Direction != SelectedItem.Direction && x.OpenOffset == (int)OffsetType.OFFSET_COVER).ToList();
            int ckNum = 0;

            if (ckitem != null && ckitem.Count > 0)
            {
                ckNum = ckitem.Sum(x => x.OrderVolume);
            }
            TransactionViewModel.Instance().dic = SelectedItem.Direction;
            TransactionViewModel.Instance().SelectFutures(SelectedItem.ContractId, SelectedItem.PositionVolume - ckNum);
            TransactionViewModel.Instance().IsEnabled = true;
            //CheckFullStop cfs = new CheckFullStop(SelectedItem);
            //cfs.Owner = ContractVariety.main;
            //cfs.ShowDialog();
        }
        public void QuicklyUnwindExecuteChanged()
        {
            if (SelectedItem == null)
            {
                MessageBox.Show("请选择平仓项", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            List <DelegationModelViewModel> ckitem = OrderCancelViewModel.Instance().KCDelegations.Where(x => x.ContractCode == SelectedItem.ContractId && x.Direction != SelectedItem.Direction && x.OpenOffset == (int)OffsetType.OFFSET_COVER).ToList();
            int ckNum = 0;

            if (ckitem != null && ckitem.Count > 0)
            {
                ckNum = ckitem.Sum(x => x.OrderVolume);
            }
            if (SelectedItem.PositionVolume - ckNum <= 0)
            {
                MessageBox.Show("可平手数不足!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            TransactionViewModel.Instance().SelectFutures(SelectedItem.ContractId, SelectedItem.PositionVolume - ckNum);
            AutoStopLossComm.OpenCloseing(SelectedItem, ckNum);
        }
        public void ExecuteSendPlaceOrderData(object para)
        {
            try
            {
                DelegationModel rtm    = para as DelegationModel;
                VarietyModel    vm     = null;
                string[]        values = rtm.contract_code.Split(' ');
                if (values.Length == 3)
                {
                    string varietie = values[1];
                    if (ContractVariety.Varieties.ContainsKey(varietie))
                    {
                        vm = ContractVariety.Varieties[varietie];
                    }
                    if (vm != null)
                    {
                        rtm.precision = vm.precision;
                    }
                }

                DelegationModelViewModel dmvm = OrderCancelViewModel.Instance().Delegations.FirstOrDefault(x => x.OrderId == rtm.order_id);
                if (dmvm == null)
                {
                    return;
                    //OrderCancelViewModel.Instance().Delegations.Add(new DelegationModelViewModel(rtm));
                }
                //DelegationModelViewModel dmvmisHave = OrderCancelViewModel.Instance().Delegations.FirstOrDefault(x => x.OrderId == rtm.order_id && x.OrderStatus == (int)DeleteType.CreateSuccess);
                ////if (dmvmisHave != null)
                //{
                //    return;
                //    //OrderCancelViewModel.Instance().Delegations.Add(new DelegationModelViewModel(rtm));
                //}
                if (rtm.order_status == (int)DeleteType.CreateSuccess || rtm.order_status == (int)DeleteType.PortionTakeEffect)
                {
                    DelegationModelViewModel dmvm1 = OrderCancelViewModel.Instance().KCDelegations.FirstOrDefault(x => x.OrderId == rtm.order_id && rtm.user_id == UserInfoHelper.UserId);
                    if (dmvm1 == null)
                    {
                        OrderCancelViewModel.Instance().KCDelegations.Add(new DelegationModelViewModel(rtm));
                        LogHelper.Info("4003  增加 可撤" + rtm.contract_code + ":" + rtm.direction + ":" + rtm.open_offset + ":" + rtm.order_status);
                    }

                    dmvm.OrderStatus = rtm.order_status;
                    //详细状态
                    dmvm.FailMsg = rtm.fail_msg;
                }
                else
                {
                    dmvm.LeftVolume  = dmvm.OrderVolume - rtm.trade_volume;
                    dmvm.TradeVolume = rtm.trade_volume;
                    dmvm.OrderStatus = rtm.order_status;
                    dmvm.LeftVolume  = rtm.left_volume;

                    //详细状态
                    dmvm.FailMsg = rtm.fail_msg;
                    DelegationModelViewModel dmvm1 = OrderCancelViewModel.Instance().KCDelegations.FirstOrDefault(x => x.OrderId == rtm.order_id && rtm.user_id == UserInfoHelper.UserId);

                    if (dmvm1 != null)
                    {
                        OrderCancelViewModel.Instance().KCDelegations.Remove(dmvm1);
                        LogHelper.Info("4003  移除 可撤" + rtm.contract_code + ":" + rtm.direction + ":" + rtm.open_offset + ":" + rtm.order_status);
                    }
                }

                DelegationModelViewModel tem1 = OrderCancelViewModel.Instance().KCDelegations.FirstOrDefault(x => x.OrderId == rtm.order_id && rtm.user_id == UserInfoHelper.UserId);
                if (tem1 != null)
                {
                    tem1.LeftVolume  = tem1.OrderVolume - rtm.trade_volume;
                    tem1.TradeVolume = rtm.trade_volume;
                    tem1.OrderStatus = rtm.order_status;
                    //详细状态
                    dmvm.FailMsg = rtm.fail_msg;
                }
                if (rtm.order_status == (int)DeleteType.UnTakeEffecUserCannel)
                {
                    if (CommParameterSetting.MessageAlert.RevokeAlert == "窗口提示")
                    {
                        MessageBox.Show(rtm.contract_id + " 委托撤单成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else if (CommParameterSetting.MessageAlert.RevokeAlert == "声音提示")
                    {
                        SoundPlayerHelper.Play();
                    }
                }
                TransactionViewModel.Instance().SelectNumExecuteChanged();
            }
            catch (Exception ex)
            {
                LogHelper.Info(ex.ToString());
            }
        }
 public TransactionPannelViewModel()
 {
     Position    = PositionViewModel.Instance();
     OrderCancel = OrderCancelViewModel.Instance();
 }