public void QuickBackhandExecuteChanged()
        {
            if (SelectedItem == null)
            {
                MessageBox.Show("请选择快捷反手项", "提示", MessageBoxButton.OK, MessageBoxImage.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("可平手数不足!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            CommParameterSetting.OpenCloseing(SelectedItem, ckNum);
            CommParameterSetting.OpenCloseing(SelectedItem, ckNum, false);
        }
        public void CloseingExecuteChanged()
        {
            if (SelectedItem == null)
            {
                MessageBox.Show("请选择平仓项", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            if (CommParameterSetting.OrderVersion != null && CommParameterSetting.OrderVersion.BeforeOrderEnter)
            {
                if (MessageBox.Show("确定平仓合约" + SelectedItem.ContractId + "吗?", "", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.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("可平手数不足!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            CommParameterSetting.OpenCloseing(SelectedItem, ckNum);
        }
        public void TradeAllExecuteChanged()
        {
            if (PMList.Count > 0)
            {
                if (MessageBox.Show("对所有持仓执行平仓操作,是否确认?", "", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.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;
                    }
                    CommParameterSetting.OpenCloseing(item, ckNum);
                    // LogHelper.Info(item.ContractCode + " " + (item.PositionVolume - ckNum) + ":总持仓:" + item.PositionVolume + " 挂单数量:" + ckNum);
                }
                if (isUns)
                {
                    MessageBox.Show("持仓中部分合约可平手数不足!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return;
                }
            }
        }
        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 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);
     }
 }
Example #6
0
        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();
        }
Example #7
0
        public void QuicklyUnwindExecuteChanged()
        {
            if (SelectedItem == null)
            {
                MessageBox.Show("请选择平仓项", "提示", MessageBoxButton.OK, MessageBoxImage.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("可平手数不足!", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            TransactionViewModel.Instance().SelectFutures(SelectedItem.ContractId, SelectedItem.PositionVolume - ckNum);
            CommParameterSetting.OpenCloseing(SelectedItem, ckNum);
        }
 public TransactionPannelViewModel()
 {
     Position    = PositionViewModel.Instance();
     OrderCancel = OrderCancelViewModel.Instance();
 }