Strategy

StockSharp.Algo.Strategies

The base class for all trade strategies.

Inherits: BaseLogReceiver

Implements: INotifyPropertyChangedEx, INotifyPropertyChanged, IMarketRuleContainer, ILogReceiver, ILogSource, IDisposable, ICloneable<Strategy>, ICloneable, IMarketDataProvider, ISubscriptionProvider, ISecurityProvider, ISecurityMessageProvider, ITransactionProvider, IScheduledTask, ICustomTypeDescriptor, ITimeProvider, IPortfolioProvider, IPositionProvider, IReportSource

Constructors

Strategy
public Strategy()
strategy = Strategy()

Initializes a new instance of the Strategy.

Properties

AggregationInterval
public TimeSpan AggregationInterval { get; set; }
value = strategy.AggregationInterval
strategy.AggregationInterval = value

Time interval for aggregation. Orders/trades within the same interval are grouped together. Default is 1 hour. Set to Zero to disable time-based grouping.

CancelOrdersWhenStopping
public bool CancelOrdersWhenStopping { get; set; }
value = strategy.CancelOrdersWhenStopping
strategy.CancelOrdersWhenStopping = value

To cancel active orders at stop. Is On by default.

ChildStrategies
public INotifyList<Strategy> ChildStrategies { get; }
value = strategy.ChildStrategies

Subsidiary trade strategies.

CommentMode
public StrategyCommentModes CommentMode { get; set; }
value = strategy.CommentMode
strategy.CommentMode = value

Set Comment by Name or Id.

Commission
public decimal? Commission { get; private set; }
value = strategy.Commission
strategy.Commission = value

Total commission.

Connector
public virtual Connector Connector { get; set; }
value = strategy.Connector
strategy.Connector = value

Connection to the trading system.

CurrentTime
public override DateTime CurrentTime { get; }
value = strategy.CurrentTime

Current time.

DisposeOnStop
public bool DisposeOnStop { get; set; }
value = strategy.DisposeOnStop
strategy.DisposeOnStop = value

Automatically to clear resources, used by the strategy, when it stops (state ProcessState becomes equal to Stopped).

Environment
public SettingsStorage Environment { get; }
value = strategy.Environment

Strategy environment parameters.

ErrorState
public LogLevels ErrorState { get; private set; }
value = strategy.ErrorState
strategy.ErrorState = value

The state of an error.

HideSecurityAndPortfolioParameters
public static bool HideSecurityAndPortfolioParameters { get; set; }
value = Strategy.HideSecurityAndPortfolioParameters
Strategy.HideSecurityAndPortfolioParameters = value

Make Security and Portfolio as non-browsable.

HistoryCalculated
protected virtual TimeSpan? HistoryCalculated { get; }
value = strategy.HistoryCalculated

Calculated from code version of HistorySize.

HistorySize
public TimeSpan? HistorySize { get; set; }
value = strategy.HistorySize
strategy.HistorySize = value

History to initialize the strategy on Live trading.

Id
public override Guid Id { get; set; }
value = strategy.Id
strategy.Id = value

Strategy ID.

Indicators
public INotifyList<IIndicator> Indicators { get; }
value = strategy.Indicators

All indicators used in strategy. Uses in default implementation of IsFormed.

IndicatorSource
public Level1Fields? IndicatorSource { get; set; }
value = strategy.IndicatorSource
strategy.IndicatorSource = value

Default source for indicators when Source is not set.

IsBacktesting
public bool IsBacktesting { get; }
value = strategy.IsBacktesting

Determines Connector is HistoryEmulationConnector.

IsFormed
public virtual bool IsFormed { get; }
value = strategy.IsFormed

Strategy fully formed.

IsOnline
public bool IsOnline { get; private set; }
value = strategy.IsOnline
strategy.IsOnline = value

True means that strategy is started and all of its subscriptions are in online state.

IsRulesSuspended
public bool IsRulesSuspended { get; }
value = strategy.IsRulesSuspended

Is rules execution suspended.

KeepStatistics
public bool KeepStatistics { get; set; }
value = strategy.KeepStatistics
strategy.KeepStatistics = value

Keep trading statistics (orders, trades, profit etc.) after restart.

LastError
public Exception LastError { get; private set; }
value = strategy.LastError
strategy.LastError = value

The last error that caused the strategy to stop.

Latency
public TimeSpan? Latency { get; private set; }
value = strategy.Latency
strategy.Latency = value

Total latency.

LogLevel
public override LogLevels LogLevel { get; set; }
value = strategy.LogLevel
strategy.LogLevel = value

The level to perform this rule logging.

MaxOrdersBeforeAggregation
public int MaxOrdersBeforeAggregation { get; set; }
value = strategy.MaxOrdersBeforeAggregation
strategy.MaxOrdersBeforeAggregation = value

Maximum number of orders before automatic aggregation is triggered. Default is 10000. Set to 0 to disable automatic aggregation.

MaxTradesBeforeAggregation
public int MaxTradesBeforeAggregation { get; set; }
value = strategy.MaxTradesBeforeAggregation
strategy.MaxTradesBeforeAggregation = value

Maximum number of trades before automatic aggregation is triggered. Default is 10000. Set to 0 to disable automatic aggregation.

