private void BindData() { try { if (m_arbitrageOrder != null) { if (m_arbitrageOrder.State <= ArbitrageOrderState.Opened) { this.tabControl1.SelectedTab = this.tpOpen; } else { this.tabControl1.SelectedTab = this.tpClose; } this.Text = string.Format("套利单 [{0}] 详情", m_arbitrageOrder.Alias); this.arbitrageCloseArgumentView2Control1.SetCloseArgument(m_arbitrageOrder.CloseArgument); this.arbitrageOpenArgumentView2Control1.SetOpenArgument(m_arbitrageOrder.OpenArgument); this.openTaskGroupView.SetDataSource(m_arbitrageOrder.OpenTaskGroup); this.closeTaskGroupView.SetDataSource(m_arbitrageOrder.CloseTaskGroup); } } catch (Exception ex) { USeFuturesSpiritUtility.ShowErrrorMessageBox(this, ex.Message); } }
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 }
private void tsmiOpen_ForceOpenFinish_Click(object sender, EventArgs e) { try { m_autoTrader.ForceOpenFinish(); } catch (Exception ex) { USeFuturesSpiritUtility.ShowErrrorMessageBox(this, ex.Message); } }
private void tsmiOpen_StopOpenChaseOrder_Click(object sender, EventArgs e) { try { m_autoTrader.StopOpenChaseOrder(); } catch (Exception ex) { USeFuturesSpiritUtility.ShowErrrorMessageBox(this, ex.Message); } }
private void btnOK_Click(object sender, EventArgs e) { List <FrontSeverConfig> serverList = new List <FrontSeverConfig>(); GlobalFontServerConfig globalConfig = new GlobalFontServerConfig(); try { foreach (FrontSeverConfigViewModel data in m_dataSource) { if (VerifyDataCheck(data) == false) { return; } FrontSeverConfig itemConfig = new FrontSeverConfig(); itemConfig.BrokerID = data.BrokerID; //经纪商代码 itemConfig.BrokerName = data.BrokerName; //经纪商 itemConfig.QuoteFrontAddress = data.QuoteFrontAddress; //行情地址 itemConfig.QuoteFrontPort = data.QuoteFrontPort; //行情端口 itemConfig.TradeFrontAddress = data.TradeFrontAddress; //交易地址 itemConfig.TradeFrontPort = data.TradeFrontPort; //交易端口 itemConfig.AuthCode = data.AuthCode; itemConfig.UserProductInfo = data.UserProductInfo; serverList.Add(itemConfig); } globalConfig.ServerList = serverList; if (serverList.Count > 0) { globalConfig.DefaultBrokerId = serverList[serverList.Count - 1].BrokerID; } } catch (Exception ex) { USeFuturesSpiritUtility.ShowErrrorMessageBox(this, "保存服务信息失败," + ex.Message); return; } try { USeManager.Instance.DataAccessor.SaveGlobalFontServerConfig(globalConfig); } catch (Exception ex) { USeFuturesSpiritUtility.ShowErrrorMessageBox(this, "保存服务信息失败," + ex.Message); return; } this.DialogResult = DialogResult.Yes; this.Close(); }
private void tsmClose_TransferToHistory_Click(object sender, EventArgs e) { try { m_autoTrader.TransferToHistoryArbitrage(); System.Threading.Thread.Sleep(200); // [yangming]加个延时,防止还未保存文件 USeManager.Instance.AutoTraderManager.RemoveAutoTrader(m_autoTrader.TraderIdentify); } catch (Exception ex) { USeFuturesSpiritUtility.ShowErrrorMessageBox(this, ex.Message); } }
private void btnOK_Click(object sender, EventArgs e) { try { m_orderDriver.SettlementInfoConfirm(); } catch (Exception ex) { USeFuturesSpiritUtility.ShowErrrorMessageBox(this, "结算单确认失败," + ex.Message); return; } this.DialogResult = DialogResult.Yes; this.Close(); }
private void ArbitrageQuoteChoiceForm_Load(object sender, EventArgs e) { try { Initialize(); InitializeAccountInfo(); InitializeProductCombox(); //先到文件中读取所有之前存在的品种套利组合 m_arbitrageInstrumentList = GetArbitrageCombineInsList(); //默认品种选择 SetDefultProduct(); } catch (Exception ex) { Debug.Assert(false, ex.Message); USeFuturesSpiritUtility.ShowErrrorMessageBox(this, ex.Message); this.Close(); } }
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(); }
private void btnOK_Click(object sender, EventArgs e) { List <ErrorUSeOrderBook> result = new List <ErrorUSeOrderBook>(); try { //如果存在未被处理的委托单,提示处理 foreach (DataRow row in m_dataTable.Rows) { string errorMessage = string.Empty; if (IsMatchRule(row, out errorMessage) == false) { USeFuturesSpiritUtility.ShowErrrorMessageBox(this, "请处理异常委托单"); return; } } USeOrderDriver orderDriver = USeManager.Instance.OrderDriver; Debug.Assert(orderDriver != null); //根据界面生成结果保存到Result foreach (DataRow row in m_dataTable.Rows) { USeInstrument instrument = row["Instrument"] as USeInstrument; Debug.Assert(instrument != null); USeInstrumentDetail instrumentDetail = orderDriver.QueryInstrumentDetail(instrument); //[yangming]合约过期后可能查不到了,此处可以考虑用品种信息获取合约乘数 Debug.Assert(instrumentDetail != null); int orderQty = Convert.ToInt32(row["OrderQty"]); int tradeQty = Convert.ToInt32(row["TradeQty"]); int cancelQty = orderQty - tradeQty; Debug.Assert(cancelQty >= 0); decimal tradePrice = Convert.ToDecimal(row["TradePrice"]); decimal tradeFee = Convert.ToDecimal(row["TradeFee"]); decimal tradeAmount = tradePrice * tradeQty * instrumentDetail.VolumeMultiple; USeOrderStatus selectedOrderStatus = (USeOrderStatus)row["SelectedOrderStatus"]; USeOrderStatus status = USeOrderStatus.Unknown; if (selectedOrderStatus == USeOrderStatus.AllTraded) { status = USeOrderStatus.AllTraded; } else if (selectedOrderStatus == USeOrderStatus.AllCanceled) { if (cancelQty == orderQty) { status = USeOrderStatus.AllCanceled; } else { status = USeOrderStatus.PartCanceled; } } USeOrderNum orderNum = row["OrderNum"] as USeOrderNum; ErrorUSeOrderBook erroOrderBook = row["ErrorUSeOrderBook"] as ErrorUSeOrderBook; erroOrderBook.OrderBook.OrderStatus = status; erroOrderBook.OrderBook.CancelQty = cancelQty; erroOrderBook.OrderBook.TradeQty = tradeQty; erroOrderBook.OrderBook.TradePrice = tradePrice; erroOrderBook.OrderBook.TradeAmount = tradeAmount; erroOrderBook.OrderBook.TradeFee = tradeFee; result.Add(erroOrderBook); } this.Result = result; } catch (Exception ex) { USeFuturesSpiritUtility.ShowWarningMessageBox(this, ex.Message); return; } this.DialogResult = DialogResult.Yes; this.Close(); }