Thread: [Quantproject-developers] QuantProject/b7_Scripts/TickerSelectionTesting EndOfDayTimerHandlerCTO.cs,
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2005-03-23 21:36:57
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23583/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandlerCTO.cs GenomeManagerForEfficientCTOPortfolio.cs RunEfficientCTOPortfolio.cs Log Message: Efficient Open to Close script has been modified (but not tested completely ...): now selection takes place only for tickers with a given open price level Index: EndOfDayTimerHandlerCTO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTO.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EndOfDayTimerHandlerCTO.cs 27 Feb 2005 19:56:08 -0000 1.4 --- EndOfDayTimerHandlerCTO.cs 23 Mar 2005 21:35:32 -0000 1.5 *************** *** 58,61 **** --- 58,63 ---- private ArrayList orders; + private string benchmark; + public int NumberOfEligibleTickers { *************** *** 71,75 **** int numberOfTickersToBeChosen, int numDaysForLiquidity, Account account, int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer) { this.tickerGroupID = tickerGroupID; --- 73,78 ---- int numberOfTickersToBeChosen, int numDaysForLiquidity, Account account, int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, ! string benchmark) { this.tickerGroupID = tickerGroupID; *************** *** 80,83 **** --- 83,87 ---- this.generationNumberForGeneticOptimizer = generationNumberForGeneticOptimizer; this.populationSizeForGeneticOptimizer = populationSizeForGeneticOptimizer; + this.benchmark = benchmark; this.orders = new ArrayList(); this.chosenTickers = new string[numberOfTickersToBeChosen]; *************** *** 94,98 **** long quantity = Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( ticker ) ) ); ! Order order = new Order( OrderType.MarketSellShort, new Instrument( ticker ) , quantity ); this.orders.Add(order); } --- 98,102 ---- long quantity = Convert.ToInt64( Math.Floor( cashForSinglePosition / this.account.DataStreamer.GetCurrentBid( ticker ) ) ); ! Order order = new Order( OrderType.MarketBuy, new Instrument( ticker ) , quantity ); this.orders.Add(order); } *************** *** 126,130 **** { if(this.orders.Count == 0 && this.account.Transactions.Count == 0) ! this.account.AddCash(30000); this.marketOpenEventHandler_orderChosenTickers(); --- 130,134 ---- { if(this.orders.Count == 0 && this.account.Transactions.Count == 0) ! this.account.AddCash(15000); this.marketOpenEventHandler_orderChosenTickers(); *************** *** 172,176 **** private DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { ! SelectorByLiquidity mostLiquid = new SelectorByLiquidity(this.tickerGroupID, false, currentDate.AddDays(-this.numDaysForLiquidity), currentDate, this.numberOfEligibleTickers); this.eligibleTickers = mostLiquid.GetTableOfSelectedTickers(); --- 176,185 ---- private DataTable getSetOfTickersToBeOptimized(DateTime currentDate) { ! SelectorByAverageRawOpenPrice selectorByOpenPrice = ! new SelectorByAverageRawOpenPrice(this.tickerGroupID, false, ! currentDate.AddDays(-this.numDaysForLiquidity), currentDate, ! this.numberOfEligibleTickers, 25, 35, 0, 0.5); ! DataTable tickersByPrice = selectorByOpenPrice.GetTableOfSelectedTickers(); ! SelectorByLiquidity mostLiquid = new SelectorByLiquidity(tickersByPrice, false, currentDate.AddDays(-this.numDaysForLiquidity), currentDate, this.numberOfEligibleTickers); this.eligibleTickers = mostLiquid.GetTableOfSelectedTickers(); *************** *** 178,182 **** new SelectorByQuotationAtEachMarketDay( this.eligibleTickers, false, currentDate.AddDays(-this.numDaysForLiquidity), ! currentDate, this.numberOfEligibleTickers, "^MIBTEL"); return quotedInEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(); } --- 187,191 ---- new SelectorByQuotationAtEachMarketDay( this.eligibleTickers, false, currentDate.AddDays(-this.numDaysForLiquidity), ! currentDate, this.numberOfEligibleTickers, this.benchmark); return quotedInEachMarketDayFromMostLiquid.GetTableOfSelectedTickers(); } Index: GenomeManagerForEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/GenomeManagerForEfficientCTOPortfolio.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** GenomeManagerForEfficientCTOPortfolio.cs 27 Feb 2005 19:56:08 -0000 1.5 --- GenomeManagerForEfficientCTOPortfolio.cs 23 Mar 2005 21:35:36 -0000 1.6 *************** *** 106,113 **** NormalDistribution normal = new NormalDistribution(portfolioRateOfReturn, Math.Sqrt(portfolioVariance)); //for long portfolio ! //returnValue = normal.GetProbability(this.targetPerformance*0.75,this.targetPerformance*1.25); //for short portfolio ! returnValue = normal.GetProbability(-this.targetPerformance*1.25,-this.targetPerformance*0.75); ! //returnValue = 1 - normal.GetProbability(this.targetPerformance); return returnValue; } --- 106,112 ---- NormalDistribution normal = new NormalDistribution(portfolioRateOfReturn, Math.Sqrt(portfolioVariance)); //for long portfolio ! returnValue = normal.GetProbability(this.targetPerformance*0.75,this.targetPerformance*1.25); //for short portfolio ! //returnValue = normal.GetProbability(-this.targetPerformance*1.25,-this.targetPerformance*0.75); return returnValue; } Index: RunEfficientCTOPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/RunEfficientCTOPortfolio.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** RunEfficientCTOPortfolio.cs 13 Mar 2005 20:28:54 -0000 1.15 --- RunEfficientCTOPortfolio.cs 23 Mar 2005 21:35:37 -0000 1.16 *************** *** 84,92 **** private IEndOfDayTimer endOfDayTimer; ! public RunEfficientCTOPorfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer) { //this.progressBarForm = new ProgressBarForm(); --- 84,96 ---- private IEndOfDayTimer endOfDayTimer; ! ! private string benchmark; ! ! public RunEfficientCTOPorfolio(string tickerGroupID, int numberOfEligibleTickers, int numberOfTickersToBeChosen, int numDaysForLiquidity, int generationNumberForGeneticOptimizer, ! int populationSizeForGeneticOptimizer, string benchmark, ! DateTime startDate, DateTime endDate) { //this.progressBarForm = new ProgressBarForm(); *************** *** 99,105 **** this.reportTable = new ReportTable( "Summary_Reports" ); this.startDateTime = new EndOfDayDateTime( ! new DateTime( 2004 , 10 , 1 ) , EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ); this.endDateTime = new EndOfDayDateTime( ! new DateTime( 2004 , 10 , 11 ) , EndOfDaySpecificTime.OneHourAfterMarketClose ); //this.numIntervalDays = 3; } --- 103,110 ---- this.reportTable = new ReportTable( "Summary_Reports" ); this.startDateTime = new EndOfDayDateTime( ! startDate, EndOfDaySpecificTime.FiveMinutesBeforeMarketClose ); this.endDateTime = new EndOfDayDateTime( ! endDate, EndOfDaySpecificTime.OneHourAfterMarketClose ); ! this.benchmark = benchmark; //this.numIntervalDays = 3; } *************** *** 132,136 **** { this.endOfDayTimer = ! new IndexBasedEndOfDayTimer( this.startDateTime, "^MIBTEL" ); } private void run_initializeAccount() --- 137,141 ---- { this.endOfDayTimer = ! new IndexBasedEndOfDayTimer( this.startDateTime, this.benchmark ); } private void run_initializeAccount() *************** *** 140,144 **** this.historicalQuoteProvider ) , new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , ! this.historicalQuoteProvider )); } --- 145,149 ---- this.historicalQuoteProvider ) , new HistoricalEndOfDayOrderExecutor( this.endOfDayTimer , ! this.historicalQuoteProvider ), new IBCommissionManager()); } *************** *** 151,155 **** this.account, this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer); --- 156,161 ---- this.account, this.generationNumberForGeneticOptimizer, ! this.populationSizeForGeneticOptimizer, ! this.benchmark); *************** *** 207,211 **** this.endOfDayTimer.Stop(); //report = new Report( this.account , this.historicalQuoteProvider ); ! //report.Show("CTO_Portfolio" , this.numIntervalDays , this.endDateTime , "^MIBTEL" ); string name = "From"+this.numberOfEligibleTickers + "LiqDays" + this.numDaysForLiquidity + "Portfolio" + --- 213,217 ---- this.endOfDayTimer.Stop(); //report = new Report( this.account , this.historicalQuoteProvider ); ! //report.Show("CTO_Portfolio" , this.numIntervalDays , this.endDateTime , this.benchmark ); string name = "From"+this.numberOfEligibleTickers + "LiqDays" + this.numDaysForLiquidity + "Portfolio" + *************** *** 213,222 **** this.generationNumberForGeneticOptimizer + "PopSize" + this.populationSizeForGeneticOptimizer; ! //AccountReport accountReport = this.account.CreateReport(name,1,this.endDateTime,"^MIBTEL", ! // new HistoricalAdjustedQuoteProvider()); ! //ObjectArchiver.Archive(accountReport, ! // System.Configuration.ConfigurationSettings.AppSettings["ReportsArchive"] + ! // "\\OpenCloseScripts\\" + ! // name + ".rep"); ObjectArchiver.Archive(this.account, --- 219,228 ---- this.generationNumberForGeneticOptimizer + "PopSize" + this.populationSizeForGeneticOptimizer; ! AccountReport accountReport = this.account.CreateReport(name,1,this.endDateTime,this.benchmark, ! new HistoricalAdjustedQuoteProvider()); ! ObjectArchiver.Archive(accountReport, ! System.Configuration.ConfigurationSettings.AppSettings["ReportsArchive"] + ! "\\OpenCloseScripts\\" + ! name + ".rep"); ObjectArchiver.Archive(this.account, |