MyTrades
public IEnumerable<MyTrade> MyTrades { get; }
value = strategy.MyTrades

Trades, matched during the strategy operation.

Name
public override string Name { get; set; }
value = strategy.Name
strategy.Name = value

Strategy name.

NameGenerator
public StrategyNameGenerator NameGenerator { get; }
value = strategy.NameGenerator

The generator of strategy name.

OrderBookSources
public virtual IEnumerable<IOrderBookSource> OrderBookSources { get; }
value = strategy.OrderBookSources

All possible IOrderBookMessage sources that can be received via OrderBookDrawing.

OrderLookup
public Subscription OrderLookup { get; }
value = strategy.OrderLookup

Get global subscription on Order lookup. Can be .

Orders
public IEnumerable<Order> Orders { get; }
value = strategy.Orders

Orders, registered within the strategy framework.

OrdersKeepTime
public TimeSpan OrdersKeepTime { get; set; }
value = strategy.OrdersKeepTime
strategy.OrdersKeepTime = value

The time for storing Orders in memory. By default it equals to 2 days. If value is set in Zero, orders will not be deleted.

Parameters
public StrategyParameterDictionary Parameters { get; }
value = strategy.Parameters

Strategy parameters.

PnL
public decimal PnL { get; }
value = strategy.PnL

The aggregate value of profit-loss without accounting commission Commission.

PnLManager
public IPnLManager PnLManager { get; set; }
value = strategy.PnLManager
strategy.PnLManager = value

The profit-loss manager.

Portfolio
public Portfolio Portfolio { get; set; }
value = strategy.Portfolio
strategy.Portfolio = value

Portfolio.

PortfolioLookup
public Subscription PortfolioLookup { get; }
value = strategy.PortfolioLookup

Get global subscription on Portfolio lookup. Can be .

PortfolioProvider
public IPortfolioProvider PortfolioProvider { get; set; }
value = strategy.PortfolioProvider
strategy.PortfolioProvider = value

IPortfolioProvider

Position
public decimal Position { get; set; }
value = strategy.Position
strategy.Position = value

The position aggregate value.

Positions
public IEnumerable<Position> Positions { get; }
value = strategy.Positions

Get all positions.

ProcessState
public virtual ProcessStates ProcessState { get; private set; }
value = strategy.ProcessState
strategy.ProcessState = value

The operation state.

ReportSource
public ReportSource ReportSource { get; }
value = strategy.ReportSource

Report data source with aggregation support.

RiskFreeRate
public decimal RiskFreeRate { get; set; }
value = strategy.RiskFreeRate
strategy.RiskFreeRate = value

Annual risk-free rate (e.g., 0.03 = 3%).

RiskManager
public IRiskManager RiskManager { get; set; }
value = strategy.RiskManager
strategy.RiskManager = value

The risks control manager.

RiskRules
public IEnumerable<IRiskRule> RiskRules { get; set; }
value = strategy.RiskRules
strategy.RiskRules = value

The risk rules.

Rules
public IMarketRuleList Rules { get; }
value = strategy.Rules

Registered rules.

Security
public Security Security { get; set; }
value = strategy.Security
strategy.Security = value

Security.

Slippage
public decimal? Slippage { get; private set; }
value = strategy.Slippage
strategy.Slippage = value

Total slippage.

StartedTime
public DateTime StartedTime { get; private set; }
value = strategy.StartedTime
strategy.StartedTime = value

Strategy start time.

StatisticManager
public IStatisticManager StatisticManager { get; protected set; }
value = strategy.StatisticManager
strategy.StatisticManager = value

The statistics manager.

TargetAlgoFactory
public Func<Sides, decimal, IPositionModifyAlgo> TargetAlgoFactory { get; set; }
value = strategy.TargetAlgoFactory
strategy.TargetAlgoFactory = value

Factory to create position modify algorithms for TargetPositionManager. Default creates MarketOrderAlgo.

TargetPositionManager
public PositionTargetManager TargetPositionManager { get; }
value = strategy.TargetPositionManager

Target position manager.

TotalWorkingTime
public TimeSpan TotalWorkingTime { get; private set; }
value = strategy.TotalWorkingTime
strategy.TotalWorkingTime = value

The total time of strategy operation less time periods, when strategy was stopped.

TradingMode
public StrategyTradingModes TradingMode { get; set; }
value = strategy.TradingMode
strategy.TradingMode = value

Allow trading.

UnrealizedPnLInterval
public TimeSpan UnrealizedPnLInterval { get; set; }
value = strategy.UnrealizedPnLInterval
strategy.UnrealizedPnLInterval = value

The interval for unrealized profit recalculation. The default value is 1 minute.

UnsubscribeOnStop
public bool UnsubscribeOnStop { get; set; }
value = strategy.UnsubscribeOnStop
strategy.UnsubscribeOnStop = value

Unsubscribe all active subscription while strategy become stopping.

Volume
public virtual decimal Volume { get; set; }
value = strategy.Volume
strategy.Volume = value

Operational volume.

WaitAllTrades
public bool WaitAllTrades { get; set; }
value = strategy.WaitAllTrades
strategy.WaitAllTrades = value

