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
this[int]
Gets a position based on the specified index.
public Position this[int index] { get; }
Parameters
index
int
Property Value
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
Last
Gets the last position in the collection or null if the collection is empty.
public Position Last { get; }
Property Value
TotalNotional
Gets the total notional value in base currency for all positions in the collection.
public double TotalNotional { get; }
Property Value
TotalPnL
Gets the total P&L in base currency for all positions in the collection.
public double TotalPnL { get; }
Property Value
TotalQuantity
Gets the total number of shares/contracts for all positions in the collection.
public double TotalQuantity { get; }
Property Value
TotalRisk
Gets the total risk in base currency for all positions in the collection.
public double TotalRisk { get; }
Property Value
TotalTodaysPnL
Gets today's total P&L in base currency for all positions in the collection.
public double TotalTodaysPnL { get; }
Property Value
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
Contains(string)
Determines whether the specified symbol can be found in the collection.
public bool Contains(string symbol)
Parameters
symbol
string
Returns
GetEnumerator()
Returns a PositionEnumerator to iterate through all positions in the collection in reverse order.
public IEnumerator<Position> GetEnumerator()
Returns
OnCollectionChanged(NotifyCollectionChangedEventArgs)
Raises a NotifyCollectionChanged event.
protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
Parameters
OnPropertyChanged(PropertyChangedEventArgs)
Raises a PropertyChanged event.
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
Parameters
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
Events
CollectionChanged
Sends a notification when the collection is changed.
public event NotifyCollectionChangedEventHandler CollectionChanged
Event Type
PropertyChanged
Sends a notification when a property is changed.
protected event PropertyChangedEventHandler PropertyChanged