public void SetHandCount(string buySell) { tbHandCount.Text = "0"; //if (rbPingcang.IsChecked == true) //{ // foreach (var item in _MainWindow.PositionCollection_Total) // { // if (txtCode.Text == item.Code && item.BuySell.Contains(buySell)) // { // if (CodeSetManager.IsCloseTodaySupport(item.Code)) // { // tbHandCount.Text = item.YesterdayPosition.ToString(); //(item.YesterdayPosition - item.FreezeCount).ToString(); // } // else // { // tbHandCount.Text = item.TotalPosition.ToString(); //(item.TotalPosition - item.FreezeCount).ToString(); // } // } // } //} //else if (rbPingjin.IsChecked == true) { foreach (var item in _MainWindow.PositionCollection_Total) { if (txtCode.Text == item.Code && item.BuySell.Contains(buySell)) { if (CodeSetManager.IsCloseTodaySupport(item.Code)) { tbHandCount.Text = item.TodayPosition.ToString(); //(item.TodayPosition - item.FreezeCount).ToString(); } else { tbHandCount.Text = item.TotalPosition.ToString(); //(item.TotalPosition - item.FreezeCount).ToString(); } } } } }
/// <summary> /// 买量 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Grid_MouseEnter_Close_Buy(object sender, MouseEventArgs e) { Grid grid = sender as Grid; if (grid == null) { return; } TextBlock tp = grid.ToolTip as TextBlock; DisplayRealData displayRealData = grid.DataContext as DisplayRealData; //卖出平仓 TradeDataClient jyDataServer = TradeDataClient.GetClientInstance(); int todayPosCount; int lastPosCount; string code = displayRealData.Code; //查找多头的单子 if (jyDataServer.GetPositionCount(code, true, out todayPosCount, out lastPosCount) == false) { grid.ToolTip = null; return; } if (todayPosCount == 0 && lastPosCount == 0) { grid.ToolTip = null; return; } if (tp == null) { grid.ToolTip = new TextBlock(); tp = grid.ToolTip as TextBlock; } tp.Inlines.Clear(); Run run = new Run(); run.Text = "双击 "; tp.Inlines.Add(run); run = new Run(); Binding binding1 = new Binding(); binding1.Source = grid.DataContext; binding1.Mode = BindingMode.OneWay; binding1.Path = new PropertyPath("StBuyPrice"); run.SetBinding(Run.TextProperty, binding1); tp.Inlines.Add(run); run = new Run(); run.Text = " 卖出"; run.Foreground = new SolidColorBrush(Color.FromRgb(0x13, 0xaf, 0x13)); tp.Inlines.Add(run); Boolean bHasComma = false; if (CodeSetManager.IsCloseTodaySupport(code) && todayPosCount != 0) { //如果支持平今 run = new Run(); run.Text = "平今"; run.FontSize = 13; run.Foreground = new SolidColorBrush(Color.FromRgb(0xff, 0x00, 0xff)); tp.Inlines.Add(run); run = new Run(); run.Text = " " + todayPosCount.ToString() + " "; run.Foreground = new SolidColorBrush(Color.FromRgb(0x13, 0xaf, 0x13)); tp.Inlines.Add(run); bHasComma = true; } else { lastPosCount += todayPosCount; } if (lastPosCount != 0) { if (bHasComma) { run = new Run(); run.Text = ","; tp.Inlines.Add(run); } run = new Run(); run.Text = " 平仓"; run.FontSize = 13; run.Foreground = new SolidColorBrush(Color.FromRgb(0xff, 0x00, 0xff)); tp.Inlines.Add(run); run = new Run(); run.Text = " " + lastPosCount.ToString() + " "; run.Foreground = new SolidColorBrush(Color.FromRgb(0x13, 0xaf, 0x13)); tp.Inlines.Add(run); } run = new Run(); run.Text = "手" + code; tp.FontWeight = FontWeights.Bold; tp.Inlines.Add(run); }
private void Exec_Click(object sender, RoutedEventArgs e) { string verifyMessage = execOrderDataVerification(); if (verifyMessage == string.Empty) { Contract optContract = CodeSetManager.GetContractInfo(txtCode.Text.Trim()); if (optContract == null) { Util.Log("Warning! Cannot find contract info for " + txtCode.Text.Trim()); return; } bool isExec = rbExec.IsChecked == true ? true : false; string order = rbExec.IsChecked == true ? "行权" : "弃权"; string strCode = optContract.Code; int handCount = CommonUtil.GetIntValue(iudNum.Value.Value); EnumThostOffsetFlagType openClose = EnumThostOffsetFlagType.Close; string kp = "平仓"; if (CodeSetManager.IsCloseTodaySupport(optContract.Code)) { if (rbPingjin.IsChecked == true) { openClose = EnumThostOffsetFlagType.CloseToday; kp = "平今"; } else if (rbPingcang.IsChecked == true) { openClose = EnumThostOffsetFlagType.CloseYesterday; kp = "平仓"; } } else if (rbPingcang.IsChecked == true) { openClose = EnumThostOffsetFlagType.Close; } if (TradingMaster.Properties.Settings.Default.ConfirmBeforeSendNewOrder == true) { CheckableMessageBox messageBox = new CheckableMessageBox(); messageBox.tbMessage.Text = string.Format("{0}:{1} {2} {3}手", order, kp, strCode, handCount); string windowTitle = string.Format("确认{0}:{1} {2} {3}手", order, kp, strCode, handCount); Window confirmWindow = CommonUtil.GetWindow(windowTitle, messageBox, _MainWindow); if (confirmWindow.ShowDialog() == true) { if (handCount > 0) { TradeDataClient.GetClientInstance().RequestOrder("", BACKENDTYPE.CTP, new RequestContent("NewExecOrder", new List <object>() { strCode, handCount, optContract.ExchName, isExec, openClose })); } } } else { if (!CodeSetManager.IsCloseTodaySupport(strCode) && openClose == EnumThostOffsetFlagType.CloseToday) { openClose = EnumThostOffsetFlagType.Close; } if (handCount > 0) { TradeDataClient.GetClientInstance().RequestOrder("", BACKENDTYPE.CTP, new RequestContent("NewExecOrder", new List <object>() { strCode, handCount, optContract.ExchName, isExec, openClose })); } } } }