Strategies

Reference

Strategies

The automated-trading surface: the Strategy base class and its context, the parameter and indicator declaration system, the managed-order and ATM controllers, data feeds, the catalog, and the backtest result and performance analytics.

Strategy & context — TradeStrike.Pipeline.Strategies

Derive from Strategy, declare parameters and indicators in OnInitialize, and act in OnBar using the protected bar/position/order helpers. The same surface is exposed abstractly as IStrategyContext for the host runtime.

Type Members
Strategy (abstract) State: Calculate, Instrument, Account, StrategyName, TickSize, PointValue, State, BarCount, CurrentBar, GetBar(barsAgo), TryGetBar(barsAgo, out bar), IsBarClosed, IsFirstTickOfBar, TradingHours, Session, IsFirstBarOfSession, InSession, Position, IsFlat/IsLong/IsShort, AccountSnapshot, WorkingOrders.
Actions: PlaceOrder/CancelOrder/ModifyOrder/Flatten, EnterLong/EnterShort/ExitLong/ExitShort(qty), Log(msg), NotifyEntryBlocked(reason), ClaimPositionManagement().
ATM: UseAtm(AtmStrategy, tickSize?, pointValue?), HasAtmBracket, SetAtmBracketGeometry(stop, target), SetNextStopPrice(price?).
Declare: IntParameter / DoubleParameter / BoolParameter / StringParameter / FilePathParameter(...), DeclareIndicator<T>(factory).
Overrides: OnInitialize / OnStart / OnBar / OnOrderUpdate / OnFill / OnPositionUpdate / OnStop.
IStrategyContext Runtime seam mirroring the above: bar accessors, CreateSessionIterator(template?), order verbs, Position, AccountSnapshot, RiskStateRegistry, WorkingOrders, IManagedOrderController CreateManagedOrderController(), IAtmService CreateAtmService(AtmStrategy, double tickSize, double pointValue), ClaimPositionManagement().
StrategyState enum: Created, Initialized, Running, Stopped, Faulted.
StrategyRunConfig record (string instrument, AccountId account, string? strategyName = null, IReadOnlyDictionary<string,object>? parameterOverrides = null, double? tickSize = null, double? pointValue = null, string? instrumentKey = null, string? instrumentVenue = null, string? tradingHoursTemplateName = null).
RenderingStrategy abstract Strategy, IChartCustomRender, IRepaintNotifier: event Action? RepaintRequested, OnCustomRender(IIndicatorRenderContext), RenderLayer, RequestChartRepaint().

Parameters & indicators

Parameters are typed, optionally optimizable, and convert implicitly to their value. Declared indicators return a handle whose Instance updates each bar.

Type Members
StrategyParameter (abstract) string Name, OptimizationRange? OptimizationRange, bool IsOptimizable, ParameterEditorKind EditorKind, string? FileFilter, object BoxedValue, Type ValueType.
StrategyParameter<T> T DefaultValue, T Value; implicit operator T(StrategyParameter<T>).
ParameterSet IReadOnlyList<StrategyParameter> All, int Count, StrategyParameter? Find(string name), bool TrySetValue(string name, object? value).
OptimizationRange record (decimal Min, decimal Max, decimal Step); Validated(string parameterName).
StrategyIndicator<T> T Instance, bool IsReady (where T : IndicatorBase).

Managed orders & ATM

Two layers of order management. IManagedOrderController turns position-aware enter/exit intents into orders; IAtmService runs an AtmStrategy bracket and advances its stop/target each bar. Create both via IStrategyContext.

Type Members
IManagedOrderController bool HasPendingOrder, void EnterLong(decimal quantity), void EnterShort(decimal quantity), void ExitLong(), void ExitShort(), void HandleOrderUpdate(Order order).
IAtmService bool HasBracket, void UpdateBracketGeometry(decimal stopOffset, decimal targetOffset), void SetNextBracketStopPrice(decimal? stopPrice), void OnBar(), void OnOrderUpdate(Order order), void OnPositionUpdate(Position position).
See also. AtmStrategy and the bracket model live in the trading contracts — see Trading → ATM.

