/// <summary> /// 添加预警 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_AddNotify_Click(object sender, EventArgs e) { ArbitragePriceSpreadAlarmType monitorType = this.arbitragePriceSpreadMonitorTypeControl.MonitorType; PriceSpreadSide priceSpreadSide = this.priceSpreadSideControl_Alarm.PriceSpreadSide; decimal threshold = this.nudPriceSpreadThreshold_Alarm.Value; ArbitrageAlarmArgument args = new ArbitrageAlarmArgument(); args.MonitorType = monitorType; args.PriceSpreadSide = priceSpreadSide; args.PriceSpreadThreshold = threshold; ArbitrageAlarmArgumentViewModel model = ArbitrageAlarmArgumentViewModel.CreatViewModel(args); ArbitrageAlarmArgumentViewModel hasModel = (from m in m_dataSourceAlarm where m.Equals(model) select m).FirstOrDefault(); if (hasModel != null) { USeFuturesSpiritUtility.ShowWarningMessageBox(this, "不能添加重复的预警"); return; } m_dataSourceAlarm.Add(ArbitrageAlarmArgumentViewModel.CreatViewModel(args)); }
/// <summary> /// 初始化预警列表。 /// </summary> private void InitializeAlarmList() { m_dataSourceAlarm = new BindingList <ArbitrageAlarmArgumentViewModel>(); this.gridAlarmCondition.AutoGenerateColumns = false; this.gridAlarmCondition.DataSource = m_dataSourceAlarm; if (m_arbitrageArgument != null && m_arbitrageArgument.AlarmArgs != null) { foreach (ArbitrageAlarmArgument alarmArg in m_arbitrageArgument.AlarmArgs) { ArbitrageAlarmArgumentViewModel model = ArbitrageAlarmArgumentViewModel.CreatViewModel(alarmArg); } } }
/// <summary> /// 设置前套利参数用于修改 /// </summary> private void SetArbitrageArgument(ArbitrageArgument arg) { this.arbitrageOperationSideControl.OperationSide = arg.OperationSide; //开仓参数参数 if (arg.OpenArg != null) { ArbitrageOpenArgument openArg = arg.OpenArg; this.preferentialSideControl_OpenArg.PreferentialSide = openArg.PreferentialSide; this.orderPriceTypeControl_OpenNearArg.OrderPriceType = openArg.NearOrderPriceType; this.orderPriceTypeControl_OpenFarArg.OrderPriceType = openArg.FarOrderPriceType; this.priceSpreadSideControl_OpenSpreadArg.PriceSpreadSide = openArg.OpenCondition.PriceSpreadSide; this.nudPriceSpreadThreshold_OpenArg.Value = openArg.OpenCondition.PriceSpreadThreshold; this.nudDifferentialUnit_OpenArg.Value = openArg.DifferentialUnit; this.nudOrderQtyUint_OpenArg.Value = openArg.OrderQtyUint; this.nudTotalOrderQty_OpenArg.Value = openArg.TotalOrderQty; } //平仓参数 if (arg.CloseArg != null) { ArbitrageCloseArgument closeArg = arg.CloseArg; this.orderPriceTypeControl_CloseNearArg.OrderPriceType = closeArg.NearOrderPriceType; this.orderPriceTypeControl_CloseFarArg.OrderPriceType = closeArg.FarOrderPriceType; this.preferentialSideControl_CloseArg.PreferentialSide = closeArg.PreferentialSide; this.priceSpreadSideControl_CloseSpreadArg.PriceSpreadSide = closeArg.CloseCondition.PriceSpreadSide; this.nudPriceSpreadThreshold_CloseArg.Value = closeArg.CloseCondition.PriceSpreadThreshold; this.nudDifferentialUnit_CloseArg.Value = closeArg.DifferentialUnit; this.nudOrderQtyUint_CloseArg.Value = closeArg.OrderQtyUint; } //止损参数 if (arg.StopLossArg != null) { this.priceSpreadSideControl_StopLossArg.PriceSpreadSide = arg.StopLossArg.StopLossCondition.PriceSpreadSide; this.nudPriceSpreadThreshold_StopLossArg.Value = arg.StopLossArg.StopLossCondition.PriceSpreadThreshold; } //预警参数 if (arg.AlarmArgs != null) { foreach (ArbitrageAlarmArgument alarmArg in arg.AlarmArgs) { m_dataSourceAlarm.Add(ArbitrageAlarmArgumentViewModel.CreatViewModel(alarmArg)); } } }