Class Position
- Namespace
- Balsam
- Assembly
- Balsam.Backtester.dll
Represents a position which can contain multiple entries and exits and even multiple legs for a spread.
public class Position : IPosition, IPortfolioHolding
- Inheritance
-
Position
- Implements
- Inherited Members
- Extension Methods
Constructors
Position(Trade)
Initializes a new position object using the specified trade.
public Position(Trade trade)
Parameters
trade
Trade
Properties
ATR
Gets the ATR at time of entry.
public double ATR { get; }
Property Value
BarsSinceEntry
Gets the number of bars that have elapsed since entry. Add 1 to get the total number of bars in the trade.
public int BarsSinceEntry { get; }
Property Value
ClosedPnL
Gets the closed P&L.
public double ClosedPnL { get; }
Property Value
Commissions
Gets commissions paid in base currency.
public double Commissions { get; }
Property Value
Entries
Gets a collection of executions that established or added to the position.
public TradeCollection Entries { get; }
Property Value
Exits
Gets a collection of executions that liquidated or reduced the position.
public TradeCollection Exits { get; }
Property Value
FXRate
Gets the current exchange rate used to convert local to base currency.
public double FXRate { get; }
Property Value
HasVariables
Returns true if the position has variables associated with it.
public bool HasVariables { get; }
Property Value
Id
Gets a unique id for this position.
public long Id { get; }
Property Value
InitialMargin
Gets the initial margin requirement in base currency.
public double InitialMargin { get; }
Property Value
InitialRisk
Gets the distance from the entry price to the initial stop if any when the position was first opened.
public double InitialRisk { get; }
Property Value
Instrument
Gets the instrument of the position.
public Instrument Instrument { get; }
Property Value
IsMoneyManagerGenerated
Returns true if the position was originally created by MoneyManager logic rather than Strategy logic.
public bool IsMoneyManagerGenerated { get; }
Property Value
IsOpen
Returns true if the position is open.
public bool IsOpen { get; }
Property Value
IsSpread
Returns true if the position has any spread legs associated with it. Should be called before iterating through Legs to avoid instantiating an empty legs collection unnecessarily.
public bool IsSpread { get; }
Property Value
Last
Gets the last price mark.
public double Last { get; }
Property Value
Legs
Gets a collection of positions that make up legs of the spread.
public SpreadLegCollection Legs { get; }
Property Value
MaxAdverseExcursion
Gets the maximum adverse excursion in points.
public double MaxAdverseExcursion { get; }
Property Value
MaxFavorableExcursion
Gets the maximum favorable excursion in points.
public double MaxFavorableExcursion { get; }
Property Value
NotionalValue
Gets the notional value of the position in base currency (for futures contracts, the acutal, not back-adjusted, price is used).
public double NotionalValue { get; }
Property Value
OpenPnL
Gets the P&L of the currently open quantity.
public double OpenPnL { get; }
Property Value
PnL
Gets the net P&L in base currency.
public double PnL { get; }
Property Value
PnLLocal
Gets the net P&L in local currency.
public double PnLLocal { get; }
Property Value
PnLPercent
Gets the percent P&L using the unadjusted price in the denominator.
public double PnLPercent { get; }
Property Value
Pricing
Gets the position pricing object that maintains pricing data.
public PositionPricing Pricing { get; }
Property Value
Quantity
Gets the current quantity (Entries.TotalQuantity - Exits.TotalQuantity).
public double Quantity { get; }
Property Value
RMultiple
Gets the movement of the position in risk terms (or ATR terms if risk isn't available).
public double RMultiple { get; }
Property Value
Risk
Gets the distance in points from the most recent price mark to the stop or NaN if there is no stop.
public double Risk { get; }
Property Value
RiskValue
Gets the risk of the position (distance to stop) in base currency.
public double RiskValue { get; }
Property Value
Rolls
Gets a collection of rolls that took place while the position was open.
public RollCollection Rolls { get; }
Property Value
Side
Gets the side of the position (long or short).
public PositionSide Side { get; }
Property Value
Slippage
Gets slippage in base currency (decimal value multiplied by instrument point value).
public double Slippage { get; }
Property Value
Stop
Gets/sets a convenience field for the user to store stop loss information.
public double Stop { get; set; }
Property Value
StrategyName
Gets the name of the strategy that generated the position.
public string StrategyName { get; }
Property Value
Symbol
Gets the symbol of the position.
public string Symbol { get; }
Property Value
Target
Gets/sets a convenience field for the user to store profit target information.
public double Target { get; set; }
Property Value
TodaysPnL
Gets the daily P&L for the most recent pricing date in base currency.
public double TodaysPnL { get; }
Property Value
TotalCommissions
Gets the total commissions paid in base currency including any legs of a spread.
public double TotalCommissions { get; }
Property Value
TotalNotionalValue
Gets the total notional value in base currency including any legs of a spread.
public double TotalNotionalValue { get; }
Property Value
TotalPnL
Gets the total net P&L in base currency including any legs of a spread.
public double TotalPnL { get; }
Property Value
TotalQuantity
Gets the total current number of contracts/shares held including any legs of a spread.
public double TotalQuantity { get; }
Property Value
TotalRiskValue
Gets the total risk of the position in base currency including any legs of a spread.
public double TotalRiskValue { get; }
Property Value
TotalSlippage
Gets the total slippage incurred in base currency including any legs of a spread.
public double TotalSlippage { get; }
Property Value
Variables
Gets a collection of trade variables.
public VariableDictionary Variables { get; }
Property Value
Methods
AddTrade(Trade)
Adds a new trade to the position.
public void AddTrade(Trade trade)
Parameters
trade
Trade
GetOffsettingOrderSide()
Returns the order side necessary to liquidate the position.
public OrderSide GetOffsettingOrderSide()
Returns
ToString()
Returns a string representation of this position object.
public override string ToString()
Returns
UpdatePricing(Bar)
Updates position pricing using the specified Bar.
public void UpdatePricing(Bar bar)
Parameters
bar
Bar