Stop strategy only after getting all trades by registered orders.

WaitRulesOnStop
public bool WaitRulesOnStop { get; set; }
value = strategy.WaitRulesOnStop
strategy.WaitRulesOnStop = value

Wait Rules to finish before strategy become into Stopped state.

WorkingTime
public WorkingTime WorkingTime { get; set; }
value = strategy.WorkingTime
strategy.WorkingTime = value

The time boundary, within which candles for give series shall be translated.

Methods

Alert
protected void Alert(AlertNotifications type, string message)
strategy.Alert(type, message)

Send alert notification with strategy name as caption.

type
Alert type.
message
Alert text.
Alert
protected void Alert(AlertNotifications type, string caption, string message)
strategy.Alert(type, caption, message)

Send alert notification.

type
Alert type.
caption
Signal header.
message
Alert text.
AlertLog
protected void AlertLog(string message)
strategy.AlertLog(message)

Send log alert notification.

message
Alert text.
AlertPopup
protected void AlertPopup(string message)
strategy.AlertPopup(message)

Send popup alert notification.

message
Alert text.
AlertSound
protected void AlertSound(string message)
strategy.AlertSound(message)

Send sound alert notification.

message
Alert text.
ApplyCommand
public virtual void ApplyCommand(CommandMessage cmdMsg)
strategy.ApplyCommand(cmdMsg)

Apply incoming command.

cmdMsg
The message contains information about command to change state.
BuyLimit
public Order BuyLimit(decimal price, decimal? volume, Security security)
result = strategy.BuyLimit(price, volume, security)

To create the initialized order object for buy.

price
Price.
volume
The volume. If value is passed, then Volume value is used.
security
The security. If value is passed, then Security value is used.

Returns: The initialized order object.

BuyMarket
public Order BuyMarket(decimal? volume, Security security)
result = strategy.BuyMarket(volume, security)

To create initialized object of buy order at market price.

volume
The volume. If value is passed, then Volume value is used.
security
The security. If value is passed, then Security value is used.

Returns: The initialized order object.

CanAttach
protected virtual bool CanAttach(Order order)
result = strategy.CanAttach(order)

Determines the specified order can be owned by the strategy.

order
Order.

Returns: Check result.

CancelActiveOrders
public void CancelActiveOrders(bool? isStopOrder, Portfolio portfolio, Sides? direction, ExchangeBoard board, Security security, SecurityTypes? securityType, long? transactionId)
strategy.CancelActiveOrders(isStopOrder, portfolio, direction, board, security, securityType, transactionId)

To cancel all active orders (to stop and regular).

isStopOrder
, if cancel only a stop orders, - if regular orders, - both.
portfolio
Portfolio. If the value is equal to , then the portfolio does not match the orders cancel filter.
direction
Order side. If the value is , the direction does not use.
board
Trading board. If the value is equal to , then the board does not match the orders cancel filter.
security
Instrument. If the value is equal to , then the instrument does not match the orders cancel filter.
securityType
Security type. If the value is , the type does not use.
transactionId
Order cancellation transaction id.
CancelOrder
public void CancelOrder(Order order)
strategy.CancelOrder(order)

Cancel the order.

order
The order which should be canceled.
CancelTargetPosition
public void CancelTargetPosition(Security security, Portfolio portfolio)
strategy.CancelTargetPosition(security, portfolio)

Cancel target position for specified security and portfolio.

security
Security.
portfolio
Portfolio.
CancelTargetPosition
public void CancelTargetPosition()
strategy.CancelTargetPosition()

Cancel target position for the strategy's Security and Portfolio.

CanTrade
protected virtual bool CanTrade(Security security, Portfolio portfolio, Sides side, decimal volume, string noTradeReason)
result = strategy.CanTrade(security, portfolio, side, volume, noTradeReason)

Check if can trade with order information.

security
Security to trade.
portfolio
Portfolio to trade.
side
Order side.
volume
Order volume.
noTradeReason
Reason why trading is not allowed.

Returns: True if trading is allowed.

Clone
public virtual Strategy Clone()
result = strategy.Clone()

Creates a deep copy of a DataSeries

ClosePosition
public Order ClosePosition(Security security, Portfolio portfolio)
result = strategy.ClosePosition(security, portfolio)

To close open position by market (to register the order of the type Market).

security
Security. If not passed the value from Security will be obtain.
portfolio
Portfolio. If not passed the value from Portfolio will be obtain.

Returns: The initialized order object.

CopyTo
protected virtual void CopyTo(Strategy copy)
strategy.CopyTo(copy)

Copy settings into .

copy
Strategy
CreateChartArea
protected IChartArea CreateChartArea()
result = strategy.CreateChartArea()

Create chart area.

Returns: IChartArea

CreateClone
protected virtual Strategy CreateClone()
result = strategy.CreateClone()

Create clone object (non-initialized).

Returns: Strategy

CreateOrder
public Order CreateOrder(Sides side, decimal price, decimal? volume)
result = strategy.CreateOrder(side, price, volume)

To create the initialized order object.

side
Order side.
price
The price. If value is passed, the order is registered at market price.
volume
The volume. If value is passed, then Volume value is used.

