Esempio n. 1
0
        private ActivatedSecurity GetSecurity(DataGridViewRow row)
        {
            ActivatedSecurity sec = new ActivatedSecurity();

            sec.SecurityClass = row.Cells[1].Value.ToString();
            sec.SecurityName  = row.Cells[3].Value.ToString();

            if (row.Cells[6].Value != null)
            {
                sec.IsOn = Convert.ToBoolean(row.Cells[6].Value);
            }

            return(sec);
        }
Esempio n. 2
0
        private void UpdateGrid(List <Security> securities)
        {
            _gridSecurities.Rows.Clear();

            // номер, класс, тип, сокращонное название бумаги, полное имя, дополнительное имя, влк/выкл

            for (int indexSecuriti = 0; indexSecuriti < securities.Count; indexSecuriti++)
            {
                DataGridViewRow nRow = new DataGridViewRow();

                nRow.Cells.Add(new DataGridViewTextBoxCell());
                nRow.Cells[0].Value = (indexSecuriti + 1).ToString();

                nRow.Cells.Add(new DataGridViewTextBoxCell());
                nRow.Cells[1].Value = securities[indexSecuriti].NameClass;

                nRow.Cells.Add(new DataGridViewTextBoxCell());
                nRow.Cells[2].Value = securities[indexSecuriti].SecurityType;

                nRow.Cells.Add(new DataGridViewTextBoxCell());
                nRow.Cells[3].Value = securities[indexSecuriti].Name;

                nRow.Cells.Add(new DataGridViewTextBoxCell());
                nRow.Cells[4].Value = securities[indexSecuriti].NameFull;

                nRow.Cells.Add(new DataGridViewTextBoxCell());
                nRow.Cells[5].Value = securities[indexSecuriti].NameId;

                DataGridViewCheckBoxCell checkBox = new DataGridViewCheckBoxCell();
                nRow.Cells.Add(checkBox);

                ActivatedSecurity activatedSecurity =
                    _screener.SecuritiesNames.Find(s => s.SecurityName == securities[indexSecuriti].Name);

                if (activatedSecurity != null &&
                    activatedSecurity.IsOn == true)
                {
                    checkBox.Value = true;
                }

                _gridSecurities.Rows.Add(nRow);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// accept button
        /// кнопка принять
        /// </summary>
        private void ButtonAccept_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                _screener.PortfolioName = ComboBoxPortfolio.Text;
                if (CheckBoxIsEmulator.IsChecked != null)
                {
                    _screener.EmulatorIsOn = CheckBoxIsEmulator.IsChecked.Value;
                }
                TimeFrame timeFrame;
                Enum.TryParse(ComboBoxTimeFrame.Text, out timeFrame);

                _screener.TimeFrame = timeFrame;
                Enum.TryParse(ComboBoxTypeServer.Text, true, out _screener.ServerType);

                CandleMarketDataType createType;
                Enum.TryParse(ComboBoxCandleMarketDataType.Text, true, out createType);
                _screener.CandleMarketDataType = createType;

                CandleCreateMethodType methodType;
                Enum.TryParse(ComboBoxCandleCreateMethodType.Text, true, out methodType);

                ComissionType typeComission;
                Enum.TryParse(ComboBoxComissionType.Text, true, out typeComission);
                _screener.ComissionType = typeComission;

                if (ComboBoxClass.SelectedItem != null)
                {
                    _screener.SecuritiesClass = ComboBoxClass.SelectedItem.ToString();
                }

                try
                {
                    _screener.ComissionValue = TextBoxComissionValue.Text.ToDecimal();
                }
                catch
                {
                    // ignore
                }

                _screener.CandleCreateMethodType = methodType;

                if (CheckBoxSetForeign.IsChecked.HasValue)
                {
                    _screener.SetForeign = CheckBoxSetForeign.IsChecked.Value;
                }

                _screener.RencoPunktsToCloseCandleInRencoType = _rencoPuncts;
                _screener.CountTradeInCandle = _countTradesInCandle;
                _screener.VolumeToCloseCandleInVolumeType = _volumeToClose;
                _screener.DeltaPeriods                = _deltaPeriods;
                _screener.RangeCandlesPunkts          = _rangeCandlesPunkts;
                _screener.ReversCandlesPunktsMinMove  = _reversCandlesPunktsMinMove;
                _screener.ReversCandlesPunktsBackMove = _reversCandlesPunktsBackMove;
                _screener.SaveTradesInCandles         = _saveTradesInCandles;

                if (CheckBoxRencoIsBuildShadows.IsChecked != null)
                {
                    _screener.RencoIsBuildShadows = CheckBoxRencoIsBuildShadows.IsChecked.Value;
                }

                List <ActivatedSecurity> securities = new List <ActivatedSecurity>();

                for (int i = 0; i < _gridSecurities.Rows.Count; i++)
                {
                    ActivatedSecurity sec = GetSecurity(_gridSecurities.Rows[i]);

                    if (sec == null)
                    {
                        continue;
                    }

                    securities.Add(sec);
                }

                _screener.SecuritiesNames = securities;

                _screener.SaveSettings();
                _screener.ReLoadTabs();
                _screener.SaveTabs();

                Close();
            }
            catch (Exception error)
            {
                SendNewLogMessage(error.ToString(), LogMessageType.Error);
            }
        }