/// <summary>
        /// 获取初始持仓数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_InitPosition_Click(object sender, EventArgs e)
        {
            m_positionDataSource.Clear();

            try
            {
                List <USePosition> positionList = m_orderDriver.GetDefaultPositionList();
                if (positionList == null)
                {
                    return;
                }

                foreach (USePosition position in positionList)
                {
                    TestPositionDataViewModel positionModel = TestPositionDataViewModel.Creat(position);
                    m_positionDataSource.Add(positionModel);

                    ////更新到客户端
                    //USePosition positionData = ConvertModelPositon(positionModel);
                    //m_orderDriver.ReloadInitPositionData(positionData);

                    ////更新初始持仓列表
                    //m_orderDriver.AddPositionList(positionData);
                }
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }
        }
        public USePosition ConvertModelPositon(TestPositionDataViewModel position_model)
        {
            USePosition positionData = new USePosition();

            if (position_model == null)
            {
                return(positionData);
            }
            positionData.Instrument        = position_model.Instrument;
            positionData.Direction         = position_model.Direction;
            positionData.NewPosition       = position_model.NewPosition;
            positionData.OldPosition       = position_model.OldPosition;
            positionData.NewFrozonPosition = position_model.NewFrozonPosition;
            positionData.OldFrozonPosition = position_model.OldFrozonPosition;
            positionData.YesterdayPosition = position_model.YesterdayPosition;
            positionData.AvgPirce          = position_model.AvgPrice;
            positionData.Amount            = position_model.Amount;
            positionData.OpenQty           = position_model.OpenQty;
            positionData.CloseQty          = position_model.CloseQty;
            return(positionData);
        }
        public static TestPositionDataViewModel Creat(USePosition entity)
        {
            TestPositionDataViewModel data_model = new TestPositionDataViewModel();

            data_model.Instrument           = entity.Instrument;
            data_model.Direction            = entity.Direction;
            data_model.NewPosition          = entity.NewPosition;
            data_model.OldPosition          = entity.OldPosition;
            data_model.NewFrozonPosition    = entity.NewFrozonPosition;
            data_model.NewAvaliablePosition = entity.NewAvaliablePosition;
            data_model.OldFrozonPosition    = entity.OldFrozonPosition;
            data_model.OldAvaliablePosition = entity.OldAvaliablePosition;
            data_model.YesterdayPosition    = entity.YesterdayPosition;
            data_model.AvaliablePosition    = entity.AvaliablePosition;
            data_model.AvgPrice             = entity.AvgPirce;
            data_model.Amount   = entity.Amount;
            data_model.OpenQty  = entity.OpenQty;
            data_model.CloseQty = entity.CloseQty;

            return(data_model);
        }
        /// <summary>
        /// 修改后的Position数据同步到前台客户端
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_AsycToClient_Click(object sender, EventArgs e)
        {
            DataGridViewRowCollection rows_collection = this.gridPosition.Rows;

            if (rows_collection.Count == 0)
            {
                return;
            }

            m_orderDriver.ClearPositionList();

            foreach (DataGridViewRow row in rows_collection)
            {
                TestPositionDataViewModel positionModel = row.DataBoundItem as TestPositionDataViewModel;
                USePosition positionData = ConvertModelPositon(positionModel);
                //重新更新持仓列表
                m_orderDriver.AddPositionList(positionData);

                //同步到客户端
                m_orderDriver.ReloadInitPositionData(positionData);
            }
        }