Esempio n. 1
0
        private void loadModel(IniUtil ini, string strategyName)
        {
            string list = getparams(strategyName);

            string[] names = list.Split(';');

            DataSet set = new DataSet();

            DataTable table = new DataTable();

            table.TableName = "param";

            DataColumn col = table.Columns.Add();

            col.ColumnName = "参数名";

            col.Caption = "参数名";

            col.DataType = System.Type.GetType("System.String");

            DataColumn col2 = table.Columns.Add();

            col2.ColumnName = "参数值";

            col2.Caption = "参数值";

            col2.DataType = System.Type.GetType("System.String");

            foreach (string param in names)
            {
                if (param != "")                //"交易合约;交易数量;开仓价;"   会多出一行来
                {
                    DataRow row = table.NewRow();

                    row[0] = param;

                    row[1] = "";

                    //读取配置文件的值
                    row[1] = ini.ReadString("params", param, "error!!!");

                    table.Rows.Add(row);
                }
            }


            set.Tables.Add(table);

            dataGridView1.DataSource = table.DefaultView;

            isLoadModel = true;
        }
Esempio n. 2
0
        //加载保存过的模型
        private void button4_Click(object sender, EventArgs e)
        {
            string filename = "";

            dataGridView1.DataSource = null;

            OpenFileDialog f1 = new OpenFileDialog();

            f1.Filter = "文本文件|*.ini";
            if (f1.ShowDialog() == DialogResult.OK)
            {
                filename = f1.FileName;
            }

            if (filename != "")
            {
                IniUtil ini = new IniUtil(filename);

                comboBox1.Text = ini.ReadString("strategyName", "策略名称", "请手动增加模型!");

                loadModel(ini, comboBox1.Text);
            }
        }