コード例 #1
0
        /// <summary>
        /// 开仓参数--远月合约价格类型。
        /// </summary>
        /// <returns></returns>
        private ArbitrageOrderPriceType GetOpenArgumentFarOrderPriceTypeFromUI()
        {
            ArbitrageOrderPriceType buyOrderPriceType = ArbitrageOrderPriceType.Unknown;

            if (orderPriceTypeControl_OpenNearArg.OrderPriceType == ArbitrageOrderPriceType.LastPrice)
            {
                return(ArbitrageOrderPriceType.LastPrice);
            }
            else if (orderPriceTypeControl_OpenNearArg.OrderPriceType == ArbitrageOrderPriceType.OpponentPrice)
            {
                return(ArbitrageOrderPriceType.OpponentPrice);
            }
            else if (orderPriceTypeControl_OpenNearArg.OrderPriceType == ArbitrageOrderPriceType.QueuePrice)
            {
                return(ArbitrageOrderPriceType.QueuePrice);
            }
            else if (orderPriceTypeControl_OpenNearArg.OrderPriceType == ArbitrageOrderPriceType.Unknown)
            {
                return(ArbitrageOrderPriceType.Unknown);
            }
            else
            {
                Debug.Assert(false);
            }

            return(buyOrderPriceType);
        }
コード例 #2
0
        private void UpdatePriceLable()
        {
            decimal nearPrice = 0m;
            decimal farPrice  = 0m;

            ArbitrageOperationSide  operationSide      = this.arbitrageOperationSideControl.OperationSide;
            ArbitrageOrderPriceType nearOrderPriceType = this.orderPriceTypeControl_OpenNearArg.OrderPriceType;
            ArbitrageOrderPriceType farOrderPriceType  = this.orderPriceTypeControl_OpenFarArg.OrderPriceType;

            if (operationSide == ArbitrageOperationSide.BuyNearSellFar)
            {
                nearPrice = GetOrderPrice(m_nearMarketData, nearOrderPriceType, USeOrderSide.Buy);
                farPrice  = GetOrderPrice(m_farMarketData, farOrderPriceType, USeOrderSide.Sell);
            }
            else if (operationSide == ArbitrageOperationSide.SellNearBuyFar)
            {
                nearPrice = GetOrderPrice(m_nearMarketData, nearOrderPriceType, USeOrderSide.Sell);
                farPrice  = GetOrderPrice(m_farMarketData, farOrderPriceType, USeOrderSide.Buy);
            }

            this.lblNearInstrumentPrice.Text = nearPrice > 0m ? nearPrice.ToString() : "---";
            this.lblFarInstrumentPrice.Text  = farPrice > 0m ? farPrice.ToString() : "---";

            if (nearPrice > 0m && farPrice >= 0m)
            {
                decimal diffPrice = (nearPrice - farPrice);
                this.lblPriceSpread.Text      = diffPrice.ToString();
                this.lblPriceSpread.ForeColor = diffPrice >= 0m ? Color.Red : Color.Green;
            }
            else
            {
                this.lblPriceSpread.Text = "---";
            }
        }
コード例 #3
0
        public static string ToDescription(this ArbitrageOrderPriceType orderPriceType)
        {
            switch (orderPriceType)
            {
            case ArbitrageOrderPriceType.LastPrice: return("最新价");

            case ArbitrageOrderPriceType.OpponentPrice: return("对手价");

            case ArbitrageOrderPriceType.QueuePrice: return("排队价");

            default: return("未知");
            }
        }
コード例 #4
0
        /// <summary>
        /// 获取优先合约下单价格。
        /// </summary>
        /// <param name="instrument">优先合约。</param>
        /// <param name="orderPriceType">下单价格类型。</param>
        /// <param name="orderSide">买卖方向。</param>
        /// <returns></returns>
        private decimal GetFirstInstrumentOrderPrice(USeInstrument instrument, ArbitrageOrderPriceType orderPriceType, USeOrderSide orderSide)
        {
            USeMarketData marketData = m_quoteDriver.Query(instrument);

            Debug.Assert(marketData != null);

            switch (orderPriceType)
            {
            case ArbitrageOrderPriceType.LastPrice: return(marketData.LastPrice);

            case ArbitrageOrderPriceType.OpponentPrice:
            {
                if (orderSide == USeOrderSide.Buy)
                {
                    return(marketData.AskPrice);
                }
                else if (orderSide == USeOrderSide.Sell)
                {
                    return(marketData.BidPrice);
                }
                else
                {
                    Debug.Assert(false);
                    return(0m);
                }
            }

            case ArbitrageOrderPriceType.QueuePrice:
            {
                if (orderSide == USeOrderSide.Buy)
                {
                    return(marketData.BidPrice);
                }
                else if (orderSide == USeOrderSide.Sell)
                {
                    return(marketData.AskPrice);
                }
                else
                {
                    Debug.Assert(false);
                    return(0m);
                }
            }

            default:
                Debug.Assert(false);
                return(0m);
            }
        }
