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
}
}
|