Returns: The initialized order object.

CreateTimer
protected ITimerHandler CreateTimer(TimeSpan interval, Action callback)
result = strategy.CreateTimer(interval, callback)

Create a timer that executes callback at specified intervals.

interval
Timer interval.
callback
Callback to execute.

Returns: ITimerHandler

DisposeManaged
protected override void DisposeManaged()
strategy.DisposeManaged()

Release resources.

DrawCandles
protected IChartCandleElement DrawCandles(IChartArea area, Subscription subscription)
result = strategy.DrawCandles(area, subscription)

Draw candles on chart.

area
IChartArea
subscription
Subscription

Returns: IChartCandleElement

DrawCandles``1
protected IChartCandleElement DrawCandles<T>(IChartArea area, ISubscriptionHandler<T> subscription)
result = strategy.DrawCandles(area, subscription)

Draw candles on chart.

area
IChartArea
subscription
SubscriptionHandler

Returns: IChartCandleElement

DrawIndicator
protected IChartIndicatorElement DrawIndicator(IChartArea area, IIndicator indicator, Color? color, Color? additionalColor)
result = strategy.DrawIndicator(area, indicator, color, additionalColor)

Draw indicator on chart.

area
IChartArea
indicator
IIndicator
color
Color
additionalColor
AdditionalColor

Returns: IChartIndicatorElement

DrawOrderBook
public void DrawOrderBook(Subscription subscription, IOrderBookSource source, IOrderBookMessage book)
strategy.DrawOrderBook(subscription, source, book)

Draw IOrderBookMessage.

subscription
Subscription
source
IOrderBookSource
book
IOrderBookMessage
DrawOrderBookOrder
public void DrawOrderBookOrder(Subscription subscription, IOrderBookSource source, Order order)
strategy.DrawOrderBookOrder(subscription, source, order)

Draw order book order.

subscription
Subscription
source
IOrderBookSource
order
Order.
DrawOrderBookOrderFail
public void DrawOrderBookOrderFail(Subscription subscription, IOrderBookSource source, OrderFail fail)
strategy.DrawOrderBookOrderFail(subscription, source, fail)

Draw order book order fail.

subscription
Subscription
source
IOrderBookSource
fail
Order fail.
DrawOrders
protected IChartOrderElement DrawOrders(IChartArea area)
result = strategy.DrawOrders(area)

Draw orders on chart.

area
IChartArea

Returns: IChartOrderElement

DrawOwnTrades
protected IChartTradeElement DrawOwnTrades(IChartArea area)
result = strategy.DrawOwnTrades(area)

Draw trades on chart.

area
IChartArea

Returns: IChartTradeElement

EditOrder
public void EditOrder(Order order, Order changes)
strategy.EditOrder(order, changes)

Edit the order.

order
Order.
changes
Order changes.
EnsureOrderMetadata
private void EnsureOrderMetadata(Order order, DateTime fallbackTime)
strategy.EnsureOrderMetadata(order, fallbackTime)

Ensures the order has metadata required by strategy surfaces.

order
Order.
fallbackTime
Fallback time.
GetAlertService
public IAlertNotificationService GetAlertService()
result = strategy.GetAlertService()

To get the IAlertNotificationService associated with the passed strategy.

Returns: Alert notification service.

GetChart
public IChart GetChart()
result = strategy.GetChart()

To get the IChart associated with the passed strategy.

Returns: Chart.

GetOptionDesk
public IOptionDesk GetOptionDesk()
result = strategy.GetOptionDesk()

To get the IOptionDesk.

Returns: IOptionDesk.

GetOptionPositionChart
public IOptionPositionChart GetOptionPositionChart()
result = strategy.GetOptionPositionChart()

To get the IOptionPositionChart associated with the passed strategy.

Returns: Chart.

GetParameters
public virtual IStrategyParam[] GetParameters()
result = strategy.GetParameters()

Get parameters.

Returns: Parameters.

GetPortfolio
public Portfolio GetPortfolio()
result = strategy.GetPortfolio()

Get Portfolio or throw InvalidOperationException if not present.

Returns: Portfolio

GetPositionValue
public decimal? GetPositionValue(Security security, Portfolio portfolio)
result = strategy.GetPositionValue(security, portfolio)

Get position.

security
Security.
portfolio
Portfolio.

Returns: Position.

GetSecurity
public Security GetSecurity()
result = strategy.GetSecurity()

Get Security or throw InvalidOperationException if not present.

Returns: Security

GetSecurityValue``1
public T GetSecurityValue<T>(Level1Fields field)
result = strategy.GetSecurityValue(field)

To get market data value for the strategy instrument.

field
Market-data field.

Returns: The field value. If no data, the will be returned.

GetStatValue``2
protected TValue GetStatValue<TParam, TValue>(TValue fallback)
result = strategy.GetStatValue(fallback)

Get the value of a statistic parameter by its type.

fallback
Fallback value if the parameter is not found.

Returns: The parameter value or .

GetTargetPosition
public decimal? GetTargetPosition(Security security, Portfolio portfolio)
result = strategy.GetTargetPosition(security, portfolio)

Get target position for specified security and portfolio.

security
Security.
portfolio
Portfolio.