コード例 #5
0
        /// <summary>
        /// 获取指定价格。
        /// </summary>
        /// <param name="marketData">行情。</param>
        /// <param name="priceType">价格类型。</param>
        /// <returns></returns>
        private decimal GetMarketPrice(USeMarketData marketData, ArbitrageOrderPriceType priceType)
        {
            if (marketData == null)
            {
                return(0m);
            }

            switch (priceType)
            {
            case ArbitrageOrderPriceType.LastPrice: return(marketData.LastPrice);

            case ArbitrageOrderPriceType.OpponentPrice: return(marketData.AskPrice);

            case ArbitrageOrderPriceType.QueuePrice: return(marketData.BidPrice);

            default: Debug.Assert(false); return(0m);
            }
        }
コード例 #6
0
        private bool VerifyDataTable(DataRow row, out string errorMessage)
        {
            errorMessage = string.Empty;

            string product = row["ProductName"] as string;

            int openVolumn    = Convert.ToInt32(row["OpenVolumn"]);
            int perOpenVolumn = Convert.ToInt32(row["PerOpenVolumn"]);

            int openDirection     = (int)row["OpenFirstDirectionID"];
            int closeDirection    = (int)row["CloseFirstDirectionID"];
            int stoplossDirection = (int)row["StopLossFirstDirectionID"];

            ArbitrageOrderPriceType nearOpenPriceStyle = (ArbitrageOrderPriceType)row["NearOpenPriceStyleID"];
            ArbitrageOrderPriceType farOpenPriceStyle  = (ArbitrageOrderPriceType)row["FarOpenPriceStyleID"];

            if (product == string.Empty)
            {
                errorMessage = "请选择产品";
                return(false);
            }
            if (openVolumn <= 0 || perOpenVolumn <= 0)
            {
                errorMessage = "开仓手数和每次开仓手数不能小于0";
                return(false);
            }
            if (openVolumn < perOpenVolumn)
            {
                errorMessage = "每次开仓手数不能大于总开仓手数";
                return(false);
            }
            if (openDirection == -1 || closeDirection == -1 || stoplossDirection == -1)
            {
                errorMessage = "优先开仓方向,优先平仓方向,优先止损方向请选择";
                return(false);
            }
            if (nearOpenPriceStyle == ArbitrageOrderPriceType.Unknown || farOpenPriceStyle == ArbitrageOrderPriceType.Unknown)
            {
                errorMessage = "请选择近月开仓价格类型,远月开仓价格类型";
                return(false);
            }

            return(true);
        }
コード例 #7
0
        /// <summary>
        /// 获取下单价格。
        /// </summary>
        /// <param name="marketData"></param>
        /// <param name="orderPriceType"></param>
        /// <param name="orderSide"></param>
        /// <returns></returns>
        private decimal GetOrderPrice(USeMarketData marketData, ArbitrageOrderPriceType orderPriceType, USeOrderSide orderSide)
        {
            if (marketData == null)
            {
                return(0m);
            }
            if (orderPriceType == ArbitrageOrderPriceType.Unknown)
            {
                return(0m);
            }

            switch (orderPriceType)
            {
            case ArbitrageOrderPriceType.LastPrice: return(marketData.LastPrice);

            case ArbitrageOrderPriceType.OpponentPrice:
                if (orderSide == USeOrderSide.Buy)
                {
                    return(marketData.AskPrice);
                }
                else
                {
                    Debug.Assert(orderSide == USeOrderSide.Sell);
                    return(marketData.BidPrice);
                }

            case ArbitrageOrderPriceType.QueuePrice:
            {
                if (orderSide == USeOrderSide.Buy)
                {
                    return(marketData.BidPrice);
                }
                else
                {
                    return(marketData.AskPrice);
                }
            }

            default:
                Debug.Assert(false);
                return(0m);
            }
        }
