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