Ejemplo n.º 1
0
        /// <summary>
        /// Add new dataset to table
        /// </summary>
        /// <param name="dsm"></param>
        /// <returns>TRUE if adding success else return FALSE</returns>
        public static bool AddDataset(DataSetModel dsm)
        {
            String query = "INSERT IGNORE INTO " + TblDatasets;
            query += "(DataSetName, Symbol_ID,TimeValue, Commission, Multiplier, ContractSize, PointValue, ZIM, TickSize) VALUES";
            query += "('";
            query += dsm.DataSetName + "',";
            query += dsm.SymbolId + ",";
            query += dsm.TimeValue + ",";
            query += dsm.Commission + ",";
            query += dsm.Multiplier + ",";
            query += dsm.ContractSize + ",";
            query += dsm.PointValue + ",";
            query += dsm.Zim + ",";
            query += dsm.TickSize + ");COMMIT;";

            return DoSql(query);
        }
Ejemplo n.º 2
0
        public ParametersDataSet(DataSetModel dataSet)
        {
            _dataSetName = dataSet.DataSetName;
            _timeValue = Math.Round(dataSet.TimeValue,2);
            _commission = Math.Round(dataSet.Commission,2);
            _multiplier = dataSet.Multiplier;
            _contractSize = dataSet.ContractSize;
            _pointValue = Math.Round(dataSet.PointValue,5);
            _zim = Math.Round(dataSet.Zim,5);
            _tickSize = Math.Round(dataSet.TickSize, 2);

            _reversalLevel = 80;
            _defaultMinValue = 60;
            _defaultMaxValue = 100;
            _defaultStepValue = 10;
            CalcelateStepValues();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// With this function you can get all datasets
        /// names from DB
        /// </summary>
        /// <returns></returns>
        public static List<DataSetModel> GetDatasets()
        {
            var res = new List<DataSetModel>();

            const string sql = "SELECT * FROM " + TblDatasets;
            var reader = GetReader(sql);
            if (reader != null)
            {
                while (reader.Read())
                {
                    var d = new DataSetModel
                    {
                        Id = reader.GetInt32(0),
                        DataSetName = reader.GetString(2),
                        SymbolId = reader.GetInt32(1),
                        TimeValue = reader.GetDouble(3),
                        Commission = reader.GetDouble(4),

                        Multiplier = reader.GetInt32(5),
                        ContractSize = reader.GetInt32(6),

                        PointValue = reader.GetDouble(7),
                        Zim = reader.GetDouble(8),
                        TickSize = reader.GetDouble(9),
                    };

                    res.Add(d);
                }

                reader.Close();
            }
            return res;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// With this function you can get all data
        /// of dataset from DB
        /// </summary>
        /// <param name="datasetId"></param>
        /// <returns></returns>
        public static DataSetModel GetDatasetData(int datasetId)
        {
            var dsm = new DataSetModel();

            var sql = "SELECT * FROM " + TblDatasets + " WHERE `ID`= " + datasetId;
            var reader = GetReader(sql);
            if (reader != null)
            {
                if (reader.Read())
                {
                    dsm.Id = reader.GetInt32(0);
                    dsm.SymbolId = reader.GetInt32(1);
                    dsm.DataSetName = reader.GetString(2);
                    dsm.TimeValue = reader.GetDouble(3);
                    dsm.Commission = reader.GetDouble(4);

                    dsm.Multiplier = reader.GetInt32(5);
                    dsm.ContractSize = reader.GetInt32(6);

                    dsm.PointValue = reader.GetDouble(7);
                    dsm.Zim = reader.GetDouble(8);
                    dsm.TickSize = reader.GetDouble(9);
                }

                reader.Close();
            }

            return dsm;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Edit dataset by id
        /// </summary>
        /// <param name="datasetId"></param>
        /// <param name="dsm"></param>
        /// <returns>return TRUE if changes saved success</returns>
        public static bool EditDataset(int datasetId, DataSetModel dsm)
        {
            String query = "UPDATE " + TblDatasets + " SET "
                + " DataSetName = '" + dsm.DataSetName + "', "
                + " TimeValue = " + dsm.TimeValue + ", "
                + " Symbol_ID = " + dsm.SymbolId + ", "
                + " Commission = " + dsm.Commission + ","
                + " Multiplier = " + dsm.Multiplier + ","
                + " ContractSize = " + dsm.ContractSize + ","
                + " PointValue = " + dsm.PointValue + ","
                + " ZIM = " + dsm.Zim + ","
                + " TickSize = " + dsm.TickSize + "";
            query += " WHERE  ID = '" + datasetId + "'; COMMIT;";

            return DoSql(query);
        }
Ejemplo n.º 6
0
        private void uiSaveDatasetButton_Click(object sender, EventArgs e)
        {
            var provider = uiStrategy_dataGridViewNoOptomizationParameters.DataSource as DataTable;

            var dataSetModel = new DataSetModel();
            try
            {
                if (provider != null)
                {
                    dataSetModel.SymbolId = _contracts.Find(a => a.ContractName == uiStrategy_comboBoxExSymbol.Text).CountractId;
                    dataSetModel.DataSetName = provider.Rows[0]["Default Value"].ToString();
                    dataSetModel.TimeValue = double.Parse(provider.Rows[1]["Default Value"].ToString(), _nfi);
                    dataSetModel.Commission = double.Parse(provider.Rows[2]["Default Value"].ToString(), _nfi);
                    dataSetModel.Multiplier = int.Parse(provider.Rows[3]["Default Value"].ToString());
                    dataSetModel.ContractSize = int.Parse(provider.Rows[4]["Default Value"].ToString(), _nfi);
                    dataSetModel.PointValue = double.Parse(provider.Rows[5]["Default Value"].ToString(), _nfi);
                    dataSetModel.Zim = double.Parse(provider.Rows[6]["Default Value"].ToString(), _nfi);
                    dataSetModel.TickSize = double.Parse(provider.Rows[7]["Default Value"].ToString(), _nfi);
                    _tickSize = dataSetModel.TickSize;
                }
            }
            catch (Exception)
            {
                MessageBox.Show(@"Please check entered values");
                return;
            }

            if (_dataSets.Exists(a => a.DataSetName == uiStrategy_comboBoxExDataSet.Text))
            {
                var dataSetId = _dataSets.Find(a => a.DataSetName == uiStrategy_comboBoxExDataSet.Text).Id;
                if (DataManager.EditDataset(dataSetId, dataSetModel))
                {
                    _dataSets = DataManager.GetDatasets();
                    uiStrategy_comboBoxExDataSet.Items.Clear();
                    uiCalendar_comboBoxXDSet.Items.Clear();
                    var symbolId = _contracts.Find(a => a.ContractName == uiStrategy_comboBoxExSymbol.Text).CountractId;

                    foreach (var dataSet in _dataSets.Where(a => a.SymbolId == symbolId))
                    {
                        uiCalendar_comboBoxXDSet.Items.Add(dataSet.DataSetName);
                        uiStrategy_comboBoxExDataSet.Items.Add(dataSet.DataSetName);
                    }
                    uiStrategy_comboBoxExDataSet.Text = dataSetModel.DataSetName;
                    uiCalendar_comboBoxXDSet.Text = dataSetModel.DataSetName;
                    UpdateOptParamsInstance(dataSetModel.Zim, dataSetModel.PointValue, _tickSize);
                }
            }
            else
            {
                if (DataManager.AddDataset(dataSetModel))
                {
                    uiStrategy_comboBoxExDataSet.Items.Add(dataSetModel.DataSetName);
                    uiCalendar_comboBoxXDSet.Items.Add(dataSetModel.DataSetName);
                    _dataSets = DataManager.GetDatasets();

                    UpdateOptParamsInstance(dataSetModel.Zim, dataSetModel.PointValue, _tickSize);
                    uiStrategy_comboBoxExDataSet.SelectedIndex = uiStrategy_comboBoxExDataSet.Items.Count - 1;
                    uiCalendar_comboBoxXDSet.SelectedIndex = uiCalendar_comboBoxXDSet.Items.Count - 1;
                }
            }
            uiStrategy_WorkingButtonsPanel.Enabled = true;
            _addingNewDataSet = false;
        }