コード例 #8
0
        /// <summary>
        /// 卖出合约价格类型。
        /// </summary>
        /// <returns></returns>
        private ArbitrageOrderPriceType GetSellOrderPriceTypeFromUI()
        {
            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);
            }
            return(sellOrderPriceType);
        }
コード例 #9
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);
        }
コード例 #10
0
        /// <summary>
        /// 创建平仓任务组。
        /// </summary>
        /// <param name="openTaskGroup">开仓任务组。</param>
        /// <param name="closeArg">平仓参数。</param>
        /// <returns></returns>
        private ArbitrageTaskGroup CreateCloseTaskGroup(ArbitrageTaskGroup openTaskGroup, ArbitrageArgument argument)
        {
            ArbitrageCloseArgument closeArg = argument.CloseArg;

            Debug.Assert(openTaskGroup.BuyInstrument == closeArg.SellInstrument);
            Debug.Assert(openTaskGroup.SellInstrument == closeArg.BuyInstrument);

            int buyPosition  = openTaskGroup.SellSubTaskTradeQty; // 平仓买入量 = 开仓卖出量
            int sellPosition = openTaskGroup.BuySubTaskTradeQty;  // 平仓卖出量 = 开仓买入量

            USeInstrument           firstInstrument      = null;
            USeInstrument           secondInstrument     = null;
            USeOrderSide            firstOrderSide       = USeOrderSide.Buy;
            USeOrderSide            secondOrderSide      = USeOrderSide.Sell;
            ArbitrageOrderPriceType firstOrderPriceType  = ArbitrageOrderPriceType.Unknown;
            ArbitrageOrderPriceType secondOrderPriceType = ArbitrageOrderPriceType.Unknown;
            int firstPosition  = 0;
            int secondPosition = 0;

            if (closeArg.PreferentialSide == USeOrderSide.Buy)
            {
                //优先买入
                firstInstrument      = closeArg.BuyInstrument;
                firstOrderSide       = USeOrderSide.Buy;
                firstOrderPriceType  = closeArg.BuyInstrumentOrderPriceType;
                secondInstrument     = closeArg.SellInstrument;
                secondOrderSide      = USeOrderSide.Sell;
                secondOrderPriceType = closeArg.SellInstrumentOrderPriceType;
                firstPosition        = buyPosition;
                secondPosition       = sellPosition;
            }
            else if (closeArg.PreferentialSide == USeOrderSide.Sell)
            {
                //优先卖出
                firstInstrument      = closeArg.SellInstrument;
                firstOrderSide       = USeOrderSide.Sell;
                firstOrderPriceType  = closeArg.SellInstrumentOrderPriceType;
                secondInstrument     = closeArg.BuyInstrument;
                secondOrderSide      = USeOrderSide.Buy;
                secondOrderPriceType = closeArg.BuyInstrumentOrderPriceType;
                firstPosition        = sellPosition;
                secondPosition       = buyPosition;
            }
            else
            {
                Debug.Assert(false);
            }


            Debug.Assert(closeArg.OrderQtyUint > 0);

            int maxPositon = Math.Max(buyPosition, sellPosition);
            int taskCount  = maxPositon / closeArg.OrderQtyUint;

            if ((maxPositon % closeArg.OrderQtyUint) > 0)
            {
                taskCount += 1;
            }

            #region 构造任务组
            ArbitrageTaskGroup taskGroup = new ArbitrageTaskGroup();
            taskGroup.OpenCloseType  = OpenCloseType.Close;
            taskGroup.BuyInstrument  = closeArg.BuyInstrument;
            taskGroup.SellInstrument = closeArg.SellInstrument;
            taskGroup.BuyInstrumentOrderPriceType  = closeArg.BuyInstrumentOrderPriceType;
            taskGroup.SellInstrumentOrderPriceType = closeArg.SellInstrumentOrderPriceType;

            taskGroup.OperationSide    = argument.OperationSide.GetOppositeSide();
            taskGroup.PreferentialSide = closeArg.PreferentialSide;

            List <ArbitrageTask> taskList = new List <ArbitrageTask>();
            int remainFirstPlanQty        = firstPosition;
            int remainSecondPlanQty       = secondPosition;
            for (int i = 1; i <= taskCount; i++)
            {
                int firstPlanOrderQty = Math.Min(closeArg.OrderQtyUint, remainFirstPlanQty);
                remainFirstPlanQty -= firstPlanOrderQty;
                int secondPlanOrderQty = Math.Min(closeArg.OrderQtyUint, remainSecondPlanQty);
                remainSecondPlanQty -= secondPlanOrderQty;

                ArbitrageTask task = new ArbitrageTask();
                task.TaskId    = i;
                task.TaskState = ArbitrageTaskState.None;
                ArbitrageSubTask firstSubTask = new ArbitrageSubTask()
                {
                    Instrument     = firstInstrument,
                    OrderPriceType = firstOrderPriceType,
                    OrderSide      = firstOrderSide,
                    PlanOrderQty   = firstPlanOrderQty,
                    OffsetType     = USeOffsetType.Close,
                };
                ArbitrageSubTask secondSubTask = new ArbitrageSubTask()
                {
                    Instrument     = secondInstrument,
                    OrderPriceType = secondOrderPriceType,
                    OrderSide      = secondOrderSide,
                    PlanOrderQty   = secondPlanOrderQty,
                    OffsetType     = USeOffsetType.Close
                };

                task.FirstSubTask  = firstSubTask;
                task.SecondSubTask = secondSubTask;

                taskList.Add(task);
            }
            Debug.Assert(remainFirstPlanQty == 0);
            Debug.Assert(remainSecondPlanQty == 0);
            taskGroup.TaskList = taskList;
            #endregion

            return(taskGroup);
        }
