Account
public string AccountThe broker account associated with the Transaction.
API documentation, members, signatures, and C# examples.
Find classes, members, and documentation.
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.
public string AccountThe broker account associated with the Transaction.
public string AccountDisplayReturns the broker account's display name or nickname when available. Otherwise, returns Account.
public BrokerBase BrokerThe Broker associated with the Transaction. If the Transaction belongs to a SignalBlock, the SignalBlock's Broker takes precedence.
public BrokerAccount BrokerAccountReturns the BrokerAccount corresponding to Account. Returns null if no Broker is assigned or if the account cannot be found.
public object BrokerTagProvides broker-specific storage that a Broker implementation can associate with the Transaction.
public bool CanCancelReturns true when the Transaction's current SignalStatus allows it to be canceled.
public bool CanPlaceReturns true when the Transaction's current SignalStatus allows it to be placed.
public double FillPriceThe fill price reported for a live Transaction.
public double FillQtyThe quantity filled so far.
public bool IsActiveReturns true when the current SignalStatus represents an active order.
public bool IsCompletedReturns true when SignalStatus is either:
public bool IsDayTradeIndicates that the Transaction has been classified as a day trade. The default value is false.
public bool IsMOOIndicates that the Broker submitted the Transaction as a Market-on-Open order. The default value is false.
public bool IsOCOReturns true if the Transaction is part of an OCO pair.
public bool IsPrePostMarketIndicates that the order was submitted for pre-market or post-market trading.
public string MappedSymbolReturns the Broker-mapped symbol for the Transaction. If the Broker does not provide a SymbolMapper, this is the same as Symbol.
public MarketDetails MarketReturns 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.
public List<string> MessagesContains status, error, Portfolio Sync, and other informational messages associated with the Transaction.
public string MessageStringReturns the most recent item in Messages. Returns an empty string when no messages are available.
public bool NeedsGTCReturns true when WealthLab should submit the Transaction as Good-Til-Canceled based on the Strategy scale or Trading Preferences.
public Transaction OcoPairReferences the other Transaction in an OCO, or One-Cancels-Other, pair. Returns null when the Transaction is not part of an OCO pair.
public void PartialFill(double qty, double price)Records a partial fill. If previous partial fills exist, WealthLab updates FillQty and recalculates FillPrice as the quantity-weighted average fill price.
public SignalStatus SignalStatusReturns 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.
public string SymbolThe symbol associated with the Transaction.
If Symbol has not been explicitly assigned and Bars is available, WealthLab derives it from Bars.Symbol.
public DateTime TimestampThe timestamp associated with the Transaction.
The default value is DateTime.Now.
public Transaction TransactionToCancelFor Broker implementations that support native order replacement, identifies the existing Transaction that should be canceled before this Transaction is submitted.
public bool UseMooOrderIfPossibleRequests that the Broker submit the Transaction as a Market-on-Open order when supported. The default value is false.
public Transaction()public Transaction( TransactionType transType, OrderType orderType, double price, BarHistory bars)public Transaction( TransactionType transType, OrderType orderType, double price, BarHistory bars, int signalIdx)public Transaction(Transaction t)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.
public string DescriptionReturns a descriptive representation of the Transaction containing its TransactionType, Quantity, OrderType, and applicable price.
public string ExecutionDateDisplayReturns ExecutionDate formatted for display. If the time portion is midnight, only the date is displayed.
public string ExecutionPriceDisplayReturns ExecutionPrice formatted using PriceFormatCode for order types that use a price.
public string FillPriceDisplayReturns FillPrice formatted according to the Transaction's price formatting rules.
public string FillQtyDisplayReturns FillQty formatted according to the Transaction's quantity formatting rules. Returns an empty string when FillQty is zero.
public double LastCloseReturns the last closing value in Bars.
Returns Double.NaN when Bars is unavailable.
public string LastCloseDisplayReturns LastClose formatted according to PriceFormatCode.
Returns an empty string if LastClose is Double.NaN.
public string LiveOrderDescriptionReturns 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.
public int OrderPriceDecimalsReturns 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.
public string PriceFormatCodeGets or sets the numeric formatting code used for prices.
If not explicitly assigned, WealthLab derives a format such as "N2" from OrderPriceDecimals.
public string QuantityDisplayReturns 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.
public string QuantityDisplaySimpleReturns Quantity formatted using QuantityFormatCode.
public string QuantityFormatCodeGets 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.
public string SecurityNameReturns the security name from Bars enclosed in parentheses. Returns an empty string when no security name is available.
public string SignalDisplayDateReturns EntryDate formatted appropriately for the associated BarHistory scale.
public string TimestampStringReturns Timestamp formatted as a short date/time string.
public override string ToString()Returns a descriptive string containing the Transaction's Symbol and Description.
public double OrderPriceThe 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.
public double OrderPriceAdjustedReturns OrderPrice rounded according to the associated Broker's supported price precision. If no Broker is assigned, returns OrderPrice unchanged.
public string OrderPriceDisplayReturns the order price formatted for display. For StopLimit orders whose stop and limit prices differ, the returned text includes both prices.
public OrderType OrderTypeSpecifies the Transaction's order type. Depending on the context, supported values include Market, Limit, Stop, StopLimit, MarketClose, LimitClose, FixedPrice, and other WealthLab order types.
public bool PriceIsBeyondOrderPrice(double price)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.
public double StopLimitLimitPriceSpecifies the limit portion of a StopLimit order. If no separate limit price is assigned, this property returns OrderPrice, which represents the stop price.
public double StopLimitLimitPriceAdjustedReturns StopLimitLimitPrice rounded according to the associated Broker's supported price precision.
public void AddPortfolioSyncMessage(string msg)Adds msg to the Transaction's Messages collection and assigns it to PortfolioSyncMessage.
public void AddTradingThresholdMessage(string msg)Adds msg to the Transaction's Messages collection and assigns it to TradingThresholdMessage.
public void AssignSignalStatus(SignalStatus ss)Assigns the Transaction's SignalStatus without firing the normal SignalStatusChanged event. This is primarily intended for framework and extension code.
public DateTime EntrySignalDatepublic MetaStrategyComponent MetaStrategyComponentThe MetaStrategy component responsible for the Transaction, if applicable.
public string MetaStrategyNameReturns a descriptive identifier for the associated MetaStrategy component. Returns an empty string when the Transaction is not associated with a MetaStrategy component.
public string PortfolioSyncMessageContains a message describing an adjustment made by Portfolio Sync.
public void Resubmit()Resets the Transaction's internal status to Staged so that it can be resubmitted.
public string TradingThresholdMessageContains a message describing why Trading Threshold processing prevented or modified an order.
public int TransactionIDA unique Transaction identifier generated by WealthLab. The ID can subsequently be transferred to Positions created from the Transaction.
public Transaction Clone()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.
public static Transaction Parse(string s)Creates a Transaction from a string previously produced by Persist.
public string Persist()Serializes a subset of the Transaction's properties into a string. The persisted information includes:
public void ApplyRoundLots(BacktestSettings bts)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.
public double AssignedQuantityGets 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.
public bool ManualQuantityIndicates that Transaction.Quantity was explicitly assigned rather than calculated automatically.
public bool NextBarPosSizeModeIndicates that the Transaction was generated using next-bar position sizing. The default value is false.
public double QuantityAdjustedReturns Quantity rounded to the number of quantity decimals supported by the associated Broker. If no Broker is assigned, returns Quantity unchanged.
public void TruncateQuantity(int precision)Truncates Quantity to the specified number of decimal places.
public void AssignAutoProfitTargetPrice(double price)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.
public void AssignAutoStopLossPrice(double price)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.
public double AutoProfitTargetPriceAssigns 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.
public double AutoStopLossPriceAssigns 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.
public double BacktestCurrentEquityContains 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.
public BarHistory BarsThe BarHistory associated with the Transaction.
public double BasisAmountContains 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.
public double BasisPriceContains the price used as the basis for position sizing.
public double CommissionThe commission applied to the Transaction during a backtest. Commission behavior is controlled by the Strategy's Backtest Settings.
public double CostBasisReturns 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.
public DateTime EntryDateThe signal date of the Transaction. This generally corresponds to the bar on which the trading signal was generated.
public string ExceededMaxOpenPosIndicates 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.
public DateTime ExecutionDateThe date and time at which the Transaction was executed by the Backtester.
public double ExecutionPriceThe price at which the Backtester executed the Transaction.
The default value is Double.NaN.
public bool FromQuotesIndicates that the Transaction originated from Quotes processing. The default value is false.
public DateTime GranularWeightBasisWhen Granular Limit/Stop Processing is used, contains the intraday DateTime that determined the Transaction's execution priority.
The default value is DateTime.MinValue.
public bool IsEntryReturns true if the Transaction is an entry:
public bool IsExitReturns true if the Transaction is an exit:
public bool MarginOverrideSet 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.
public double MarketOpenPriceReturns the opening price of the bar following SignalIndex.
Returns Double.NaN if Bars is unavailable, SignalIndex is -1, or there is no following bar.
public bool NSFIndicates that the Transaction was flagged as Non-Sufficient Funds by the Backtester.
public int PositionTagAn internal identifier used to associate Transactions with specific Positions or Building Block entries. Strategy developers should normally use Tag instead for custom data.
public PositionType PositionTypeReturns the PositionType represented by the Transaction.
Buy and Sell Transactions correspond to PositionType.Long.
Short and Cover Transactions correspond to PositionType.Short.
public double QuantityGets 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.
public void SetPositionMetric(string metric, double value)public int SignalIndexThe bar index at which the Transaction signal was generated.
public string SignalNameAn optional descriptive name associated with the signal. For an entry Transaction, this value is transferred to the resulting Position's EntrySignalName.
public Strategy SignalStrategypublic Strategy StrategyThe Strategy that generated the Transaction.
public object TagProvides 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.
public TransactionType TransactionTypeSpecifies the direction of the Transaction. Possible values include:
TransactionType.BuyTransactionType.SellTransactionType.ShortTransactionType.Coverpublic double WeightSpecifies 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.
Ask the community or explore custom development services.