Table of Contents

Class DateSeries

Namespace
Balsam
Assembly
Balsam.Backtester.dll

Encapsulates series of dates conforming to ISeries interface.

public class DateSeries : ISeries, IEnumerable<DateTime>, IEnumerable
Inheritance
DateSeries
Implements
Inherited Members
Extension Methods

Constructors

DateSeries()

Instantiates an empty DateSeries.

public DateSeries()

DateSeries(IEnumerable<DateTime>)

Instantiates a new DateSeries using the specified enumerable of dates.

public DateSeries(IEnumerable<DateTime> dates)

Parameters

dates IEnumerable<DateTime>

DateSeries(int)

Instantiates a new DateSeries of the specified capacity.

public DateSeries(int capacity)

Parameters

capacity int

Properties

Count

Gets the number of dates in the collection.

public int Count { get; }

Property Value

int

CurrentDate

Gets the current date if concurrency is being maintained, otherwise returns DateTime.MinValue.

public DateTime CurrentDate { get; }

Property Value

DateTime

FirstDate

Gets the first date on which valid data is available.

public DateTime FirstDate { get; }

Property Value

DateTime

Index

Gets the current index.

public int Index { get; }

Property Value

int

Indexing

Gets the indexing strategy currently being used.

public IndexKind Indexing { get; }

Property Value

IndexKind

this[int]

Gets the date of the specified index value according to the indexing strategy employed (Absolute, RelativeToCurrentBar).

public DateTime this[int index] { get; }

Parameters

index int

Property Value

DateTime

LastDate

Gets the last available date of the series or DateTime.MinValue if the series is empty.

public DateTime LastDate { get; }

Property Value

DateTime

Name

Gets/sets the name.

public string Name { get; set; }

Property Value

string

NextDate

Gets the next date if available and concurrency is being maintained, otherwise returns DateTime.MaxValue.

public DateTime NextDate { get; }

Property Value

DateTime

Periodicity

Gets/sets the periodicity of this series. If Periodicity is unknown, an estimate will be made.

public Periodicity Periodicity { get; set; }

Property Value

Periodicity

PreviousDate

Gets the previous date if concurrency is being maintained, otherwise returns DateTime.MinValue.

public DateTime PreviousDate { get; }

Property Value

DateTime

Symbol

Gets/sets the symbol.

public string Symbol { get; set; }

Property Value

string

Methods

Add(DateTime)

Adds the specified date to the series. Not for use when used as a property of an ISeries.

public void Add(DateTime date)

Parameters

date DateTime

Add(TimeSpan)

Adds the value of the specified TimeSpan to all dates in the series.

public void Add(TimeSpan value)

Parameters

value TimeSpan

Contains(DateTime)

Determines whether a particular date is in the collection.

public bool Contains(DateTime date)

Parameters

date DateTime

Returns

bool

Contains(DateTime, out int)

Determines whether a particular date is in the collection.

public bool Contains(DateTime date, out int bar)

Parameters

date DateTime

The date of interest.

bar int

The index value of the specified date or a number less than zero if not found. The bitwise complement (~) of negative return values may be used to find the index before which you should insert the specified date.

Returns

bool

GetEnumerator()

Returns an enumerator to iterate through the collection.

public IEnumerator<DateTime> GetEnumerator()

Returns

IEnumerator<DateTime>

Load(string)

Loads a list of dates from the specified file.

public static DateSeries Load(string fileName)

Parameters

fileName string

Returns

DateSeries

Load(string, string, int)

Loads a list of dates from the specified file using the specified column delimiter and column number.

public static DateSeries Load(string fileName, string delimiter, int column)

Parameters

fileName string
delimiter string
column int

Returns

DateSeries

OnGetValue(int)

Returns the value of the specified index.

protected virtual DateTime OnGetValue(int index)

Parameters

index int

Returns

DateTime

OnSetIndex(DateTime)

Sets the current bar based on the specified date.

protected virtual int OnSetIndex(DateTime date)

Parameters

date DateTime

Returns

int

RemoveTimeOfDay()

Removes the time of day component from all dates in the series.

public void RemoveTimeOfDay()

Save(string)

Saves this DateSeries to a text file using the specified file name.

public void Save(string fileName)

Parameters

fileName string

Exceptions

ArgumentNullException

SetValue(int, object)

Sets the index to the specified value.

protected virtual void SetValue(int index, object value)

Parameters

index int
value object

Sync(IEnumerable<DateTime>)

Returns a new DateSeries with the specified dates.

public ISeries Sync(IEnumerable<DateTime> dates)

Parameters

dates IEnumerable<DateTime>

Returns

ISeries

ToString()

Returns a string representation of this object.

public override string ToString()

Returns

string