コード例 #11
0
        /// <summary>
        /// 创建开仓任务组。
        /// </summary>
        /// <param name="openArg">开仓参数。</param>
        /// <returns></returns>
        private static ArbitrageTaskGroup CreateOpenTaskGroup(ArbitrageArgument argument)
        {
            ArbitrageOpenArgument openArg = argument.OpenArg;

            USeInstrument           firstInstrument      = null;
            USeInstrument           secondInstrument     = null;
            USeOrderSide            firstOrderSide       = USeOrderSide.Buy;
            USeOrderSide            secondOrderSide      = USeOrderSide.Sell;
            ArbitrageOrderPriceType firstOrderPriceType  = ArbitrageOrderPriceType.Unknown;
            ArbitrageOrderPriceType secondOrderPriceType = ArbitrageOrderPriceType.Unknown;

            if (openArg.PreferentialSide == USeOrderSide.Buy)
            {
                //优先买入
                firstInstrument     = openArg.BuyInstrument;
                firstOrderSide      = USeOrderSide.Buy;
                firstOrderPriceType = openArg.BuyInstrumentOrderPriceType;

                secondInstrument     = openArg.SellInstrument;
                secondOrderSide      = USeOrderSide.Sell;
                secondOrderPriceType = openArg.SellInstrumentOrderPriceType;
            }
            else if (openArg.PreferentialSide == USeOrderSide.Sell)
            {
                //优先卖出
                firstInstrument     = openArg.SellInstrument;
                firstOrderSide      = USeOrderSide.Sell;
                firstOrderPriceType = openArg.SellInstrumentOrderPriceType;

                secondInstrument     = openArg.BuyInstrument;
                secondOrderSide      = USeOrderSide.Buy;
                secondOrderPriceType = openArg.BuyInstrumentOrderPriceType;
            }
            else
            {
                Debug.Assert(false);
            }

            Debug.Assert(openArg.OrderQtyUint > 0);
            int taskCount = openArg.TotalOrderQty / openArg.OrderQtyUint;

            if ((openArg.TotalOrderQty % openArg.OrderQtyUint) > 0)
            {
                taskCount += 1;
            }

            #region 构造任务组
            ArbitrageTaskGroup taskGroup = new ArbitrageTaskGroup();
            taskGroup.OpenCloseType  = OpenCloseType.Open;
            taskGroup.BuyInstrument  = openArg.BuyInstrument;
            taskGroup.SellInstrument = openArg.SellInstrument;
            taskGroup.BuyInstrumentOrderPriceType  = openArg.BuyInstrumentOrderPriceType;
            taskGroup.SellInstrumentOrderPriceType = openArg.SellInstrumentOrderPriceType;

            taskGroup.OperationSide    = argument.OperationSide;
            taskGroup.PreferentialSide = openArg.PreferentialSide;

            List <ArbitrageTask> taskList = new List <ArbitrageTask>();
            int remainPlanQty             = openArg.TotalOrderQty;
            for (int i = 1; i <= taskCount; i++)
            {
                int planOrderQty = Math.Min(openArg.OrderQtyUint, remainPlanQty);
                Debug.Assert(planOrderQty > 0 && planOrderQty <= openArg.OrderQtyUint);
                remainPlanQty -= planOrderQty;

                ArbitrageTask task = new ArbitrageTask();
                task.TaskId    = i;
                task.TaskState = ArbitrageTaskState.None;
                ArbitrageSubTask firstSubTask = new ArbitrageSubTask()
                {
                    Instrument     = firstInstrument,
                    OrderPriceType = firstOrderPriceType,
                    OrderSide      = firstOrderSide,
                    PlanOrderQty   = planOrderQty,
                    OffsetType     = USeOffsetType.Open,
                };
                ArbitrageSubTask secondSubTask = new ArbitrageSubTask()
                {
                    Instrument     = secondInstrument,
                    OrderPriceType = secondOrderPriceType,
                    OrderSide      = secondOrderSide,
                    PlanOrderQty   = planOrderQty,
                    OffsetType     = USeOffsetType.Open
                };

                task.FirstSubTask  = firstSubTask;
                task.SecondSubTask = secondSubTask;

                taskList.Add(task);
            }
            Debug.Assert(remainPlanQty == 0);
            taskGroup.TaskList = taskList;
            #endregion

            return(taskGroup);
        }
