Class Trade
- Namespace
- Balsam
- Assembly
- Balsam.Backtester.dll
Encapsulates trade information. Used to size positions in the money manager by setting the Quantity property.
public class Trade : IOrder, ITrade, ICloneable
- Inheritance
-
Trade
- Implements
- Inherited Members
- Extension Methods
Constructors
Trade(long, Order)
Creates a new trade object using the specified id and order.
public Trade(long tradeId, Order order)
Parameters
Properties
ATR
Gets/sets the strategy generated Average True Range value.
public double ATR { get; set; }
Property Value
Commission
Gets/sets the commission per contract/share in local currency.
public double Commission { get; set; }
Property Value
FXRate
Gets the FX rate used to convert trade values into the base currency.
public double FXRate { get; }
Property Value
HasVariables
Returns true if the trade has variables associated with it.
public bool HasVariables { get; }
Property Value
Id
Gets a unique identifier for this trade.
public long Id { get; }
Property Value
Instrument
Gets the instrument being traded.
public Instrument Instrument { get; }
Property Value
IsBuy
Returns true if trade is a buy or cover.
public bool IsBuy { get; }
Property Value
IsCanceled
Returns true if the trade has been canceled.
public bool IsCanceled { get; }
Property Value
IsMoneyManagerGenerated
Returns true if this trade was generated by money management logic instead of by the strategy.
public bool IsMoneyManagerGenerated { get; }
Property Value
IsMultiplier
Returns true for mutliplier trades which act on existing positions.
public bool IsMultiplier { get; }
Property Value
IsOpening
Returns true for opening trades (Buy and SellShort order types).
public bool IsOpening { get; }
Property Value
IsSpread
Returns true if the trade has any 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
Legs
Gets a collection of legs for spread trades.
public TradeCollection Legs { get; }
Property Value
Multiplier
Gets the multiplier value for multiplier trades, else zero.
public double Multiplier { get; }
Property Value
NotionalValue
Gets the notional value of this trade in base currency at the time of execution.
public double NotionalValue { get; }
Property Value
OrderDate
Gets the date the order was submitted that resulted in this trade.
public DateTime OrderDate { get; }
Property Value
OrderType
Gets the order type that generated this trade.
public string OrderType { get; }
Property Value
Price
Gets the price at which the trade was executed.
public double Price { get; }
Property Value
Quantity
Gets/sets the number of contracts/shares, which can be fractional.
public double Quantity { get; set; }
Property Value
Reason
Gets the reason for a trade rejection or cancellation, otherwise null.
public string Reason { get; }
Property Value
Risk
Gets the distance to the stop in points. If there is no stop, returns NaN.
public double Risk { get; }
Property Value
RiskValue
Gets the risk of the trade in base currency terms.
public double RiskValue { get; }
Property Value
Side
Gets the order type (Buy, Sell, SellShort, or Cover).
public OrderSide Side { get; set; }
Property Value
SignalName
Gets the name of the signal that generated this trade.
public string SignalName { get; }
Property Value
Slippage
Gets/sets the slippage per contract/share in points.
public double Slippage { get; set; }
Property Value
StrategyName
Gets the name of the strategy associated with this trade.
public string StrategyName { get; }
Property Value
Symbol
Gets the ticker symbol.
public string Symbol { get; }
Property Value
TimeInForce
Gets the time in force from the order that generated this trade.
public TimeInForce TimeInForce { get; }
Property Value
TradeDate
Gets the trade date.
public DateTime TradeDate { get; }
Property Value
UnadjustedPrice
Gets the entry price that would have existed at the time, without the effects of backadjusting or stock splits.
public double UnadjustedPrice { get; }
Property Value
Variables
Gets a collection of trade variables associated with this trade.
public VariableDictionary Variables { get; }
Property Value
Methods
Cancel()
Cancels the trade.
public void Cancel()
Cancel(string)
Cancels the trade using the specified message.
public void Cancel(string reason)
Parameters
reason
string
Clone()
Returns a clone of this trade object.
public Trade Clone()
Returns
ToString()
Returns a string representation of this trade.
public override string ToString()