Returns: Target position, or null if not set.

GetTargetPosition
public decimal? GetTargetPosition()
result = strategy.GetTargetPosition()

Get target position for the strategy's Security and Portfolio.

Returns: Target position, or null if not set.

GetWorkingPortfolios
public virtual IEnumerable<Portfolio> GetWorkingPortfolios()
result = strategy.GetWorkingPortfolios()

Get all portfolios required for strategy.

Returns: Portfolios.

GetWorkingSecurities
public virtual IEnumerable<ValueTuple<Security, DataType>> GetWorkingSecurities()
result = strategy.GetWorkingSecurities()

Get all securities required for strategy.

Returns: Securities.

InitStartValues
protected void InitStartValues()
strategy.InitStartValues()

Init.

IsFormedAndOnline
public bool IsFormedAndOnline()
result = strategy.IsFormedAndOnline()

IsFormed and IsOnline.

Returns: Check result.

IsFormedAndOnlineAndAllowTrading
public bool IsFormedAndOnlineAndAllowTrading(StrategyTradingModes required)
result = strategy.IsFormedAndOnlineAndAllowTrading(required)

IsFormedAndOnline and TradingMode.

required
Required action.

Returns: Check result.

IsOrderEditable
public bool? IsOrderEditable(Order order)
result = strategy.IsOrderEditable(order)

Determines the specified order can be edited by Order).

order
Order.

Returns: if the order is editable, order cannot be changed, means no information.

IsOrderReplaceable
public bool? IsOrderReplaceable(Order order)
result = strategy.IsOrderReplaceable(order)

Determines the specified order can be replaced by Order).

order
Order.

Returns: if the order is replaceable, order cannot be replaced, means no information.

Load
public override void Load(SettingsStorage storage)
strategy.Load(storage)

Load settings.

storage
Settings storage.
LookupByIdAsync
public ValueTask<Security> LookupByIdAsync(SecurityId id, CancellationToken cancellationToken)
result = strategy.LookupByIdAsync(id, cancellationToken)

To get the instrument by the identifier.

id
Security ID.
cancellationToken
CancellationToken

Returns: The got instrument. If there is no instrument by given criteria, is returned.

OnError
protected virtual void OnError(Strategy strategy, Exception error)
strategy.OnError(strategy, error)

Processing of error, occurred as result of strategy operation.

strategy
Strategy.
error
Error.
OnOrderReceived
protected virtual void OnOrderReceived(Order order)
strategy.OnOrderReceived(order)

Order received.

order
Order
OnOrderRegistered
protected virtual void OnOrderRegistered(Order order)
strategy.OnOrderRegistered(order)

To call the event OrderRegistered.

order
Order.
OnOrderRegisterFailed
protected virtual void OnOrderRegisterFailed(OrderFail fail, bool calcRisk)
strategy.OnOrderRegisterFailed(fail, calcRisk)

The method, called at strategy order registration error.

fail
Error registering order.
calcRisk
Invoke risk manager.
OnOrderRegistering
protected virtual void OnOrderRegistering(Order order)
strategy.OnOrderRegistering(order)

To call the event OrderRegistering.

order
Order.
OnOrderReRegistering
protected virtual void OnOrderReRegistering(Order oldOrder, Order newOrder)
strategy.OnOrderReRegistering(oldOrder, newOrder)

To call the event OrderReRegistering.

oldOrder
Cancelling order.
newOrder
New order to register.
OnOwnTradeReceived
protected virtual void OnOwnTradeReceived(MyTrade trade)
strategy.OnOwnTradeReceived(trade)

Own trade received.

trade
MyTrade
OnPositionReceived
protected virtual void OnPositionReceived(Position position)
strategy.OnPositionReceived(position)

Position received.

position
Position
OnReseted
protected virtual void OnReseted()
strategy.OnReseted()

It is called from the Reset method.

OnStarted
protected virtual void OnStarted(DateTimeOffset time)
strategy.OnStarted(time)

The method is called when the Start method has been called and the ProcessState state has been taken the Started value.

OnStarted
protected virtual void OnStarted()
strategy.OnStarted()

The method is called when the Start method has been called and the ProcessState state has been taken the Started value.

OnStarted2
protected virtual void OnStarted2(DateTime time)
strategy.OnStarted2(time)

The method is called when the Start method has been called and the ProcessState state has been taken the Started value.

OnStopped
protected virtual void OnStopped()
strategy.OnStopped()

The method is called when the ProcessState process state has been taken the Stopped value.

OnStopping
protected virtual void OnStopping()
strategy.OnStopping()

The method is called when the ProcessState process state has been taken the Stopping value.

Param``1
public StrategyParam<T> Param<T>(string id, T initialValue)
result = strategy.Param(id, initialValue)

Initializes a new instance of the StrategyParam.

id
Parameter identifier.
initialValue
The initial value.

Returns: The strategy parameter.

Prepare
public void Prepare()
strategy.Prepare()

Prepare data for report generation. Call this before accessing any data to ensure all values are up-to-date.

ProcessOrder
private void ProcessOrder(Order order, bool isChanging)
strategy.ProcessOrder(order, isChanging)

To add the order to the strategy.