コード例 #12
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            List <ArbitrageCombineOrderSetting> arbitrageCombineOrderList = new List <ArbitrageCombineOrderSetting>();

            try
            {
                //保存之前数据校验
                foreach (DataRow row in m_dataTable.Rows)
                {
                    string errorMessage = string.Empty;
                    if (VerifyDataTable(row, out errorMessage) == false)
                    {
                        USeFuturesSpiritUtility.ShowErrrorMessageBox(this, "请填写完整的默认信息:" + errorMessage);
                        return;
                    }
                }

                //根据界面生成结果保存
                foreach (DataRow row in m_dataTable.Rows)
                {
                    string productCode = row["ProductName"] as string;
                    Debug.Assert(productCode != string.Empty);

                    int openVolumn    = Convert.ToInt32(row["OpenVolumn"]);
                    int perOpenVolumn = Convert.ToInt32(row["PerOpenVolumn"]);

                    USeDirection openDirection = (USeDirection)row["OpenFirstDirectionID"];

                    USeDirection closeDirection    = (USeDirection)row["CloseFirstDirectionID"];
                    USeDirection stoplossDirection = (USeDirection)row["StopLossFirstDirectionID"];

                    ArbitrageOrderPriceType nearOpenPriceStyle = (ArbitrageOrderPriceType)row["NearOpenPriceStyleID"];
                    ArbitrageOrderPriceType farOpenPriceStyle  = (ArbitrageOrderPriceType)row["FarOpenPriceStyleID"];

                    ArbitrageCombineOrderSetting order = new ArbitrageCombineOrderSetting();
                    USeProduct product = new USeProduct()
                    {
                        ProductCode = productCode
                    };
                    order.Product = product;

                    order.OpenVolumn             = openVolumn;
                    order.OpenVolumnPerNum       = perOpenVolumn;
                    order.OpenFirstDirection     = openDirection;
                    order.CloseFirstDirection    = closeDirection;
                    order.StoplossFirstDirection = stoplossDirection;
                    order.NearPriceStyle         = nearOpenPriceStyle;
                    order.FarPriceStyle          = farOpenPriceStyle;

                    arbitrageCombineOrderList.Add(order);
                }
            }
            catch (Exception ex)
            {
                USeFuturesSpiritUtility.ShowWarningMessageBox(this, ex.Message);
                return;
            }

            string brokerId = USeManager.Instance.LoginUser.BrokerId;
            string account  = USeManager.Instance.LoginUser.Account;

            USeManager.Instance.DataAccessor.SaveCombineOrderSettings(brokerId, account, arbitrageCombineOrderList);

            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
コード例 #13
0
        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;
            //}
        }
コード例 #14
0
 private void btnQueuePrice_Click(object sender, EventArgs e)
 {
     this.OrderPriceType = ArbitrageOrderPriceType.QueuePrice;
 }
コード例 #15
0
 private void btnOpponentPrice_Click(object sender, EventArgs e)
 {
     this.OrderPriceType = ArbitrageOrderPriceType.OpponentPrice;
 }