Table of Contents

Class SeriesCollectionBase<T>

Namespace
Balsam
Assembly
Balsam.Backtester.dll

An abstract class for collections of ISeries objects which supports access by key or index.

[ProtoContract(IgnoreListHandling = true)]
[ProtoInclude(3, typeof(TimeSeriesCollection))]
[ProtoInclude(4, typeof(BooleanSeriesCollection))]
public abstract class SeriesCollectionBase<T> : IEnumerable<T>, IEnumerable, ISeries, INotifyCollectionChanged where T : ISeries

Type Parameters

T
An abstract class for collections of ISeries objects which supports access by key or index.
Inheritance
SeriesCollectionBase<T>
Implements
Derived
Inherited Members
Extension Methods

Constructors

SeriesCollectionBase()

Initializes an empty series collection.

public SeriesCollectionBase()

SeriesCollectionBase(IEnumerable<T>)

Initializes a series collection and adds the specified series to the collection.

public SeriesCollectionBase(IEnumerable<T> series)

Parameters

series IEnumerable<T>

SeriesCollectionBase(int)

Initializes an empty series collection with the specified capacity.

public SeriesCollectionBase(int capacity)

Parameters

capacity int

Properties

AllowDuplicateSymbols

Allows multiple series with the same symbol to be added to the collection, otherwise an exception is thrown.

public bool AllowDuplicateSymbols { get; set; }

Property Value

bool

Count

Gets the number of elements in the collection.

public int Count { get; }

Property Value

int

CurrentDate

The current date if concurrency is being maintained; otherwise DateTime.MinValue.

public DateTime CurrentDate { get; }

Property Value

DateTime

FirstDate

The first date in the collection or DateTime.MinValue if the collection is empty.

public DateTime FirstDate { get; }

Property Value

DateTime

HasDuplicateSymbols

Returns true if the collection has duplicate symbols. If AllowDuplicateSymbols is true, duplicate symbols will automatically be appended with a hypen and number.

public bool HasDuplicateSymbols { get; }

Property Value

bool

IsActive

Returns true if concurrency is being maintained and the CurrentDate is greater than or equal to the FirstDate.

public bool IsActive { get; }

Property Value

bool

IsReadOnly

Gets/sets whether the collection is read-only.

public bool IsReadOnly { get; protected set; }

Property Value

bool

this[int]

Gets/sets an element by index.

public T this[int index] { get; set; }

Parameters

index int

Property Value

T

this[string]

Gets/sets an element by key.

public T this[string key] { get; set; }

Parameters

key string

Property Value

T

Key

Gets/sets the function used to determine the key for the collection. Defaults to symbol.

public Func<ISeries, string> Key { get; set; }

Property Value

Func<ISeries, string>

LastDate

The last date in the collection or DateTime.MinValue if the collection is empty.

public DateTime LastDate { get; }

Property Value

DateTime

Name

Gets/sets the name for this collection.

public string Name { get; set; }

Property Value

string

Symbol

Gets/sets a symbol for this collection.

public string Symbol { get; set; }

Property Value

string

Methods

Add(IEnumerable<T>)

Adds all the BarSeries in the specified enumerable to the collection.

public void Add(IEnumerable<T> series)

Parameters

series IEnumerable<T>

Add(string, T)

Adds the specified BarSeries to the collection using the specifed key.

public void Add(string key, T series)

Parameters

key string
series T

Add(T)

Adds the specified BarSeries to the collection using the symbol as the key.

public void Add(T series)

Parameters

series T

Clear()

Clears the collection.

public void Clear()

Contains(T)

Determines whether the specified element is in the collection.

public bool Contains(T item)

Parameters

item T

Returns

bool

ContainsKey(string)

Returns true if the collection contains the specified key.

public bool ContainsKey(string key)

Parameters

key string

Returns

bool

GetActiveSymbols()

Returns an enumerable of symbols for which the CurrentDate is greater than or equal to FirstDate (i.e. concurrency is being maintained).

public IEnumerable<string> GetActiveSymbols()

Returns

IEnumerable<string>

GetEnumerator()

Returns an enumerator for iterating through the collection.

public IEnumerator<T> GetEnumerator()

Returns

IEnumerator<T>

GetKeys()

Returns an enumerable of keys.

public IEnumerable<string> GetKeys()

Returns

IEnumerable<string>

OnCollectionChanged(NotifyCollectionChangedEventArgs)

Raises a NotifyCollectionChanged event.

protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)

Parameters

e NotifyCollectionChangedEventArgs

OnGetItem(string)

Gets the item using the specified key.

protected virtual T OnGetItem(string key)

Parameters

key string

Returns

T

OnGetKey(T)

Returns the symbol to be used as a key. Can be overridden in derived classes to use something else.

protected virtual string OnGetKey(T series)

Parameters

series T

Returns

string

OnLoad(string)

Deserialize previously saved .bin file back into a series collection.

protected static SeriesCollectionBase<T> OnLoad(string fileName)

Parameters

fileName string

Returns

SeriesCollectionBase<T>

OnSave(string)

Serializes the collection to disk to allow for quick loading. File extension is .bin.

protected virtual void OnSave(string fileName)

Parameters

fileName string

OnSetIndex(DateTime)

Sets the current bar to the specified date.

protected int OnSetIndex(DateTime date)

Parameters

date DateTime

Returns

int

OnSetIndex(int)

Sets the current bar to the specified index. Currently only -1 is a valid index.

protected void OnSetIndex(int index)

Parameters

index int

OnSync(IEnumerable<DateTime>, SyncOption)

Override this method to support syncing of collections.

protected virtual ISeries OnSync(IEnumerable<DateTime> dates, SyncOption syncOption)

Parameters

dates IEnumerable<DateTime>
syncOption SyncOption

Returns

ISeries

Remove(string)

Removes the BarSeries with the specified key from the collection.

public bool Remove(string key)

Parameters

key string

Returns

bool

Remove(T)

Removes the specified BarSeries from the collection.

public bool Remove(T series)

Parameters

series T

Returns

bool

Save(string)

Serializes the collection to disk in a .bin file for quick loading.

public void Save(string fileName)

Parameters

fileName string

ToDictionary()

Converts the collection to a dictionary.

public Dictionary<string, T> ToDictionary()

Returns

Dictionary<string, T>

ToString()

Returns a string representation of this collection.

public override string ToString()

Returns

string

Events

CollectionChanged

Raises an event when the collection is changed.

public event NotifyCollectionChangedEventHandler CollectionChanged

Event Type

NotifyCollectionChangedEventHandler