order
Order.
isChanging
The order came from the change event.
RaiseLog
protected override void RaiseLog(LogMessage message)
strategy.RaiseLog(message)
RaiseParametersChanged
public void RaiseParametersChanged(string name)
strategy.RaiseParametersChanged(name)

To call events ParametersChanged and PropertyChanged.

name
Parameter name.
RaiseProcessStateChanged
protected void RaiseProcessStateChanged(Strategy strategy)
strategy.RaiseProcessStateChanged(strategy)

To call the event ProcessStateChanged.

strategy
Strategy.
RaiseReseted
private void RaiseReseted()
strategy.RaiseReseted()

To call the event Reseted.

RegisterOrder
public void RegisterOrder(Order order)
strategy.RegisterOrder(order)

Register new order.

order
Registration details.
ReRegisterOrder
public void ReRegisterOrder(Order oldOrder, Order newOrder)
strategy.ReRegisterOrder(oldOrder, newOrder)

Reregister the order.

oldOrder
Cancelling order.
newOrder
New order to register.
Reset
public void Reset()
strategy.Reset()

To re-initialize the trade algorithm. It is called after initialization of the strategy object and loading stored parameters.

SafeGetConnector
public IConnector SafeGetConnector()
result = strategy.SafeGetConnector()

To get the strategy getting Connector. If it is not initialized, the exception will be discarded.

Returns: Connector.

Save
public void Save(SettingsStorage storage, bool saveStatistics, bool saveSystemParameters)
strategy.Save(storage, saveStatistics, saveSystemParameters)

Save settings.

storage
SettingsStorage
saveStatistics
KeepStatistics
saveSystemParameters
Save system parameters.
Save
public override void Save(SettingsStorage storage)
strategy.Save(storage)

Save settings.

storage
Settings storage.
SellLimit
public Order SellLimit(decimal price, decimal? volume, Security security)
result = strategy.SellLimit(price, volume, security)

To create the initialized order object for sell.

price
Price.
volume
The volume. If value is passed, then Volume value is used.
security
The security. If value is passed, then Security value is used.

Returns: The initialized order object.

SellMarket
public Order SellMarket(decimal? volume, Security security)
result = strategy.SellMarket(volume, security)

To create the initialized order object of sell order at market price.

volume
The volume. If value is passed, then Volume value is used.
security
The security. If value is passed, then Security value is used.

Returns: The initialized order object.

SetAlertService
public void SetAlertService(IAlertNotificationService service)
strategy.SetAlertService(service)

To set a IAlertNotificationService for the strategy.

service
Alert notification service.
SetChart
public void SetChart(IChart chart)
strategy.SetChart(chart)

To set a IChart for the strategy.

chart
Chart.
SetOptionDesk
public void SetOptionDesk(IOptionDesk desk)
strategy.SetOptionDesk(desk)

To set the IOptionDesk.

desk
IOptionDesk.
SetOptionPositionChart
public void SetOptionPositionChart(IOptionPositionChart chart)
strategy.SetOptionPositionChart(chart)

To set a IChart for the strategy.

chart
Chart.
SetPositionValue
public void SetPositionValue(Security security, Portfolio portfolio, decimal value, DateTime time)
strategy.SetPositionValue(security, portfolio, value, time)

Set position.

security
Security.
portfolio
Portfolio.
value
Position.
time
Timestamp to assign into LocalTime and ServerTime if position is created anew.
SetTargetPosition
public void SetTargetPosition(decimal target)
strategy.SetTargetPosition(target)

Set target position for the strategy's Security and Portfolio.

target
Target position value.
SetTargetPosition
public void SetTargetPosition(Security security, Portfolio portfolio, decimal target)
strategy.SetTargetPosition(security, portfolio, target)

Set target position for specified security and portfolio.

security
Security.
portfolio
Portfolio.
target
Target position value.
Start
public virtual void Start()
strategy.Start()

To start the trade algorithm.

StartProtection
protected void StartProtection(Unit takeProfit, Unit stopLoss, bool isStopTrailing, TimeSpan? takeTimeout, TimeSpan? stopTimeout, bool useMarketOrders, bool isLocalStop)
strategy.StartProtection(takeProfit, stopLoss, isStopTrailing, takeTimeout, stopTimeout, useMarketOrders, isLocalStop)

Start position protection.

takeProfit
Take offset.
stopLoss
Stop offset.
isStopTrailing
Whether to use a trailing technique.
takeTimeout
Time limit. If protection has not worked by this time, the position will be closed on the market.
stopTimeout
Time limit. If protection has not worked by this time, the position will be closed on the market.
useMarketOrders
Whether to use market orders.
isLocalStop
Force local stop processing regardless of adapter capabilities.
StartTimer
protected ITimerHandler StartTimer(TimeSpan interval, Action callback)
result = strategy.StartTimer(interval, callback)

Create a timer that executes callback at specified intervals and starts it immediately.

interval
Timer interval.
callback
Callback to execute.

Returns: ITimerHandler

Stop
public virtual void Stop()
strategy.Stop()

To stop the trade algorithm.

Stop
public void Stop(Exception error)
strategy.Stop(error)

To stop the trade algorithm by error reason.

