コード例 #1
0
        private void SetDefaultAribtrageArgument()
        {
            ArbitrageCombineOrderSetting combineSetting = null;

            try
            {
                string brokerId = USeManager.Instance.LoginUser.BrokerId;
                string account  = USeManager.Instance.LoginUser.Account;
                combineSetting = USeManager.Instance.DataAccessor.GetCombineOrderSetting(brokerId, account, m_product.ProductCode);
            }
            catch (Exception ex)
            {
                USeFuturesSpiritUtility.ShowErrrorMessageBox(this, "获取套利下单参数异常:" + ex.Message);
                return;
            }

            if (combineSetting == null)
            {
                combineSetting = CreateDefaultCombineOrderSetting();
            }

            //开仓参数
            this.preferentialSideControl_OpenArg.PreferentialSide     = (combineSetting.OpenFirstDirection == USeDirection.Long) ? USeOrderSide.Buy : USeOrderSide.Sell;
            this.orderPriceTypeControl_OpenNearArg.OrderPriceType     = combineSetting.NearPriceStyle;
            this.orderPriceTypeControl_OpenFarArg.OrderPriceType      = combineSetting.FarPriceStyle;
            this.priceSpreadSideControl_OpenSpreadArg.PriceSpreadSide = PriceSpreadSide.LessOrEqual;
            this.nudPriceSpreadThreshold_OpenArg.Value = 0;
            this.nudDifferentialUnit_OpenArg.Value     = 0;
            this.nudOrderQtyUint_OpenArg.Value         = combineSetting.OpenVolumnPerNum;
            this.nudTotalOrderQty_OpenArg.Value        = combineSetting.OpenVolumn;

            //平仓参数
            this.preferentialSideControl_CloseArg.PreferentialSide     = (combineSetting.CloseFirstDirection == USeDirection.Long) ? USeOrderSide.Buy : USeOrderSide.Sell;
            this.orderPriceTypeControl_CloseNearArg.OrderPriceType     = combineSetting.NearPriceStyle;
            this.orderPriceTypeControl_CloseFarArg.OrderPriceType      = combineSetting.FarPriceStyle;
            this.priceSpreadSideControl_CloseSpreadArg.PriceSpreadSide = PriceSpreadSide.LessOrEqual;
            this.nudPriceSpreadThreshold_CloseArg.Value = 0;
            this.nudDifferentialUnit_CloseArg.Value     = 0;

            //止损
            this.priceSpreadSideControl_StopLossArg.PriceSpreadSide = PriceSpreadSide.LessOrEqual;
            this.nudPriceSpreadThreshold_StopLossArg.Value          = 0;

            //预警
            this.arbitragePriceSpreadMonitorTypeControl.MonitorType = ArbitragePriceSpreadAlarmType.Open;
            this.nudPriceSpreadThreshold_Alarm.Value = 0;

#if DEBUG
            this.arbitrageOperationSideControl.OperationSide = ArbitrageOperationSide.BuyNearSellFar;
            this.nudPriceSpreadThreshold_OpenArg.Value       = -50;
            this.nudPriceSpreadThreshold_CloseArg.Value      = -70;
            this.nudPriceSpreadThreshold_StopLossArg.Value   = -30;
            this.nudTotalOrderQty_OpenArg.Value     = 10;
            this.nudDifferentialUnit_OpenArg.Value  = 2;
            this.nudDifferentialUnit_CloseArg.Value = 2;
            this.nudOrderQtyUint_OpenArg.Value      = 2;
            this.nudOrderQtyUint_CloseArg.Value     = 2;
#endif
        }
コード例 #2
0
        /// <summary>
        /// 创建默认下单参数
        /// </summary>
        /// <returns></returns>
        private ArbitrageCombineOrderSetting CreateDefaultCombineOrderSetting()
        {
            ArbitrageCombineOrderSetting orderSetting = new ArbitrageCombineOrderSetting();

            orderSetting.OpenFirstDirection = USeDirection.Long;
            orderSetting.NearPriceStyle     = ArbitrageOrderPriceType.OpponentPrice;
            orderSetting.FarPriceStyle      = ArbitrageOrderPriceType.OpponentPrice;

            orderSetting.CloseFirstDirection = USeDirection.Long;
            orderSetting.OpenVolumn          = 0;
            orderSetting.OpenVolumnPerNum    = 0;



            return(orderSetting);
        }
コード例 #3
0
        private void FillData(List <ArbitrageCombineOrderSetting> arbitrageSettingsList, DataTable table)
        {
            if (arbitrageSettingsList == null || table == null)
            {
                return;
            }
            foreach (ArbitrageCombineOrderSetting combineOrder in arbitrageSettingsList)
            {
                ArbitrageCombineOrderSetting order = combineOrder;
                DataRow row = table.NewRow();
                row["Product"]     = order.Product;
                row["ProductDesc"] = order.Product.ShortName;
                row["ProductName"] = order.Product.ProductCode;

                row["OpenVolumn"]    = order.OpenVolumn;
                row["PerOpenVolumn"] = order.OpenVolumnPerNum;

                row["OpenFirstDirection"]     = order.OpenFirstDirection;
                row["OpenFirstDirectionID"]   = (int)order.OpenFirstDirection;
                row["OpenFirstDirectionDesc"] = order.OpenFirstDirection.ToDescription();

                row["CloseFirstDirection"]     = order.CloseFirstDirection;
                row["CloseFirstDirectionDesc"] = order.CloseFirstDirection.ToDescription();
                row["CloseFirstDirectionID"]   = (int)order.CloseFirstDirection;

                row["StopLossFirstDirection"]     = order.StoplossFirstDirection;
                row["StopLossFirstDirectionDesc"] = order.StoplossFirstDirection.ToDescription();
                row["StopLossFirstDirectionID"]   = (int)order.StoplossFirstDirection;


                row["NearOpenPriceStyle"]     = order.NearPriceStyle;
                row["NearOpenPriceStyleDesc"] = order.NearPriceStyle.ToDescription();
                row["NearOpenPriceStyleID"]   = (int)order.NearPriceStyle;

                row["FarOpenPriceStyle"]     = order.FarPriceStyle;
                row["FarOpenPriceStyleDesc"] = order.FarPriceStyle.ToDescription();
                row["FarOpenPriceStyleID"]   = (int)order.FarPriceStyle;


                table.Rows.Add(row);
            }
        }
コード例 #4
0
 /// <summary>
 /// 设置合约默认下单参数
 /// </summary>
 /// <param name="combineOrderSetting"></param>
 private void SetOrderArgument(ArbitrageCombineOrderSetting combineOrderSetting)
 {
     Debug.Assert(combineOrderSetting != null);
 }
コード例 #5
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();
        }