quantproject-developers Mailing List for QuantProject (Page 13)
Brought to you by:
glauco_1
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(7) |
Nov
(103) |
Dec
(67) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(52) |
Feb
(9) |
Mar
(69) |
Apr
(53) |
May
(80) |
Jun
(23) |
Jul
(24) |
Aug
(112) |
Sep
(9) |
Oct
|
Nov
(58) |
Dec
(93) |
| 2005 |
Jan
(90) |
Feb
(93) |
Mar
(61) |
Apr
(56) |
May
(37) |
Jun
(61) |
Jul
(55) |
Aug
(68) |
Sep
(25) |
Oct
(46) |
Nov
(41) |
Dec
(37) |
| 2006 |
Jan
(33) |
Feb
(7) |
Mar
(19) |
Apr
(27) |
May
(73) |
Jun
(49) |
Jul
(83) |
Aug
(66) |
Sep
(45) |
Oct
(16) |
Nov
(15) |
Dec
(7) |
| 2007 |
Jan
(14) |
Feb
(33) |
Mar
|
Apr
(21) |
May
|
Jun
(34) |
Jul
(18) |
Aug
(100) |
Sep
(39) |
Oct
(55) |
Nov
(12) |
Dec
(2) |
| 2008 |
Jan
(120) |
Feb
(133) |
Mar
(129) |
Apr
(104) |
May
(42) |
Jun
(2) |
Jul
(52) |
Aug
(99) |
Sep
(134) |
Oct
|
Nov
(137) |
Dec
(48) |
| 2009 |
Jan
(48) |
Feb
(55) |
Mar
(61) |
Apr
(3) |
May
(2) |
Jun
(1) |
Jul
|
Aug
(51) |
Sep
|
Oct
(7) |
Nov
|
Dec
|
| 2010 |
Jan
(7) |
Feb
(1) |
Mar
(145) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(8) |
Dec
|
| 2011 |
Jan
(78) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(88) |
Sep
(6) |
Oct
(1) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
(1) |
Mar
|
Apr
(6) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:35:23
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv25763/a2_Strategies/returnsManagement Modified Files: ReturnsManager.cs Log Message: The interface IReturnsManager is now implemented The read only property IHistoricalMarketValueProvider HistoricalMarketValueProvider is now exposed Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ReturnsManager.cs 29 Sep 2008 21:17:39 -0000 1.10 --- ReturnsManager.cs 28 Mar 2010 14:35:15 -0000 1.11 *************** *** 40,47 **** /// </summary> [Serializable] ! public class ReturnsManager { private ReturnIntervals returnIntervals; // a return for each interval ! private HistoricalMarketValueProvider historicalMarketValueProvider; private Set tickersMissingQuotes; --- 40,47 ---- /// </summary> [Serializable] ! public class ReturnsManager : IReturnsManager { private ReturnIntervals returnIntervals; // a return for each interval ! private IHistoricalMarketValueProvider historicalMarketValueProvider; private Set tickersMissingQuotes; *************** *** 50,53 **** --- 50,59 ---- private Hashtable tickersReturnsStandardDeviations; + + public IHistoricalMarketValueProvider HistoricalMarketValueProvider + { + get { return this.historicalMarketValueProvider; } + } + /// <summary> /// End of day intervals on which returns are computed *************** *** 79,83 **** /// n-1 elements</param> public ReturnsManager( ReturnIntervals returnIntervals , ! HistoricalMarketValueProvider historicalMarketValueProvider ) { // TO DO: let WFLagEligibleTickers use this class also!!! --- 85,89 ---- /// n-1 elements</param> public ReturnsManager( ReturnIntervals returnIntervals , ! IHistoricalMarketValueProvider historicalMarketValueProvider ) { // TO DO: let WFLagEligibleTickers use this class also!!! |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:34:07
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv25251/a2_Strategies/returnsManagement/time Modified Files: ReturnIntervals.cs Log Message: The public read only property ReturnInterval SeconLastInterval has been added Index: ReturnIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/ReturnIntervals.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ReturnIntervals.cs 13 Mar 2009 15:05:42 -0000 1.11 --- ReturnIntervals.cs 28 Mar 2010 14:33:58 -0000 1.12 *************** *** 31,35 **** { /// <summary> ! /// End of day intervals in a timed sequence, i.e. the (n+1)th interval /// never begins before the (n)th interval ends /// </summary> --- 31,35 ---- { /// <summary> ! /// Time intervals in a timed sequence, i.e. the (n+1)th interval /// never begins before the (n)th interval ends /// </summary> *************** *** 84,87 **** --- 84,100 ---- } } + + public ReturnInterval SeconLastInterval + { + get + { + if ( this.Count < 2 ) + throw new Exception( + "SeconLastInterval cannot be used when ReturnIntervals has " + + "less then two intervals!" ); + ReturnInterval lastInterval = this[ this.Count - 2 ]; + return lastInterval; + } + } /// <summary> /// The History made up by queuing all |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:33:19
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv25041/a05_Timing Modified Files: IndexBasedEndOfDayTimer.cs Log Message: The private member indexQuotes is now marked as [NonSerialized] Index: IndexBasedEndOfDayTimer.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a05_Timing/IndexBasedEndOfDayTimer.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** IndexBasedEndOfDayTimer.cs 30 Aug 2009 15:54:12 -0000 1.11 --- IndexBasedEndOfDayTimer.cs 28 Mar 2010 14:33:10 -0000 1.12 *************** *** 43,46 **** --- 43,47 ---- } + [NonSerialized] private Quotes indexQuotes; public Quotes IndexQuotes |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:31:23
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/FitnessEvaluation In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv24546/a2_Strategies/Optimizing/FitnessEvaluation Modified Files: IFitnessEvaluator.cs Log Message: IReturnsManager is now used, instead of ReturnsManager Index: IFitnessEvaluator.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/FitnessEvaluation/IFitnessEvaluator.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IFitnessEvaluator.cs 10 Feb 2008 14:10:04 -0000 1.1 --- IFitnessEvaluator.cs 28 Mar 2010 14:31:14 -0000 1.2 *************** *** 41,45 **** /// <param name="returnsManager"></param> /// <returns></returns> ! double GetFitnessValue( object meaning , ReturnsManager returnsManager ); } } --- 41,45 ---- /// <param name="returnsManager"></param> /// <returns></returns> ! double GetFitnessValue( object meaning , IReturnsManager returnsManager ); } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:31:08
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/Decoding In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv24469/a2_Strategies/Optimizing/Decoding Modified Files: IDecoderForTestingPositions.cs Log Message: IReturnsManager is now used, instead of ReturnsManager Index: IDecoderForTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/Decoding/IDecoderForTestingPositions.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IDecoderForTestingPositions.cs 27 Feb 2008 22:15:19 -0000 1.3 --- IDecoderForTestingPositions.cs 28 Mar 2010 14:31:00 -0000 1.4 *************** *** 44,48 **** TestingPositions Decode( int[] encoded , EligibleTickers eligibleTickers , ! ReturnsManager returnsManager ); } } --- 44,48 ---- TestingPositions Decode( int[] encoded , EligibleTickers eligibleTickers , ! IReturnsManager returnsManager ); } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:30:50
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv24380/a07_DataProviders Modified Files: HistoricalMarketValueProvider.cs Log Message: The interface IHistoricalMarketValueProvider is now implemented A new public method WereAllExchanged( ICollection<string> tickers , DateTime dateTime ) has been added. It returns true iif all the given tickers were traded at the given DateTime. A new public method GetDateTimesWithMarketValues( string ticker , History history ) has been added It returns the subset of DateTimes when ticker is exchanged Index: HistoricalMarketValueProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalMarketValueProvider.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HistoricalMarketValueProvider.cs 20 Nov 2008 20:49:58 -0000 1.2 --- HistoricalMarketValueProvider.cs 28 Mar 2010 14:30:42 -0000 1.3 *************** *** 22,25 **** --- 22,26 ---- using System; + using System.Collections.Generic; using QuantProject.ADT.Histories; *************** *** 34,38 **** /// </summary> [Serializable] ! public abstract class HistoricalMarketValueProvider : ILogDescriptor { public string Description --- 35,40 ---- /// </summary> [Serializable] ! public abstract class HistoricalMarketValueProvider : ! IHistoricalMarketValueProvider , ILogDescriptor { public string Description *************** *** 76,79 **** --- 78,101 ---- public abstract bool WasExchanged( string ticker , DateTime dateTime ); + /// <summary> + /// True iif all the given tickers were traded at the given DateTime + /// </summary> + /// <param name="tickers"></param> + /// <param name="dateTime"></param> + /// <returns></returns> + public virtual bool WereAllExchanged( ICollection<string> tickers , DateTime dateTime ) + { + IEnumerator<string> tickersEnumerator = tickers.GetEnumerator(); + tickersEnumerator.Reset(); + bool wereAllExchanged = true; + bool isEndOfCollection = !tickersEnumerator.MoveNext(); + while ( wereAllExchanged && !isEndOfCollection ) + { + wereAllExchanged = this.WasExchanged( tickersEnumerator.Current , dateTime ); + isEndOfCollection = !tickersEnumerator.MoveNext(); + } + return wereAllExchanged; + } + #region GetQuotes *************** *** 95,99 **** private void addMarketValue( string ticker , int historyIndex , ! History history , History quotes ) { DateTime currentDateTime = --- 117,121 ---- private void addMarketValue( string ticker , int historyIndex , ! History history , History quotes ) { DateTime currentDateTime = *************** *** 109,113 **** } public History GetMarketValues( string ticker , ! History history ) { History quotes = new History(); --- 131,135 ---- } public History GetMarketValues( string ticker , ! History history ) { History quotes = new History(); *************** *** 117,120 **** --- 139,159 ---- } #endregion GetQuotes + + #region GetDateTimesWithMarketValues + /// <summary> + /// returns the subset of DateTimes when ticker is exchanged + /// </summary> + /// <param name="ticker"></param> + /// <param name="history">DateTimes returned are a subset of this parameter</param> + /// <returns></returns> + public History GetDateTimesWithMarketValues( string ticker , History history ) + { + History dateTimesWithMarketValues = new History(); + foreach( DateTime dateTime in history.Keys ) + if ( this.WasExchanged( ticker , dateTime ) ) + dateTimesWithMarketValues.Add( dateTime , dateTime ); + return dateTimesWithMarketValues; + } + #endregion GetDateTimesWithMarketValues } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:28:48
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/GenomeManagers In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv23511/a2_Strategies/Optimizing/GenomeManagers Modified Files: GenomeManagerWithDuplicateGenes.cs Log Message: IReturnsManager is now used, instead of ReturnsManager Index: GenomeManagerWithDuplicateGenes.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/GenomeManagers/GenomeManagerWithDuplicateGenes.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GenomeManagerWithDuplicateGenes.cs 29 Sep 2008 21:16:51 -0000 1.2 --- GenomeManagerWithDuplicateGenes.cs 28 Mar 2010 14:28:39 -0000 1.3 *************** *** 41,45 **** int numberOfPortfolioPositions , EligibleTickers eligibleTickers , ! ReturnsManager returnsManager , IDecoderForTestingPositions decoderForTestingPositions , IFitnessEvaluator fitnessEvaluator , --- 41,45 ---- int numberOfPortfolioPositions , EligibleTickers eligibleTickers , ! IReturnsManager returnsManager , IDecoderForTestingPositions decoderForTestingPositions , IFitnessEvaluator fitnessEvaluator , |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:28:29
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/InSample In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv23373/a2_Strategies/InSample Modified Files: GeneticChooser.cs Log Message: The [NonSerialized] attribute has been added to the protected member geneticOptimizer. This dramatically reduces the size of the AccountReport(s) Index: GeneticChooser.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/InSample/GeneticChooser.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** GeneticChooser.cs 30 Aug 2009 15:51:47 -0000 1.11 --- GeneticChooser.cs 28 Mar 2010 14:28:20 -0000 1.12 *************** *** 67,72 **** protected int populationSizeForGeneticOptimizer; protected int generationNumberForGeneticOptimizer; ! protected int seedForRandomGenerator; protected GeneticOptimizer geneticOptimizer; --- 67,73 ---- protected int populationSizeForGeneticOptimizer; protected int generationNumberForGeneticOptimizer; ! protected int seedForRandomGeneratorForTheGeneticOptimizer; + [NonSerialized] protected GeneticOptimizer geneticOptimizer; *************** *** 101,105 **** int populationSizeForGeneticOptimizer , int generationNumberForGeneticOptimizer , ! int seedForRandomGenerator ) { this.numberOfPortfolioPositions = numberOfPortfolioPositions; --- 102,106 ---- int populationSizeForGeneticOptimizer , int generationNumberForGeneticOptimizer , ! int seedForRandomGeneratorForTheGeneticOptimizer ) { this.numberOfPortfolioPositions = numberOfPortfolioPositions; *************** *** 115,119 **** this.generationNumberForGeneticOptimizer = generationNumberForGeneticOptimizer; ! this.seedForRandomGenerator = seedForRandomGenerator; } --- 116,121 ---- this.generationNumberForGeneticOptimizer = generationNumberForGeneticOptimizer; ! this.seedForRandomGeneratorForTheGeneticOptimizer = ! seedForRandomGeneratorForTheGeneticOptimizer; } *************** *** 231,235 **** this.generationNumberForGeneticOptimizer , this.genomeManager , ! this.seedForRandomGenerator ); this.geneticOptimizer.NewGeneration += new NewGenerationEventHandler( this.newGenerationEventHandler ); --- 233,237 ---- this.generationNumberForGeneticOptimizer , this.genomeManager , ! this.seedForRandomGeneratorForTheGeneticOptimizer ); this.geneticOptimizer.NewGeneration += new NewGenerationEventHandler( this.newGenerationEventHandler ); *************** *** 244,248 **** /// <param name="eligibleTickers"></param> /// <returns></returns> ! public object AnalyzeInSample( EligibleTickers eligibleTickers , ReturnsManager returnsManager ) --- 246,250 ---- /// <param name="eligibleTickers"></param> /// <returns></returns> ! public virtual object AnalyzeInSample( EligibleTickers eligibleTickers , ReturnsManager returnsManager ) |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:18:11
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv20549/a2_Strategies Modified Files: EndOfDayStrategyBackTester.cs Log Message: A new feature has been added, to allow the user to force the script to complete and produce a report, without having to wait for the conditions written in the code. The user can to request an immediate completion of the script, by creating a file with name stop.txt in the folder where the .exe file is launched. Index: EndOfDayStrategyBackTester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/EndOfDayStrategyBackTester.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** EndOfDayStrategyBackTester.cs 24 Nov 2008 21:03:42 -0000 1.15 --- EndOfDayStrategyBackTester.cs 28 Mar 2010 14:18:03 -0000 1.16 *************** *** 22,25 **** --- 22,26 ---- using System; + using System.IO; using QuantProject.ADT; *************** *** 233,236 **** --- 234,251 ---- #region Run + + private void checkIfAFileStopTxtIsAlreadyInTheExecutionFolder() + { + bool isAFileStopTxtIsInTheExecutionFolder = + this.checkIfAFileStopTxtIsInTheExecutionFolder(); + if ( isAFileStopTxtIsInTheExecutionFolder ) + throw new Exception( + "The backtester has been asket to run, but a file stop.txt is " + + "in the execution folder. A file stop.txt should be put " + + "in the execution folder when the user wants to stop the " + + "backtest. Such a file should not be in the execution " + + "folder when the backtest begins." ); + } + #region run_addEventHandlers private void handlerToAddCashToStart( *************** *** 312,315 **** --- 327,331 ---- public void Run() { + this.checkIfAFileStopTxtIsAlreadyInTheExecutionFolder(); this.startingTimeForScript = DateTime.Now; *************** *** 328,331 **** --- 344,363 ---- #region isTimeToStop + + #region checkIfAFileStopTxtIsInTheExecutionFolder + private string getFullPathFileName() + { + string currentDirectory = Environment.CurrentDirectory; + string fullPathFileName = currentDirectory + "\\stop.txt"; + return fullPathFileName; + } + private bool checkIfAFileStopTxtIsInTheExecutionFolder() + { + string fullPathFileName = this.getFullPathFileName(); + bool isFileStopTxtInTheExecutionFolder = File.Exists( fullPathFileName ); + return isFileStopTxtInTheExecutionFolder; + } + #endregion checkIfAFileStopTxtIsInTheExecutionFolder + private bool getIsMaxScriptRealTimeElapsed() { *************** *** 338,341 **** --- 370,375 ---- private bool isTimeToStop( DateTime currentTime ) { + bool isFileStopTxtInTheExecutionFolder = + this.checkIfAFileStopTxtIsInTheExecutionFolder(); bool isMaxScriptRealTimeElapsed = this.getIsMaxScriptRealTimeElapsed(); *************** *** 345,348 **** --- 379,383 ---- return ( ( currentTime > this.lastDateTime ) || + isFileStopTxtInTheExecutionFolder || ( isMaxScriptRealTimeElapsed && stopBacktestIfMaxRunningHoursHasBeenReached ) || |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:12:44
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv19086/a2_Strategies/Eligibles Modified Files: EligibleTickers.cs Log Message: A new constructor EligibleTickers( ICollection<string> tickers ) has been added A new public method AddAdditionalEligibles( EligibleTickers eligibileTickers ) has been added Index: EligibleTickers.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles/EligibleTickers.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EligibleTickers.cs 29 Sep 2008 21:16:18 -0000 1.3 --- EligibleTickers.cs 28 Mar 2010 14:12:36 -0000 1.4 *************** *** 22,25 **** --- 22,26 ---- using System; + using System.Collections.Generic; using System.Data; *************** *** 47,50 **** --- 48,57 ---- } + public EligibleTickers( ICollection<string> tickers ) + { + foreach( string ticker in tickers ) + this.List.Add( ticker ); + } + /// <summary> /// *************** *** 93,96 **** --- 100,109 ---- } } + + public void AddAdditionalEligibles( EligibleTickers eligibileTickers ) + { + foreach ( string ticker in eligibileTickers.Tickers ) + this.addTicker_actually( ticker ); + } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:11:52
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv18844/a2_Strategies/Eligibles Modified Files: ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs Log Message: The code has been reformatted, and it now follows "standard" indentation Index: ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Eligibles/ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs 29 Sep 2008 21:14:49 -0000 1.3 --- ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.cs 28 Mar 2010 14:11:44 -0000 1.4 *************** *** 19,23 **** 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; --- 19,23 ---- 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; *************** *** 42,52 **** /// -step 2: from tickers selected by step 1, the most liquid /// are selected (not more than maxNumberOfMostLiquidTickersToBeChosen); ! /// -step 3: from tickers selected by step 2, the ones that are /// less volatile (OTC returns in the last /// numOfDaysForVolatilityComputation days ! /// are analyzed) are selected /// (not more than maxNumberOfEligibleTickersToBeChosen); /// -step 4: from tickers selected by step 3, the ones that are ! /// always quoted at all market days are selected /// (not more than maxNumberOfEligibleTickersToBeChosen); /// </summary> --- 42,52 ---- /// -step 2: from tickers selected by step 1, the most liquid /// are selected (not more than maxNumberOfMostLiquidTickersToBeChosen); ! /// -step 3: from tickers selected by step 2, the ones that are /// less volatile (OTC returns in the last /// numOfDaysForVolatilityComputation days ! /// are analyzed) are selected /// (not more than maxNumberOfEligibleTickersToBeChosen); /// -step 4: from tickers selected by step 3, the ones that are ! /// always quoted at all market days are selected /// (not more than maxNumberOfEligibleTickersToBeChosen); /// </summary> *************** *** 74,78 **** private void byPriceMostLiquidLessVolatileOTCAlwaysQuoted_checkParameters() { ! if(this.maxNumberOfMostLiquidTickersToBeChosen <= this.maxNumberOfEligibleTickersToBeChosen) throw new Exception("The set of the most liquid tickers has to " + --- 74,78 ---- private void byPriceMostLiquidLessVolatileOTCAlwaysQuoted_checkParameters() { ! if(this.maxNumberOfMostLiquidTickersToBeChosen <= this.maxNumberOfEligibleTickersToBeChosen) throw new Exception("The set of the most liquid tickers has to " + *************** *** 81,90 **** public ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( ! string tickersGroupID , bool temporizedGroup, int maxNumberOfEligibleTickersToBeChosen, int maxNumberOfMostLiquidTickersToBeChosen, ! int numOfDaysForAverageOpenRawPriceComputation, int numOfDaysForVolatilityComputation, ! double minPrice, double maxPrice) { this.temporizedGroup = temporizedGroup; --- 81,90 ---- public ByPriceMostLiquidLessVolatileOTCAlwaysQuoted( ! string tickersGroupID , bool temporizedGroup, int maxNumberOfEligibleTickersToBeChosen, int maxNumberOfMostLiquidTickersToBeChosen, ! int numOfDaysForAverageOpenRawPriceComputation, int numOfDaysForVolatilityComputation, ! double minPrice, double maxPrice) { this.temporizedGroup = temporizedGroup; *************** *** 92,100 **** this.maxNumberOfEligibleTickersToBeChosen = maxNumberOfEligibleTickersToBeChosen; ! this.maxNumberOfMostLiquidTickersToBeChosen = maxNumberOfMostLiquidTickersToBeChosen; this.numOfDaysForAverageOpenRawPriceComputation = numOfDaysForAverageOpenRawPriceComputation; ! this.numOfDaysForVolatilityComputation = numOfDaysForVolatilityComputation; this.minPrice = minPrice; --- 92,100 ---- this.maxNumberOfEligibleTickersToBeChosen = maxNumberOfEligibleTickersToBeChosen; ! this.maxNumberOfMostLiquidTickersToBeChosen = maxNumberOfMostLiquidTickersToBeChosen; this.numOfDaysForAverageOpenRawPriceComputation = numOfDaysForAverageOpenRawPriceComputation; ! this.numOfDaysForVolatilityComputation = numOfDaysForVolatilityComputation; this.minPrice = minPrice; *************** *** 106,144 **** History history ) { ! DateTime currentDate = history.LastDateTime; SelectorByGroup group; if(this.temporizedGroup) ! //the group is "temporized": returned set of tickers ! // depends on time group = new SelectorByGroup(this.tickersGroupID, currentDate); ! else//the group is not temporized ! group = new SelectorByGroup(this.tickersGroupID); ! DataTable tickersFromGroup = group.GetTableOfSelectedTickers(); ! int numOfTickersInGroupAtCurrentDate = tickersFromGroup.Rows.Count; ! SelectorByAverageRawOpenPrice byPrice = ! new SelectorByAverageRawOpenPrice(tickersFromGroup,false, ! currentDate.AddDays(-this.numOfDaysForAverageOpenRawPriceComputation), ! currentDate, ! numOfTickersInGroupAtCurrentDate, ! this.minPrice,this.maxPrice, 0.00001, double.MaxValue); ! DataTable dataTableByPrice = byPrice.GetTableOfSelectedTickers(); SelectorByLiquidity mostLiquidSelector = new SelectorByLiquidity( dataTableByPrice , ! false, history.FirstDateTime, currentDate, ! this.maxNumberOfMostLiquidTickersToBeChosen); ! DataTable dataTableMostLiquid = mostLiquidSelector.GetTableOfSelectedTickers(); ! SelectorByOpenToCloseVolatility lessVolatileSelector = new SelectorByOpenToCloseVolatility( dataTableMostLiquid , ! true, currentDate.AddDays(-this.numOfDaysForVolatilityComputation), currentDate, ! this.maxNumberOfEligibleTickersToBeChosen); ! ! DataTable dataTableLessVolatile = lessVolatileSelector.GetTableOfSelectedTickers(); // DataSet dataSet = new DataSet(); --- 106,144 ---- History history ) { ! DateTime currentDate = history.LastDateTime; SelectorByGroup group; if(this.temporizedGroup) ! //the group is "temporized": returned set of tickers ! // depends on time group = new SelectorByGroup(this.tickersGroupID, currentDate); ! else//the group is not temporized ! group = new SelectorByGroup(this.tickersGroupID); ! DataTable tickersFromGroup = group.GetTableOfSelectedTickers(); ! int numOfTickersInGroupAtCurrentDate = tickersFromGroup.Rows.Count; ! SelectorByAverageRawOpenPrice byPrice = ! new SelectorByAverageRawOpenPrice(tickersFromGroup,false, ! currentDate.AddDays(-this.numOfDaysForAverageOpenRawPriceComputation), ! currentDate, ! numOfTickersInGroupAtCurrentDate, ! this.minPrice,this.maxPrice, 0.00001, double.MaxValue); ! DataTable dataTableByPrice = byPrice.GetTableOfSelectedTickers(); SelectorByLiquidity mostLiquidSelector = new SelectorByLiquidity( dataTableByPrice , ! false, history.FirstDateTime, currentDate, ! this.maxNumberOfMostLiquidTickersToBeChosen); ! DataTable dataTableMostLiquid = mostLiquidSelector.GetTableOfSelectedTickers(); ! SelectorByOpenToCloseVolatility lessVolatileSelector = new SelectorByOpenToCloseVolatility( dataTableMostLiquid , ! true, currentDate.AddDays(-this.numOfDaysForVolatilityComputation), currentDate, ! this.maxNumberOfEligibleTickersToBeChosen); ! ! DataTable dataTableLessVolatile = lessVolatileSelector.GetTableOfSelectedTickers(); // DataSet dataSet = new DataSet(); *************** *** 146,157 **** // dataSet.WriteXml( "c:\\qpReports\\pairsTrading\\eligiblesCon_ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.xml" ); ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromLastSelection = ! new SelectorByQuotationAtEachMarketDay( dataTableLessVolatile , ! false, history, ! this.maxNumberOfEligibleTickersToBeChosen); ! DataTable dataTableToBeReturned = quotedAtEachMarketDayFromLastSelection.GetTableOfSelectedTickers(); ! return new EligibleTickers( dataTableToBeReturned ); } --- 146,157 ---- // dataSet.WriteXml( "c:\\qpReports\\pairsTrading\\eligiblesCon_ByPriceMostLiquidLessVolatileOTCAlwaysQuoted.xml" ); ! SelectorByQuotationAtEachMarketDay quotedAtEachMarketDayFromLastSelection = ! new SelectorByQuotationAtEachMarketDay( dataTableLessVolatile , ! false, history, ! this.maxNumberOfEligibleTickersToBeChosen); ! DataTable dataTableToBeReturned = quotedAtEachMarketDayFromLastSelection.GetTableOfSelectedTickers(); ! return new EligibleTickers( dataTableToBeReturned ); } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:10:15
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv18449/a2_Strategies Modified Files: Benchmark.cs Log Message: The following public method has been added: DateTime GetThisOrNextDateTimeWhenTraded( DateTime startingDateTime , Time dailyTime , DateTime lastAcceptableDateTime ) Starting from startingDateTime, this method searches for the next dateTime when the benchmark is traded at time dailyTime. The returned value is greater than or equal to startingDateTime, that is, startingDateTime itself is a valid candidate. If no solution is found within maxNumberOfDaysToLookAheadFor days, then an exception is returned Index: Benchmark.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Benchmark.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Benchmark.cs 29 Sep 2008 21:14:23 -0000 1.4 --- Benchmark.cs 28 Mar 2010 14:10:07 -0000 1.5 *************** *** 3,6 **** --- 3,7 ---- using QuantProject.ADT; using QuantProject.ADT.Histories; + using QuantProject.ADT.Timing; using QuantProject.Business.DataProviders; using QuantProject.Business.Strategies.ReturnsManagement.Time; *************** *** 17,21 **** { private string ticker; ! private HistoricalMarketValueProvider historicalQuoteProvider; public string Ticker --- 18,22 ---- { private string ticker; ! private HistoricalMarketValueProvider historicalMarketValueProvider; public string Ticker *************** *** 28,32 **** this.ticker = ticker; ! this.historicalQuoteProvider = new HistoricalAdjustedQuoteProvider(); } --- 29,41 ---- this.ticker = ticker; ! this.historicalMarketValueProvider = new HistoricalAdjustedQuoteProvider(); ! } ! ! public Benchmark( ! string ticker , HistoricalMarketValueProvider historicalMarketValueProvider ) ! { ! this.ticker = ticker; ! ! this.historicalMarketValueProvider = historicalMarketValueProvider; } *************** *** 35,43 **** DateTime timeStepBegin ) { ! if ( !this.historicalQuoteProvider.WasExchanged( this.ticker , ! timeStepBegin ) ) throw new Exception( "The benchmark '" + this.ticker + ! "' was not exchanged at the given timeStepBegin " + ! timeStepBegin.ToString() ); } private void isExchanged_checkParameter( --- 44,52 ---- DateTime timeStepBegin ) { ! if ( !this.historicalMarketValueProvider.WasExchanged( this.ticker , ! timeStepBegin ) ) throw new Exception( "The benchmark '" + this.ticker + ! "' was not exchanged at the given timeStepBegin " + ! timeStepBegin.ToString() ); } private void isExchanged_checkParameter( *************** *** 45,58 **** { if ( dateTime.Year > ! DateTime.Now.Year ) throw new Exception( "It looks like this is a loop! " + ! "You have probably asked for a GetTimeStep, but " + ! "there is no other trading day for this benchmark: '" + ! this.ticker + "'" ); } private bool isExchanged( DateTime dateTime ) { this.isExchanged_checkParameter( dateTime ); ! bool isTraded = this.historicalQuoteProvider.WasExchanged( this.ticker , dateTime ); return isTraded; --- 54,67 ---- { if ( dateTime.Year > ! DateTime.Now.Year ) throw new Exception( "It looks like this is a loop! " + ! "You have probably asked for a GetTimeStep, but " + ! "there is no other trading day for this benchmark: '" + ! this.ticker + "'" ); } private bool isExchanged( DateTime dateTime ) { this.isExchanged_checkParameter( dateTime ); ! bool isTraded = this.historicalMarketValueProvider.WasExchanged( this.ticker , dateTime ); return isTraded; *************** *** 89,93 **** /// <summary> /// Returns either the next market close or the next market open ! /// (when the benchmark is exchanged), whichever is the nearest. /// If dateTime is either a market close or a market open /// when the benchmark is exchanged, then dateTime itself --- 98,102 ---- /// <summary> /// Returns either the next market close or the next market open ! /// (when the benchmark is exchanged), whichever is the nearest. /// If dateTime is either a market close or a market open /// when the benchmark is exchanged, then dateTime itself *************** *** 122,126 **** if( lastDateTime <= firstDateTime ) throw new Exception("lastDateTime has to be greater than " + ! "firstEndOfDayDateTime !!"); History endOfDayHistory = new History(); DateTime dateTimeToAddToHistory = --- 131,135 ---- if( lastDateTime <= firstDateTime ) throw new Exception("lastDateTime has to be greater than " + ! "firstEndOfDayDateTime !!"); History endOfDayHistory = new History(); DateTime dateTimeToAddToHistory = *************** *** 140,143 **** --- 149,219 ---- } + #region GetThisOrNextDateTimeWhenTraded + private DateTime getDateTimeCandidate( + DateTime minDateTimeToTry , Time dailyTime ) + { + Date dateUsedToBuildDateTimeCandidate = new Date( minDateTimeToTry ); + Time timeForMinDateTimeToTry = new Time( minDateTimeToTry ); + if ( timeForMinDateTimeToTry > dailyTime ) + dateUsedToBuildDateTimeCandidate = + dateUsedToBuildDateTimeCandidate.AddDays( 1 ); + DateTime dateTimeCandidate = new DateTime( + dateUsedToBuildDateTimeCandidate.Year , + dateUsedToBuildDateTimeCandidate.Month , + dateUsedToBuildDateTimeCandidate.Day , + dailyTime.Hour , + dailyTime.Minute , + dailyTime.Second ); + return dateTimeCandidate; + } + // private bool isCandidateTooFarAhead( + // DateTime startingDateTime , DateTime dateTimeCandidate , + // int maxNumberOfDaysToLookAheadFor ) + // { + // bool isTooFarAhead; + // TimeSpan timeSpan = dateTimeCandidate.Subtract( startingDateTime ); + // isTooFarAhead = ( timeSpan.Days > maxNumberOfDaysToLookAheadFor ); + // return isTooFarAhead; + // } + /// <summary> + /// Starting from startingDateTime, this method searches for the next + /// dateTime when the benchmark is traded at time dailyTime. + /// The returned value is greater than or equal to startingDateTime, + /// that is, startingDateTime itself is a valid candidate. + /// If no solution is found within maxNumberOfDaysToLookAheadFor days, + /// then an exception is returned + /// </summary> + /// <param name="startingDateTime"></param> + /// <param name="dailyTime"></param> + /// <param name="maxNumberOfDaysToLookAheadFor"></param> + /// <returns></returns> + public virtual DateTime GetThisOrNextDateTimeWhenTraded( + DateTime startingDateTime , + Time dailyTime , + DateTime lastAcceptableDateTime ) + { + DateTime dateTimeCandidate = this.getDateTimeCandidate( + startingDateTime , dailyTime ); + DateTime thisOrNextDateTimeWhenTraded = DateTime.MinValue; + while ( dateTimeCandidate <= lastAcceptableDateTime && + // !this.isCandidateTooFarAhead( + // startingDateTime , dateTimeCandidate , maxNumberOfDaysToLookAheadFor ) && + ( thisOrNextDateTimeWhenTraded == DateTime.MinValue ) ) + { + // a valid dateTime when traded has not been found yet + if ( this.isExchanged( dateTimeCandidate ) ) + thisOrNextDateTimeWhenTraded = dateTimeCandidate; + else + dateTimeCandidate = this.getDateTimeCandidate( + dateTimeCandidate.AddSeconds( 1 ) , dailyTime ); + } + if ( thisOrNextDateTimeWhenTraded == DateTime.MinValue ) + throw new Exception( + "In the specified number of days, the benchmark is never " + + "traded at the specified dailyTime!" ); + return thisOrNextDateTimeWhenTraded; + } + #endregion GetThisOrNextDateTimeWhenTraded + } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 14:07:32
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv17549/a2_Strategies Modified Files: BasicStrategyForBacktester.cs Log Message: A new protected member outOfSampleReturnIntervals has been added. Out of sample return intervals are updated whenever NewDateTimeEventHandler starts executing. An virtual implementation of arePositionsToBeOpened() is now given. Index: BasicStrategyForBacktester.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/BasicStrategyForBacktester.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BasicStrategyForBacktester.cs 10 Dec 2008 19:29:27 -0000 1.4 --- BasicStrategyForBacktester.cs 28 Mar 2010 14:07:24 -0000 1.5 *************** *** 51,55 **** protected int numDaysForInSampleOptimization; protected IIntervalsSelector intervalsSelectorForInSample; ! // protected IIntervalsSelector intervalsSelectorForOutOfSample; protected IEligiblesSelector eligiblesSelector; protected IInSampleChooser inSampleChooser; --- 51,55 ---- protected int numDaysForInSampleOptimization; protected IIntervalsSelector intervalsSelectorForInSample; ! protected IIntervalsSelector intervalsSelectorForOutOfSample; protected IEligiblesSelector eligiblesSelector; protected IInSampleChooser inSampleChooser; *************** *** 57,60 **** --- 57,61 ---- protected DateTime lastOptimizationDateTime; + protected ReturnIntervals outOfSampleReturnIntervals; private Account account; *************** *** 124,128 **** int numDaysForInSampleOptimization , IIntervalsSelector intervalsSelectorForInSample , ! // IIntervalsSelector intervalsSelectorForOutOfSample , IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , --- 125,129 ---- int numDaysForInSampleOptimization , IIntervalsSelector intervalsSelectorForInSample , ! IIntervalsSelector intervalsSelectorForOutOfSample , IEligiblesSelector eligiblesSelector , IInSampleChooser inSampleChooser , *************** *** 133,137 **** this.numDaysForInSampleOptimization = numDaysForInSampleOptimization; this.intervalsSelectorForInSample = intervalsSelectorForInSample; ! // this.intervalsSelectorForOutOfSample = intervalsSelectorForOutOfSample; this.eligiblesSelector = eligiblesSelector; this.inSampleChooser = inSampleChooser; --- 134,138 ---- this.numDaysForInSampleOptimization = numDaysForInSampleOptimization; this.intervalsSelectorForInSample = intervalsSelectorForInSample; ! this.intervalsSelectorForOutOfSample = intervalsSelectorForOutOfSample; this.eligiblesSelector = eligiblesSelector; this.inSampleChooser = inSampleChooser; *************** *** 139,148 **** historicalMarketValueProviderForInSample; ! // this.returnIntervals = ! // new ReturnIntervals( this.intervalsSelectorForOutOfSample ); } #region NewDateTimeEventHandler #region updateOptimalTestingPositions --- 140,163 ---- historicalMarketValueProviderForInSample; ! this.outOfSampleReturnIntervals = ! new ReturnIntervals( this.intervalsSelectorForOutOfSample ); } #region NewDateTimeEventHandler + private void updateReturnIntervals() + { + DateTime currentDateTime = this.now(); + if ( this.outOfSampleReturnIntervals.Count == 0 ) + // no interval has been added yet + this.outOfSampleReturnIntervals.AppendFirstInterval( + currentDateTime ); + else + // at least one interval has already been added + if ( this.outOfSampleReturnIntervals.LastDateTime <= currentDateTime ) + this.outOfSampleReturnIntervals.AppendIntervalsToGoJustBeyond( + currentDateTime ); + } + #region updateOptimalTestingPositions *************** *** 241,255 **** protected abstract bool arePositionsToBeClosed(); ! protected abstract bool arePositionsToBeOpened(); protected abstract WeightedPositions getPositionsToBeOpened(); public void NewDateTimeEventHandler( Object sender , DateTime dateTime ) { if ( this.areOptimalWeightedPositionsToBeUpdated() ) this.updateOptimalTestingPositions(); - if ( ( dateTime.Month == 3 ) && ( dateTime.Day == 15 ) ) - { - ; - } if ( this.arePositionsToBeClosed() ) AccountManager.ClosePositions( this.account ); --- 256,285 ---- protected abstract bool arePositionsToBeClosed(); ! ! #region arePositionsToBeOpened ! protected ReturnInterval lastIntervalAppended() ! { ! ReturnInterval lastInterval = ! this.outOfSampleReturnIntervals[ this.outOfSampleReturnIntervals.Count - 1 ]; ! return lastInterval; ! } ! protected virtual bool arePositionsToBeOpened() ! { ! bool beginsTheLastInterval = ! ( this.now() == ! this.lastIntervalAppended().Begin ); ! bool areToBeOpened = ! ( beginsTheLastInterval && this.bestTestingPositionsInSample != null ); ! return ( beginsTheLastInterval ); ! } ! #endregion arePositionsToBeOpened ! protected abstract WeightedPositions getPositionsToBeOpened(); public void NewDateTimeEventHandler( Object sender , DateTime dateTime ) { + this.updateReturnIntervals(); if ( this.areOptimalWeightedPositionsToBeUpdated() ) this.updateOptimalTestingPositions(); if ( this.arePositionsToBeClosed() ) AccountManager.ClosePositions( this.account ); |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:51:03
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/GenomeManagers In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv12214/a2_Strategies/Optimizing/GenomeManagers Modified Files: BasicGenomeManager.cs Log Message: IReturnsManager is now used, instead of ReturnsManager Index: BasicGenomeManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/GenomeManagers/BasicGenomeManager.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BasicGenomeManager.cs 30 Aug 2009 15:42:32 -0000 1.3 --- BasicGenomeManager.cs 28 Mar 2010 13:50:55 -0000 1.4 *************** *** 44,48 **** protected GenomeManagerType genomeManagerType; protected EligibleTickers eligibleTickers; ! protected ReturnsManager returnsManager; protected IDecoderForTestingPositions decoderForTestingPositions; protected IFitnessEvaluator fitnessEvaluator; --- 44,48 ---- protected GenomeManagerType genomeManagerType; protected EligibleTickers eligibleTickers; ! protected IReturnsManager returnsManager; protected IDecoderForTestingPositions decoderForTestingPositions; protected IFitnessEvaluator fitnessEvaluator; *************** *** 66,70 **** IFitnessEvaluator fitnessEvaluator, GenomeManagerType genomeManagerType, ! ReturnsManager returnsManager , int seedForRandomGenerator ) --- 66,70 ---- IFitnessEvaluator fitnessEvaluator, GenomeManagerType genomeManagerType, ! IReturnsManager returnsManager , int seedForRandomGenerator ) |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:50:47
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/Decoding In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv12116/a2_Strategies/Optimizing/Decoding Modified Files: BasicDecoderForTestingPositions.cs Log Message: IReturnsManager is now used, instead of ReturnsManager Index: BasicDecoderForTestingPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/Optimizing/Decoding/BasicDecoderForTestingPositions.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** BasicDecoderForTestingPositions.cs 30 Aug 2009 15:46:50 -0000 1.9 --- BasicDecoderForTestingPositions.cs 28 Mar 2010 13:50:39 -0000 1.10 *************** *** 44,48 **** protected int[] encoded; protected EligibleTickers eligibleTickers; ! protected ReturnsManager returnsManager; /// <summary> --- 44,48 ---- protected int[] encoded; protected EligibleTickers eligibleTickers; ! protected IReturnsManager returnsManager; /// <summary> *************** *** 122,126 **** protected virtual TestingPositions getMeaningForUndecodable() { ! return new TestingPositions(); } --- 122,126 ---- protected virtual TestingPositions getMeaningForUndecodable() { ! return new TestingPositionsForUndecodableEncoded(); } *************** *** 201,205 **** private void decode_updateProtectedMembers(int[] encoded , EligibleTickers eligibleTickers , ! ReturnsManager returnsManager) { this.encoded = encoded; --- 201,205 ---- private void decode_updateProtectedMembers(int[] encoded , EligibleTickers eligibleTickers , ! IReturnsManager returnsManager) { this.encoded = encoded; *************** *** 218,222 **** /// <returns></returns> public TestingPositions Decode(int[] encoded , EligibleTickers eligibleTickers , ! ReturnsManager returnsManager) { this.decode_updateProtectedMembers(encoded , eligibleTickers , --- 218,222 ---- /// <returns></returns> public TestingPositions Decode(int[] encoded , EligibleTickers eligibleTickers , ! IReturnsManager returnsManager) { this.decode_updateProtectedMembers(encoded , eligibleTickers , |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:50:16
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/StatisticsSummaryRows In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv11959/a1_Financial/a2_Accounting/h5_Reporting/StatisticsSummaryRows Modified Files: AverageReturnOnDayOfWeekWithOpenPositions.cs Log Message: A little bug has been fixed, that came up when a return value next to zero was computed, and then the result was presented in exponential notation. In such cases, the first four digits of the mantissa where shown, then actully displaying a large (wrong) percentage return. Index: AverageReturnOnDayOfWeekWithOpenPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/StatisticsSummaryRows/AverageReturnOnDayOfWeekWithOpenPositions.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AverageReturnOnDayOfWeekWithOpenPositions.cs 29 Sep 2008 21:13:46 -0000 1.4 --- AverageReturnOnDayOfWeekWithOpenPositions.cs 28 Mar 2010 13:50:07 -0000 1.5 *************** *** 79,86 **** averagePercentageReturn = 100.0 * sumOfReturnsOnSpecificDayOfWeek / (double)totalNumberOfSpecificDayOfWeek; string numOfDays = totalNumberOfSpecificDayOfWeek.ToString(); ! return averagePercentageReturn.ToString().Substring(0,4) + ! "#" + ! numOfDays.Substring(0,Math.Min(numOfDays.Length,4)); } --- 79,95 ---- averagePercentageReturn = 100.0 * sumOfReturnsOnSpecificDayOfWeek / (double)totalNumberOfSpecificDayOfWeek; + averagePercentageReturn = Math.Round( averagePercentageReturn , 3 ); string numOfDays = totalNumberOfSpecificDayOfWeek.ToString(); ! ! string rowValue = averagePercentageReturn.ToString(); ! int digits = Math.Min( 4 , rowValue.Length ); ! rowValue = rowValue.Substring(0, digits ); ! rowValue += "#" + numOfDays.Substring(0,Math.Min(numOfDays.Length,4)); ! ! return rowValue; ! ! // return averagePercentageReturn.ToString().Substring(0,4) + ! // "#" + ! // numOfDays.Substring(0,Math.Min(numOfDays.Length,4)); } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:45:30
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv10401/a1_Financial/a2_Accounting/h5_Reporting Modified Files: AccountReport.cs Log Message: Old commented out code has been removed Index: AccountReport.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a1_Financial/a2_Accounting/h5_Reporting/AccountReport.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** AccountReport.cs 10 Dec 2008 19:27:19 -0000 1.24 --- AccountReport.cs 28 Mar 2010 13:45:21 -0000 1.25 *************** *** 47,50 **** --- 47,51 ---- { private Account account; + private HistoricalMarketValueProvider historicalMarketValueProvider; private IDateTimeSelectorForEquityLine dateTimeSelectorForEquityLine; *************** *** 382,392 **** this.setDetailedDataTable( numDaysForInterval ); this.transactionTable = new Tables.Transactions( reportName , detailedDataTable ); - // this.transactionTable = getTransactionTable( reportName , detailedDataTable ); this.roundTrades = new Tables.RoundTrades( reportName , this.transactionTable ); this.equity = new Tables.Equity( reportName , detailedDataTable ); if ( benchmark != "" ) this.setBenchmarkEquityLine(); - //this.equity = getEquity( reportName , detailedDataTable ); - //this.summary = getSummary( reportName ); this.summary = new Tables.Summary( this , historicalMarketValueProvider ); this.statisticsSummary = new Tables.StatisticsSummary( this, historicalMarketValueProvider ); --- 383,390 ---- |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:43:38
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv9972/a2_Strategies Modified Files: AccountManager.cs Log Message: Some small changes have been done because WeightedPositions now is a List<WeightedPosition>, while it was a SortedList in the previous version Index: AccountManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/AccountManager.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AccountManager.cs 30 Aug 2009 15:42:18 -0000 1.8 --- AccountManager.cs 28 Mar 2010 13:43:27 -0000 1.9 *************** *** 115,119 **** orders.Clear(); double valueToInvestInPositions = account.CashAmount * leverage; ! foreach(WeightedPosition weightedPosition in weightedPositions.Values) addWeightedPositionToOrderList( weightedPosition, account, valueToInvestInPositions ); foreach(object item in orders) --- 115,119 ---- orders.Clear(); double valueToInvestInPositions = account.CashAmount * leverage; ! foreach(WeightedPosition weightedPosition in weightedPositions) addWeightedPositionToOrderList( weightedPosition, account, valueToInvestInPositions ); foreach(object item in orders) *************** *** 162,166 **** orders.Clear(); WeightedPositions currentWeightedPositions = GetWeightedPositions( account ); ! currentWeightedPositions.Reverse(); ClosePositions(account); OpenPositions( currentWeightedPositions, account ); --- 162,166 ---- orders.Clear(); WeightedPositions currentWeightedPositions = GetWeightedPositions( account ); ! currentWeightedPositions.ReverseSigns(); ClosePositions(account); OpenPositions( currentWeightedPositions, account ); |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:41:58
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv9657/a2_Strategies Modified Files: WeightedPositions.cs Log Message: The name for the method Reverse() has now been changed by ReverseSigns(), because List<T> already has a method Reverse() Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/WeightedPositions.cs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** WeightedPositions.cs 28 Mar 2010 13:38:31 -0000 1.16 --- WeightedPositions.cs 28 Mar 2010 13:41:50 -0000 1.17 *************** *** 796,800 **** /// long positions become then short positions and viceversa /// </summary> ! public void ReverseSign() { foreach( WeightedPosition weightedPosition in this ) --- 796,800 ---- /// long positions become then short positions and viceversa /// </summary> ! public void ReverseSigns() { foreach( WeightedPosition weightedPosition in this ) |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:38:41
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv9087/a2_Strategies Modified Files: WeightedPositions.cs Log Message: This class, previously inherited a SortedList. Now it inherits List<WeightedPosition>. Now there is a "deterministic" mapping between genomes and weighted positions. Furthermore, now this class implements IReturnsCalculator (this helps with unit testing and mocking) Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/WeightedPositions.cs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** WeightedPositions.cs 29 Sep 2008 21:17:57 -0000 1.15 --- WeightedPositions.cs 28 Mar 2010 13:38:31 -0000 1.16 *************** *** 3,7 **** WeightedPositions.cs ! Copyright (C) 2003 Glauco Siliprandi --- 3,7 ---- WeightedPositions.cs ! Copyright (C) 2003 Glauco Siliprandi *************** *** 19,26 **** 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.Statistics; --- 19,27 ---- 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 System.Collections.Generic; using QuantProject.ADT.Statistics; *************** *** 40,44 **** /// checked to sum up to 1. /// </summary> ! public class WeightedPositions : SortedList { /// <summary> --- 41,45 ---- /// checked to sum up to 1. /// </summary> ! public class WeightedPositions : List<WeightedPosition> , IReturnsCalculator { /// <summary> *************** *** 61,70 **** get { if(this.numberOfLongPositions == int.MaxValue) ! //that is private field has not been assigned yet { this.numberOfLongPositions = 0; ! foreach(WeightedPosition weightedPosition in this.Values) if(weightedPosition.IsLong) ! this.numberOfLongPositions++; } return this.numberOfLongPositions; --- 62,71 ---- get { if(this.numberOfLongPositions == int.MaxValue) ! //that is private field has not been assigned yet { this.numberOfLongPositions = 0; ! foreach(WeightedPosition weightedPosition in this) if(weightedPosition.IsLong) ! this.numberOfLongPositions++; } return this.numberOfLongPositions; *************** *** 75,84 **** get { if(this.numberOfShortPositions == int.MaxValue) ! //that is private field has not been assigned yet { this.numberOfShortPositions = 0; ! foreach(WeightedPosition weightedPosition in this.Values) if(weightedPosition.IsShort) ! this.numberOfShortPositions++; } return this.numberOfShortPositions; --- 76,85 ---- get { if(this.numberOfShortPositions == int.MaxValue) ! //that is private field has not been assigned yet { this.numberOfShortPositions = 0; ! foreach(WeightedPosition weightedPosition in this) if(weightedPosition.IsShort) ! this.numberOfShortPositions++; } return this.numberOfShortPositions; *************** *** 107,111 **** string[] tickers = {"DUMMY"}; WeightedPositions testInstance = new WeightedPositions( weights , tickers ); ! return testInstance; } } --- 108,112 ---- string[] tickers = {"DUMMY"}; WeightedPositions testInstance = new WeightedPositions( weights , tickers ); ! return testInstance; } } *************** *** 142,146 **** private void weightedPositions_default( double[] normalizedWeightValues , ! string[] tickers ) { this.checkParameters( normalizedWeightValues , tickers ); --- 143,147 ---- private void weightedPositions_default( double[] normalizedWeightValues , ! string[] tickers ) { this.checkParameters( normalizedWeightValues , tickers ); *************** *** 149,178 **** string ticker = tickers[ i ]; double weight = normalizedWeightValues[ i ]; ! if ( !this.ContainsKey( ticker ) ) ! this.Add( ticker , new WeightedPosition( weight , ticker ) ); } } public WeightedPositions( double[] normalizedWeightValues , ! string[] tickers ) { this.weightedPositions_default( normalizedWeightValues, ! tickers ); } public WeightedPositions( double[] normalizedUnsignedWeightValues, ! SignedTickers signedTickers ) { string[] unsignedTickers = new string [ signedTickers.Count ]; ! double[] normalizedSignedWeightValues = new double[ normalizedUnsignedWeightValues.Length ]; for(int i = 0; i < signedTickers.Count; i++) { unsignedTickers[i] = signedTickers[i].Ticker; ! normalizedSignedWeightValues[i] = ! signedTickers[i].Multiplier * normalizedUnsignedWeightValues[i]; } this.weightedPositions_default(normalizedSignedWeightValues, ! unsignedTickers); } --- 150,180 ---- string ticker = tickers[ i ]; double weight = normalizedWeightValues[ i ]; ! this.Add( new WeightedPosition( weight , ticker ) ); ! // if ( !this.ContainsKey( ticker ) ) ! // this.Add( ticker , new WeightedPosition( weight , ticker ) ); } } public WeightedPositions( double[] normalizedWeightValues , ! string[] tickers ) { this.weightedPositions_default( normalizedWeightValues, ! tickers ); } public WeightedPositions( double[] normalizedUnsignedWeightValues, ! SignedTickers signedTickers ) { string[] unsignedTickers = new string [ signedTickers.Count ]; ! double[] normalizedSignedWeightValues = new double[ normalizedUnsignedWeightValues.Length ]; for(int i = 0; i < signedTickers.Count; i++) { unsignedTickers[i] = signedTickers[i].Ticker; ! normalizedSignedWeightValues[i] = ! signedTickers[i].Multiplier * normalizedUnsignedWeightValues[i]; } this.weightedPositions_default(normalizedSignedWeightValues, ! unsignedTickers); } *************** *** 184,197 **** { string[] unsignedTickers = new string [ signedTickers.Count ]; ! double[] allEqualSignedWeights = new double[ signedTickers.Count ]; for(int i = 0; i < signedTickers.Count; i++) { unsignedTickers[i] = signedTickers[i].Ticker; ! allEqualSignedWeights[i] = signedTickers[i].Multiplier / (double)signedTickers.Count; } this.weightedPositions_default( allEqualSignedWeights, ! unsignedTickers ); } --- 186,199 ---- { string[] unsignedTickers = new string [ signedTickers.Count ]; ! double[] allEqualSignedWeights = new double[ signedTickers.Count ]; for(int i = 0; i < signedTickers.Count; i++) { unsignedTickers[i] = signedTickers[i].Ticker; ! allEqualSignedWeights[i] = signedTickers[i].Multiplier / (double)signedTickers.Count; } this.weightedPositions_default( allEqualSignedWeights, ! unsignedTickers ); } *************** *** 202,246 **** foreach ( string ticker in tickers ) if ( !sortedTicker.ContainsKey( ticker ) ) ! sortedTicker.Add( ticker , ticker ); ! else ! throw new Exception( "The WeightedPositions constructur " + ! "has received a tickers parameter with the ticker '" + ! ticker + "' that is contained twice! This is not allowed." ); } private void checkParameters( double[] normalizedWeightValues , ! string[] tickers ) { if ( normalizedWeightValues.Length != tickers.Length ) throw new Exception( "The number of normalized weights is " + ! "different from the number of tickers. They should be the same " + ! "number!" ); double totalWeight = ADT.Statistics.BasicFunctions.SumOfAbs( normalizedWeightValues ); if ( ( totalWeight < 0.999 ) || ( totalWeight > 1.001 ) ) throw new Exception( "The total of (absolute) weights " + ! "should sum up to 1, " + ! "but it sums up to " + totalWeight.ToString() ); this.checkParameters_checkDoubleTickers( tickers ); } #endregion ! public WeightedPosition GetWeightedPosition( string ticker ) { ! return (WeightedPosition)this[ ticker ]; } ! public WeightedPosition GetWeightedPosition( int i ) { ! return (WeightedPosition)this.GetByIndex( i ); } ! public WeightedPosition this[ int index ] { ! get ! { ! return (WeightedPosition)this.GetByIndex( index ); ! } ! set ! { ! this.SetByIndex( index, value ); ! } } #region GetEquityLine --- 204,281 ---- foreach ( string ticker in tickers ) if ( !sortedTicker.ContainsKey( ticker ) ) ! sortedTicker.Add( ticker , ticker ); ! else ! throw new Exception( "The WeightedPositions constructur " + ! "has received a tickers parameter with the ticker '" + ! ticker + "' that is contained twice! This is not allowed." ); } private void checkParameters( double[] normalizedWeightValues , ! string[] tickers ) { if ( normalizedWeightValues.Length != tickers.Length ) throw new Exception( "The number of normalized weights is " + ! "different from the number of tickers. They should be the same " + ! "number!" ); double totalWeight = ADT.Statistics.BasicFunctions.SumOfAbs( normalizedWeightValues ); if ( ( totalWeight < 0.999 ) || ( totalWeight > 1.001 ) ) throw new Exception( "The total of (absolute) weights " + ! "should sum up to 1, " + ! "but it sums up to " + totalWeight.ToString() ); this.checkParameters_checkDoubleTickers( tickers ); } #endregion ! ! /// <summary> ! /// if a position with the given ticker has been found, then its index ! /// is returned; if it is not found, then -1 is returned ! /// </summary> ! /// <param name="ticker"></param> ! /// <returns></returns> ! public int GetIndexOfTicker( string ticker ) { ! int indexOfTicker = -1; ! int indexCandidate = 0; ! while ( indexCandidate < this.Count && ! this[ indexCandidate ].Ticker != ticker ) ! indexCandidate++; ! if ( this[ indexCandidate ].Ticker == ticker ) ! indexOfTicker = indexCandidate; ! return indexOfTicker; } ! ! public bool ContainsTicker( string ticker ) { ! int indexOfTicker = this.GetIndexOfTicker( ticker ); ! bool containsTicker = ( indexOfTicker == -1 ); ! return containsTicker; } ! ! public WeightedPosition GetWeightedPosition( string ticker ) { ! WeightedPosition weightedPosition = null; ! int indexOfTicker = this.GetIndexOfTicker( ticker ); ! if ( indexOfTicker >= 0 ) ! // a position with the given ticker has been found ! weightedPosition = this[ indexOfTicker ]; ! return weightedPosition; } + + public WeightedPosition GetWeightedPosition( int i ) + { + return this[ i ]; + } + + // public WeightedPosition this[ int index ] + // { + // get + // { + // return (WeightedPosition)this.GetByIndex( index ); + // } + // set + // { + // this.SetByIndex( index, value ); + // } + // } #region GetEquityLine *************** *** 258,262 **** // EndOfDayDateTime endOfDayDateTime = // new EndOfDayDateTime( dateTime , EndOfDaySpecificTime.MarketClose ); ! foreach( WeightedPosition weightedPosition in this.Values ) { string ticker = weightedPosition.Ticker; --- 293,297 ---- // EndOfDayDateTime endOfDayDateTime = // new EndOfDayDateTime( dateTime , EndOfDaySpecificTime.MarketClose ); ! foreach( WeightedPosition weightedPosition in this ) { string ticker = weightedPosition.Ticker; *************** *** 276,280 **** { double cash = beginningCash; ! foreach ( WeightedPosition weightedPosition in this.Values ) { double thisVirtualQuantity = --- 311,315 ---- { double cash = beginningCash; ! foreach ( WeightedPosition weightedPosition in this ) { double thisVirtualQuantity = *************** *** 292,296 **** } private double getVirtualPortfolioValue( DateTime dateTime , ! Hashtable tickerVirtualQuantities ) { HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider = --- 327,331 ---- } private double getVirtualPortfolioValue( DateTime dateTime , ! Hashtable tickerVirtualQuantities ) { HistoricalAdjustedQuoteProvider historicalAdjustedQuoteProvider = *************** *** 324,334 **** Hashtable virtualQuantities = this.getVirtualQuantities( beginningCash , firstDate ); ! double cash = this.getCash( beginningCash , virtualQuantities ); for( int i = 0 ; i < equityDates.Count ; i++ ) { DateTime dateTime = (DateTime)equityDates.GetKey( i ); equityLine.Add( dateTime , ! cash + this.getVirtualPortfolioValue( dateTime , ! virtualQuantities ) ); } return equityLine; --- 359,369 ---- Hashtable virtualQuantities = this.getVirtualQuantities( beginningCash , firstDate ); ! double cash = this.getCash( beginningCash , virtualQuantities ); for( int i = 0 ; i < equityDates.Count ; i++ ) { DateTime dateTime = (DateTime)equityDates.GetKey( i ); equityLine.Add( dateTime , ! cash + this.getVirtualPortfolioValue( dateTime , ! virtualQuantities ) ); } return equityLine; *************** *** 343,347 **** double dailyReturn = 0.0; foreach ( WeightedPosition weightedPosition in ! this.Values ) dailyReturn += weightedPosition.GetCloseToCloseDailyReturn( dateTime ); --- 378,382 ---- double dailyReturn = 0.0; foreach ( WeightedPosition weightedPosition in ! this ) dailyReturn += weightedPosition.GetCloseToCloseDailyReturn( dateTime ); *************** *** 358,362 **** closeToClosePortfolioReturns[ i ] = this.getCloseToClosePortfolioReturn( ! datesForReturnComputation , i ); return closeToClosePortfolioReturns; } --- 393,397 ---- closeToClosePortfolioReturns[ i ] = this.getCloseToClosePortfolioReturn( ! datesForReturnComputation , i ); return closeToClosePortfolioReturns; } *************** *** 403,407 **** } private static double[] getNormalizedWeights( double[] nonNormalizedWeights , ! double normalizingFactor ) { double[] normalizedWeights = new double[ nonNormalizedWeights.Length ]; --- 438,442 ---- } private static double[] getNormalizedWeights( double[] nonNormalizedWeights , ! double normalizingFactor ) { double[] normalizedWeights = new double[ nonNormalizedWeights.Length ]; *************** *** 437,442 **** // return tickerReturns; // } ! private static float getTickerReturnsStandardDeviations( int tickerIndex , ! SignedTickers signedTickers , ReturnsManager returnsManager ) { string ticker = signedTickers[ tickerIndex ].Ticker; --- 472,477 ---- // return tickerReturns; // } ! private static float getTickerReturnsStandardDeviations( ! int tickerIndex , SignedTickers signedTickers , IReturnsManager returnsManager ) { string ticker = signedTickers[ tickerIndex ].Ticker; *************** *** 446,450 **** } private static float[] getTickersReturnsStandardDeviations( ! SignedTickers signedTickers , ReturnsManager returnsManager ) { float[] tickersReturnsStandardDeviations = --- 481,485 ---- } private static float[] getTickersReturnsStandardDeviations( ! SignedTickers signedTickers , IReturnsManager returnsManager ) { float[] tickersReturnsStandardDeviations = *************** *** 453,457 **** tickersReturnsStandardDeviations[ i ] = getTickerReturnsStandardDeviations( i , ! signedTickers , returnsManager ); return tickersReturnsStandardDeviations; } --- 488,492 ---- tickersReturnsStandardDeviations[ i ] = getTickerReturnsStandardDeviations( i , ! signedTickers , returnsManager ); return tickersReturnsStandardDeviations; } *************** *** 469,473 **** nonNormalizedWeightsButBalancedForVolatility[ i ] = getNonNormalizedWeightsButBalancedForVolatility( ! standardDeviations , maxStandardDeviation , i ); return nonNormalizedWeightsButBalancedForVolatility; } --- 504,508 ---- nonNormalizedWeightsButBalancedForVolatility[ i ] = getNonNormalizedWeightsButBalancedForVolatility( ! standardDeviations , maxStandardDeviation , i ); return nonNormalizedWeightsButBalancedForVolatility; } *************** *** 481,489 **** } private static double[] getUnsignedNormalizedBalancedWeights( ! SignedTickers signedTickers , ReturnsManager returnManager ) { float[] standardDeviations = getTickersReturnsStandardDeviations( signedTickers , ! returnManager ); double[] nonNormalizedButBalancedWeights = getNonNormalizedWeightsButBalancedForVolatility( standardDeviations ); --- 516,524 ---- } private static double[] getUnsignedNormalizedBalancedWeights( ! SignedTickers signedTickers , IReturnsManager returnManager ) { float[] standardDeviations = getTickersReturnsStandardDeviations( signedTickers , ! returnManager ); double[] nonNormalizedButBalancedWeights = getNonNormalizedWeightsButBalancedForVolatility( standardDeviations ); *************** *** 511,515 **** double[] signedNormalizedBalancedWeights = getSignedNormalizedBalancedWeights( multipliers , ! unsignedNormalizedBalancedWeights ); return signedNormalizedBalancedWeights; } --- 546,550 ---- double[] signedNormalizedBalancedWeights = getSignedNormalizedBalancedWeights( multipliers , ! unsignedNormalizedBalancedWeights ); return signedNormalizedBalancedWeights; } *************** *** 522,533 **** /// <returns></returns> public static double[] GetBalancedWeights( ! SignedTickers signedTickers , ReturnsManager returnManager ) { double[] unsignedNormalizedBalancedWeights = getUnsignedNormalizedBalancedWeights( ! signedTickers , returnManager ); double[] balancedWeights = getSignedNormalizedBalancedWeights( ! signedTickers , unsignedNormalizedBalancedWeights ); return balancedWeights; } --- 557,568 ---- /// <returns></returns> public static double[] GetBalancedWeights( ! SignedTickers signedTickers , IReturnsManager returnManager ) { double[] unsignedNormalizedBalancedWeights = getUnsignedNormalizedBalancedWeights( ! signedTickers , returnManager ); double[] balancedWeights = getSignedNormalizedBalancedWeights( ! signedTickers , unsignedNormalizedBalancedWeights ); return balancedWeights; } *************** *** 535,539 **** #region GetReturn private void getReturnCheckParameters( int i , ! ReturnsManager returnsManager ) { if ( ( i < 0 ) || ( i > returnsManager.ReturnIntervals.Count - 1 ) ) --- 570,574 ---- #region GetReturn private void getReturnCheckParameters( int i , ! IReturnsManager returnsManager ) { if ( ( i < 0 ) || ( i > returnsManager.ReturnIntervals.Count - 1 ) ) *************** *** 541,562 **** } private float getTickerReturn( string ticker , int i , ! ReturnsManager returnsManager ) { return returnsManager.GetReturn( ticker , i ); } private float getReturnActually( WeightedPosition weightedPosition , ! int i , ReturnsManager returnsManager ) { float tickerReturn = this.getTickerReturn( weightedPosition.Ticker , ! i , returnsManager ); return tickerReturn * Convert.ToSingle( weightedPosition.Weight ); } ! private float getReturnActually( int i , ReturnsManager returnsManager ) { float linearCombinationReturn = 0; ! foreach ( WeightedPosition weightedPosition in this.Values ) linearCombinationReturn += this.getReturnActually( weightedPosition , ! i , returnsManager ); return linearCombinationReturn; } --- 576,597 ---- } private float getTickerReturn( string ticker , int i , ! IReturnsManager returnsManager ) { return returnsManager.GetReturn( ticker , i ); } private float getReturnActually( WeightedPosition weightedPosition , ! int i , IReturnsManager returnsManager ) { float tickerReturn = this.getTickerReturn( weightedPosition.Ticker , ! i , returnsManager ); return tickerReturn * Convert.ToSingle( weightedPosition.Weight ); } ! private float getReturnActually( int i , IReturnsManager returnsManager ) { float linearCombinationReturn = 0; ! foreach ( WeightedPosition weightedPosition in this ) linearCombinationReturn += this.getReturnActually( weightedPosition , ! i , returnsManager ); return linearCombinationReturn; } *************** *** 568,572 **** /// ticker returns</param> /// <returns></returns> ! public float GetReturn( int i , ReturnsManager returnsManager ) { this.getReturnCheckParameters( i , returnsManager ); --- 603,607 ---- /// ticker returns</param> /// <returns></returns> ! public float GetReturn( int i , IReturnsManager returnsManager ) { this.getReturnCheckParameters( i , returnsManager ); *************** *** 575,578 **** --- 610,614 ---- } #endregion GetReturn + /// <summary> /// Computes an array of floats representing the returns *************** *** 581,585 **** /// <param name="returnsManager"></param> /// <returns></returns> ! public float[] GetReturns( ReturnsManager returnsManager ) { float[] returns = new float[ --- 617,621 ---- /// <param name="returnsManager"></param> /// <returns></returns> ! public float[] GetReturns( IReturnsManager returnsManager ) { float[] returns = new float[ *************** *** 599,607 **** for ( int intervalIndex = 0 ; ! intervalIndex < returnsManager.NumberOfReturns ; intervalIndex++ ) { returns[ intervalIndex ] = 0; for ( int positionIndex = 0 ; positionIndex < this.Count ; ! positionIndex++ ) returns[ intervalIndex ] += tickersReturns[ positionIndex ][ intervalIndex ] * --- 635,643 ---- for ( int intervalIndex = 0 ; ! intervalIndex < returnsManager.NumberOfReturns ; intervalIndex++ ) { returns[ intervalIndex ] = 0; for ( int positionIndex = 0 ; positionIndex < this.Count ; ! positionIndex++ ) returns[ intervalIndex ] += tickersReturns[ positionIndex ][ intervalIndex ] * *************** *** 610,632 **** return returns; } /// <summary> ! /// Gets the Open To Close return for the current instance of WeightedPositions ! /// </summary> ! /// <param name="marketDate">Market date for which return has to be computed</param> ! public double GetOpenToCloseReturn(DateTime marketDate) ! { ! Quotes[] tickersQuotes = new Quotes[this.Count]; ! for(int i = 0; i<this.Count; i++) tickersQuotes[i] = new Quotes( this[i].Ticker,marketDate,marketDate ); ! double openToCloseReturn = 0.0; ! for(int i = 0; i < this.Count ; i++) ! openToCloseReturn += ! ( (float)tickersQuotes[i].Rows[0]["quClose"] / ! (float)tickersQuotes[i].Rows[0]["quOpen"] - 1.0f ) * ! (float)this[i].Weight; ! return openToCloseReturn; ! } ! // private double getLastNightReturn( float[] weightedPositionsLastNightReturns ) // { // double returnValue = 0.0; --- 646,711 ---- return returns; } + /// <summary> ! /// Computes an array of floats representing the returns ! /// of all weighted position ! /// </summary> ! /// <param name="returnsManager">intervals on which returns are to ! /// be computed</param> ! /// <param name="firstInterval">0-base index of the first interval to ! /// be considered</param> ! /// <param name="lastInterval">0-base index of the last interval to ! /// be considered</param> ! /// <returns></returns> ! public float[] GetReturns( ! IReturnsManager returnsManager , int firstInterval , int lastInterval ) ! { ! float[] returns = new float[ ! returnsManager.ReturnIntervals.Count ]; ! ! ! // weights[] is set to avoid several double to float conversions ! float[] weights = new float[ this.Count ]; ! float[][] tickersReturns = new float[ this.Count ][]; ! for ( int positionIndex = 0 ; positionIndex < this.Count ; positionIndex++ ) ! { ! weights[ positionIndex ] = ! Convert.ToSingle( ((WeightedPosition)(this[ positionIndex ])).Weight ); ! tickersReturns[ positionIndex ] = returnsManager.GetReturns( ! ((WeightedPosition)(this[ positionIndex ])).Ticker ); ! } ! ! for ( int intervalIndex = firstInterval ; ! intervalIndex <= lastInterval ; intervalIndex++ ) ! { ! returns[ intervalIndex ] = 0; ! for ( int positionIndex = 0 ; positionIndex < this.Count ; ! positionIndex++ ) ! returns[ intervalIndex ] += ! tickersReturns[ positionIndex ][ intervalIndex ] * ! weights[ positionIndex ]; ! } ! return returns; ! } ! ! /// <summary> ! /// Gets the Open To Close return for the current instance of WeightedPositions ! /// </summary> ! /// <param name="marketDate">Market date for which return has to be computed</param> ! public double GetOpenToCloseReturn(DateTime marketDate) ! { ! Quotes[] tickersQuotes = new Quotes[this.Count]; ! for(int i = 0; i<this.Count; i++) tickersQuotes[i] = new Quotes( this[i].Ticker,marketDate,marketDate ); ! double openToCloseReturn = 0.0; ! for(int i = 0; i < this.Count ; i++) ! openToCloseReturn += ! ( (float)tickersQuotes[i].Rows[0]["quClose"] / ! (float)tickersQuotes[i].Rows[0]["quOpen"] - 1.0f ) * ! (float)this[i].Weight; ! return openToCloseReturn; ! } ! // private double getLastNightReturn( float[] weightedPositionsLastNightReturns ) // { // double returnValue = 0.0; *************** *** 645,715 **** // } ! ! /// <summary> /// Gets the last night return for the current instance /// </summary> /// <param name="lastMarketDay">The last market date before today</param> ! /// <param name="today">today</param> // public double GetLastNightReturn( DateTime lastMarketDay , DateTime today ) // { // float[] weightedPositionsLastNightReturns = new float[this.Count]; // for(int i = 0; i<this.Count; i++) ! // weightedPositionsLastNightReturns[i] = // this.getLastNightReturn_getLastNightReturnForTicker( // this[i].Ticker, lastMarketDay, today ); // return getLastNightReturn( weightedPositionsLastNightReturns ); // } ! private double getCloseToCloseReturn_setReturns_getReturn( int returnDayIndex, Quotes[] tickersQuotes ) ! { ! double returnValue = 0.0; ! for(int indexForTicker = 0; indexForTicker<this.Count; indexForTicker++) ! returnValue += ! ((float)tickersQuotes[indexForTicker].Rows[returnDayIndex][Quotes.AdjustedCloseToCloseRatio] - 1.0f)* ! (float)this[indexForTicker].Weight; ! return returnValue; ! } ! private void getCloseToCloseReturn_setReturns( double[] returnsToSet, ! Quotes[] tickersQuotes ) ! { ! for(int i = 0; i < returnsToSet.Length; i++) ! { ! returnsToSet[i] = ! getCloseToCloseReturn_setReturns_getReturn(i,tickersQuotes); ! } ! } ! /// <summary> ! /// Gets portfolio's return for a given period, for the current instance ! /// of weighted positions ! /// </summary> ! /// <param name="startDate">Start date for the period for which return has to be computed</param> ! /// <param name="endDate">End date for the period for which return has to be computed</param> ! public double GetCloseToCloseReturn(DateTime startDate,DateTime endDate ) ! { ! const double initialEquity = 1.0; ! double equityValue = initialEquity; ! Quotes[] tickersQuotes = new Quotes[this.Count]; ! int numberOfQuotesOfPreviousTicker = 0; ! for(int i = 0; i < this.Count; i++) ! { ! tickersQuotes[i] = new Quotes( this[i].Ticker,startDate, endDate ); ! if( i == 0 ) ! numberOfQuotesOfPreviousTicker = tickersQuotes[i].Rows.Count; ! else if ( (i > 0 && ( tickersQuotes[i].Rows.Count > numberOfQuotesOfPreviousTicker)) || ! tickersQuotes[i].Rows.Count == 0) ! // not all the tickers have the same available n. of quotes ! // for the given period or a ticker has no quotes ! throw new MissingQuotesException(this.SignedTickers.Tickers, ! startDate, endDate); ! } ! double[] returns = new double[tickersQuotes[0].Rows.Count]; ! getCloseToCloseReturn_setReturns(returns,tickersQuotes); ! for(int i = 0; i < returns.Length; i++) ! equityValue = ! equityValue + equityValue * returns[i]; ! return (equityValue - initialEquity)/initialEquity; ! } /// <summary> --- 724,794 ---- // } ! ! /// <summary> /// Gets the last night return for the current instance /// </summary> /// <param name="lastMarketDay">The last market date before today</param> ! /// <param name="today">today</param> // public double GetLastNightReturn( DateTime lastMarketDay , DateTime today ) // { // float[] weightedPositionsLastNightReturns = new float[this.Count]; // for(int i = 0; i<this.Count; i++) ! // weightedPositionsLastNightReturns[i] = // this.getLastNightReturn_getLastNightReturnForTicker( // this[i].Ticker, lastMarketDay, today ); // return getLastNightReturn( weightedPositionsLastNightReturns ); // } ! private double getCloseToCloseReturn_setReturns_getReturn( int returnDayIndex, Quotes[] tickersQuotes ) ! { ! double returnValue = 0.0; ! for(int indexForTicker = 0; indexForTicker<this.Count; indexForTicker++) ! returnValue += ! ((float)tickersQuotes[indexForTicker].Rows[returnDayIndex][Quotes.AdjustedCloseToCloseRatio] - 1.0f)* ! (float)this[indexForTicker].Weight; ! return returnValue; ! } ! private void getCloseToCloseReturn_setReturns( double[] returnsToSet, ! Quotes[] tickersQuotes ) ! { ! for(int i = 0; i < returnsToSet.Length; i++) ! { ! returnsToSet[i] = ! getCloseToCloseReturn_setReturns_getReturn(i,tickersQuotes); ! } ! } ! /// <summary> ! /// Gets portfolio's return for a given period, for the current instance ! /// of weighted positions ! /// </summary> ! /// <param name="startDate">Start date for the period for which return has to be computed</param> ! /// <param name="endDate">End date for the period for which return has to be computed</param> ! public double GetCloseToCloseReturn(DateTime startDate,DateTime endDate ) ! { ! const double initialEquity = 1.0; ! double equityValue = initialEquity; ! Quotes[] tickersQuotes = new Quotes[this.Count]; ! int numberOfQuotesOfPreviousTicker = 0; ! for(int i = 0; i < this.Count; i++) ! { ! tickersQuotes[i] = new Quotes( this[i].Ticker,startDate, endDate ); ! if( i == 0 ) ! numberOfQuotesOfPreviousTicker = tickersQuotes[i].Rows.Count; ! else if ( (i > 0 && ( tickersQuotes[i].Rows.Count > numberOfQuotesOfPreviousTicker)) || ! tickersQuotes[i].Rows.Count == 0) ! // not all the tickers have the same available n. of quotes ! // for the given period or a ticker has no quotes ! throw new MissingQuotesException(this.SignedTickers.Tickers, ! startDate, endDate); ! } ! double[] returns = new double[tickersQuotes[0].Rows.Count]; ! getCloseToCloseReturn_setReturns(returns,tickersQuotes); ! for(int i = 0; i < returns.Length; i++) ! equityValue = ! equityValue + equityValue * returns[i]; ! return (equityValue - initialEquity)/initialEquity; ! } /// <summary> *************** *** 717,723 **** /// long positions become then short positions and viceversa /// </summary> ! public void Reverse() { ! foreach(WeightedPosition weightedPosition in this.Values) weightedPosition.Weight = - weightedPosition.Weight; } --- 796,802 ---- /// long positions become then short positions and viceversa /// </summary> ! public void ReverseSign() { ! foreach( WeightedPosition weightedPosition in this ) weightedPosition.Weight = - weightedPosition.Weight; } *************** *** 730,734 **** } ! public bool HasTheSameSignedTickersAs(WeightedPositions weightedPositions) { //Check for null and compare run-time types and compare length of the weightedPositions --- 809,813 ---- } ! public bool HasTheSameSignedTickersAs(WeightedPositions weightedPositions) { //Check for null and compare run-time types and compare length of the weightedPositions *************** *** 744,753 **** for (int j = 0; j<this.Count; j++) if ( this[i].HasTheSameSignedTickerAs(weightedPositions[j]) ) ! numOfEquals++; ! return numOfEquals == this.Count; } ! public bool HasTheOppositeSignedTickersAs(WeightedPositions weightedPositions) { //Check for null and compare run-time types and compare length of the weightedPositions --- 823,832 ---- for (int j = 0; j<this.Count; j++) if ( this[i].HasTheSameSignedTickerAs(weightedPositions[j]) ) ! numOfEquals++; ! return numOfEquals == this.Count; } ! public bool HasTheOppositeSignedTickersAs(WeightedPositions weightedPositions) { //Check for null and compare run-time types and compare length of the weightedPositions *************** *** 764,769 **** for (int j = 0; j<this.Count; j++) if ( this[i].HasTheOppositeSignedTickerAs(weightedPositions[j]) ) ! numOfEqualsWithOppositeSign++; ! return numOfEqualsWithOppositeSign == this.Count; } --- 843,848 ---- for (int j = 0; j<this.Count; j++) if ( this[i].HasTheOppositeSignedTickerAs(weightedPositions[j]) ) ! numOfEqualsWithOppositeSign++; ! return numOfEqualsWithOppositeSign == this.Count; } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:34:34
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv8222 Modified Files: Business_SD.csproj Log Message: a07_DataProviders\IHistoricalMarketValueProvider.cs has been added a2_Strategies\Eligibles\OftenExchanged.cs has been added a2_Strategies\Optimizing\Decoding\DummyDecoderForTestingPositions.cs has been added a2_Strategies\OutOfSample\IEntryStrategy.cs has been added a2_Strategies\OutOfSample\IExitStrategy.cs has been added a2_Strategies\OutOfSample\TestingPositionsForUndecodableEncoded.cs has been added a2_Strategies\returnsManagement\IReturnsCalculator.cs has been added a2_Strategies\returnsManagement\IReturnsManager.cs has been added a2_Strategies\returnsManagement\time\IReturnIntervalsBuilderForTradingAndForSignaling.cs has been added a2_Strategies\returnsManagement\time\IReturnIntervalSelectorForSignaling.cs has been added Index: Business_SD.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/Business_SD.csproj,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** Business_SD.csproj 30 Oct 2009 23:09:23 -0000 1.41 --- Business_SD.csproj 28 Mar 2010 13:34:21 -0000 1.42 *************** *** 54,57 **** --- 54,58 ---- <Compile Include="a07_DataProviders\HistoricalBarInterpolatingProvider.cs" /> <Compile Include="a07_DataProviders\HistoricalMarketValueProviderWithQuoteBackupOnClose.cs" /> + <Compile Include="a07_DataProviders\IHistoricalMarketValueProvider.cs" /> <Compile Include="a07_DataProviders\PriceAdjustmentDetector.cs" /> <Compile Include="a07_DataProviders\HistoricalBarProvider.cs" /> *************** *** 92,95 **** --- 93,97 ---- <Compile Include="a2_Strategies\Eligibles\IEligiblesSelector.cs" /> <Compile Include="a2_Strategies\Eligibles\ByPriceMostLiquidQuotedAtEachDateTime.cs" /> + <Compile Include="a2_Strategies\Eligibles\OftenExchanged.cs" /> <Compile Include="a2_Strategies\EndOfDayStrategies\BasicEndOfDayStrategyForBacktester.cs" /> <Compile Include="a2_Strategies\EndOfDayStrategies\EndOfDayStrategy.cs" /> *************** *** 117,120 **** --- 119,123 ---- <Compile Include="a2_Strategies\Optimizing\Decoding\DecoderForTestingPositionsWithBalancedWeights.cs" /> <Compile Include="a2_Strategies\Optimizing\Decoding\DecoderForTestingPositionsWithWeights.cs" /> + <Compile Include="a2_Strategies\Optimizing\Decoding\DummyDecoderForTestingPositions.cs" /> <Compile Include="a2_Strategies\Optimizing\Decoding\IDecoderForTestingPositions.cs" /> <Compile Include="a2_Strategies\Optimizing\Decoding\IDecoderForWeightedPositions.cs" /> *************** *** 123,128 **** --- 126,136 ---- <Compile Include="a2_Strategies\Optimizing\GenomeManagers\GenomeManagerWithDuplicateGenes.cs" /> <Compile Include="a2_Strategies\Optimizing\GenomeManagers\GenomeManagerType.cs" /> + <Compile Include="a2_Strategies\OutOfSample\IEntryStrategy.cs" /> + <Compile Include="a2_Strategies\OutOfSample\IExitStrategy.cs" /> <Compile Include="a2_Strategies\OutOfSample\IGeneticallyOptimizable.cs" /> <Compile Include="a2_Strategies\OutOfSample\TestingPositions.cs" /> + <Compile Include="a2_Strategies\OutOfSample\TestingPositionsForUndecodableEncoded.cs" /> + <Compile Include="a2_Strategies\returnsManagement\IReturnsCalculator.cs" /> + <Compile Include="a2_Strategies\returnsManagement\IReturnsManager.cs" /> <Compile Include="a2_Strategies\returnsManagement\time\CloseToCloseIntervals.cs" /> <Compile Include="a2_Strategies\returnsManagement\time\CloseToOpenIntervals.cs" /> *************** *** 130,133 **** --- 138,143 ---- <Compile Include="a2_Strategies\returnsManagement\time\IntervalsType.cs" /> <Compile Include="a2_Strategies\returnsManagement\time\IntradayReturnIntervals.cs" /> + <Compile Include="a2_Strategies\returnsManagement\time\IReturnIntervalsBuilderForTradingAndForSignaling.cs" /> + <Compile Include="a2_Strategies\returnsManagement\time\IReturnIntervalSelectorForSignaling.cs" /> <Compile Include="a2_Strategies\returnsManagement\time\OpenToCloseCloseToOpenIntervals.cs" /> <Compile Include="a2_Strategies\returnsManagement\time\OpenToOpenIntervals.cs" /> |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:23:25
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5758/a2_Strategies/returnsManagement/time Added Files: IReturnIntervalSelectorForSignaling.cs Log Message: Interface to be implemented by those classes which, given a ReturnInterval for trading, find out the correspondig ReturnInterval for signaling --- NEW FILE: IReturnIntervalSelectorForSignaling.cs --- /* QuantProject - Quantitative Finance Library IReturnIntervalSelectorForSignaling.cs Copyright (C) 2010 Glauco Siliprandi 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; namespace QuantProject.Business.Strategies.ReturnsManagement.Time { /// <summary> /// Interface to be implemented by those classes which, given a /// ReturnInterval for trading, find out the correspondig ReturnInterval /// for signaling /// </summary> public interface IReturnIntervalSelectorForSignaling { ReturnInterval GetReturnIntervalUsedForSignaling( ReturnInterval returnIntervalForTrading ); } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:23:00
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5599/a2_Strategies/returnsManagement/time Added Files: IReturnIntervalsBuilderForTradingAndForSignaling.cs Log Message: Interface to be implemented by those classes that build intervals for trading and for signaling --- NEW FILE: IReturnIntervalsBuilderForTradingAndForSignaling.cs --- /* QuantProject - Quantitative Finance Library IReturnIntervalsBuilderForTradingAndForSignaling.cs Copyright (C) 2010 Glauco Siliprandi 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 QuantProject.Business.Strategies.Eligibles; namespace QuantProject.Business.Strategies.ReturnsManagement.Time { /// <summary> /// Interface to be implemented by those classes that build intervals /// for trading and for signaling /// </summary> public interface IReturnIntervalsBuilderForTradingAndForSignaling { /// <summary> /// Builds returnIntervalsForTrading and returnIntervalsForSignaling /// </summary> /// <param name="returnsManager"></param> /// <param name="eligibleTickersForTrading"></param> /// <param name="eligibleTickersForSignaling"></param> /// <param name="returnIntervalsForTrading"></param> /// <param name="returnIntervalsForSignaling"></param> void BuildIntervals( IReturnsManager returnsManager , IReturnIntervalSelectorForSignaling returnIntervalSelectorForSignaling , string[] eligibleTickersForTrading , string[] eligibleTickersForSignaling , out ReturnIntervals returnIntervalsForTrading , out ReturnIntervals returnIntervalsForSignaling ); // ReturnIntervals ReturnIntervalsForTrading { get; } // ReturnIntervals ReturnIntervalsForSignaling { get; } } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:22:20
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5453/a2_Strategies/returnsManagement Added Files: IReturnsManager.cs Log Message: Interface to be implemented by those classes that compute returns on intervals --- NEW FILE: IReturnsManager.cs --- /* QuantProject - Quantitative Finance Library IReturnsManager.cs Copyright (C) 2010 Glauco Siliprandi 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 QuantProject.Business.DataProviders; using QuantProject.Business.Strategies.ReturnsManagement.Time; namespace QuantProject.Business.Strategies.ReturnsManagement { /// <summary> /// Interface to be implemented by those classes that compute returns /// on intervals /// </summary> public interface IReturnsManager { IHistoricalMarketValueProvider HistoricalMarketValueProvider{ get; } int NumberOfReturns{ get; } ReturnIntervals ReturnIntervals{ get; } float GetReturn( string ticker , int returnIndex ); float[] GetReturns( string ticker ); float GetReturnsStandardDeviation( string ticker ); } } |
|
From: Glauco S. <gla...@us...> - 2010-03-28 13:19:12
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv4588/a2_Strategies/returnsManagement Added Files: IReturnsCalculator.cs Log Message: Interface to be implemented by those classes that calculate returns using a ReturnsManager --- NEW FILE: IReturnsCalculator.cs --- /* QuantProject - Quantitative Finance Library IEligiblesSelector.cs Copyright (C) 2010 Glauco Siliprandi 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; namespace QuantProject.Business.Strategies.ReturnsManagement { /// <summary> /// Interface to be implemented by those classes that calculate /// returns using a ReturnsManager /// </summary> public interface IReturnsCalculator { float[] GetReturns( IReturnsManager returnsManager , int firstInterval , int lastInterval ); float GetReturn( int i , IReturnsManager returnsManager ); } } |