/// <summary> /// /// </summary> private void AddSLControl() { if (StopLossSec.IsNull()) { AutoSLLog("Инструмент не определен."); return; } if (numericUpDownASLTiks.Value <= 0) { AutoSLLog("Кол-во пунктов должно быть больше 0."); return; } if (comboBoxASLAccount.SelectedItem.IsNull()) { AutoSLLog("Не выбран счет клиента."); return; } var itemExists = ASLObject.GetItem((i) => { return(i.SecAndCode == StopLossSec.ToString()); }); if (itemExists.NotIsNull()) { AutoSLLog("Стоп инструкция уже существует."); return; } var newControl = new AutoStopLoss.Item() { SecAndCode = StopLossSec.ToString(), SecName = StopLossSec.Name, Comment = comboBoxASLAccount.SelectedItem.ToString(), Tiks = numericUpDownASLTiks.Value }; ASLObject.Add(newControl); AutoSLUpdateGrid(); }
private void buttonLastPrice_Click(object sender, EventArgs e) { if (LastSecSignal.IsNull()) { return; } numericUpDownPrice.Value = LastSecSignal.LastPrice.NotIsNull() ? LastSecSignal.LastPrice : 0; }
public void Init(Securities security) { if (security.IsNull()) { return; } var param = new BaseParams() { CountFloat = security.Scale, MarginCandle = 0.5f, Class = security.Class.Code, Code = security.Code, MinStepPrice = security.MinPriceStep }; MainPanel = new ViewPanel(param); InitAdd(); InitNativeEvents(); }
/// <summary> Добавляет торговый элемент в коллекцию по указанному инструменту. /// Если элемент существует в коллекции, то он возвращается.</summary> /// <param name="newElem"></param> public TElement AddOrFind(Securities sec) { if (sec.IsNull()) { return(null); } lock (syncLock) { if (lastFoundElem.NotIsNull() && lastFoundElem.Security == sec) { return(lastFoundElem); } var el = this._Collection.FirstOrDefault(t => t.Security == sec); if (el.IsNull()) { el = new TElement(sec); this._Collection.Add(el); el.Create(); } lastFoundElem = el; return(el); } }
/// <summary> Кликеры по таблице стакана </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridViewDepth_Click(object sender, EventArgs e) { if (Securities.IsNull()) { return; } var MouseEvent = (MouseEventArgs)e; var dataGrid = (DataGridView)sender; dataGrid.ClearSelection(); var hti = dataGrid.HitTest(MouseEvent.X, MouseEvent.Y); int indexRow = hti.RowIndex; int indexCol = hti.ColumnIndex; if (indexRow < 0 || indexCol < 0) { return; } DataGridViewCell cell = dataGrid.Rows[indexRow].Cells[indexCol]; if (MouseEvent.Button == MouseButtons.Left) { if (cell.Tag != null) { int Volume = Convert.ToInt32(numericUpDownVolume.Value); if (Volume == 0) { ShowTransReply("Не указан объем!"); } if (cell.Tag.GetType().ToString().Contains("StructClickDepth")) { var data = (StructClickDepth)cell.Tag; OrderDirection?direction = null; if (data.Flag == "buy") { direction = OrderDirection.Buy; } if (data.Flag == "sell") { direction = OrderDirection.Sell; } var clientCode = comboBoxCodeClient.SelectedItem.NotIsNull() ? comboBoxCodeClient.SelectedItem.ToString() : ""; MThread.InitThread(() => { Trader.CreateOrder(new Order() { Sec = Securities, Direction = direction, Price = data.Price, Volume = Volume, ClientCode = clientCode }); }); } } } if (MouseEvent.Button == MouseButtons.Right) { if (cell.Tag != null) { if (cell.Tag.GetType().ToString().Contains("StructClickDepth")) { var data = (StructClickDepth)cell.Tag; if (data.Flag == "buy" || data.Flag == "sell") { MThread.InitThread(() => { var ords = Trader.Objects.tOrders.SearchAll(o => o.Sec == Securities && o.Price == data.Price && o.IsActive()); if (ords.NotIsNull()) { foreach (var ord in ords) { Trader.CancelOrder(ord.Sec, ord.OrderNumber); } } }); } } } } }
private void AddAutoOrder(bool isBuy) { if (AutoOrderSec.IsNull()) { AutoOrdersLog("Инструмент не определен."); return; } if (AutoOrderSec.LastPrice <= 0) { AutoOrdersLog("Некущая цена должна быть больше 0."); return; } if (numericUpDownAOPrice.Value <= 0) { AutoOrdersLog("Не корректная цена условия."); return; } if (numericUpDownAOVolume.Value <= 0) { AutoOrdersLog("Обьем долженбыть больше 0."); return; } if (comboBoxAOAccount.SelectedItem.IsNull()) { AutoOrdersLog("Не выбран счет клиента."); return; } var getOrder = new AutoOrders.ConditionOrder() { PriceCondition = numericUpDownAOPrice.Value, SecAndCode = AutoOrderSec.ToString(), SecName = AutoOrderSec.Name, Comment = comboBoxAOAccount.SelectedItem.ToString(), Price = numericUpDownAOPrice.Value, Volume = (int)numericUpDownAOVolume.Value, }; if (isBuy) { getOrder.Direction = OrderDirection.Buy; if (AutoOrderSec.LastPrice < getOrder.PriceCondition) { getOrder.CondAutoOrder = AutoOrders.CondAutoOrder.MoreOrEquals; } else { getOrder.CondAutoOrder = AutoOrders.CondAutoOrder.LessOrEquals; } } else { getOrder.Direction = OrderDirection.Sell; if (AutoOrderSec.LastPrice > getOrder.PriceCondition) { getOrder.CondAutoOrder = AutoOrders.CondAutoOrder.LessOrEquals; } else { getOrder.CondAutoOrder = AutoOrders.CondAutoOrder.MoreOrEquals; } } ObjAutoOrders.Add(getOrder); AutoOrdersUpdateGrid(); }