public bool SetParameter(string parameter, string value) { bool created = false; DataRow row = ParametersTable.FindByParameter(parameter); if (row == null) { row = ParametersTable.NewRow(); row["Parameter"] = parameter; ParametersTable.Rows.Add(row); created = true; } row["Value"] = value; ParametersTable.AcceptChanges(); return(created); }
private bool New() { DataRow row; MarginMath mm = null; ResultMath rm = null; bool changed = false; try { string[] AllTypes = new string[] { "Long Stock", "Short Stock", "Long Call", "Short Call", "Long Put", "Short Put" }; string[] IntTypes = new string[] { "Debit", "Credit", "Federal" }; foreach (string s in AllTypes) { if (CommissionsTable.FindByType(s) == null) { changed = true; row = CommissionsTable.NewRow(); row["Type"] = s; row["PerTransaction"] = 0; row["PerUnit"] = 0; CommissionsTable.Rows.Add(row); } } foreach (string s in IntTypes) { if (InterestTable.FindByType(s) == null) { changed = true; row = InterestTable.NewRow(); row["Type"] = s; row["Interest"] = 0; InterestTable.Rows.Add(row); } } if (ParametersTable.FindByParameter("Option Calculation Prices") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Option Calculation Prices"; row["Value"] = "Ask/Bid Prices"; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Stock Calculation Prices") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Stock Calculation Prices"; row["Value"] = "Last Price"; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Simple Options Commission") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Simple Options Commission"; row["Value"] = "Yes"; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Created with Version") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Created with Version"; row["Value"] = CurrentVersion; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Installation Date") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Installation Date"; row["Value"] = DateTime.Now.ToShortDateString(); ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Last Version Check") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Last Version Check"; row["Value"] = CurrentVersion; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Remote Configuration") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Remote Configuration"; row["Value"] = REMOTE_CONFIG; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Online Server") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Online Server"; row["Value"] = Global.DEFAULT_ONLINE_SERVER; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Server Mode") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Server Mode"; row["Value"] = ""; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Auto Refresh") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Auto Refresh"; row["Value"] = Global.DEFAULT_AUTO_REFRESH; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Federal Interest Auto Update") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Federal Interest Auto Update"; row["Value"] = Global.DEFAULT_FEDERAL_INTEREST_AUTO_UPDATE; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Volatility Mode") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Volatility Mode"; row["Value"] = Global.DEFAULT_VOLATILITY_MODE; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Fixed Volatility") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Fixed Volatility"; row["Value"] = Global.DEFAULT_FIXED_VOLATILITY; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Download Historical Volatility") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Download Historical Volatility"; row["Value"] = "No"; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Use Historical Volatility For StdDev") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Use Historical Volatility For StdDev"; row["Value"] = "No"; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Implied Volatility Fallback") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Implied Volatility Fallback"; row["Value"] = "No"; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Historical Volatility Algorithm") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Historical Volatility Algorithm"; row["Value"] = Global.DEFAULT_HISVOL_ALGORITHM; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Last Wizard Stock List") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Last Wizard Stock List"; row["Value"] = ""; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Pricing Model") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Pricing Model"; row["Value"] = "BlackScholes"; ParametersTable.Rows.Add(row); } if (ParametersTable.FindByParameter("Binominal Steps") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Binominal Steps"; row["Value"] = "50"; ParametersTable.Rows.Add(row); } row = ParametersTable.FindByParameter("Customization Mode"); if (row == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Customization Mode"; row["Value"] = Properties.Resources.AppCustomizationMode.ToString(); ParametersTable.Rows.Add(row); } else if (row["Value"].ToString() == "" && Properties.Resources.AppCustomizationMode.ToString() != "") { row["Value"] = Properties.Resources.AppCustomizationMode.ToString(); } // create table view configuration TableConfig.CreateDefaultTableView(false); // delete old column width configuration if (ParametersTable.FindByParameter("Main Table Columns Width") != null || ParametersTable.FindByParameter("Portfolio Table Columns Width") != null) { Config.Local.DeleteParameter("Main Table Columns Width"); Config.Local.DeleteParameter("Portfolio Table Columns Width"); changed = true; } // backward competability - rename portfolio OPO list, and create portfolio-list variable // which includes list of portfolios if (ParametersTable.FindByParameter("Portfolio OPO List") != null) { changed = RenameParameter("Portfolio OPO List", "Portfolio (My Portfolio)"); } if (ParametersTable.FindByParameter("Table Columns Width") != null) { changed = RenameParameter("Table Columns Width", "Main Table Columns Width"); } if (ParametersTable.FindByParameter("Portfolio List") == null) { changed = true; row = ParametersTable.NewRow(); row["Parameter"] = "Portfolio List"; row["Value"] = "My Portfolio"; ParametersTable.Rows.Add(row); } if (MarginTable.Rows.Count == 0) { // reset margin if (mm == null) { mm = new MarginMath(null); } mm.resetToMarginAccount(); } if (CriteriaTable.Rows.Count == 0) { // reset criteria if (rm == null) { rm = new ResultMath(null); } rm.resetToDefaultCriteriaList(); } CriteriaTable.DefaultView.Sort = "Index ASC"; if (LinksTable.Rows.Count == 0) { // reset links LinksConfig.ResetToDefaultLinks(); } // accept changes CriteriaTable.AcceptChanges(); CommissionsTable.AcceptChanges(); MarginTable.AcceptChanges(); InterestTable.AcceptChanges(); ParametersTable.AcceptChanges(); LinksTable.AcceptChanges(); } catch { } // rename old parameters name to new ones for (int j = 1; j <= 2; j++) { RenameParameter("Indicator" + j.ToString() + " Name", "Last Wizard Indicator Name " + j.ToString()); RenameParameter("Indicator" + j.ToString() + " Equation", "Last Wizard Indicator Equation " + j.ToString()); RenameParameter("Indicator" + j.ToString() + " Enable", "Last Wizard Indicator Enable " + j.ToString()); RenameParameter("Indicator" + j.ToString() + " Filter Enable", "Last Wizard Indicator Filter Enable " + j.ToString()); RenameParameter("Indicator" + j.ToString() + " Min Value", "Last Wizard Indicator Min Value " + j.ToString()); RenameParameter("Indicator" + j.ToString() + " Max Value", "Last Wizard Indicator Max Value " + j.ToString()); } row = ParametersTable.FindByParameter("Created with Version"); if (row != null) { // 1.0.8.0 -> 1.0.8.1 if ((string)row["Value"] == "1.0.8.0") { changed = true; // update configuration version row["Value"] = "1.0.8.1"; // update and save ParametersTable.AcceptChanges(); // mark upgrade flag first_upgrade = true; } // 1.0.8.1 -> 1.0.8.2 if ((string)row["Value"] == "1.0.8.1") { changed = true; // update configuration version row["Value"] = "1.0.8.2"; if (MessageBox.Show("As part of the upgrade to version 1.0.8.2, OptionsOracle needs to reset your margin-account configuration. \nIf you are using private or cash-account configuration press \"Cancel\", otherwise please press \"OK\".", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { // reset margin if (mm == null) { mm = new MarginMath(null); } mm.resetToMarginAccount(); } // update and save ParametersTable.AcceptChanges(); // mark upgrade flag first_upgrade = true; } // -> CurrentVersion if ((string)row["Value"] != CurrentVersion) { changed = true; // update configuration version row["Value"] = CurrentVersion; // don't show the market selection message Config.Local.SetParameter("Server Was Selected", "Yes"); Config.Local.SetParameter("Last Command", "0"); // update and save ParametersTable.AcceptChanges(); // mark upgrade flag first_upgrade = true; } } return(changed); }