/// <summary> /// /// </summary> private void AutoSLUpdateGrid() { dataGridViewASLList.GuiAsync(() => { dataGridViewASLList.Rows.Clear(); var list = ASLObject.ToArray; //ВЫбрать по инструменту if (checkBoxASLBySec.Checked) { if (StopLossSec.NotIsNull()) { list = list.Where(o => o.SecAndCode == StopLossSec.ToString()).ToArray(); } } foreach (var itemControl in list) { if (itemControl.NotIsNull()) { var newRow = (DataGridViewRow)dataGridViewASLList.Rows[0].Clone(); newRow.Cells[0].Value = itemControl.SecAndCode + " " + itemControl.SecName; newRow.Cells[1].Value = itemControl.Tiks.ToString(); newRow.Cells[2].Value = itemControl.Comment; newRow.Tag = itemControl; dataGridViewASLList.Rows.Add(newRow); } } }); }
private void buttonCancelAll_Click(object sender, EventArgs e) { if (Securities.NotIsNull()) { Trader.CancelAllOrder(Securities); } }
private void EventNewSec(IEnumerable <Securities> listSec) { Qlog.CatchException(() => { Securities last = null; foreach (var s in listSec) { var el = DataTrading.AddOrFind(s); last = s; } if (last.NotIsNull()) { ChangeTextMainStatusBar(Trader.Objects.tSecurities.Count + " " + last.ToString()); } }); }
/// <summary> /// /// </summary> private void AutoSLUpdatePanel() { if (comboBoxASLSec.SelectedItem.NotIsNull()) { StopLossSec = GetSecCodeAndClass(comboBoxASLSec.SelectedItem.ToString()); if (StopLossSec.NotIsNull()) { labelASLInfo.Text = StopLossSec.Code + "\r\n" + StopLossSec.Name + "\r\n" + StopLossSec.Shortname + "\r\n" + "Lot: " + StopLossSec.Lot + "\r\n" + "MinPriceStep: " + StopLossSec.MinPriceStep + "\r\n" + "LastPrice: " + StopLossSec.LastPrice + "\r\n"; numericUpDownASLTiks.InitWheelDecimal(0, 1000000, 1, 0); } } }
private void AutoOrdersUpdatePanelOrder() { if (comboBoxAOSecurities.SelectedItem.NotIsNull()) { AutoOrderSec = GetSecCodeAndClass(comboBoxAOSecurities.SelectedItem.ToString()); if (AutoOrderSec.NotIsNull()) { labelAOInfo.Text = AutoOrderSec.Code + "\r\n" + AutoOrderSec.Name + "\r\n" + AutoOrderSec.Shortname + "\r\n" + "Lot: " + AutoOrderSec.Lot + "\r\n" + "MinPriceStep: " + AutoOrderSec.MinPriceStep + "\r\n" + "LastPrice: " + AutoOrderSec.LastPrice + "\r\n"; numericUpDownAOPrice.InitSecurity(AutoOrderSec, 0); numericUpDownAOVolume.InitWheelDecimal(0, 1000000, 1, 0); } } }
private void buttonExitPos_Click(object sender, EventArgs e) { if (Securities.NotIsNull()) { var pos = Trader.Objects.tPositions.SearchFirst(p => p.Sec == Securities); if (pos != null) { if (pos.CurrentVolume != 0) { MThread.InitThread(() => { OrderDirection?direction = pos.IsBuy() ? OrderDirection.Sell : OrderDirection.Buy; decimal LastPrice = Securities.Params.LastPrice; decimal Price = direction == OrderDirection.Sell ? Price = LastPrice - Securities.Params.MinPriceStep * 5 : LastPrice + Securities.Params.MinPriceStep * 5; this.GuiAsync(() => { var clientCode = comboBoxCodeClient.SelectedItem.NotIsNull() ? comboBoxCodeClient.SelectedItem.ToString() : ""; Trader.CreateOrder(new Order() { Sec = Securities, Direction = direction, Price = Price, Volume = pos.CurrentVolume, ClientCode = clientCode }); }); }); } else { ShowTransReply("По данному инструменту нет позиций."); } } } }
private void buttonAddSign_Click(object sender, EventArgs e) { SignalMarket.CondSignal cond = SignalMarket.CondSignal.MoreOrEquals;; var strCond = (string)comboBoxCond.SelectedItem; if (strCond == ">=") { cond = SignalMarket.CondSignal.MoreOrEquals; } else if (strCond == ">") { cond = SignalMarket.CondSignal.More; } else if (strCond == "<=") { cond = SignalMarket.CondSignal.LessOrEquals; } else if (strCond == "<") { cond = SignalMarket.CondSignal.Less; } else if (strCond == "==") { cond = SignalMarket.CondSignal.Equals; } var sec = LastSecSignal.NotIsNull() ? LastSecSignal.ToString() : null; var newSign = new SignalMarket() { Type = SignalMarket.TypeSignal.ByPrice, SecClass = sec, Price = numericUpDownPrice.Value, Condition = cond, Comment = textBoxSignComment.Text }; SignalView.GSMSignaler.AddSignal(newSign); textBoxSignComment.Text = ""; }
/// <summary> /// /// </summary> private void Init() { LastSignal = DateTime.Now; comboBoxFutSec.TextChanged += (s, e) => { var text = comboBoxFutSec.Text; if (text.Length >= 2) { var listSec = Trader.Objects.tSecurities.SearchAll(el => el.Code.ToLower().Contains(text.ToLower()) || el.Name.ToLower().Contains(text.ToLower())).Select(el => el.ToString()); if (listSec.Count() > 0) { comboBoxFutSec.Clear(); comboBoxFutSec.SetListValues(listSec); UpdateData(null); } } comboBoxFutSec.SelectionStart = comboBoxFutSec.Text.Length; //comboBoxBaseSec.Select(text.Length, 0); }; comboBoxBaseSec.TextChanged += (s, e) => { var text = comboBoxBaseSec.Text; if (text.Length >= 2) { var listSec = Trader.Objects.tSecurities.SearchAll(el => el.Code.ToLower().Contains(text.ToLower()) || el.Name.ToLower().Contains(text.ToLower())).Select(el => el.ToString()); if (listSec.Count() > 0) { comboBoxBaseSec.Clear(); comboBoxBaseSec.SetListValues(listSec); UpdateData(null); } } comboBoxBaseSec.SelectionStart = comboBoxBaseSec.Text.Length; //comboBoxBaseSec.Select(text.Length, 0); }; comboBoxBaseSec.SelectedIndexChanged += (s, e) => { SecBase = null; if (comboBoxBaseSec.SelectedItem.NotIsNull()) { SecBase = Parent.GetSecCodeAndClass(comboBoxBaseSec.SelectedItem.ToString()); if (SecBase.NotIsNull()) { Trader.RegisterSecurities(SecBase); } } UpdateData(null); }; comboBoxFutSec.SelectedIndexChanged += (s, e) => { SecFut = null; if (comboBoxFutSec.SelectedItem.NotIsNull()) { SecFut = Parent.GetSecCodeAndClass(comboBoxFutSec.SelectedItem.ToString()); if (SecFut.NotIsNull()) { Trader.RegisterSecurities(SecFut); } } UpdateData(null); }; comboBoxFutAccount.SetListValues(Trader.Objects.tClients.ToArray().Select(c => c.Code).ToArray()); comboBoxBaseAccount.SetListValues(Trader.Objects.tClients.ToArray().Select(c => c.Code).ToArray()); }
/// <summary> /// /// </summary> /// <param name="timer"></param> public void UpdateData(DispatcherTimer timer) { DataArb = new DataCalc(); if (SecFut.NotIsNull()) { labelFutLot.Text = SecFut.Lot.ToString(); labelFutGo.Text = SecFut.Params.SellDepo.ToString(); labelFutPriceStep.Text = SecFut.StepPrice.ToString(); labelFutPrice.Text = SecFut.LastPrice.ToString() + " ( " + (SecFut.LastPrice / SecFut.Lot).ToString() + ")"; } else { labelFutLot.Text = "0"; labelFutGo.Text = "0.0"; labelFutPriceStep.Text = "0.0"; labelFutPrice.Text = "0.0"; } if (SecBase.NotIsNull()) { labelBaseSecLot.Text = SecBase.Lot.ToString(); labelBaseSecPrice.Text = SecBase.LastPrice.ToString(); } else { labelBaseSecLot.Text = "0"; labelBaseSecPrice.Text = "0.0"; } if (SecFut.NotIsNull() && SecBase.NotIsNull()) { DataArb.futPrice = SecFut.LastPrice; DataArb.basePrice = SecBase.LastPrice; var priceFut = DataArb.futPrice / SecFut.Lot; DataArb.diffPrice = priceFut > DataArb.basePrice ? priceFut - DataArb.basePrice : DataArb.basePrice - priceFut; DataArb.diffPrice = DataArb.diffPrice * SecFut.Lot; DataArb.sumFutPos = SecFut.Params.SellDepo * numericUpDownFutPos.Value; DataArb.basePos = Math.Round(numericUpDownFutPos.Value * SecFut.Lot / SecBase.Lot, 1); DataArb.sumBasePos = DataArb.basePos * SecBase.Lot * DataArb.basePrice; var posFut = Trader.Objects.tPositions.SearchFirst(p => p.Sec == SecFut); if (posFut.NotIsNull()) { DataArb.futCurPos = posFut.Data.CurrentNet; } var posBase = Trader.Objects.tPositions.SearchFirst(p => p.Sec == SecBase && p.Data.Type == 2); if (posBase.NotIsNull()) { DataArb.baseCurPos = posBase.Data.CurrentNet; } ControlEvent(); } else { DataArb.diffPrice = 0; DataArb.sumFutPos = 0; DataArb.basePos = 0; DataArb.sumBasePos = 0; } //fut labelDiffPrice.Text = DataArb.diffPrice.ToString(); labelFutSumPos.Text = DataArb.sumFutPos.ToString(); labelFutCurrPos.Text = DataArb.futCurPos.ToString(); //base labelBasePos.Text = DataArb.basePos.ToString(); labelBaseSumPos.Text = DataArb.sumBasePos.ToString(); labelBaseCurrPos.Text = DataArb.baseCurPos.ToString(); }
public void InitAutoOrders() { ObjAutoOrders.Load(); comboBoxAOAccount.Click += (s, e) => { if (comboBoxAOAccount.Items.Count == 0) { comboBoxAOAccount.SetListValues(this.Trader.Objects.tClients.ToArray() .Select(c => c.Code).ToArray()); } }; comboBoxAOSecurities.SetListValues(Global.GetWorkingListSec().ToArray()); comboBoxAOSecurities.TextChanged += (s, e) => { AutoOrderSec = null; var text = comboBoxAOSecurities.Text; if (text.Length >= 2) { var listSec = Trader.Objects.tSecurities.SearchAll(el => el.Code.ToLower().Contains(text.ToLower()) || el.Name.ToLower().Contains(text.ToLower())).Select(el => el.ToString()); if (listSec.Count() > 0) { comboBoxAOSecurities.Clear(); comboBoxAOSecurities.SetListValues(listSec); AutoOrdersUpdateGrid(); } } comboBoxAOSecurities.Select(text.Length, 0); }; comboBoxAOSecurities.KeyPress += (s, e) => { var k = e.KeyChar; if (e.KeyChar == 13) { if (comboBoxAOSecurities.Items.Count > 0) { comboBoxAOSecurities.SelectedItem = comboBoxAOSecurities.Items[0]; AutoOrdersUpdatePanelOrder(); AutoOrdersUpdateGrid(); } } }; comboBoxAOSecurities.SelectedIndexChanged += (s, e) => { AutoOrdersUpdatePanelOrder(); }; buttonAOBuy.Click += (s, e) => { AddAutoOrder(true); }; buttonAOSell.Click += (s, e) => { AddAutoOrder(false); }; ObjAutoOrders.OnAdd += (condOrder) => { AutoOrdersUpdateGrid(); }; ObjAutoOrders.OnDelete += (condOrder) => { AutoOrdersUpdateGrid(); }; buttonAODelete.Click += (s, e) => { if (dataGridViewAOList.SelectedRows.NotIsNull() && dataGridViewAOList.SelectedRows.Count > 0) { foreach (var row in dataGridViewAOList.SelectedRows) { if (row is DataGridViewRow) { var rowEl = (DataGridViewRow)row; if (rowEl.Tag.NotIsNull()) { ObjAutoOrders.Delete((AutoOrders.ConditionOrder)rowEl.Tag); } } } } AutoOrdersUpdateGrid(); }; buttonAODeleteSec.Click += (s, e) => { if (AutoOrderSec.NotIsNull()) { ObjAutoOrders.Delete(AutoOrderSec); AutoOrdersUpdateGrid(); } }; checkBoxAOSelectSec.CheckedChanged += (s, e) => { AutoOrdersUpdateGrid(); }; AutoOrdersUpdateGrid(); }
/// <summary> /// /// </summary> public void InitPanelSignal() { SignalView.GSMSignaler.Phone = Connector.QuikConnector.ConfSettings.GetParam("Main", "PhoneSignal").Value; comboBoxSecSign.SetListValues(Global.GetWorkingListSec().ToArray()); comboBoxSecSign.TextChanged += (s, e) => { var text = comboBoxSecSign.Text; if (text.Length >= 2) { var listSec = Trader.Objects.tSecurities.SearchAll(el => el.Code.ToLower().Contains(text.ToLower()) || el.Name.ToLower().Contains(text.ToLower())).Select(el => el.ToString()); if (listSec.Count() > 0) { comboBoxSecSign.Clear(); comboBoxSecSign.SetListValues(listSec); } } comboBoxSecSign.Select(text.Length, 0); UpdateGridSignals(); }; comboBoxSecSign.KeyPress += (s, e) => { var k = e.KeyChar; if (e.KeyChar == 13) { if (comboBoxSecSign.Items.Count > 0) { comboBoxSecSign.Text = comboBoxSecSign.Items[0].ToString(); } } }; tableLayoutPanel14.Enabled = false; tableLayoutPanel8.Enabled = false; splitContainer2.Enabled = false; SetCurrentPorts(); numericUpDownPrice.InitWheelDecimal(); numericUpDownPrice.Maximum = 1000000000; numericUpDownSignVolume.InitWheelDecimal(); numericUpDownSignVolume.Maximum = 1000000000; numericUpDownSignVolume.Minimum = 0; numericUpDownSignVolume.Increment = 1; var tf = SelectorTimeFrame.GetAll(); comboBoxSignTimeFrame.DataSource = tf.ToArray(); comboBoxSignTimeFrame.SelectedIndex = 3; buttonSignAddVol1000.Click += (s, e) => { numericUpDownSignVolume.Value += 1000; }; buttonAddSignVolume.Click += buttonAddSignVolume_Click; comboBoxSecSign.SelectedValueChanged += (s, e) => { if (comboBoxSecSign.SelectedItem is string) { LastSecSignal = GetSecCodeAndClass(comboBoxSecSign.SelectedItem.ToString()); if (LastSecSignal.NotIsNull()) { numericUpDownPrice.InitSecurity(LastSecSignal); numericUpDownPrice.Value = LastSecSignal.LastPrice.NotIsNull() ? LastSecSignal.LastPrice : 0; labelSignNameSec.Text = LastSecSignal.Name; } } UpdateGridSignals(); }; comboBoxCond.InitDefault(); comboBoxCond.SetListValues(new string[] { ">=", ">", "<=", "<", "==" }); comboBoxCond.SelectedIndex = 0; SignalView.GSMSignaler.OnAdd += (s) => { UpdateGridSignals(); }; SignalView.GSMSignaler.OnRemove += (s) => { UpdateGridSignals(); }; /*GSMSignaler.OnLoad += () => * { * UpdateGridSignals(); * };*/ SignalView.GSMSignaler.Load(); buttonSignUp.Click += (s, e) => { MoveSignal(true); }; buttonSignDown.Click += (s, e) => { MoveSignal(false); }; dataGridViewListSign.Click += (s, e) => { if (s is DataGridView) { var dataGrid = (DataGridView)s; foreach (DataGridViewRow r in dataGrid.Rows) { if (r.Selected) { LastIndexSelectRow = r.Index; } } } }; UpdateGridSignals(); AutoFindPort(); }