error
Error.
Subscribe
public void Subscribe(Subscription subscription)
strategy.Subscribe(subscription)

Subscribe.

subscription
Subscription.
SubscribeCandles
protected ISubscriptionHandler<ICandleMessage> SubscribeCandles(Subscription subscription)
result = strategy.SubscribeCandles(subscription)

Subscribe to candles.

subscription
Subscription

Returns: SubscriptionHandler

SubscribeCandles
protected ISubscriptionHandler<ICandleMessage> SubscribeCandles(DataType dt, bool isFinishedOnly, Security security)
result = strategy.SubscribeCandles(dt, isFinishedOnly, security)

Subscribe to candles.

dt
DataType
isFinishedOnly
IsFinishedOnly
security
Security. If security is not passed, then Security value is used.

Returns: SubscriptionHandler

SubscribeCandles
protected ISubscriptionHandler<ICandleMessage> SubscribeCandles(TimeSpan tf, bool isFinishedOnly, Security security)
result = strategy.SubscribeCandles(tf, isFinishedOnly, security)

Subscribe to candles.

tf
Time-frame.
isFinishedOnly
IsFinishedOnly
security
Security. If security is not passed, then Security value is used.

Returns: SubscriptionHandler

SubscribeLevel1
protected ISubscriptionHandler<Level1ChangeMessage> SubscribeLevel1(Subscription subscription)
result = strategy.SubscribeLevel1(subscription)

Subscribe to Level1.

subscription
Subscription

Returns: SubscriptionHandler

SubscribeLevel1
protected ISubscriptionHandler<Level1ChangeMessage> SubscribeLevel1(Security security)
result = strategy.SubscribeLevel1(security)

Subscribe to Level1.

security
Security. If security is not passed, then Security value is used.

Returns: SubscriptionHandler

SubscribeOrderBook
protected ISubscriptionHandler<IOrderBookMessage> SubscribeOrderBook(Subscription subscription)
result = strategy.SubscribeOrderBook(subscription)

Subscribe to MarketDepth.

subscription
Subscription

Returns: SubscriptionHandler

SubscribeOrderBook
protected ISubscriptionHandler<IOrderBookMessage> SubscribeOrderBook(Security security)
result = strategy.SubscribeOrderBook(security)

Subscribe to MarketDepth.

security
Security. If security is not passed, then Security value is used.

Returns: SubscriptionHandler

SubscribeTicks
protected ISubscriptionHandler<ITickTradeMessage> SubscribeTicks(Subscription subscription)
result = strategy.SubscribeTicks(subscription)

Subscribe to Ticks.

subscription
Subscription

Returns: SubscriptionHandler

SubscribeTicks
protected ISubscriptionHandler<ITickTradeMessage> SubscribeTicks(Security security)
result = strategy.SubscribeTicks(security)

Subscribe to Ticks.

security
Security. If security is not passed, then Security value is used.

Returns: SubscriptionHandler

ToReportValue
protected virtual object ToReportValue(object value)
result = strategy.ToReportValue(value)

To convert parameter value to report value.

value
The parameter value.

Returns: The report value.

TryAddMyTrade
public bool TryAddMyTrade(MyTrade trade)
result = strategy.TryAddMyTrade(trade)

Try add own trade.

trade
MyTrade

Returns: Operation result.

UnSubscribe
public void UnSubscribe(Subscription subscription)
strategy.UnSubscribe(subscription)

Unsubscribe.

subscription
Subscription.

Events

BoardReceived
public event Action<Subscription, ExchangeBoard> BoardReceived
strategy.BoardReceived += handler

ExchangeBoard received.

CandleReceived
public event Action<Subscription, ICandleMessage> CandleReceived
strategy.CandleReceived += handler

ICandleMessage received.

CommissionChanged
public event Action CommissionChanged
strategy.CommissionChanged += handler

Commission change event.

ConnectorChanged
public event Action ConnectorChanged
strategy.ConnectorChanged += handler

The event of strategy connection change.

CurrentTimeChanged
public event Action<TimeSpan> CurrentTimeChanged
strategy.CurrentTimeChanged += handler

Server time changed CurrentTime. It passed the time difference since the last call of the event. The first time the event passes the value Zero.

DataTypeReceived
public event Action<Subscription, DataType> DataTypeReceived
strategy.DataTypeReceived += handler

DataType received.

Error
public event Action<Strategy, Exception> Error
strategy.Error += handler

The event of error occurrence in the strategy.

IsOnlineChanged
public event Action<Strategy> IsOnlineChanged
strategy.IsOnlineChanged += handler

The event of strategy online state change.

LatencyChanged
public event Action LatencyChanged
strategy.LatencyChanged += handler

Latency change event.

Level1Received
public event Action<Subscription, Level1ChangeMessage> Level1Received
strategy.Level1Received += handler

Level1ChangeMessage received.

NewMyTrade
public event Action<MyTrade> NewMyTrade
strategy.NewMyTrade += handler

Own trade received.

NewsReceived
public event Action<Subscription, News> NewsReceived
strategy.NewsReceived += handler

News received.

OrderBookDrawing
public event Action<Subscription, IOrderBookSource, IOrderBookMessage> OrderBookDrawing
strategy.OrderBookDrawing += handler

