Table of Contents

Class PositionCollection

Namespace
Balsam
Assembly
Balsam.Backtester.dll

Used to encapsulate positions and provide a read-only collection to user

public class PositionCollection : IEnumerable<Position>, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
Inheritance
PositionCollection
Implements
Inherited Members
Extension Methods

Constructors

PositionCollection()

Initializes a new empty PositionCollection.

public PositionCollection()

PositionCollection(IEnumerable<Position>)

Intializes a new PositionCollection using the specified positions.

public PositionCollection(IEnumerable<Position> collection)

Parameters

collection IEnumerable<Position>

Properties

Count

Gets the number of positions contained within the collection.

public int Count { get; }

Property Value

int

this[int]

Gets a position based on the specified index.

public Position this[int index] { get; }

Parameters

index int

Property Value

Position

this[string]

Gets a position based on the specified symbol or null if symbol not found. Multiple positions with the same symbol will throw an exception.

public Position this[string symbol] { get; }

Parameters

symbol string

Property Value

Position

Last

Gets the last position in the collection or null if the collection is empty.

public Position Last { get; }

Property Value

Position

TotalNotional

Gets the total notional value in base currency for all positions in the collection.

public double TotalNotional { get; }

Property Value

double

TotalPnL

Gets the total P&L in base currency for all positions in the collection.

public double TotalPnL { get; }

Property Value

double

TotalQuantity

Gets the total number of shares/contracts for all positions in the collection.

public double TotalQuantity { get; }

Property Value

double

TotalRisk

Gets the total risk in base currency for all positions in the collection.

public double TotalRisk { get; }

Property Value

double

TotalTodaysPnL

Gets today's total P&L in base currency for all positions in the collection.

public double TotalTodaysPnL { get; }

Property Value

double

Methods

Add(Position)

Adds a position to the end of the collection.

protected void Add(Position position)

Parameters

position Position

Contains(Position)

Determines whether a position is in the collection.

public bool Contains(Position position)

Parameters

position Position

Returns

bool

Contains(string)

Determines whether the specified symbol can be found in the collection.

public bool Contains(string symbol)

Parameters

symbol string

Returns

bool

GetEnumerator()

Returns a PositionEnumerator to iterate through all positions in the collection in reverse order.

public IEnumerator<Position> GetEnumerator()

Returns

IEnumerator<Position>

OnCollectionChanged(NotifyCollectionChangedEventArgs)

Raises a NotifyCollectionChanged event.

protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)

Parameters

e NotifyCollectionChangedEventArgs

OnPropertyChanged(PropertyChangedEventArgs)

Raises a PropertyChanged event.

protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)

Parameters

e PropertyChangedEventArgs

Remove(Position)

Removes a position from the collection.

protected void Remove(Position position)

Parameters

position Position

ToString()

Returns a string representation of this collection.

public override string ToString()

Returns

string

Events

CollectionChanged

Sends a notification when the collection is changed.

public event NotifyCollectionChangedEventHandler CollectionChanged

Event Type

NotifyCollectionChangedEventHandler

PropertyChanged

Sends a notification when a property is changed.

protected event PropertyChangedEventHandler PropertyChanged

Event Type

PropertyChangedEventHandler