Table of Contents

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

tradeId long
order Order

Properties

ATR

Gets/sets the strategy generated Average True Range value.

public double ATR { get; set; }

Property Value

double

Commission

Gets/sets the commission per contract/share in local currency.

public double Commission { get; set; }

Property Value

double

FXRate

Gets the FX rate used to convert trade values into the base currency.

public double FXRate { get; }

Property Value

double

HasVariables

Returns true if the trade has variables associated with it.

public bool HasVariables { get; }

Property Value

bool

Id

Gets a unique identifier for this trade.

public long Id { get; }

Property Value

long

Instrument

Gets the instrument being traded.

public Instrument Instrument { get; }

Property Value

Instrument

IsBuy

Returns true if trade is a buy or cover.

public bool IsBuy { get; }

Property Value

bool

IsCanceled

Returns true if the trade has been canceled.

public bool IsCanceled { get; }

Property Value

bool

IsMoneyManagerGenerated

Returns true if this trade was generated by money management logic instead of by the strategy.

public bool IsMoneyManagerGenerated { get; }

Property Value

bool

IsMultiplier

Returns true for mutliplier trades which act on existing positions.

public bool IsMultiplier { get; }

Property Value

bool

IsOpening

Returns true for opening trades (Buy and SellShort order types).

public bool IsOpening { get; }

Property Value

bool

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

bool

Legs

Gets a collection of legs for spread trades.

public TradeCollection Legs { get; }

Property Value

TradeCollection

Multiplier

Gets the multiplier value for multiplier trades, else zero.

public double Multiplier { get; }

Property Value

double

NotionalValue

Gets the notional value of this trade in base currency at the time of execution.

public double NotionalValue { get; }

Property Value

double

OrderDate

Gets the date the order was submitted that resulted in this trade.

public DateTime OrderDate { get; }

Property Value

DateTime

OrderType

Gets the order type that generated this trade.

public string OrderType { get; }

Property Value

string

Price

Gets the price at which the trade was executed.

public double Price { get; }

Property Value

double

Quantity

Gets/sets the number of contracts/shares, which can be fractional.

public double Quantity { get; set; }

Property Value

double

Reason

Gets the reason for a trade rejection or cancellation, otherwise null.

public string Reason { get; }

Property Value

string

Risk

Gets the distance to the stop in points. If there is no stop, returns NaN.

public double Risk { get; }

Property Value

double

RiskValue

Gets the risk of the trade in base currency terms.

public double RiskValue { get; }

Property Value

double

Side

Gets the order type (Buy, Sell, SellShort, or Cover).

public OrderSide Side { get; set; }

Property Value

OrderSide

SignalName

Gets the name of the signal that generated this trade.

public string SignalName { get; }

Property Value

string

Slippage

Gets/sets the slippage per contract/share in points.

public double Slippage { get; set; }

Property Value

double

StrategyName

Gets the name of the strategy associated with this trade.

public string StrategyName { get; }

Property Value

string

Symbol

Gets the ticker symbol.

public string Symbol { get; }

Property Value

string

TimeInForce

Gets the time in force from the order that generated this trade.

public TimeInForce TimeInForce { get; }

Property Value

TimeInForce

TradeDate

Gets the trade date.

public DateTime TradeDate { get; }

Property Value

DateTime

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

double

Variables

Gets a collection of trade variables associated with this trade.

public VariableDictionary Variables { get; }

Property Value

VariableDictionary

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

Trade

ToString()

Returns a string representation of this trade.

public override string ToString()

Returns

string