/// <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>
        /// <returns></returns>
        private PriceSpreadSide GetPriceSpreadSideFromUI()
        {
            PriceSpreadSide priceSpreadSide = PriceSpreadSide.Unknown;

            if (this.rbnPriceSpreadSide_Greater.Checked)
            {
                priceSpreadSide = PriceSpreadSide.GreaterOrEqual;
            }
            else if (this.rbnPriceSpreadSide_Less.Checked)
            {
                priceSpreadSide = PriceSpreadSide.LessOrEqual;
            }
            else
            {
                Debug.Assert(false);
            }
            return(priceSpreadSide);
        }
        /// <summary>
        /// 开仓参数--获取价差监控类型
        /// </summary>
        /// <returns></returns>
        private PriceSpreadSide GetOpenArgumentSpreadTypeFromUI()
        {
            PriceSpreadSide spreadType = PriceSpreadSide.Unknown;

            if (priceSpreadSideControl_OpenSpreadArg.PriceSpreadSide == PriceSpreadSide.GreaterOrEqual)
            {
                return(PriceSpreadSide.GreaterOrEqual);
            }
            else if (priceSpreadSideControl_OpenSpreadArg.PriceSpreadSide == PriceSpreadSide.LessOrEqual)
            {
                return(PriceSpreadSide.LessOrEqual);
            }
            else
            {
                Debug.Assert(false);
            }

            return(spreadType);
        }
示例#4
0
        public ArbitrageOpenArgument GetOpenArgument(out string errorMessage)
        {
            if (VerifyOpenArgument(out errorMessage) == false)
            {
                return(null);
            }

            USeInstrument buyInstrument  = this.cbxBuyInstrument.SelectedItem as USeInstrument;
            USeInstrument sellInstrument = this.cbxSellInstrument.SelectedItem as USeInstrument;

            ArbitrageOrderPriceType buyOrderPriceType = ArbitrageOrderPriceType.Unknown;

            if (this.rbnBuyOrderPriceType_LastPrice.Checked)
            {
                buyOrderPriceType = ArbitrageOrderPriceType.LastPrice;
            }
            else if (this.rbnBuyOrderPriceType_OpponentPrice.Checked)
            {
                buyOrderPriceType = ArbitrageOrderPriceType.OpponentPrice;
            }
            else if (this.rbnBuyOrderPriceType_QueuePrice.Checked)
            {
                buyOrderPriceType = ArbitrageOrderPriceType.QueuePrice;
            }
            else
            {
                Debug.Assert(false);
            }

            ArbitrageOrderPriceType sellOrderPriceType = ArbitrageOrderPriceType.Unknown;

            if (this.rbnSellOrderPriceType_LastPrice.Checked)
            {
                sellOrderPriceType = ArbitrageOrderPriceType.LastPrice;
            }
            else if (this.rbnSellOrderPriceType_OpponentPrice.Checked)
            {
                sellOrderPriceType = ArbitrageOrderPriceType.OpponentPrice;
            }
            else if (this.rbnSellOrderPriceType_QueuePrice.Checked)
            {
                sellOrderPriceType = ArbitrageOrderPriceType.QueuePrice;
            }
            else
            {
                Debug.Assert(false);
            }

            USeOrderSide preferentialSide = USeOrderSide.Buy;

            if (this.rbnPreferentialSide_Buy.Checked)
            {
                preferentialSide = USeOrderSide.Buy;
            }
            else if (this.rbnPreferentialSide_Sell.Checked)
            {
                preferentialSide = USeOrderSide.Sell;
            }
            else
            {
                Debug.Assert(false);
            }

            PriceSpreadSide priceSpreadSide = PriceSpreadSide.Unknown;

            if (this.rbnPriceSpreadSide_Greater.Checked)
            {
                priceSpreadSide = PriceSpreadSide.GreaterOrEqual;
            }
            else if (this.rbnPriceSpreadSide_Less.Checked)
            {
                priceSpreadSide = PriceSpreadSide.LessOrEqual;
            }
            else
            {
                Debug.Assert(false);
            }

            ArbitrageOpenArgument openArg = new ArbitrageOpenArgument();

            openArg.BuyInstrument = buyInstrument;
            openArg.BuyInstrumentOrderPriceType = buyOrderPriceType;
            openArg.SellInstrument = sellInstrument;
            openArg.SellInstrumentOrderPriceType = sellOrderPriceType;
            openArg.PreferentialSide             = preferentialSide;
            openArg.OpenCondition = new PriceSpreadCondition()
            {
                PriceSpreadSide      = priceSpreadSide,
                PriceSpreadThreshold = this.nudPriceSpreadThreshold.Value
            };
            openArg.TotalOrderQty    = (int)this.nudTotalOrderQty.Value;
            openArg.OrderQtyUint     = (int)this.nudOrderQtyUint.Value;
            openArg.DifferentialUnit = (int)this.nudDifferentialUnit.Value;

            return(openArg);
        }
