[Quantproject-developers] QuantProject/b91_QuantProject Main.cs,1.14,1.15
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2005-06-10 18:45:58
|
Update of /cvsroot/quantproject/QuantProject/b91_QuantProject In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19231/b91_QuantProject Modified Files: Main.cs Log Message: Added the function to ShowReportFromFile for retrieving a report, through the ReportShower, from a serialized TransactionHistory object; Added new MenuItem to Main form for creating report from a serialized transaction History; Added new MenuItem to Report form for saving the TransactionHistory on which the current showed report is based Index: Main.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b91_QuantProject/Main.cs,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Main.cs 23 Mar 2005 21:35:38 -0000 1.14 --- Main.cs 10 Jun 2005 18:45:45 -0000 1.15 *************** *** 22,25 **** --- 22,26 ---- using System; + using System.IO; using System.Drawing; using System.Collections; *************** *** 28,32 **** using QuantProject.Scripts; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; ! //using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Scripts.SimpleTesting; --- 29,33 ---- using QuantProject.Scripts; using QuantProject.Scripts.TickerSelectionTesting.EfficientPortfolios; ! using QuantProject.ADT.Optimizing.Genetic; using QuantProject.Scripts.SimpleTesting; *************** *** 34,37 **** --- 35,41 ---- using QuantProject.Scripts.CallingReportsForRunScripts; using QuantProject.Presentation.Reporting.WindowsForm; + using QuantProject.ADT.Statistics; + + *************** *** 44,48 **** public class Principale : System.Windows.Forms.Form { ! private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; --- 48,54 ---- public class Principale : System.Windows.Forms.Form { ! public static RunEfficientPorfolio runEfficientPortfolio; ! ! private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; *************** *** 64,67 **** --- 70,74 ---- private System.Windows.Forms.MenuItem menuItemRunReleasingMode; private System.Windows.Forms.MenuItem menuItemShowSavedReport; + private System.Windows.Forms.MenuItem menuItemShowReportFromTransactions; /// <summary> /// Required designer variable. *************** *** 112,115 **** --- 119,123 ---- this.menuItemAccountViewer = new System.Windows.Forms.MenuItem(); this.menuItemShowReportFromAccount = new System.Windows.Forms.MenuItem(); + this.menuItemShowSavedReport = new System.Windows.Forms.MenuItem(); this.menuItemRunReleasingMode = new System.Windows.Forms.MenuItem(); this.menuItem13 = new System.Windows.Forms.MenuItem(); *************** *** 122,126 **** this.menuItem6 = new System.Windows.Forms.MenuItem(); this.menuItem7 = new System.Windows.Forms.MenuItem(); ! this.menuItemShowSavedReport = new System.Windows.Forms.MenuItem(); // // mainMenu1 --- 130,134 ---- this.menuItem6 = new System.Windows.Forms.MenuItem(); this.menuItem7 = new System.Windows.Forms.MenuItem(); ! this.menuItemShowReportFromTransactions = new System.Windows.Forms.MenuItem(); // // mainMenu1 *************** *** 172,176 **** this.menuItemAccountViewer, this.menuItemShowReportFromAccount, ! this.menuItemShowSavedReport}); this.menuItemSavedTests.Text = "Saved Tests"; // --- 180,185 ---- this.menuItemAccountViewer, this.menuItemShowReportFromAccount, ! this.menuItemShowSavedReport, ! this.menuItemShowReportFromTransactions}); this.menuItemSavedTests.Text = "Saved Tests"; // *************** *** 187,190 **** --- 196,205 ---- this.menuItemShowReportFromAccount.Click += new System.EventHandler(this.menuItemShowReportFromAccount_Click); // + // menuItemShowSavedReport + // + this.menuItemShowSavedReport.Index = 2; + this.menuItemShowSavedReport.Text = "Show saved report"; + this.menuItemShowSavedReport.Click += new System.EventHandler(this.menuItemShowSavedReport_Click); + // // menuItemRunReleasingMode // *************** *** 241,249 **** this.menuItem7.Text = ""; // ! // menuItemShowSavedReport // ! this.menuItemShowSavedReport.Index = 2; ! this.menuItemShowSavedReport.Text = "Show saved report"; ! this.menuItemShowSavedReport.Click += new System.EventHandler(this.menuItemShowSavedReport_Click); // // Principale --- 256,264 ---- this.menuItem7.Text = ""; // ! // menuItemShowReportFromTransactions // ! this.menuItemShowReportFromTransactions.Index = 3; ! this.menuItemShowReportFromTransactions.Text = "Show report from transactions"; ! this.menuItemShowReportFromTransactions.Click += new System.EventHandler(this.menuItemShowReportFromTransactions_Click); // // Principale *************** *** 267,276 **** { } [STAThread] static void Main() { ! //try { //new RunMSFTsimpleTest().Run(); --- 282,376 ---- { } + + static void runMilloScripts() + { + /*QuantProject.Principale.Principale.runEfficientPortfolio = + new RunEfficientCTCPorfolio("Test",150,4,60,10,15000,"^SPX", + new DateTime(2004,3,1), + new DateTime(2004,5,31),15,2,0.0, + PortfolioType.ShortAndLong,0.05, + 2);*/ + /*QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTCPortfolio("Test",150,4,60,10,25000,"^SPX", + new DateTime(2004,3,1), + new DateTime(2004,3,1).AddDays(60),15,2,0.015, + PortfolioType.ShortAndLong,0.1, + 2);/* + /*QuantProject.Principale.Principale.runEfficientPortfolio = + new RunEfficientCTOPorfolio("Test",150,4,45,10,1000, + "^SPX", + new DateTime(2004,1,1), + new DateTime(2004,1,15), + 0.0, PortfolioType.ShortAndLong, 2);*/ + + QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTOPorfolio("Test",150,5,45,10,50000, + "^SPX", + new DateTime(2004,3,1), + new DateTime(2004,3,1).AddDays(45), + 0.0005, PortfolioType.ShortAndLong, 12); + + /*new RunTestOptimizedCTCPortfolio("Test",150,6,90,10,20000, + "^SPX", + new DateTime(2002,10,1), + new DateTime(2002,10,1).AddDays(120), + 5,2,0.0, + PortfolioType.ShortAndLong, 0.50, 10);*/ + + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); + /* QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTOPorfolio("Test",150,6,45,10,150000, + "^SPX", + new DateTime(2003,1,1), + new DateTime(2003,1,1).AddDays(45), + 0.0, PortfolioType.OnlyShort, 12); + + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); */ + /* + QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTCPortfolio("Test",100,5,120,10,150000, + "^SPX", + new DateTime(2002,10,1), + new DateTime(2002,10,1).AddDays(120), + 5, 0.0, + PortfolioType.ShortAndLong, 0.50, 10); + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); + + QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTCPortfolio("Test",150,5,80,15,60000, + "^SPX", + new DateTime(2002,10,1), + new DateTime(2002,10,1).AddDays(80), + 5, 0.0, + PortfolioType.OnlyLong , 0.50, 10); + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); + QuantProject.Principale.Principale.runEfficientPortfolio = + new RunTestOptimizedCTCPortfolio("Test",150,5,160,15,60000, + "^SPX", + new DateTime(2002,10,1), + new DateTime(2002,10,1).AddDays(160), + 5, 0.0, + PortfolioType.ShortAndLong, 0.50, 10); + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); + */ + + /* + QuantProject.Principale.Principale.runEfficientPortfolio = + new RunEfficientCTOPorfolio("Test",500,6,45,15,50000, + "^SPX", + new DateTime(2002,1,1), + new DateTime(2004,12,31), + 0.0, PortfolioType.OnlyLong); + + QuantProject.Principale.Principale.runEfficientPortfolio.Run(); + */ + + } [STAThread] static void Main() { ! try { //new RunMSFTsimpleTest().Run(); *************** *** 285,288 **** --- 385,395 ---- //new RunEfficientPorfolio().Run(); Application.Run(new Principale()); + //geneticOptimizerTest(); + //Application.Run(new OneRankForm()); + //runMilloScripts(); + + //new RunEfficientCTOPorfolio("Test",200,5,60,10,5000, "^SPX", + // new DateTime(2000,1,1), + // new DateTime(2001,12,31)).Run(); // new RunMSFTwalkForward().Run(); *************** *** 298,317 **** } ! //catch ( Exception ex ) { ! //MessageBox.Show( ex.ToString() ) ; } } ! /* private static void geneticOptimizerTest() { IGenomeManager genomeManagerTest = new GenomeManagerTest(5,1,10); ! GeneticOptimizer GO = new GeneticOptimizer(genomeManagerTest); ! GO.KeepOnRunningUntilConvergenceIsReached = true; GO.Run(true); System.Console.WriteLine("\n\nThe best solution found is: " + (string)GO.BestGenome.Meaning + " with {0} generations", GO.GenerationCounter); } ! */ private void menuItem14_Click(object sender, System.EventArgs e) { --- 405,450 ---- } ! catch ( Exception ex ) { ! QuantProject.Principale.Principale.runEfficientPortfolio.SaveScriptResults(); ! writeExceptionToLogFile(ex); } } ! static private void writeExceptionToLogFile(Exception ex) ! { ! string path = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf('\\')) ! + @"\ExceptionLog.txt"; ! if(File.Exists(path)) ! { ! StreamWriter w = File.AppendText(path); ! w.Write("\r\nTime of exception : "); ! w.WriteLine("{0} {1}", DateTime.Now.ToLongDateString(), ! DateTime.Now.ToLocalTime()); ! w.Write("\r\nScript name: {0}", ! QuantProject.Principale.Principale.runEfficientPortfolio.ScriptName ); ! w.Write("\r\nTimer date: {0}", ! QuantProject.Principale.Principale.runEfficientPortfolio.TimerLastDate.ToLongDateString() ); ! ! w.WriteLine("\n :{0}", ex.ToString()); ! w.WriteLine("\n :{0}", ex.StackTrace.ToString()); ! w.WriteLine ("\n-----------------------------------"); ! // Update the underlying file. ! w.Flush(); ! w.Close(); ! } ! ! ! } ! private static void geneticOptimizerTest() { IGenomeManager genomeManagerTest = new GenomeManagerTest(5,1,10); ! GeneticOptimizer GO = new GeneticOptimizer(genomeManagerTest,1000,10); ! //GO.KeepOnRunningUntilConvergenceIsReached = true; GO.Run(true); System.Console.WriteLine("\n\nThe best solution found is: " + (string)GO.BestGenome.Meaning + " with {0} generations", GO.GenerationCounter); } ! private void menuItem14_Click(object sender, System.EventArgs e) { *************** *** 326,332 **** //new RunOneRank().Run(); ! new RunEfficientCTOPorfolio("Test2",100,5,45, 1, 3000, "^SPX", ! new DateTime(2004,10,1), ! new DateTime(2004,10,15)).Run(); // } --- 459,474 ---- //new RunOneRank().Run(); ! //new RunEfficientCTCPorfolio("Test",400,5,90,10,10000, ! // "^SPX", ! // new DateTime(2004,1,1), ! // new DateTime(2004,2,29), ! // 3).Run(); ! ! //this.Close(); ! runMilloScripts(); ! ! //new RunEfficientCTOPorfolio("Test",200,5,60,2,500, "^SPX", ! // new DateTime(2004,1,1), ! // new DateTime(2004,1,15)).Run(); // } *************** *** 375,379 **** catch ( Exception ex ) { ! string notUsed = ex.ToString(); //in this way qP shouldn't stop if running a single script fails ... } --- 517,521 ---- catch ( Exception ex ) { ! ex = ex; //in this way qP shouldn't stop if running a single script fails ... } *************** *** 391,394 **** --- 533,543 ---- } + private void menuItemShowReportFromTransactions_Click(object sender, System.EventArgs e) + { + string chosenPath = this.getPath("Select a serialized TransactionHistory please ..."); + if(chosenPath != "") + ShowReportFromFile.ShowReportFromSerializedTransactionHistory(chosenPath); + } + |