private bool Form_LoadData(object sender, object data) { if (data == null) { return(false); } if (!(data is List <CancelRedoItem>)) { return(false); } //Get the price type PriceType spotBuyPrice = PriceTypeHelper.GetPriceType(this.cbSpotBuyPrice); PriceType spotSellPrice = PriceTypeHelper.GetPriceType(this.cbSpotSellPrice); PriceType futureBuyPrice = PriceTypeHelper.GetPriceType(this.cbFuturesBuyPrice); PriceType futureSellPrice = PriceTypeHelper.GetPriceType(this.cbFuturesSellPrice); EntrustPriceType shPriceType = EntrustPriceTypeHelper.GetPriceType(this.cbSHExchangePrice); EntrustPriceType szPriceType = EntrustPriceTypeHelper.GetPriceType(this.cbSZExchangePrice); _secuDataSource.Clear(); var cancelSecuItems = data as List <CancelRedoItem>; foreach (var cancelRedoItem in cancelSecuItems) { if (cancelRedoItem.SecuType == SecurityType.Stock && cancelRedoItem.EDirection == EntrustDirection.BuySpot) { cancelRedoItem.EPriceSetting = spotBuyPrice; } else if (cancelRedoItem.SecuType == SecurityType.Stock && cancelRedoItem.EDirection == EntrustDirection.BuySpot) { cancelRedoItem.EPriceSetting = spotSellPrice; } else if (cancelRedoItem.SecuType == SecurityType.Futures && cancelRedoItem.EDirection == EntrustDirection.SellOpen) { cancelRedoItem.EPriceSetting = futureSellPrice; } else if (cancelRedoItem.SecuType == SecurityType.Futures && cancelRedoItem.EDirection == EntrustDirection.BuyClose) { cancelRedoItem.EPriceSetting = futureBuyPrice; } SetEntrustPriceType(cancelRedoItem, shPriceType, szPriceType); _secuDataSource.Add(cancelRedoItem); } //update the quote QueryQuote(); return(true); }
private DefaultSetting GetSetting() { var oldSetting = SettingManager.Instance.Get(); DefaultSetting setting = new DefaultSetting { Timeout = oldSetting.Timeout, UFXSetting = new DefaultUFXSetting { Timeout = oldSetting.Timeout, }, EntrustSetting = new DefaultEntrustSetting(), }; PriceType spotBuyPrice = PriceTypeHelper.GetPriceType(cbSpotBuyPrice); PriceType spotSellPrice = PriceTypeHelper.GetPriceType(cbSpotSellPrice); PriceType futuBuyPrice = PriceTypeHelper.GetPriceType(cbFutuBuyPrice); PriceType futuSellPrice = PriceTypeHelper.GetPriceType(cbFutuSellPrice); setting.EntrustSetting.BuySpotPrice = spotBuyPrice; setting.EntrustSetting.SellSpotPrice = spotSellPrice; setting.EntrustSetting.BuyFutuPrice = futuBuyPrice; setting.EntrustSetting.SellFutuPrice = futuSellPrice; setting.EntrustSetting.SseEntrustPriceType = EntrustPriceTypeHelper.GetPriceType(cbSseEntrustPriceType); setting.EntrustSetting.SzseEntrustPriceType = EntrustPriceTypeHelper.GetPriceType(cbSzseEntrustPriceType); setting.EntrustSetting.OddShareMode = ComboBoxHelper.GetPriceType(cbOddShareMode); int temp = 0; if (int.TryParse(tbSpotLimitEntrustRatio.Text, out temp)) { setting.UFXSetting.LimitEntrustRatio = temp; } if (int.TryParse(tbFutuLimitEntrustRatio.Text, out temp)) { setting.UFXSetting.FutuLimitEntrustRatio = temp; } return(setting); }
private void ComboBox_PriceType_SelectedIndexChange(object sender, EventArgs e) { if (sender == null || !(sender is ComboBox)) { return; } ComboBox cb = sender as ComboBox; PriceType priceType = PriceTypeHelper.GetPriceType(cb); EntrustDirection direction = EntrustDirection.BuySpot; SecurityType secuType = SecurityType.All; EntrustPriceType shPriceType = EntrustPriceTypeHelper.GetPriceType(this.cbSHExchangePrice); EntrustPriceType szPriceType = EntrustPriceTypeHelper.GetPriceType(this.cbSZExchangePrice); switch (cb.Name) { case "cbSpotBuyPrice": { direction = EntrustDirection.BuySpot; secuType = SecurityType.Stock; } break; case "cbSpotSellPrice": { direction = EntrustDirection.SellSpot; secuType = SecurityType.Stock; } break; case "cbFuturesBuyPrice": { direction = EntrustDirection.BuyClose; secuType = SecurityType.Futures; } break; case "cbFuturesSellPrice": { direction = EntrustDirection.SellOpen; secuType = SecurityType.Futures; } break; default: break; } var stockItems = _secuDataSource.Where(p => p.EDirection == direction && p.SecuType == secuType).ToList(); if (stockItems.Count > 0) { stockItems.ForEach(p => { p.EPriceSetting = priceType; SetEntrustPriceType(p, shPriceType, szPriceType); }); } //update the quote QueryQuote(); this.secuGridView.Invalidate(); }
private void Button_Confirm_Click(object sender, EventArgs e) { string outMsg = string.Empty; var selectItems = _secuDataSource.Where(p => p.Selection).ToList(); if (selectItems.Count == 0) { MessageDialog.Warn(this, msgNoSecuritySelected); return; } if (!ValidateEntrustSecurities(selectItems, out outMsg)) { MessageDialog.Warn(this, outMsg); return; } if (MessageDialog.Info(this, msgEntrustCancelRedoConfirm, MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } var commandIds = selectItems.Select(p => p.CommandId).Distinct().ToList(); var submitIds = selectItems.Select(p => p.SubmitId).Distinct().ToList(); var failedCancelItems = new List <CancelRedoItem>(); var successCancelItems = new List <CancelRedoItem>(); foreach (var commandId in commandIds) { foreach (var submitId in submitIds) { var secuItems = selectItems.Where(p => p.Selection && p.CommandId == commandId && p.SubmitId == submitId).ToList(); var cancelItems = _withdrawBLL.CancelSecuItem(submitId, commandId, secuItems, null); if (cancelItems.Count > 0) { successCancelItems.AddRange(cancelItems); } if (cancelItems.Count != secuItems.Count) { var failItems = secuItems.Except(cancelItems); failedCancelItems.AddRange(failItems); } } } //Get the price type PriceType spotBuyPrice = PriceTypeHelper.GetPriceType(this.cbSpotBuyPrice); PriceType spotSellPrice = PriceTypeHelper.GetPriceType(this.cbSpotSellPrice); PriceType futureBuyPrice = PriceTypeHelper.GetPriceType(this.cbFuturesBuyPrice); PriceType futureSellPrice = PriceTypeHelper.GetPriceType(this.cbFuturesSellPrice); string resultMsg = string.Empty; foreach (var commandId in commandIds) { var oneCancelRedoItem = successCancelItems.Where(p => p.CommandId == commandId).ToList(); if (oneCancelRedoItem.Count > 0) { resultMsg += Submit(commandId, oneCancelRedoItem, null); } } StringBuilder sb = new StringBuilder(); if (failedCancelItems.Count > 0) { string format1 = ConfigManager.Instance.GetLabelConfig().GetLabelText(msgEntrustCancelPartialFail); string format2 = ConfigManager.Instance.GetLabelConfig().GetLabelText(msgEntrustCancelFailSecurity); sb.Append(format1); failedCancelItems.ForEach(p => { sb.AppendFormat(format2, p.SubmitId, p.CommandId, p.SecuCode); }); } if (!string.IsNullOrEmpty(resultMsg)) { sb.Append(resultMsg); } if (sb.Length > 0) { MessageDialog.Warn(this, sb.ToString()); } DialogResult = System.Windows.Forms.DialogResult.OK; }