IOrderBookMessage).

OrderBookDrawingOrder
public event Action<Subscription, IOrderBookSource, Order> OrderBookDrawingOrder
strategy.OrderBookDrawingOrder += handler

Order).

OrderBookDrawingOrderFail
public event Action<Subscription, IOrderBookSource, OrderFail> OrderBookDrawingOrderFail
strategy.OrderBookDrawingOrderFail += handler

OrderFail).

OrderBookReceived
public event Action<Subscription, IOrderBookMessage> OrderBookReceived
strategy.OrderBookReceived += handler

IOrderBookMessage received.

OrderCancelFailed
public event Action<OrderFail> OrderCancelFailed
strategy.OrderCancelFailed += handler

Order cancellation error event.

OrderCancelFailReceived
public event Action<Subscription, OrderFail> OrderCancelFailReceived
strategy.OrderCancelFailReceived += handler

OrderFail cancellation event.

OrderCanceling
public event Action<Order> OrderCanceling
strategy.OrderCanceling += handler

The event of sending order for cancelling.

OrderChanged
public event Action<Order> OrderChanged
strategy.OrderChanged += handler

Order changed (cancelled, matched).

OrderEdited
public event Action<long, Order> OrderEdited
strategy.OrderEdited += handler

Order) success result event.

OrderEditFailed
public event Action<long, OrderFail> OrderEditFailed
strategy.OrderEditFailed += handler

Order) error result event.

OrderEditFailReceived
public event Action<Subscription, OrderFail> OrderEditFailReceived
strategy.OrderEditFailReceived += handler

OrderFail edition event.

OrderLogReceived
public event Action<Subscription, IOrderLogMessage> OrderLogReceived
strategy.OrderLogReceived += handler

IOrderLogMessage received.

OrderReceived
public event Action<Subscription, Order> OrderReceived
strategy.OrderReceived += handler

Order received.

OrderRegistered
public event Action<Order> OrderRegistered
strategy.OrderRegistered += handler

The event of order successful registration.

OrderRegisterFailed
public event Action<OrderFail> OrderRegisterFailed
strategy.OrderRegisterFailed += handler

Order registration error event.

OrderRegisterFailReceived
public event Action<Subscription, OrderFail> OrderRegisterFailReceived
strategy.OrderRegisterFailReceived += handler

OrderFail registration event.

OrderRegistering
public event Action<Order> OrderRegistering
strategy.OrderRegistering += handler

The event of sending order for registration.

OrderReRegistering
public event Action<Order, Order> OrderReRegistering
strategy.OrderReRegistering += handler

The event of sending order for re-registration.

OwnTradeReceived
public event Action<Subscription, MyTrade> OwnTradeReceived
strategy.OwnTradeReceived += handler

MyTrade received.

ParametersChanged
public event Action ParametersChanged
strategy.ParametersChanged += handler

Parameters change event.

PnLChanged
public event Action PnLChanged
strategy.PnLChanged += handler

PnL change event.

PnLReceived
public event Action<Subscription> PnLReceived
strategy.PnLReceived += handler

PnL change event.

PnLReceived2
public event Action<Subscription, Portfolio, DateTime, decimal, decimal?, decimal?> PnLReceived2
strategy.PnLReceived2 += handler

PnL change event.

PortfolioReceived
public event Action<Subscription, Portfolio> PortfolioReceived
strategy.PortfolioReceived += handler

Portfolio received.

PositionChanged
public event Action PositionChanged
strategy.PositionChanged += handler

Position change event.

PositionReceived
public event Action<Subscription, Position> PositionReceived
strategy.PositionReceived += handler

Position received.

ProcessStateChanged
public event Action<Strategy> ProcessStateChanged
strategy.ProcessStateChanged += handler

ProcessState change event.

PropertyChanged
public event PropertyChangedEventHandler PropertyChanged
strategy.PropertyChanged += handler

The diagram element properties value change event.

Reseted
public event Action Reseted
strategy.Reseted += handler

The event of the strategy re-initialization.

SecurityReceived
public event Action<Subscription, Security> SecurityReceived
strategy.SecurityReceived += handler

Security received.

SlippageChanged
public event Action SlippageChanged
strategy.SlippageChanged += handler

Slippage change event.

SubscriptionFailed
public event Action<Subscription, Exception, bool> SubscriptionFailed
strategy.SubscriptionFailed += handler

Subscription is failed.

SubscriptionOnline
public event Action<Subscription> SubscriptionOnline
strategy.SubscriptionOnline += handler

Subscription is online.

SubscriptionReceived
public event Action<Subscription, object> SubscriptionReceived
strategy.SubscriptionReceived += handler

Value received.

SubscriptionStarted
public event Action<Subscription> SubscriptionStarted
strategy.SubscriptionStarted += handler

Subscription is started.

SubscriptionStopped
public event Action<Subscription, Exception> SubscriptionStopped
strategy.SubscriptionStopped += handler

Subscription is stopped.

TickTradeReceived
public event Action<Subscription, ITickTradeMessage> TickTradeReceived
strategy.TickTradeReceived += handler

ITickTradeMessage received.