quantproject-developers Mailing List for QuantProject (Page 67)
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: Marco M. <mi...@us...> - 2007-10-02 14:40:16
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv5445/a2_Strategies/returnsManagement/time Modified Files: CloseToCloseIntervals.cs ReturnIntervals.cs Log Message: Fixed bug: intervalLength has to be a protected member inside ReturnIntervals class. Added new constructor to ReturnIntervals Index: ReturnIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/ReturnIntervals.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ReturnIntervals.cs 25 Sep 2007 21:48:15 -0000 1.2 --- ReturnIntervals.cs 2 Oct 2007 14:40:06 -0000 1.3 *************** *** 40,43 **** --- 40,44 ---- protected History marketDaysForBenchmark; private EndOfDayHistory bordersHistory; + protected int intervalLength; public ReturnInterval this[ int index ] *************** *** 77,80 **** --- 78,96 ---- } } + + private void returnIntervals_initialize(EndOfDayDateTime firstEndOfDayDateTime , + EndOfDayDateTime lastEndOfDayDateTime , string benchmark, + int intervalLength) + { + if(intervalLength < 1) + throw new Exception("Interval length has to be greater than 0!"); + this.intervalLength = intervalLength; + this.firstEndOfDayDateTime = firstEndOfDayDateTime; + this.lastEndOfDayDateTime = lastEndOfDayDateTime; + this.benchmark = benchmark; + this.setMarketDaysForBenchmark(); + this.setIntervals(); + } + /// <summary> /// Creates the proper intervals, for the given benchmark, from *************** *** 87,95 **** EndOfDayDateTime lastEndOfDayDateTime , string benchmark ) { ! this.firstEndOfDayDateTime = firstEndOfDayDateTime; ! this.lastEndOfDayDateTime = lastEndOfDayDateTime; ! this.benchmark = benchmark; ! this.setMarketDaysForBenchmark(); ! this.setIntervals(); } --- 103,124 ---- EndOfDayDateTime lastEndOfDayDateTime , string benchmark ) { ! this.returnIntervals_initialize( firstEndOfDayDateTime, ! lastEndOfDayDateTime, benchmark, 1 );//default intervals are daily ! } ! ! /// <summary> ! /// Creates the proper intervals, for the given benchmark, from ! /// the first EndOfDayDateTime to the last EndOfDayDateTime ! /// </summary> ! /// <param name="firstEndOfDayDateTime"></param> ! /// <param name="lastEndOfDayDateTime"></param> ! /// <param name="benchmark"></param> ! /// <param name="intervalLength"></param> ! public ReturnIntervals( EndOfDayDateTime firstEndOfDayDateTime , ! EndOfDayDateTime lastEndOfDayDateTime , string benchmark, ! int intervalLength) ! { ! this.returnIntervals_initialize( firstEndOfDayDateTime, ! lastEndOfDayDateTime, benchmark, intervalLength ); } Index: CloseToCloseIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/CloseToCloseIntervals.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CloseToCloseIntervals.cs 25 Sep 2007 21:48:14 -0000 1.3 --- CloseToCloseIntervals.cs 2 Oct 2007 14:40:05 -0000 1.4 *************** *** 32,37 **** public class CloseToCloseIntervals : ReturnIntervals { - private int intervalLength; - /// <summary> /// Creates the close to close intervals for the given benchmark, from --- 32,35 ---- *************** *** 45,49 **** base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { ! this.intervalLength = 1;//default intervals are daily } /// <summary> --- 43,47 ---- base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { ! } /// <summary> *************** *** 60,68 **** EndOfDayDateTime lastEndOfDayDateTime , string benchmark , int intervalLength ) : ! base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { ! if(intervalLength < 1) ! throw new Exception("Interval length has to be greater than 0!"); ! this.intervalLength = intervalLength; } --- 58,65 ---- EndOfDayDateTime lastEndOfDayDateTime , string benchmark , int intervalLength ) : ! base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark , ! intervalLength) { ! } |
|
From: Marco M. <mi...@us...> - 2007-09-26 22:01:58
|
Update of /cvsroot/quantproject/QuantProject/b3_Data/DataTables In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1863/DataTables Modified Files: TickerDataTable.cs Log Message: Changed implementation of GetTickersQuotedInEachMarketDay: now the method returns the tickers that are effectively traded at each market day (for a given benchmark). Index: TickerDataTable.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b3_Data/DataTables/TickerDataTable.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** TickerDataTable.cs 28 Aug 2007 09:35:52 -0000 1.8 --- TickerDataTable.cs 26 Sep 2007 22:01:44 -0000 1.9 *************** *** 23,27 **** --- 23,29 ---- using System; using System.Data; + using QuantProject.ADT; + using QuantProject.ADT.Histories; using QuantProject.DataAccess.Tables; *************** *** 214,217 **** --- 216,220 ---- } + //new implementation public static DataTable GetTickersQuotedInEachMarketDay(string marketIndex, string groupID, DateTime firstQuoteDate, *************** *** 219,225 **** long maxNumOfReturnedTickers) { ! int marketDaysForTheGivenMarket = ! TickerDataTable.getNumberOfTradingDays(marketIndex, firstQuoteDate, lastQuoteDate); ! DataTable groupOfTicker = QuantProject.DataAccess.Tables.Tickers_tickerGroups.GetTickers(groupID); TickerDataTable.addColumnNumberOfQuotes(groupOfTicker); QuantProject.Data.DataTables.GroupQuotes tickerQuotes = --- 222,228 ---- long maxNumOfReturnedTickers) { ! History marketDaysForIndex = Quotes.GetMarketDays(marketIndex, ! firstQuoteDate , lastQuoteDate); ! DataTable groupOfTicker = QuantProject.DataAccess.Tables.Tickers_tickerGroups.GetTickers(groupID); TickerDataTable.addColumnNumberOfQuotes(groupOfTicker); QuantProject.Data.DataTables.GroupQuotes tickerQuotes = *************** *** 227,242 **** groupID, firstQuoteDate, lastQuoteDate); DataTable returnValue = groupOfTicker.Clone(); foreach(DataRow row in groupOfTicker.Rows) { ! if(tickerQuotes.GetNumberOfDaysWithEffectiveTrades((string)row[0]) == marketDaysForTheGivenMarket) //the current ticker has been effectively traded in each market day ! TickerDataTable.getTickersQuotedInEachMarketDay_addRow(row, marketDaysForTheGivenMarket, ! returnValue); } ExtendedDataTable.DeleteRows(returnValue, maxNumOfReturnedTickers); return returnValue; - } ! public static DataTable GetTickersQuotedInEachMarketDay(string marketIndex, DataTable setOfTickers, DateTime firstQuoteDate, --- 230,247 ---- groupID, firstQuoteDate, lastQuoteDate); DataTable returnValue = groupOfTicker.Clone(); + History marketDaysForTicker; foreach(DataRow row in groupOfTicker.Rows) { ! marketDaysForTicker = Quotes.GetMarketDays( (string)row[0], ! firstQuoteDate , lastQuoteDate); ! if( marketDaysForTicker.ContainsAllTheDatesIn(marketDaysForIndex) ) //the current ticker has been effectively traded in each market day ! TickerDataTable.getTickersQuotedInEachMarketDay_addRow( ! row, marketDaysForTicker.Count, returnValue); } ExtendedDataTable.DeleteRows(returnValue, maxNumOfReturnedTickers); return returnValue; } ! //new implementation public static DataTable GetTickersQuotedInEachMarketDay(string marketIndex, DataTable setOfTickers, DateTime firstQuoteDate, *************** *** 244,261 **** long maxNumOfReturnedTickers) { ! int marketDaysForTheGivenMarket = ! TickerDataTable.getNumberOfTradingDays(marketIndex, firstQuoteDate, lastQuoteDate); TickerDataTable.addColumnNumberOfQuotes(setOfTickers); ! DataTable returnValue = setOfTickers.Clone(); foreach(DataRow row in setOfTickers.Rows) { ! if(QuantProject.DataAccess.Tables.Quotes.GetNumberOfDaysWithEffectiveTrades((string)row[0],firstQuoteDate,lastQuoteDate) == marketDaysForTheGivenMarket) ! //the current ticker has the same number of quotes as the market index ! TickerDataTable.getTickersQuotedInEachMarketDay_addRow(row, marketDaysForTheGivenMarket, ! returnValue); } ExtendedDataTable.DeleteRows(returnValue, maxNumOfReturnedTickers); return returnValue; } private static void getTickersQuotedNotAtEachMarketDay_addRow(DataRow rowToBeAdded, --- 249,315 ---- long maxNumOfReturnedTickers) { ! History marketDaysForIndex = Quotes.GetMarketDays(marketIndex, ! firstQuoteDate , lastQuoteDate); TickerDataTable.addColumnNumberOfQuotes(setOfTickers); ! DataTable returnValue = setOfTickers.Clone(); ! History marketDaysForTicker; foreach(DataRow row in setOfTickers.Rows) { ! marketDaysForTicker = Quotes.GetMarketDays( (string)row[0], ! firstQuoteDate , lastQuoteDate); ! if( marketDaysForTicker.ContainsAllTheDatesIn(marketDaysForIndex) ) ! //the current ticker has been effectively traded in each market day ! TickerDataTable.getTickersQuotedInEachMarketDay_addRow( ! row, marketDaysForTicker.Count, returnValue); } ExtendedDataTable.DeleteRows(returnValue, maxNumOfReturnedTickers); return returnValue; } + + //OLD IMPLEMENTATION OF GetTickersQuotedInEachMarketDay + // public static DataTable GetTickersQuotedInEachMarketDay(string marketIndex, string groupID, + // DateTime firstQuoteDate, + // DateTime lastQuoteDate, + // long maxNumOfReturnedTickers) + // { + // int marketDaysForTheGivenMarket = + // TickerDataTable.getNumberOfTradingDays(marketIndex, firstQuoteDate, lastQuoteDate); + // DataTable groupOfTicker = QuantProject.DataAccess.Tables.Tickers_tickerGroups.GetTickers(groupID); + // TickerDataTable.addColumnNumberOfQuotes(groupOfTicker); + // QuantProject.Data.DataTables.GroupQuotes tickerQuotes = + // new QuantProject.Data.DataTables.GroupQuotes( + // groupID, firstQuoteDate, lastQuoteDate); + // DataTable returnValue = groupOfTicker.Clone(); + // foreach(DataRow row in groupOfTicker.Rows) + // { + // if(tickerQuotes.GetNumberOfDaysWithEffectiveTrades((string)row[0]) == marketDaysForTheGivenMarket) + // //the current ticker has been effectively traded in each market day + // TickerDataTable.getTickersQuotedInEachMarketDay_addRow(row, marketDaysForTheGivenMarket, + // returnValue); + // } + // ExtendedDataTable.DeleteRows(returnValue, maxNumOfReturnedTickers); + // return returnValue; + // + // } + // + // public static DataTable GetTickersQuotedInEachMarketDay(string marketIndex, DataTable setOfTickers, + // DateTime firstQuoteDate, + // DateTime lastQuoteDate, + // long maxNumOfReturnedTickers) + // { + // int marketDaysForTheGivenMarket = + // TickerDataTable.getNumberOfTradingDays(marketIndex, firstQuoteDate, lastQuoteDate); + // TickerDataTable.addColumnNumberOfQuotes(setOfTickers); + // DataTable returnValue = setOfTickers.Clone(); + // foreach(DataRow row in setOfTickers.Rows) + // { + // if(QuantProject.DataAccess.Tables.Quotes.GetNumberOfDaysWithEffectiveTrades((string)row[0],firstQuoteDate,lastQuoteDate) == marketDaysForTheGivenMarket) + // //the current ticker has the same number of quotes as the market index + // TickerDataTable.getTickersQuotedInEachMarketDay_addRow(row, marketDaysForTheGivenMarket, + // returnValue); + // } + // ExtendedDataTable.DeleteRows(returnValue, maxNumOfReturnedTickers); + // return returnValue; + // } private static void getTickersQuotedNotAtEachMarketDay_addRow(DataRow rowToBeAdded, |
|
From: Marco M. <mi...@us...> - 2007-09-26 21:58:40
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Histories In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv476/Histories Modified Files: History.cs Log Message: Added method: ContainsAllTheDatesIn ( History comparingHistory ) Index: History.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Histories/History.cs,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** History.cs 1 Aug 2007 22:58:03 -0000 1.11 --- History.cs 26 Sep 2007 21:58:18 -0000 1.12 *************** *** 80,83 **** --- 80,99 ---- } + /// <summary> + /// Returns true iif current history contains all the + /// dates contained in the given comparingHistory + /// </summary> + /// <param name="comparingHistory">Provides the relevant dates to be checked + /// in the current History</param> + /// <returns></returns> + public bool ContainsAllTheDatesIn( History comparingHistory ) + { + bool returnValue = true; + foreach ( DateTime dateTime in comparingHistory.Keys ) + if ( ! this.ContainsKey( dateTime ) ) + returnValue = false; + return returnValue; + } + public void Interpolate( ICollection dateTimeCollection , IInterpolationMethod interpolationMethod ) |
|
From: Marco M. <mi...@us...> - 2007-09-25 21:48:21
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14131 Modified Files: CloseToCloseIntervals.cs CloseToOpenIntervals.cs DailyOpenToCloseIntervals.cs OpenToCloseCloseToOpenIntervals.cs ReturnIntervals.cs Log Message: Added protected field marketDaysForBenchmark (History) to ReturnIntervals, to be used for intervals' settings inside inherited classes. Index: ReturnIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/ReturnIntervals.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ReturnIntervals.cs 16 Sep 2007 21:42:56 -0000 1.1 --- ReturnIntervals.cs 25 Sep 2007 21:48:15 -0000 1.2 *************** *** 24,27 **** --- 24,28 ---- using System.Collections; + using QuantProject.ADT.Histories; using QuantProject.Business.Timing; *************** *** 37,41 **** protected EndOfDayDateTime lastEndOfDayDateTime; protected string benchmark; ! private EndOfDayHistory bordersHistory; --- 38,42 ---- protected EndOfDayDateTime lastEndOfDayDateTime; protected string benchmark; ! protected History marketDaysForBenchmark; private EndOfDayHistory bordersHistory; *************** *** 89,95 **** --- 90,106 ---- this.lastEndOfDayDateTime = lastEndOfDayDateTime; this.benchmark = benchmark; + this.setMarketDaysForBenchmark(); this.setIntervals(); } + + protected virtual void setMarketDaysForBenchmark() + { + this.marketDaysForBenchmark = + QuantProject.Data.DataTables.Quotes.GetMarketDays( this.benchmark , + firstEndOfDayDateTime.DateTime , lastEndOfDayDateTime.DateTime ); + } + protected abstract void setIntervals(); + /// <summary> /// True iff for each interval border, there is an EndOfDayDateTime Index: OpenToCloseCloseToOpenIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/OpenToCloseCloseToOpenIntervals.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OpenToCloseCloseToOpenIntervals.cs 23 Sep 2007 21:46:31 -0000 1.1 --- OpenToCloseCloseToOpenIntervals.cs 25 Sep 2007 21:48:14 -0000 1.2 *************** *** 23,27 **** using System; - using QuantProject.ADT.Histories; using QuantProject.Business.Timing; --- 23,26 ---- *************** *** 49,57 **** } #region setIntervals ! private void addInterval( History marketDaysForBenchmark , int i ) { //adds the open to close interval DateTime dateTimeForOTC = ! (DateTime)marketDaysForBenchmark.GetKey( i ); ReturnInterval returnOTCInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForOTC , --- 48,56 ---- } #region setIntervals ! private void addInterval( int i ) { //adds the open to close interval DateTime dateTimeForOTC = ! (DateTime)this.marketDaysForBenchmark.GetKey( i ); ReturnInterval returnOTCInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForOTC , *************** *** 62,66 **** //adds the following close to open interval DateTime dateTimeForCTOEnd = ! (DateTime)marketDaysForBenchmark.GetKey( i + 1 ); ReturnInterval returnCTOInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForOTC , --- 61,65 ---- //adds the following close to open interval DateTime dateTimeForCTOEnd = ! (DateTime)this.marketDaysForBenchmark.GetKey( i + 1 ); ReturnInterval returnCTOInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForOTC , *************** *** 70,85 **** this.Add( returnCTOInterval ); } - private void setIntervals( History marketDaysForBenchmark ) - { - for( int i = 0 ; i < marketDaysForBenchmark.Count - 1 ; i++ ) - this.addInterval( marketDaysForBenchmark , i ); - } protected override void setIntervals() { ! History marketDaysForBenchmark = ! QuantProject.Data.DataTables.Quotes.GetMarketDays( this.benchmark , ! firstEndOfDayDateTime.DateTime , lastEndOfDayDateTime.DateTime ); ! this.setIntervals( marketDaysForBenchmark ); } #endregion setIntervals } --- 69,78 ---- this.Add( returnCTOInterval ); } protected override void setIntervals() { ! for( int i = 0 ; i < marketDaysForBenchmark.Count - 1 ; i++ ) ! this.addInterval( i ); } + #endregion setIntervals } Index: CloseToOpenIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/CloseToOpenIntervals.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CloseToOpenIntervals.cs 23 Sep 2007 21:44:35 -0000 1.1 --- CloseToOpenIntervals.cs 25 Sep 2007 21:48:14 -0000 1.2 *************** *** 23,27 **** using System; - using QuantProject.ADT.Histories; using QuantProject.Business.Timing; --- 23,26 ---- *************** *** 46,55 **** } #region setIntervals ! private void addInterval( History marketDaysForBenchmark , int i ) { DateTime dateTimeForIntervalBegin = ! (DateTime)marketDaysForBenchmark.GetKey( i ); DateTime dateTimeForIntervalEnd = ! (DateTime)marketDaysForBenchmark.GetKey( i + 1 ); ReturnInterval returnInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForIntervalBegin , --- 45,54 ---- } #region setIntervals ! private void addInterval( int i ) { DateTime dateTimeForIntervalBegin = ! (DateTime)this.marketDaysForBenchmark.GetKey( i ); DateTime dateTimeForIntervalEnd = ! (DateTime)this.marketDaysForBenchmark.GetKey( i + 1 ); ReturnInterval returnInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForIntervalBegin , *************** *** 59,73 **** this.Add( returnInterval ); } - private void setIntervals( History marketDaysForBenchmark ) - { - for( int i = 0 ; i < marketDaysForBenchmark.Count - 1 ; i++ ) - this.addInterval( marketDaysForBenchmark , i ); - } protected override void setIntervals() { ! History marketDaysForBenchmark = ! QuantProject.Data.DataTables.Quotes.GetMarketDays( this.benchmark , ! firstEndOfDayDateTime.DateTime , lastEndOfDayDateTime.DateTime ); ! this.setIntervals( marketDaysForBenchmark ); } #endregion setIntervals --- 58,65 ---- this.Add( returnInterval ); } protected override void setIntervals() { ! for( int i = 0 ; i < marketDaysForBenchmark.Count - 1 ; i++ ) ! this.addInterval( i ); } #endregion setIntervals Index: DailyOpenToCloseIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/DailyOpenToCloseIntervals.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DailyOpenToCloseIntervals.cs 20 Sep 2007 22:33:35 -0000 1.2 --- DailyOpenToCloseIntervals.cs 25 Sep 2007 21:48:14 -0000 1.3 *************** *** 23,27 **** using System; - using QuantProject.ADT.Histories; using QuantProject.Business.Timing; --- 23,26 ---- *************** *** 45,53 **** { } #region setIntervals ! private void addInterval( History marketDaysForBenchmark , int i ) { DateTime dateTimeForIntervalBegin = ! (DateTime)marketDaysForBenchmark.GetKey( i ); DateTime dateTimeForIntervalEnd = dateTimeForIntervalBegin; ReturnInterval returnInterval = new ReturnInterval( --- 44,53 ---- { } + #region setIntervals ! private void addInterval( int i ) { DateTime dateTimeForIntervalBegin = ! (DateTime)this.marketDaysForBenchmark.GetKey( i ); DateTime dateTimeForIntervalEnd = dateTimeForIntervalBegin; ReturnInterval returnInterval = new ReturnInterval( *************** *** 58,73 **** this.Add( returnInterval ); } - private void setIntervals( History marketDaysForBenchmark ) - { - for( int i = 0 ; i < marketDaysForBenchmark.Count ; i++ ) - this.addInterval( marketDaysForBenchmark , i ); - } protected override void setIntervals() { ! History marketDaysForBenchmark = ! QuantProject.Data.DataTables.Quotes.GetMarketDays( this.benchmark , ! firstEndOfDayDateTime.DateTime , lastEndOfDayDateTime.DateTime ); ! this.setIntervals( marketDaysForBenchmark ); } #endregion setIntervals } --- 58,67 ---- this.Add( returnInterval ); } protected override void setIntervals() { ! for( int i = 0 ; i < this.marketDaysForBenchmark.Count ; i++ ) ! this.addInterval( i ); } + #endregion setIntervals } Index: CloseToCloseIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/CloseToCloseIntervals.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CloseToCloseIntervals.cs 23 Sep 2007 22:04:10 -0000 1.2 --- CloseToCloseIntervals.cs 25 Sep 2007 21:48:14 -0000 1.3 *************** *** 23,27 **** using System; - using QuantProject.ADT.Histories; using QuantProject.Business.Timing; --- 23,26 ---- *************** *** 33,37 **** public class CloseToCloseIntervals : ReturnIntervals { ! private int intervalLength = 1;//default intervals are daily /// <summary> --- 32,36 ---- public class CloseToCloseIntervals : ReturnIntervals { ! private int intervalLength; /// <summary> *************** *** 46,50 **** base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { ! } /// <summary> --- 45,49 ---- base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { ! this.intervalLength = 1;//default intervals are daily } /// <summary> *************** *** 63,76 **** base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { this.intervalLength = intervalLength; } #region setIntervals ! private void addInterval( History marketDaysForBenchmark , int i ) { DateTime dateTimeForIntervalBegin = ! (DateTime)marketDaysForBenchmark.GetKey( i ); DateTime dateTimeForIntervalEnd = ! (DateTime)marketDaysForBenchmark.GetKey( i + this.intervalLength ); ReturnInterval returnInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForIntervalBegin , --- 62,77 ---- base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { + if(intervalLength < 1) + throw new Exception("Interval length has to be greater than 0!"); this.intervalLength = intervalLength; } #region setIntervals ! private void addInterval( int i ) { DateTime dateTimeForIntervalBegin = ! (DateTime)this.marketDaysForBenchmark.GetKey( i ); DateTime dateTimeForIntervalEnd = ! (DateTime)this.marketDaysForBenchmark.GetKey( i + this.intervalLength ); ReturnInterval returnInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForIntervalBegin , *************** *** 80,97 **** this.Add( returnInterval ); } ! private void setIntervals( History marketDaysForBenchmark ) { for( int i = 0 ; ! i < marketDaysForBenchmark.Count - this.intervalLength; i = i + this.intervalLength ) ! this.addInterval( marketDaysForBenchmark , i ); ! } ! protected override void setIntervals() ! { ! History marketDaysForBenchmark = ! QuantProject.Data.DataTables.Quotes.GetMarketDays( this.benchmark , ! firstEndOfDayDateTime.DateTime , lastEndOfDayDateTime.DateTime ); ! this.setIntervals( marketDaysForBenchmark ); } #endregion setIntervals // private History getTimeLineForOptimization( EndOfDayDateTime now ) --- 81,92 ---- this.Add( returnInterval ); } ! protected override void setIntervals() { for( int i = 0 ; ! i < this.marketDaysForBenchmark.Count - this.intervalLength; i = i + this.intervalLength ) ! this.addInterval( i ); } + #endregion setIntervals // private History getTimeLineForOptimization( EndOfDayDateTime now ) |
|
From: Marco M. <mi...@us...> - 2007-09-23 22:09:40
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv8163/b7_Scripts/TickerSelectionTesting Modified Files: EndOfDayTimerHandlerCTC.cs EndOfDayTimerHandlerCTCWeekly.cs Log Message: Minor changes: added an empty handler for market open events Index: EndOfDayTimerHandlerCTCWeekly.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTCWeekly.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** EndOfDayTimerHandlerCTCWeekly.cs 29 Aug 2007 09:43:32 -0000 1.7 --- EndOfDayTimerHandlerCTCWeekly.cs 23 Sep 2007 22:09:34 -0000 1.8 *************** *** 68,71 **** --- 68,77 ---- } + public override void MarketOpenEventHandler( + Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) + { + ; + } + #region MarketCloseEventHandler Index: EndOfDayTimerHandlerCTC.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TickerSelectionTesting/EndOfDayTimerHandlerCTC.cs,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** EndOfDayTimerHandlerCTC.cs 29 Aug 2007 09:43:31 -0000 1.23 --- EndOfDayTimerHandlerCTC.cs 23 Sep 2007 22:09:24 -0000 1.24 *************** *** 83,86 **** --- 83,91 ---- } + public override void MarketOpenEventHandler( + Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) + { + ; + } #region MarketCloseEventHandler |
|
From: Marco M. <mi...@us...> - 2007-09-23 22:08:35
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/TrendFollowing/ImmediateTrendFollower In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7121/b7_Scripts/TechnicalAnalysisTesting/TrendFollowing/ImmediateTrendFollower Modified Files: EndOfDayTimerHandlerITF.cs Log Message: Minor changes: added an empty handler for market open events Index: EndOfDayTimerHandlerITF.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/TrendFollowing/ImmediateTrendFollower/EndOfDayTimerHandlerITF.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EndOfDayTimerHandlerITF.cs 29 Aug 2007 09:43:31 -0000 1.4 --- EndOfDayTimerHandlerITF.cs 23 Sep 2007 22:08:31 -0000 1.5 *************** *** 80,83 **** --- 80,88 ---- } + public override void MarketOpenEventHandler( + Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) + { + ; + } #region MarketCloseEventHandler |
|
From: Marco M. <mi...@us...> - 2007-09-23 22:08:03
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6196/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator Modified Files: EndOfDayTimerHandlerPVO.cs Log Message: Minor changes: added an empty handler for market open events Index: EndOfDayTimerHandlerPVO.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/FixedLevelOscillators/PortfolioValueOscillator/EndOfDayTimerHandlerPVO.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** EndOfDayTimerHandlerPVO.cs 29 Aug 2007 09:50:20 -0000 1.6 --- EndOfDayTimerHandlerPVO.cs 23 Sep 2007 22:07:57 -0000 1.7 *************** *** 106,109 **** --- 106,114 ---- } + public override void MarketOpenEventHandler( + Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) + { + ; + } #region MarketCloseEventHandler |
|
From: Marco M. <mi...@us...> - 2007-09-23 22:08:01
|
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6196/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend Modified Files: EndOfDayTimerHandlerECT.cs Log Message: Minor changes: added an empty handler for market open events Index: EndOfDayTimerHandlerECT.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/TechnicalAnalysisTesting/Oscillators/ExtremeCounterTrend/EndOfDayTimerHandlerECT.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** EndOfDayTimerHandlerECT.cs 29 Aug 2007 09:43:30 -0000 1.6 --- EndOfDayTimerHandlerECT.cs 23 Sep 2007 22:07:56 -0000 1.7 *************** *** 87,90 **** --- 87,96 ---- } + public override void MarketOpenEventHandler( + Object sender , EndOfDayTimingEventArgs endOfDayTimingEventArgs ) + { + ; + } + #region MarketCloseEventHandler |
|
From: Marco M. <mi...@us...> - 2007-09-23 22:04:24
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv2565/a2_Strategies/returnsManagement/time Modified Files: CloseToCloseIntervals.cs Log Message: Added a new constructor to the class, in order to set the IntervalLength for each return (each interval begins at a given market day "i" and ends at market day "i + intervalLength"). Default IntervalLength is equal to 1 (daily close to close intervals). Index: CloseToCloseIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/CloseToCloseIntervals.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CloseToCloseIntervals.cs 16 Sep 2007 21:38:05 -0000 1.1 --- CloseToCloseIntervals.cs 23 Sep 2007 22:04:10 -0000 1.2 *************** *** 33,36 **** --- 33,38 ---- public class CloseToCloseIntervals : ReturnIntervals { + private int intervalLength = 1;//default intervals are daily + /// <summary> /// Creates the close to close intervals for the given benchmark, from *************** *** 44,48 **** --- 46,69 ---- base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { + } + /// <summary> + /// Creates the close to close intervals for the given benchmark, from + /// the first EndOfDayDateTime to the last EndOfDayDateTime: + /// each interval begins at a given market day "i" and ends at + /// market day "i + intervalLength" + /// </summary> + /// <param name="firstEndOfDayDateTime"></param> + /// <param name="lastEndOfDayDateTime"></param> + /// <param name="benchmark"></param> + /// <param name="intervalLength"></param> + public CloseToCloseIntervals( EndOfDayDateTime firstEndOfDayDateTime , + EndOfDayDateTime lastEndOfDayDateTime , + string benchmark , int intervalLength ) : + base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) + { + this.intervalLength = intervalLength; + } + #region setIntervals private void addInterval( History marketDaysForBenchmark , int i ) *************** *** 51,55 **** (DateTime)marketDaysForBenchmark.GetKey( i ); DateTime dateTimeForIntervalEnd = ! (DateTime)marketDaysForBenchmark.GetKey( i + 1 ); ReturnInterval returnInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForIntervalBegin , --- 72,76 ---- (DateTime)marketDaysForBenchmark.GetKey( i ); DateTime dateTimeForIntervalEnd = ! (DateTime)marketDaysForBenchmark.GetKey( i + this.intervalLength ); ReturnInterval returnInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForIntervalBegin , *************** *** 61,65 **** private void setIntervals( History marketDaysForBenchmark ) { ! for( int i = 0 ; i < marketDaysForBenchmark.Count - 1 ; i++ ) this.addInterval( marketDaysForBenchmark , i ); } --- 82,88 ---- private void setIntervals( History marketDaysForBenchmark ) { ! for( int i = 0 ; ! i < marketDaysForBenchmark.Count - this.intervalLength; ! i = i + this.intervalLength ) this.addInterval( marketDaysForBenchmark , i ); } |
|
From: Marco M. <mi...@us...> - 2007-09-23 21:55:01
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv30858/a2_Strategies Modified Files: WeightedPositions.cs Log Message: Simplified the code using the indexer syntax (no need to cast) Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/WeightedPositions.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** WeightedPositions.cs 16 Sep 2007 22:10:17 -0000 1.8 --- WeightedPositions.cs 23 Sep 2007 21:54:57 -0000 1.9 *************** *** 600,604 **** double returnValue = 0.0; for(int i = 0; i<weightedPositionsLastNightReturns.Length; i++) ! returnValue += weightedPositionsLastNightReturns[i]*((WeightedPosition)this[i]).Weight; return returnValue; } --- 600,604 ---- double returnValue = 0.0; for(int i = 0; i<weightedPositionsLastNightReturns.Length; i++) ! returnValue += weightedPositionsLastNightReturns[i] * this[i].Weight; return returnValue; } *************** *** 625,629 **** weightedPositionsLastNightReturns[i] = this.getLastNightReturn_getLastNightReturnForTicker( ! ((WeightedPosition)this[i]).Ticker, lastMarketDay, today ); return getLastNightReturn( weightedPositionsLastNightReturns ); } --- 625,629 ---- weightedPositionsLastNightReturns[i] = this.getLastNightReturn_getLastNightReturnForTicker( ! this[i].Ticker, lastMarketDay, today ); return getLastNightReturn( weightedPositionsLastNightReturns ); } |
|
From: Marco M. <mi...@us...> - 2007-09-23 21:53:23
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv30380/a2_Strategies Modified Files: AccountManager.cs Log Message: In OpenPositions method, some cash is added if the account has no cash and no transaction has been made Index: AccountManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/AccountManager.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AccountManager.cs 30 Aug 2007 13:34:27 -0000 1.2 --- AccountManager.cs 23 Sep 2007 21:53:20 -0000 1.3 *************** *** 89,93 **** Account account) { ! if(weightedPositions == null || account == null) throw new Exception("Both parameters have to be set to valid objects!"); orders.Clear(); --- 89,95 ---- Account account) { ! if(account.CashAmount == 0.0 && account.Transactions.Count == 0) ! account.AddCash(15000); ! if(weightedPositions == null || account == null) throw new Exception("Both parameters have to be set to valid objects!"); orders.Clear(); |
|
From: Marco M. <mi...@us...> - 2007-09-23 21:51:01
|
Update of /cvsroot/quantproject/QuantProject/b4_Business In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv29152 Modified Files: b4_Business.csproj Log Message: Added CloseToOpenIntervals, DailyOpenToCloseIntervals (the name will be changed soon) and OpenToCloseCloseToOpenIntervals Index: b4_Business.csproj =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/b4_Business.csproj,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** b4_Business.csproj 16 Sep 2007 21:45:21 -0000 1.47 --- b4_Business.csproj 23 Sep 2007 21:50:55 -0000 1.48 *************** *** 2,6 **** <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9466" SchemaVersion = "1.0" ProjectGuid = "{6EE31501-376E-491B-869E-F06D5B7C9C30}" --- 2,6 ---- <CSHARP ProjectType = "Local" ! ProductVersion = "7.0.9955" SchemaVersion = "1.0" ProjectGuid = "{6EE31501-376E-491B-869E-F06D5B7C9C30}" *************** *** 688,691 **** --- 688,706 ---- /> <File + RelPath = "a2_Strategies\returnsManagement\time\CloseToOpenIntervals.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "a2_Strategies\returnsManagement\time\DailyOpenToCloseIntervals.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "a2_Strategies\returnsManagement\time\OpenToCloseCloseToOpenIntervals.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "a2_Strategies\returnsManagement\time\ReturnInterval.cs" SubType = "Code" |
|
From: Marco M. <mi...@us...> - 2007-09-23 21:46:36
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv27047 Added Files: OpenToCloseCloseToOpenIntervals.cs Log Message: Added OpenToCloseCloseToOpenIntervals for computation of OpenToClose CloseToOpen returns (returns where an open to close return is followed by the next close to open return, and this is followed by the next open to close return, and so on) --- NEW FILE: OpenToCloseCloseToOpenIntervals.cs --- /* QuantProject - Quantitative Finance Library OpenToCloseCloseToOpenIntervals.cs Copyright (C) 2007 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Histories; using QuantProject.Business.Timing; namespace QuantProject.Business.Strategies.ReturnsManagement.Time { /// <summary> /// Open to Close - Close to Open intervals, to be used /// to compute returns where an open to close return is followed /// by the next close to open return, and this is followed /// by the next open to close return, and so on /// </summary> public class OpenToCloseCloseToOpenIntervals : ReturnIntervals { /// <summary> /// Creates the OTC-CTO intervals for the given benchmark, from /// the first EndOfDayDateTime to the last EndOfDayDateTime /// </summary> /// <param name="firstEndOfDayDateTime"></param> /// <param name="lastEndOfDayDateTime"></param> /// <param name="benchmark"></param> public OpenToCloseCloseToOpenIntervals( EndOfDayDateTime firstEndOfDayDateTime , EndOfDayDateTime lastEndOfDayDateTime , string benchmark ) : base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { } #region setIntervals private void addInterval( History marketDaysForBenchmark , int i ) { //adds the open to close interval DateTime dateTimeForOTC = (DateTime)marketDaysForBenchmark.GetKey( i ); ReturnInterval returnOTCInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForOTC , EndOfDaySpecificTime.MarketOpen ) , new EndOfDayDateTime( dateTimeForOTC , EndOfDaySpecificTime.MarketClose ) ); this.Add( returnOTCInterval ); //adds the following close to open interval DateTime dateTimeForCTOEnd = (DateTime)marketDaysForBenchmark.GetKey( i + 1 ); ReturnInterval returnCTOInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForOTC , EndOfDaySpecificTime.MarketClose ) , new EndOfDayDateTime( dateTimeForCTOEnd , EndOfDaySpecificTime.MarketOpen ) ); this.Add( returnCTOInterval ); } private void setIntervals( History marketDaysForBenchmark ) { for( int i = 0 ; i < marketDaysForBenchmark.Count - 1 ; i++ ) this.addInterval( marketDaysForBenchmark , i ); } protected override void setIntervals() { History marketDaysForBenchmark = QuantProject.Data.DataTables.Quotes.GetMarketDays( this.benchmark , firstEndOfDayDateTime.DateTime , lastEndOfDayDateTime.DateTime ); this.setIntervals( marketDaysForBenchmark ); } #endregion setIntervals } } |
|
From: Marco M. <mi...@us...> - 2007-09-23 21:44:42
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26137 Added Files: CloseToOpenIntervals.cs Log Message: Added CloseToOpenIntervals for computation of CloseToOpen returns --- NEW FILE: CloseToOpenIntervals.cs --- /* QuantProject - Quantitative Finance Library CloseToOpenIntervals.cs Copyright (C) 2007 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Histories; using QuantProject.Business.Timing; namespace QuantProject.Business.Strategies.ReturnsManagement.Time { /// <summary> /// Close to Open intervals to be used to compute close to open returns /// </summary> public class CloseToOpenIntervals : ReturnIntervals { /// <summary> /// Creates the close to open intervals for the given benchmark, from /// the first EndOfDayDateTime to the last EndOfDayDateTime /// </summary> /// <param name="firstEndOfDayDateTime"></param> /// <param name="lastEndOfDayDateTime"></param> /// <param name="benchmark"></param> public CloseToOpenIntervals( EndOfDayDateTime firstEndOfDayDateTime , EndOfDayDateTime lastEndOfDayDateTime , string benchmark ) : base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { } #region setIntervals private void addInterval( History marketDaysForBenchmark , int i ) { DateTime dateTimeForIntervalBegin = (DateTime)marketDaysForBenchmark.GetKey( i ); DateTime dateTimeForIntervalEnd = (DateTime)marketDaysForBenchmark.GetKey( i + 1 ); ReturnInterval returnInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForIntervalBegin , EndOfDaySpecificTime.MarketClose ) , new EndOfDayDateTime( dateTimeForIntervalEnd , EndOfDaySpecificTime.MarketOpen ) ); this.Add( returnInterval ); } private void setIntervals( History marketDaysForBenchmark ) { for( int i = 0 ; i < marketDaysForBenchmark.Count - 1 ; i++ ) this.addInterval( marketDaysForBenchmark , i ); } protected override void setIntervals() { History marketDaysForBenchmark = QuantProject.Data.DataTables.Quotes.GetMarketDays( this.benchmark , firstEndOfDayDateTime.DateTime , lastEndOfDayDateTime.DateTime ); this.setIntervals( marketDaysForBenchmark ); } #endregion setIntervals } } |
|
From: Glauco S. <gla...@us...> - 2007-09-23 16:24:56
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv655/b4_Business/a2_Strategies/returnsManagement Modified Files: ReturnsManager.cs Log Message: Fixed bug: the last interval was not considered at all. Finally, I'm getting the very same result for scripts as I got with the previous version (I mean, the version just before intervals' classes have been introduced). Millo, please note that this bug affected ALL your latest scripts' run. I'm afraid you will need to run them again to see their real behavior. Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ReturnsManager.cs 19 Sep 2007 22:29:04 -0000 1.5 --- ReturnsManager.cs 23 Sep 2007 16:24:45 -0000 1.6 *************** *** 149,153 **** float[] returnsWithRespectToTheGivenIntervals = new float[ this.returnIntervals.Count ]; ! for ( int i = 0 ; i < this.returnIntervals.Count - 1 ; i++ ) returnsWithRespectToTheGivenIntervals[ i ] = this.selectReturnWithRespectToTheGivenIterval( endOfDayQuotes , i ); --- 149,153 ---- float[] returnsWithRespectToTheGivenIntervals = new float[ this.returnIntervals.Count ]; ! for ( int i = 0 ; i < this.returnIntervals.Count ; i++ ) returnsWithRespectToTheGivenIntervals[ i ] = this.selectReturnWithRespectToTheGivenIterval( endOfDayQuotes , i ); |
|
From: Marco M. <mi...@us...> - 2007-09-20 22:33:39
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv13491/time Modified Files: DailyOpenToCloseIntervals.cs Log Message: Fixed bug in DailyOpenToCloseIntervals: a ReturnInterval should be added for each MarketDay for the given benchmark for the given period (also for the last MarketDay. In the case of CloseToCloseInterval you can't add an interval for the last benchmark market day). Index: DailyOpenToCloseIntervals.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time/DailyOpenToCloseIntervals.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DailyOpenToCloseIntervals.cs 19 Sep 2007 22:36:37 -0000 1.1 --- DailyOpenToCloseIntervals.cs 20 Sep 2007 22:33:35 -0000 1.2 *************** *** 60,64 **** private void setIntervals( History marketDaysForBenchmark ) { ! for( int i = 0 ; i < marketDaysForBenchmark.Count - 1 ; i++ ) this.addInterval( marketDaysForBenchmark , i ); } --- 60,64 ---- private void setIntervals( History marketDaysForBenchmark ) { ! for( int i = 0 ; i < marketDaysForBenchmark.Count ; i++ ) this.addInterval( marketDaysForBenchmark , i ); } |
|
From: Marco M. <mi...@us...> - 2007-09-19 22:36:43
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/time In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv24182/time Added Files: DailyOpenToCloseIntervals.cs Log Message: Added DailyOpenToCloseIntervals: (in the future it could be replaced by a more general OpenToCloseIntervals implementing multiday OTC intervals) --- NEW FILE: DailyOpenToCloseIntervals.cs --- /* QuantProject - Quantitative Finance Library DailyOpenToCloseIntervals.cs Copyright (C) 2007 Marco Milletti This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ using System; using QuantProject.ADT.Histories; using QuantProject.Business.Timing; namespace QuantProject.Business.Strategies.ReturnsManagement.Time { /// <summary> /// Open to close intervals to be used to compute open to close returns /// </summary> public class DailyOpenToCloseIntervals : ReturnIntervals { /// <summary> /// Creates the open to close intervals for the given benchmark, from /// the first EndOfDayDateTime to the last EndOfDayDateTime /// </summary> /// <param name="firstEndOfDayDateTime"></param> /// <param name="lastEndOfDayDateTime"></param> /// <param name="benchmark"></param> public DailyOpenToCloseIntervals( EndOfDayDateTime firstEndOfDayDateTime , EndOfDayDateTime lastEndOfDayDateTime , string benchmark ) : base( firstEndOfDayDateTime , lastEndOfDayDateTime , benchmark ) { } #region setIntervals private void addInterval( History marketDaysForBenchmark , int i ) { DateTime dateTimeForIntervalBegin = (DateTime)marketDaysForBenchmark.GetKey( i ); DateTime dateTimeForIntervalEnd = dateTimeForIntervalBegin; ReturnInterval returnInterval = new ReturnInterval( new EndOfDayDateTime( dateTimeForIntervalBegin , EndOfDaySpecificTime.MarketOpen ) , new EndOfDayDateTime( dateTimeForIntervalEnd , EndOfDaySpecificTime.MarketClose ) ); this.Add( returnInterval ); } private void setIntervals( History marketDaysForBenchmark ) { for( int i = 0 ; i < marketDaysForBenchmark.Count - 1 ; i++ ) this.addInterval( marketDaysForBenchmark , i ); } protected override void setIntervals() { History marketDaysForBenchmark = QuantProject.Data.DataTables.Quotes.GetMarketDays( this.benchmark , firstEndOfDayDateTime.DateTime , lastEndOfDayDateTime.DateTime ); this.setIntervals( marketDaysForBenchmark ); } #endregion setIntervals } } |
|
From: Marco M. <mi...@us...> - 2007-09-19 22:29:09
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14539/b4_Business/a2_Strategies/returnsManagement Modified Files: ReturnsManager.cs Log Message: Fixed bug in ReturnsManager: terms in calculation of the return for the given interval were inverted. Please Glauco check ... Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReturnsManager.cs 16 Sep 2007 22:00:27 -0000 1.4 --- ReturnsManager.cs 19 Sep 2007 22:29:04 -0000 1.5 *************** *** 139,143 **** double firstQuote = (double)endOfDayQuotes[ returnInterval.Begin ]; double lastQuote = (double)endOfDayQuotes[ returnInterval.End ]; ! float intervalReturn = Convert.ToSingle( firstQuote / lastQuote - 1 ); return intervalReturn; } --- 139,143 ---- double firstQuote = (double)endOfDayQuotes[ returnInterval.Begin ]; double lastQuote = (double)endOfDayQuotes[ returnInterval.End ]; ! float intervalReturn = Convert.ToSingle( lastQuote / firstQuote - 1 ); return intervalReturn; } |
|
From: Marco M. <mi...@us...> - 2007-09-18 22:42:14
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv7542/b4_Business/a07_DataProviders Modified Files: HistoricalQuoteProvider.cs Log Message: Added Serializable attribute to the class Index: HistoricalQuoteProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalQuoteProvider.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HistoricalQuoteProvider.cs 16 Sep 2007 21:32:19 -0000 1.1 --- HistoricalQuoteProvider.cs 18 Sep 2007 22:42:08 -0000 1.2 *************** *** 30,33 **** --- 30,34 ---- /// Abstract base class for historical quotes providers /// </summary> + [Serializable] public abstract class HistoricalQuoteProvider : IHistoricalQuoteProvider { |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6744/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio Modified Files: WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs Log Message: A ReturnsManager is now used instead of a CloseToCloseReturnsManager. Furthermore, a ReturnIntervals object (named returnIntervalsForOptimization) is now used instead of a history object (that was named timeLineForOptimization) Index: WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio/WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs 27 Aug 2007 22:24:21 -0000 1.5 --- WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio.cs 16 Sep 2007 22:17:18 -0000 1.6 *************** *** 28,34 **** --- 28,36 ---- using QuantProject.ADT.Optimizing.Genetic; using QuantProject.ADT.Statistics; + using QuantProject.Business.DataProviders; using QuantProject.Business.Financial.Accounting; using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.ReturnsManagement; + using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Strategies.EquityEvaluation; *************** *** 48,53 **** private int numberOfDrivingPositions; private SignedTickers portfolioSignedTickers; ! private History timeLineForOptimization; // this time line goes from ! // the first optimization date for driving positions to the // last optimization date; this optimization is meant to be // launched one hour after the last market close --- 50,55 ---- private int numberOfDrivingPositions; private SignedTickers portfolioSignedTickers; ! private ReturnIntervals returnIntervalsForOptimization; // this time line ! // goes from the first optimization date for driving positions to the // last optimization date; this optimization is meant to be // launched one hour after the last market close *************** *** 69,73 **** private WFLagMeaningForUndecodableGenomes wFLagMeaningForUndecodableGenomes; private string[] tickersForPortfolioPositions; ! private CloseToCloseReturnsManager closeToCloseReturnsManager; --- 71,75 ---- private WFLagMeaningForUndecodableGenomes wFLagMeaningForUndecodableGenomes; private string[] tickersForPortfolioPositions; ! private ReturnsManager closeToCloseReturnsManager; *************** *** 100,104 **** DataTable eligibleTickersForDrivingWeightedPositions , SignedTickers portfolioSignedTickers , ! History timeLineForOptimization , IEquityEvaluator equityEvaluator , int seedForRandomGenerator ) --- 102,106 ---- DataTable eligibleTickersForDrivingWeightedPositions , SignedTickers portfolioSignedTickers , ! ReturnIntervals returnIntervalsForOptimization , IEquityEvaluator equityEvaluator , int seedForRandomGenerator ) *************** *** 113,117 **** // eligibleTickersForPortfolioWeightedPositions; this.portfolioSignedTickers = portfolioSignedTickers; ! this.timeLineForOptimization = timeLineForOptimization; // this.minimumPositionWeight = 0.2; // TO DO this value should become a constructor parameter --- 115,119 ---- // eligibleTickersForPortfolioWeightedPositions; this.portfolioSignedTickers = portfolioSignedTickers; ! this.returnIntervalsForOptimization = returnIntervalsForOptimization; // this.minimumPositionWeight = 0.2; // TO DO this value should become a constructor parameter *************** *** 125,134 **** // 11 ); GenomeManagement.SetRandomGenerator( seedForRandomGenerator ); ! ! // this.wFLagCandidates = new WFLagCandidates( ! // this.eligibleTickersForDrivingWeightedPositions , ! // this.firstOptimizationDateForDrivingPositions , this.lastOptimizationDate ); this.closeToCloseReturnsManager = ! new CloseToCloseReturnsManager( this.timeLineForOptimization ); this.wFLagMeaningForUndecodableGenomes = --- 127,135 ---- // 11 ); GenomeManagement.SetRandomGenerator( seedForRandomGenerator ); ! IHistoricalQuoteProvider historicalQuoteProvider = ! new HistoricalAdjustedQuoteProvider(); this.closeToCloseReturnsManager = ! new ReturnsManager( this.returnIntervalsForOptimization , ! historicalQuoteProvider ); this.wFLagMeaningForUndecodableGenomes = |
Update of /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1959/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio Modified Files: WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs Log Message: CloseToCloseIntervals is now used instead of timeLineForOptimization (that was an History) Index: WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b7_Scripts/WalkForwardTesting/WalkForwardLag/WeightedPositionsChoosers/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio/WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs 7 Aug 2007 16:54:17 -0000 1.6 --- WFLagGeneticFixedPortfolioWithNormalDrivingAndPortfolio.cs 16 Sep 2007 22:12:48 -0000 1.7 *************** *** 28,31 **** --- 28,32 ---- using QuantProject.Business.Strategies; using QuantProject.Business.Strategies.EquityEvaluation; + using QuantProject.Business.Strategies.ReturnsManagement.Time; using QuantProject.Business.Timing; using QuantProject.Data.DataTables; *************** *** 127,131 **** } #region setChosenPositions_usingTheGeneticOptimizer ! private History getTimeLineForOptimization( EndOfDayDateTime now ) { DateTime firstInSampleDateForDrivingPositions = --- 128,132 ---- } #region setChosenPositions_usingTheGeneticOptimizer ! private ReturnIntervals getReturnIntervals( EndOfDayDateTime now ) { DateTime firstInSampleDateForDrivingPositions = *************** *** 134,139 **** DateTime lastInSampleOptimizationDate = now.DateTime; ! return Quotes.GetMarketDays( this.benchmark , ! firstInSampleDateForDrivingPositions , lastInSampleOptimizationDate ); } private void newGenerationEventHandler( --- 135,146 ---- DateTime lastInSampleOptimizationDate = now.DateTime; ! ReturnIntervals returnIntervals = ! new CloseToCloseIntervals( ! new EndOfDayDateTime( firstInSampleDateForDrivingPositions , ! EndOfDaySpecificTime.MarketClose ) , ! new EndOfDayDateTime( lastInSampleOptimizationDate , ! EndOfDaySpecificTime.MarketClose ) , ! this.benchmark ); ! return returnIntervals; } private void newGenerationEventHandler( *************** *** 182,187 **** EndOfDayDateTime now ) { ! History timeLineForOptimization = ! this.getTimeLineForOptimization( now ); WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio --- 189,194 ---- EndOfDayDateTime now ) { ! ReturnIntervals returnIntervals = ! this.getReturnIntervals( now ); WFLagGenomeManagerForFixedPortfolioWithNormalDrivingAndPortfolio *************** *** 191,195 **** eligibleTickersForDrivingPositions.EligibleTickers , this.portfolioSignedTickers , ! timeLineForOptimization , this.equityEvaluator , QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator ); --- 198,202 ---- eligibleTickersForDrivingPositions.EligibleTickers , this.portfolioSignedTickers , ! returnIntervals , this.equityEvaluator , QuantProject.ADT.ConstantsProvider.SeedForRandomGenerator ); |
|
From: Glauco S. <gla...@us...> - 2007-09-16 22:10:26
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31835/b4_Business/a2_Strategies Modified Files: WeightedPositions.cs Log Message: returnsManager.ReturnIntervals.Count is now used instead of returnsManager.TimeLine.Count Index: WeightedPositions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/WeightedPositions.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WeightedPositions.cs 5 Sep 2007 22:07:19 -0000 1.7 --- WeightedPositions.cs 16 Sep 2007 22:10:17 -0000 1.8 *************** *** 504,509 **** ReturnsManager returnsManager ) { ! if ( ( i < 0 ) || ( i > returnsManager.TimeLine.Count - 2 ) ) ! throw new Exception( "i is larger than the number of returns" ); } private float getTickerReturn( string ticker , int i , --- 504,509 ---- ReturnsManager returnsManager ) { ! if ( ( i < 0 ) || ( i > returnsManager.ReturnIntervals.Count - 1 ) ) ! throw new Exception( "i is larger than the max return index" ); } private float getTickerReturn( string ticker , int i , *************** *** 572,576 **** { float[] returns = new float[ ! returnsManager.TimeLine.Count - 1 ]; for ( int i = 0 ; i < returnsManager.NumberOfReturns ; i++ ) returns[ i ] = this.GetReturn( i , returnsManager ); --- 572,576 ---- { float[] returns = new float[ ! returnsManager.ReturnIntervals.Count ]; for ( int i = 0 ; i < returnsManager.NumberOfReturns ; i++ ) returns[ i ] = this.GetReturn( i , returnsManager ); |
|
From: Glauco S. <gla...@us...> - 2007-09-16 22:00:41
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv23667/b4_Business/a2_Strategies/returnsManagement Modified Files: ReturnsManager.cs Log Message: - in the previous version, this class was an abstract class (returns where actually computed by classes inheriting ReturnsManager) - in this version, instead, this class itself computes returns - now, an object of type ReturnIntervals must be given to the constructor: returns will be computed on such intervals - now, a IHistoricalQuoteProvider is also required by the constructor: this way, it can be decided either to use adjusted quotes or raw quotes Index: ReturnsManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a2_Strategies/returnsManagement/ReturnsManager.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReturnsManager.cs 4 Aug 2007 19:59:08 -0000 1.3 --- ReturnsManager.cs 16 Sep 2007 22:00:27 -0000 1.4 *************** *** 27,30 **** --- 27,33 ---- using QuantProject.ADT.Histories; using QuantProject.ADT.Statistics; + using QuantProject.Business.DataProviders; + using QuantProject.Business.Strategies.ReturnsManagement.Time; + using QuantProject.Business.Timing; using QuantProject.Data.DataTables; *************** *** 32,42 **** { /// <summary> ! /// This abstract class is used to keep and provide, in an efficient ! /// way, array of returns (to be used by in sample optimizations) /// </summary> ! public abstract class ReturnsManager { ! protected History timeLineForQuotes; // if we have n market days for quotes, ! // we will then have n-1 returns private Set tickersMissingQuotes; --- 35,46 ---- { /// <summary> ! /// This class is used to keep and provide, in an efficient ! /// way, array of returns on EndOfDayIntervals (to be used ! /// by in sample optimizations) /// </summary> ! public class ReturnsManager { ! private ReturnIntervals returnIntervals; // a return for each interval ! private IHistoricalQuoteProvider historicalQuoteProvider; private Set tickersMissingQuotes; *************** *** 46,77 **** /// <summary> ! /// Dates when quotes are computed. If TimeLine contains ! /// n elements, then returns are n-1 elements /// </summary> ! public History TimeLine { ! get { return this.timeLineForQuotes; } } /// <summary> ! /// Number of returns, that is TimeLine's elements minus 1 /// </summary> public int NumberOfReturns { ! get { return this.TimeLine.Count - 1; } ! } ! protected DateTime firstDateTime ! { ! get { return this.timeLineForQuotes.GetDateTime( 0 ); } ! } ! protected DateTime lastDateTime ! { ! get ! { ! int lastIndex = this.timeLineForQuotes.Count - 1; ! return this.timeLineForQuotes.GetDateTime( lastIndex ); ! } } ! /// <summary> /// Abstract class used to store and efficiently provide arrays of --- 50,80 ---- /// <summary> ! /// End of day intervals on which returns are computed /// </summary> ! public ReturnIntervals ReturnIntervals { ! get { return this.returnIntervals; } } /// <summary> ! /// Number of returns, that is number of intervals /// </summary> public int NumberOfReturns { ! get { return this.returnIntervals.Count; } } ! // protected DateTime firstDateTime ! // { ! // get { return this.timeLineForQuotes.GetDateTime( 0 ); } ! // } ! // protected DateTime lastDateTime ! // { ! // get ! // { ! // int lastIndex = this.timeLineForQuotes.Count - 1; ! // return this.timeLineForQuotes.GetDateTime( lastIndex ); ! // } ! // } ! // /// <summary> /// Abstract class used to store and efficiently provide arrays of *************** *** 87,103 **** /// for the benchmark, each array of returns will have exactly /// n-1 elements</param> ! public ReturnsManager( DateTime firstDate , DateTime lastDate , ! string benchmark ) ! { ! // TO DO: let WFLagEligibleTickers use this class also!!! ! this.timeLineForQuotes = ! this.getMarketDaysForQuotes( firstDate , lastDate , benchmark ); ! this.commonInitialization(); ! } ! public ReturnsManager( History timeLine ) { // TO DO: let WFLagEligibleTickers use this class also!!! ! this.timeLineForQuotes = timeLine; this.commonInitialization(); } private void commonInitialization() --- 90,108 ---- /// for the benchmark, each array of returns will have exactly /// n-1 elements</param> ! // public ReturnsManager( DateTime firstDate , DateTime lastDate , ! // string benchmark ) ! // { ! // // TO DO: let WFLagEligibleTickers use this class also!!! ! // this.timeLineForQuotes = ! // this.getMarketDaysForQuotes( firstDate , lastDate , benchmark ); ! // this.commonInitialization(); ! // } ! public ReturnsManager( ReturnIntervals returnIntervals , ! IHistoricalQuoteProvider historicalQuoteProvider ) { // TO DO: let WFLagEligibleTickers use this class also!!! ! this.returnIntervals = returnIntervals; this.commonInitialization(); + this.historicalQuoteProvider = historicalQuoteProvider; } private void commonInitialization() *************** *** 117,121 **** private bool isAValidIndexForAReturn( int index ) { ! return ( ( index >= 0 ) && ( index <= this.TimeLine.Count - 2 ) ); } #region GetReturns --- 122,127 ---- private bool isAValidIndexForAReturn( int index ) { ! return ( ( index >= 0 ) && ! ( index <= this.ReturnIntervals.Count - 1 ) ); } #region GetReturns *************** *** 124,166 **** return this.tickersReturns.ContainsKey( ticker ); } ! protected abstract History getQuotes( string ticker ); #region setReturns ! private bool areMarketDaysForQuotesAllCovered( History returns ) ! { ! bool areAllCovered = true; ! foreach ( DateTime dateTime in this.timeLineForQuotes.TimeLine ) ! if ( !returns.ContainsKey( dateTime ) ) ! areAllCovered = false; ! return areAllCovered; ! } ! private float selectReturnWithRespectToTheTimeLine( History quotes , ! int i ) { ! float currentQuote = (float)quotes.GetByIndex( i ); ! float nextQuote = (float)quotes.GetByIndex( i + 1 ); ! float currentReturn = nextQuote / currentQuote - 1; ! return currentReturn; } ! private float[] selectReturnsWithRespectToTheTimeLine( History quotes ) { // TO DO: this method is n log n, it could be implemented to // be have a linear complexity!!! ! float[] returnsWithRespectToTheTimeLine = ! new float[ this.timeLineForQuotes.Count - 1 ]; ! for ( int i = 0 ; i < this.timeLineForQuotes.Count - 1 ; i++ ) ! returnsWithRespectToTheTimeLine[ i ] = ! this.selectReturnWithRespectToTheTimeLine( quotes , i ); ! return returnsWithRespectToTheTimeLine; } ! private void setReturnsActually( string ticker , History quotes ) { float[] arrayOfReturns = ! this.selectReturnsWithRespectToTheTimeLine( quotes ); this.tickersReturns.Add( ticker , arrayOfReturns ); } ! private void setReturns( string ticker , History quotes ) { ! if ( this.areMarketDaysForQuotesAllCovered( quotes ) ) ! this.setReturnsActually( ticker , quotes ); else this.tickersMissingQuotes.Add( ticker ); --- 130,170 ---- return this.tickersReturns.ContainsKey( ticker ); } ! // protected abstract History getQuotes( string ticker ); #region setReturns ! private float selectReturnWithRespectToTheGivenIterval( ! EndOfDayHistory endOfDayQuotes , int i ) { ! ReturnInterval returnInterval = ! this.returnIntervals[ i ]; ! double firstQuote = (double)endOfDayQuotes[ returnInterval.Begin ]; ! double lastQuote = (double)endOfDayQuotes[ returnInterval.End ]; ! float intervalReturn = Convert.ToSingle( firstQuote / lastQuote - 1 ); ! return intervalReturn; } ! private float[] selectReturnsWithRespectToTheGivenIntervals( ! EndOfDayHistory endOfDayQuotes ) { // TO DO: this method is n log n, it could be implemented to // be have a linear complexity!!! ! float[] returnsWithRespectToTheGivenIntervals = ! new float[ this.returnIntervals.Count ]; ! for ( int i = 0 ; i < this.returnIntervals.Count - 1 ; i++ ) ! returnsWithRespectToTheGivenIntervals[ i ] = ! this.selectReturnWithRespectToTheGivenIterval( endOfDayQuotes , i ); ! return returnsWithRespectToTheGivenIntervals; } ! private void setReturnsActually( string ticker , ! EndOfDayHistory endOfDayQuotes ) { float[] arrayOfReturns = ! this.selectReturnsWithRespectToTheGivenIntervals( endOfDayQuotes ); this.tickersReturns.Add( ticker , arrayOfReturns ); } ! private void setReturns( string ticker , ! EndOfDayHistory endOfDayQuotes ) { ! if ( this.returnIntervals.AreIntervalBordersAllCoveredBy( ! endOfDayQuotes ) ) ! this.setReturnsActually( ticker , endOfDayQuotes ); else this.tickersMissingQuotes.Add( ticker ); *************** *** 168,173 **** private void setReturns( string ticker ) { ! History quotes = this.getQuotes( ticker ); ! this.setReturns( ticker , quotes ); } #endregion setReturns --- 172,183 ---- private void setReturns( string ticker ) { ! // EndOfDayDateTime firstEndOfDayDateTime = ! // this.returnIntervals[ 0 ].Begin; ! // EndOfDayDateTime lastEndOfDayDateTime = ! // this.returnIntervals.LastEndOfDayDateTime; ! EndOfDayHistory endOfDayQuotes = ! this.historicalQuoteProvider.GetEndOfDayQuotes( ticker , ! this.returnIntervals.BordersHistory ); ! this.setReturns( ticker , endOfDayQuotes ); } #endregion setReturns |
|
From: Glauco S. <gla...@us...> - 2007-09-16 21:54:43
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20998/b4_Business/a07_DataProviders Modified Files: HistoricalRawQuoteProvider.cs Log Message: This class inherits the HistoricalQuoteProvider class now (in the previous version, it directly implemented the IHistoricalQuoteProvider interface) Index: HistoricalRawQuoteProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalRawQuoteProvider.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HistoricalRawQuoteProvider.cs 6 Feb 2005 20:10:18 -0000 1.2 --- HistoricalRawQuoteProvider.cs 16 Sep 2007 21:54:40 -0000 1.3 *************** *** 32,41 **** /// </summary> [Serializable] ! public class HistoricalRawQuoteProvider : IHistoricalQuoteProvider { public HistoricalRawQuoteProvider() { } ! public double GetMarketValue( string instrumentKey , EndOfDayDateTime endOfDayDateTime ) { --- 32,41 ---- /// </summary> [Serializable] ! public class HistoricalRawQuoteProvider : HistoricalQuoteProvider { public HistoricalRawQuoteProvider() { } ! public override double GetMarketValue( string instrumentKey , EndOfDayDateTime endOfDayDateTime ) { |
|
From: Glauco S. <gla...@us...> - 2007-09-16 21:53:56
|
Update of /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20577/b4_Business/a07_DataProviders Modified Files: HistoricalAdjustedQuoteProvider.cs Log Message: This class inherits the HistoricalQuoteProvider class now (in the previous version, it directly implemented the IHistoricalQuoteProvider interface) Index: HistoricalAdjustedQuoteProvider.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b4_Business/a07_DataProviders/HistoricalAdjustedQuoteProvider.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HistoricalAdjustedQuoteProvider.cs 30 Jan 2005 19:57:38 -0000 1.2 --- HistoricalAdjustedQuoteProvider.cs 16 Sep 2007 21:53:53 -0000 1.3 *************** *** 32,41 **** /// </summary> [Serializable] ! public class HistoricalAdjustedQuoteProvider : IHistoricalQuoteProvider { public HistoricalAdjustedQuoteProvider() { } ! public double GetMarketValue( string instrumentKey , EndOfDayDateTime endOfDayDateTime ) { --- 32,41 ---- /// </summary> [Serializable] ! public class HistoricalAdjustedQuoteProvider : HistoricalQuoteProvider { public HistoricalAdjustedQuoteProvider() { } ! public override double GetMarketValue( string instrumentKey , EndOfDayDateTime endOfDayDateTime ) { |