示例#5
0
 private void btnLessOrEqual_Click(object sender, EventArgs e)
 {
     this.PriceSpreadSide = PriceSpreadSide.LessOrEqual;
 }
        private void btnOpenArbitrageOrder_Click(object sender, EventArgs e)
        {
            string errorMessage = string.Empty;

            if (VerifyOpenArgument(out errorMessage) == false)
            {
                USeFuturesSpiritUtility.ShowWarningMessageBox(this, errorMessage);
                return;
            }

            USeInstrument buyInstrument  = this.cbxBuyInstrument.SelectedItem as USeInstrument;
            USeInstrument sellInstrument = this.cbxSellInstrument.SelectedItem as USeInstrument;

            ArbitrageOrderPriceType buyOrderPriceType  = GetBuyOrderPriceTypeFromUI();
            ArbitrageOrderPriceType sellOrderPriceType = GetSellOrderPriceTypeFromUI();
            USeOrderSide            preferentialSide   = GetPreferentialSideFromUI();
            PriceSpreadSide         priceSpreadSide    = GetPriceSpreadSideFromUI();

            ArbitrageOpenArgument openArg = new ArbitrageOpenArgument();

            openArg.BuyInstrument = buyInstrument;
            openArg.BuyInstrumentOrderPriceType = buyOrderPriceType;
            openArg.SellInstrument = sellInstrument;
            openArg.SellInstrumentOrderPriceType = sellOrderPriceType;
            openArg.PreferentialSide             = preferentialSide;
            openArg.OpenCondition = new PriceSpreadCondition()
            {
                PriceSpreadSide      = priceSpreadSide,
                PriceSpreadThreshold = this.nudPriceSpreadThreshold.Value
            };
            openArg.TotalOrderQty    = (int)this.nudTotalOrderQty.Value;
            openArg.OrderQtyUint     = (int)this.nudOrderQtyUint.Value;
            openArg.DifferentialUnit = (int)this.nudDifferentialUnit.Value;

            if (VerifyMargin(openArg, out errorMessage) == false)
            {
                USeFuturesSpiritUtility.ShowWarningMessageBox(this, errorMessage);
                return;
            }

            decimal evaluateMargin = EvaluateMargin(openArg);
            string  text           = string.Format("套利单预计占用保证金 {0},确定跟单么?", evaluateMargin.ToString("#,0"));

            if (DialogResult.Yes != USeFuturesSpiritUtility.ShowYesNoMessageBox(this, text))
            {
                return;
            }

            //try
            //{
            //    AutoTraderManager traderManager = USeManager.Instance.AutoTraderManager;
            //    Debug.Assert(traderManager != null);

            //    AutoTrader trader = traderManager.CreateNewAutoTrader(openArg, USeManager.Instance.LoginUser);
            //    trader.BeginOpen();
            //    //[yangming]创建后应该启动跟单
            //    trader.StartOpenOrCloseMonitor();

            //    USeManager.Instance.DataSaver.AddSaveTask(trader.GetArbitrageOrder());
            //}
            //catch (Exception ex)
            //{
            //    USeFuturesSpiritUtility.ShowWarningMessageBox(this, ex.Message);
            //    return;
            //}
        }