[Quantproject-developers] QuantProject/b4_Business/a2_Strategies/InSample BasicChooserFromSavedBac
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2008-04-08 21:31:36
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/InSample In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31246 Added Files: BasicChooserFromSavedBackTestLog.cs Log Message: Added IInSampleChooser based on a BackTestLog already saved to disk. It is useful for avoiding optimizing process when you just need to change out of sample parameters. --- NEW FILE: BasicChooserFromSavedBackTestLog.cs --- /* QuantProject - Quantitative Finance Library BasicChooserFromSavedBackTestLog.cs Copyright (C) 2008 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using System.Collections; using QuantProject.ADT; using QuantProject.ADT.FileManaging; using QuantProject.ADT.Messaging; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.Logging; using QuantProject.Business.Strategies.Eligibles; using QuantProject.Business.Strategies.ReturnsManagement; using QuantProject.Business.Timing; using QuantProject.Business.Strategies.OutOfSample; namespace QuantProject.Business.Strategies.InSample { /// <summary> /// Abstract basic IInSampleChooser for returning /// log items already saved in a BackTestLog saved to disk /// </summary> public abstract class BasicChooserFromSavedBackTestLog : IInSampleChooser { public event NewProgressEventHandler NewProgress; public event NewMessageEventHandler NewMessage; protected string backTestLogFullPath; protected BackTestLog backTestLog; public virtual string Description { get { string description = "ChooserFromSavedBackTestLog"; return description; } } /// <summary> /// Abstract BasicChooserFromSavedBackTestLog to be used for /// retrieving TestingPositions from a BackTestLog /// already saved to disk /// </summary> public BasicChooserFromSavedBackTestLog( string backTestLogFullPath) { this.backTestLogFullPath = backTestLogFullPath; } protected abstract TestingPositions[] getTestingPositionsFromBackTestLog( EndOfDayDateTime lastInSampleDateOfOptimizedTestingPositions ); protected void analyzeInSample_setBackTestLog() { if( this.backTestLog == null ) { object savedObject = ObjectArchiver.Extract( this.backTestLogFullPath); if( savedObject is BackTestLog ) this.backTestLog = (BackTestLog)savedObject; else // savedObject is not a BackTestLog throw new Exception("The loaded object is not " + " a BackTestLog!"); } } /// <summary> /// Returns the best TestingPositions /// stored in the BackTestLog /// </summary> /// <param name="eligibleTickers">Also a dummy eligibleTickers (not used)</param> /// <param name="returnsManager">Also a dummy returnsManager (not used)</param> public object AnalyzeInSample( EligibleTickers eligibleTickers , ReturnsManager returnsManager ) { this.analyzeInSample_setBackTestLog(); TestingPositions[] bestTestingPositionsInSample = this.getTestingPositionsFromBackTestLog( returnsManager.ReturnIntervals.LastEndOfDayDateTime ); return bestTestingPositionsInSample; } } } |