Data feeds

Type Members
IStrategyDataFeed IReadOnlyList<Bar> History, event Action<Bar>? BarClosed.
IIntrabarStrategyDataFeed : IStrategyDataFeed adds event Action<IntrabarUpdate>? BarUpdated.
IntrabarUpdate readonly record struct: Bar DevelopingBar, bool IsFirstTickOfBar.
ILiveStrategyDataFeed : IStrategyDataFeed, IDisposable Task StartAsync(ct), Task StopAsync(), event Action<Exception>? Faulted.
IStrategyLogger void Log(string strategyName, string message); NullStrategyLogger.Instance.

Catalog — TradeStrike.Pipeline.Strategies.Catalog

Discovery and registration. Decorate a strategy with [StrategyMetadata] for a friendly name; the catalog reflects assemblies into launchable StrategyDescriptors.

Type Members
StrategyMetadataAttribute [AttributeUsage(Class)]: string? DisplayName, string? Description.
StrategyDescriptor string Id, Type StrategyType, string DisplayName, string Description, IReadOnlyList<StrategyParameter> Parameters, Strategy CreateInstance().
StrategyCatalog event Action? Changed, IReadOnlyList<StrategyDescriptor> Strategies, RegisterDynamic(...), ClearDynamic(), static BuildDefault() / BuildFrom(IEnumerable<Assembly>), StrategyDescriptor? Find(string name).

Backtest result & analytics

A backtest returns a BacktestResult with the final account/position, fills, equity curve and a rich PerformanceReport (namespace TradeStrike.Pipeline.Analytics and …Analytics.Metrics).

Type Members
BacktestResult StartingCash, FinalAccount, FinalPosition, Fills, Orders, EquityCurve, BarsReplayed, FinalState, FaultException, Performance, RealizedPnL, NetProfit, FillCount, WasCancelled.
PerformanceReport record: Pnl, Trades, Drawdown, RiskAdjusted, Excursion, Exposure, TradeList, EquityCurve, HasTrades; static Empty(startingCash).
Trade record: Number, Direction, EntryTimeUtc/ExitTimeUtc, EntryPrice/ExitPrice, Quantity, GrossPnL, Commission, NetPnL, IsWinner/IsLoser/IsOpen, Duration, BarsInTrade, Mae/Mfe(Currency/Price), EndTradeDrawdown.
TradeDirection enum: Long, Short.
EquityPoint readonly record struct (DateTime TimeUtc, decimal Equity).
PnLSummary StartingCash, NetProfit, GrossProfit/GrossLoss, TotalCommission, ProfitFactor, ReturnPct, EndingEquity.
TradeStatistics TotalTrades, Winning/Losing/BreakEven, Long/Short splits, AverageTrade/Winner/Loser, LargestWinner/Loser, MaxConsecutiveWinners/Losers, WinLossRatio, Sqn, WinRatePct.
DrawdownMetrics MaxDrawdown, MaxDrawdownPct, AverageDrawdown, LongestDrawdownDuration, MaxRunup, UlcerIndex, RecoveryFactor.
RiskAdjustedMetrics SharpeRatio, SortinoRatio, CalmarRatio, AnnualReturnPct, DailyReturnStdDevPct.
ExcursionMetrics AverageMae/AverageMfe, WorstMae/BestMfe, AverageEndTradeDrawdown, AverageTradeEfficiencyPct.
ExposureMetrics TimeInMarketPct, TotalContractsTraded, AveragePositionSize.

Replay options — TradeStrike.Pipeline.Strategies.Replay

Type Values
BacktestResolution enum: BarOpenOnly, BarClose, BarOHLC, BarMagnifier, EveryTickGenerated, EveryTickReal.
IntrabarTieBreak enum: UseBarDirection, LowBeforeHigh, HighBeforeLow.