Parent: Object
The Transaction class represents a trading order or signal generated during a backtest or processed by WealthLab's trading infrastructure. When developing a C# Strategy, methods such as PlaceTrade return a Transaction instance. You can modify selected properties of the Transaction, such as Quantity, Weight, Tag, AutoStopLossPrice, or AutoProfitTargetPrice, to customize the resulting order. A Transaction also contains information about backtest execution, live broker status, fills, signal origin, account information, and the Position that can result from the order.
The broker account associated with the Transaction.
Returns the broker account's display name or nickname when available. Otherwise, returns Account.
The Broker associated with the Transaction. If the Transaction belongs to a SignalBlock, the SignalBlock's Broker takes precedence.
Returns the BrokerAccount corresponding to Account. Returns null if no Broker is assigned or if the account cannot be found.
Provides broker-specific storage that a Broker implementation can associate with the Transaction.
Returns true when the Transaction's current SignalStatus allows it to be canceled.
Returns true when the Transaction's current SignalStatus allows it to be placed.
The fill price reported for a live Transaction.
The quantity filled so far.
Returns true when the current SignalStatus represents an active order.
Returns true when SignalStatus is either:
- Filled
- PartialFilled
Indicates that the Transaction has been classified as a day trade. The default value is false.
Indicates that the Broker submitted the Transaction as a Market-on-Open order. The default value is false.
Returns true if the Transaction is part of an OCO pair.
Indicates that the order was submitted for pre-market or post-market trading.
Returns the Broker-mapped symbol for the Transaction. If the Broker does not provide a SymbolMapper, this is the same as Symbol.
Returns the MarketDetails associated with the Transaction. If Bars is available, its Market is returned. For Transactions without Bars, Market can be assigned directly. If no Market has been supplied, US Stocks is used by default.
Contains status, error, Portfolio Sync, and other informational messages associated with the Transaction.
Returns the most recent item in Messages. Returns an empty string when no messages are available.
Returns true when WealthLab should submit the Transaction as Good-Til-Canceled based on the Strategy scale or Trading Preferences.
References the other Transaction in an OCO, or One-Cancels-Other, pair. Returns null when the Transaction is not part of an OCO pair.
Records a partial fill. If previous partial fills exist, WealthLab updates FillQty and recalculates FillPrice as the quantity-weighted average fill price.
Returns the current trading status of the Transaction. WealthLab manages this property as the signal moves through states such as Staged, Placed, Filled, PartialFilled, Canceled, or Error.
The symbol associated with the Transaction.
If Symbol has not been explicitly assigned and Bars is available, WealthLab derives it from Bars.Symbol.
The timestamp associated with the Transaction.
The default value is DateTime.Now.
For Broker implementations that support native order replacement, identifies the existing Transaction that should be canceled before this Transaction is submitted.
Requests that the Broker submit the Transaction as a Market-on-Open order when supported. The default value is false.
Creates a new Transaction. The overload accepting another Transaction creates a copy containing the principal properties of the supplied Transaction. Normally, Strategy code does not construct Transaction instances directly. Instead, a Transaction is returned from methods such as PlaceTrade.
Returns a descriptive representation of the Transaction containing its TransactionType, Quantity, OrderType, and applicable price.
Returns ExecutionDate formatted for display. If the time portion is midnight, only the date is displayed.
Returns ExecutionPrice formatted using PriceFormatCode for order types that use a price.
Returns FillPrice formatted according to the Transaction's price formatting rules.
Returns FillQty formatted according to the Transaction's quantity formatting rules. Returns an empty string when FillQty is zero.
Returns the last closing value in Bars.
Returns Double.NaN when Bars is unavailable.
Returns LastClose formatted according to PriceFormatCode.
Returns an empty string if LastClose is Double.NaN.
Returns a descriptive string containing the Transaction description and current SignalStatus. For error Transactions, the latest message is included. For filled or partially filled Transactions, the fill price is included.
Returns the number of decimal places WealthLab should use when displaying the order price. The value is derived from the Broker, Market, or Bars where possible, and defaults to 2.
Gets or sets the numeric formatting code used for prices.
If not explicitly assigned, WealthLab derives a format such as "N2" from OrderPriceDecimals.
Returns the Transaction quantity formatted for display. For entry Transactions using next-bar position sizing, this can display BasisAmount as a dollar value instead of a share or contract quantity.
Returns Quantity formatted using QuantityFormatCode.
Gets or sets the numeric formatting code used for quantities. If not explicitly assigned, WealthLab derives the required precision from the Broker and the Quantity itself.
Returns the security name from Bars enclosed in parentheses. Returns an empty string when no security name is available.
Returns EntryDate formatted appropriately for the associated BarHistory scale.
Returns Timestamp formatted as a short date/time string.
Returns a descriptive string containing the Transaction's Symbol and Description.
The requested order price. This property is relevant to order types that use a price, such as Limit, Stop, and StopLimit orders. The default value is 0.
Returns OrderPrice rounded according to the associated Broker's supported price precision. If no Broker is assigned, returns OrderPrice unchanged.
Returns the order price formatted for display. For StopLimit orders whose stop and limit prices differ, the returned text includes both prices.
Specifies the Transaction's order type. Depending on the context, supported values include Market, Limit, Stop, StopLimit, MarketClose, LimitClose, FixedPrice, and other WealthLab order types.
Returns true if price is beyond the Transaction's Limit, Stop, or StopLimit order price in the direction that would cause the order to be executable. Returns false for order types that are not Limit or Stop based.
Specifies the limit portion of a StopLimit order. If no separate limit price is assigned, this property returns OrderPrice, which represents the stop price.
Returns StopLimitLimitPrice rounded according to the associated Broker's supported price precision.
Adds msg to the Transaction's Messages collection and assigns it to PortfolioSyncMessage.
Adds msg to the Transaction's Messages collection and assigns it to TradingThresholdMessage.
Assigns the Transaction's SignalStatus without firing the normal SignalStatusChanged event. This is primarily intended for framework and extension code.
The MetaStrategy component responsible for the Transaction, if applicable.
Returns a descriptive identifier for the associated MetaStrategy component. Returns an empty string when the Transaction is not associated with a MetaStrategy component.
Contains a message describing an adjustment made by Portfolio Sync.
Resets the Transaction's internal status to Staged so that it can be resubmitted.
Contains a message describing why Trading Threshold processing prevented or modified an order.
A unique Transaction identifier generated by WealthLab. The ID can subsequently be transferred to Positions created from the Transaction.
Creates a lightweight copy of the Transaction using the same fields persisted by Persist.
This is not equivalent to the Transaction(Transaction t) copy constructor, which copies considerably more Transaction state.
Creates a Transaction from a string previously produced by Persist.
Serializes a subset of the Transaction's properties into a string. The persisted information includes:
- Symbol
- TransactionType
- Quantity
- OrderType
- OrderPrice
- Weight
- ExecutionDate
- Broker name
- Account
- IsDayTrade
Applies the Round Lots settings in bts to the Transaction quantity. When enabled and applicable, quantities above 10 are rounded to standard 10- or 100-unit lots.
Gets or assigns Quantity without marking the Transaction as manually sized. This property is primarily useful to WealthLab framework and extension code that needs to change Quantity while preserving the distinction between automatic and manual sizing. Negative values are converted to zero.
Indicates that Transaction.Quantity was explicitly assigned rather than calculated automatically.
Indicates that the Transaction was generated using next-bar position sizing. The default value is false.
Returns Quantity rounded to the number of quantity decimals supported by the associated Broker. If no Broker is assigned, returns Quantity unchanged.
Truncates Quantity to the specified number of decimal places.
Assigns an AutoProfitTargetPrice while applying WealthLab's pruning logic when more than one candidate target price is assigned. This method is primarily used by Building Block processing.
Assigns an AutoStopLossPrice while applying WealthLab's pruning logic when more than one candidate stop price is assigned. This method is primarily used by Building Block processing.
Assigns a same-bar profit target price to an entry Transaction. When the entry fills, WealthLab can attempt to exit the resulting Position at this limit price on the same bar. This applies both to backtesting and live trading. For realistic backtesting, same-bar exits are most reliable with Market entries. Limit and Stop entries can introduce uncertainty because the intrabar sequence of prices may not be known. The assigned price is adjusted to the security's tick size when Futures Mode is applicable.
Assigns a same-bar stop-loss price to an entry Transaction. When the entry fills, WealthLab can attempt to exit the resulting Position at this stop price on the same bar. This applies both to backtesting and live trading. The assigned price is adjusted to the security's tick size when Futures Mode is applicable.
Contains the Backtester's current equity value associated with the Transaction.
WealthLab uses this when comparing simulated equity to broker-reported account equity for Portfolio Sync position sizing.
The default value is Double.NaN.
Contains the amount of capital on which the Transaction's quantity calculation was based. This is also used when displaying signals created using next-bar position sizing.
Contains the price used as the basis for position sizing.
The commission applied to the Transaction during a backtest. Commission behavior is controlled by the Strategy's Backtest Settings.
Returns the approximate capital represented by the Transaction. For Market and MarketClose orders, WealthLab uses the close of the EntryDate bar. For other order types, it uses Quantity � OrderPrice.
The signal date of the Transaction. This generally corresponds to the bar on which the trading signal was generated.
Indicates that an entry Transaction exceeded a maximum-open-position constraint.
The value can identify the affected side, such as "Long", "Short", or "Long+Short".
Returns null when the Transaction was not rejected for this reason.
The date and time at which the Transaction was executed by the Backtester.
The price at which the Backtester executed the Transaction.
The default value is Double.NaN.
Indicates that the Transaction originated from Quotes processing. The default value is false.
When Granular Limit/Stop Processing is used, contains the intraday DateTime that determined the Transaction's execution priority.
The default value is DateTime.MinValue.
Returns true if the Transaction is an entry:
- Buy
- Short
Returns true if the Transaction is an exit:
- Sell
- Cover
Set this property to true to allow the Backtester to fill the Transaction even when insufficient simulated capital would normally prevent the fill. The default value is false.
Returns the opening price of the bar following SignalIndex.
Returns Double.NaN if Bars is unavailable, SignalIndex is -1, or there is no following bar.
Indicates that the Transaction was flagged as Non-Sufficient Funds by the Backtester.
An internal identifier used to associate Transactions with specific Positions or Building Block entries. Strategy developers should normally use Tag instead for custom data.
Returns the PositionType represented by the Transaction.
Buy and Sell Transactions correspond to PositionType.Long.
Short and Cover Transactions correspond to PositionType.Short.
Gets or assigns the Transaction quantity. For entry Transactions, explicitly assigning Quantity in Strategy code overrides normal Position Sizing. For exit Transactions, assigning a Quantity smaller than the Position quantity can be used to generate a partial exit. Assigning this property also marks the Transaction as having a manually assigned quantity. Negative values are converted to zero.
The bar index at which the Transaction signal was generated.
An optional descriptive name associated with the signal. For an entry Transaction, this value is transferred to the resulting Position's EntrySignalName.
Provides a general-purpose property for associating custom data with the Transaction. When an entry Transaction creates a Position, the Transaction's Tag is transferred to the Position's Tag property.
Specifies the direction of the Transaction. Possible values include:
TransactionType.BuyTransactionType.SellTransactionType.ShortTransactionType.Cover
Specifies the Transaction's priority when more candidate Transactions exist than available simulated capital permits. Transactions are sorted from higher Weight to lower Weight. Assign a larger Weight to give a Transaction greater fill priority.