ATAS
Loading...
Searching...
No Matches
ATAS.Strategies.Strategy Class Reference

Base class for implementing trading strategies. More...

Inheritance diagram for ATAS.Strategies.Strategy:
[legend]
Collaboration diagram for ATAS.Strategies.Strategy:
[legend]

Public Member Functions

void Start ()
 
void Stop ()
 
async Task StartAsync ()
 Starts the strategy, allowing it to execute its trading logic.
 
async Task WatchAsync ()
 
async Task StartFromWatchAsync ()
 
async Task StopAsync ()
 Stops the strategy, terminating its execution and releasing any resources.
 
async void OpenOrder (Order order, bool isAutomated=true)
 Открыть ордер.
 
async Task OpenOrderAsync (Order order, bool isAutomated=true)
 Открыть ордер.
 
async void ModifyOrder (Order order, Order neworder, bool isAutomated=true)
 Изменить ордер.
 
async Task ModifyOrderAsync (Order order, Order neworder, bool isAutomated=true)
 Изменить ордер.
 
async void CancelOrder (Order order, bool isAutomated=true)
 Отменить ордер.
 
async Task CancelOrderAsync (Order order, bool isAutomated=true)
 Отменить ордер.
 
Task StartAsync ()
 Starts the strategy, allowing it to execute its trading logic.
 
Task StopAsync ()
 Stops the strategy, terminating its execution and releasing any resources.
 

Protected Member Functions

 Strategy ()
 
void SetState (StrategyStates state)
 Set strategy state.
 
void SetErrorState (StrategyErrorTypes type, string[] errorDescriptions)
 Set StrategyStates.Error state.
 
void ResetErrorState ()
 Reset error state.
 
void RaisePropertyChanged (string propertyName)
 Raises the PropertyChanged event with the specified property name.
 
void RaiseShowNotification (string message, string title=null, bool isError=false)
 Raises the ShowNotification event with the specified message, title, and error flag.
 
bool SetProperty< TValue > (ref TValue storage, TValue newValue, string propertyName, Action< TValue, TValue > onChanged=null)
 Sets the property with the specified name to the new value and raises the PropertyChanged event if the value has changed.
 
string GetOCOGroup ()
 Generates a unique OCO (One-Cancels-the-Other) group identifier based on the current timestamp.
 
bool CanProcess (Order order)
 Checks if the specified order can be processed by this strategy.
 
ICollection< MyTradeFilterMyTrades (IEnumerable< MyTrade > trades)
 Filters and returns the collection of MyTrade that belong to the current portfolio and security and have occurred after the latest trade time.
 
void UpdateCurrentPosition ()
 Update thr CurrentPosition and AveragePrice values.
 
virtual Task OnStarted ()
 Called when the strategy is started from StrategyStates.Stopped state.
 
virtual Task OnStartedFromWatch ()
 Called when the strategy is started from StrategyStates.Watch state.
 
virtual Task OnStopping ()
 Called when the strategy is stopping.
 
virtual Task OnStopped ()
 Called when the strategy is stopped.
 
virtual Task OnOpenOrder (Order order, bool isAutomated)
 Called when a new order is opened.
 
virtual Task OnModifyOrder (Order order, Order newOrder, bool isAutomated)
 Called when an existing order is modified.
 
virtual Task OnCancelOrder (Order order, bool isAutomated)
 Called when an order is canceled.
 
virtual void OnMarketDepth (IEnumerable< MarketDepth > depths)
 Called when market depth data is received.
 
virtual void OnBestBidAsk (MarketDepth depth)
 Called when the best bid or ask market depth data is received.
 
virtual void OnNewTrade (Trade trade)
 Called when a new trade occurs.
 
virtual void OnNewPortfolio (Portfolio portfolio)
 Called when a new portfolio is added.
 
virtual void OnNewPosition (Position position)
 Called when a new position is added.
 
virtual void OnPositionChanged (Position position)
 Called when an existing position is changed.
 
virtual void OnPnLChanged (int ticks)
 Called when the profit and loss (PnL) changes.
 
virtual void OnNewOrder (Order order)
 Called when a new order is added.
 
virtual void OnOrderChanged (Order order)
 Called when an existing order is changed.
 
virtual void OnOrderRegisterFailed (Order order, string message)
 Called when an order registration fails.
 
virtual void OnOrderCancelFailed (Order order, string message)
 Called when an order cancellation fails.
 
virtual void OnOrderModifyFailed (Order order, Order newOrder, string message)
 Called when an order modification fails.
 
virtual void OnNewMyTrade (MyTrade myTrade)
 Called when a new trade is added to the collection of MyTrade.
 
virtual void OnCurrentPositionChanged ()
 Called when the volume of the current position changes.
 
virtual void OnUpdateStrategyState ()
 Called when the strategy state needs to be updated.
 
virtual bool CanProcess ()
 Checks if the strategy can process operations in the current state.
 
virtual bool CanUpdateCurrentPosition (Position position)
 Checks if the current position can be updated with the specified position.
 
virtual void LogParameters ()
 Log current parameters.
 

Properties

Security Security [get, set]
 Gets or sets the security associated with the strategy.
 
Portfolio Portfolio [get, set]
 Gets or sets the portfolio associated with the strategy.
 
TPlusLimitsTPlusLimit [get, set]
 Gets or sets the T+ limits for the strategy.
 
IDataFeedConnector Connector [get, set]
 Gets or sets the data feed connector for the strategy.
 
IEnumerable< MyTradeMyTrades [get]
 
IEnumerable< OrderOrders [get]
 
Position Position [get, set]
 
decimal CurrentPosition [get]
 Gets the current position volume of the strategy.
 
decimal AveragePrice [get]
 Gets the average price of the strategy's trades.
 
int OpenTicksPnL [get]
 
decimal OpenPnL [get]
 Gets the open profit and loss of the strategy.
 
decimal ClosedPnL [get]
 Gets the closed profit and loss of the strategy.
 
MarketDepth BestBid [get]
 
MarketDepth BestAsk [get]
 
StrategyStates State [get, protected set]
 Gets the current state of the strategy.
 
StrategyStateDescription StateDescription [get]
 
string Name [get, set]
 Gets or sets the name of the strategy.
 
- Properties inherited from ATAS.Strategies.IStrategy
string Name [get, set]
 Gets or sets the name of the strategy.
 
StrategyStates State [get]
 Gets the current state of the strategy.
 
decimal CurrentPosition [get]
 Gets the current position volume of the strategy.
 
decimal AveragePrice [get]
 Gets the average price of the strategy's trades.
 
decimal OpenPnL [get]
 Gets the open profit and loss of the strategy.
 
decimal ClosedPnL [get]
 Gets the closed profit and loss of the strategy.
 
Security Security [get, set]
 Gets or sets the security associated with the strategy.
 
Portfolio Portfolio [get, set]
 Gets or sets the portfolio associated with the strategy.
 
TPlusLimitsTPlusLimit [get, set]
 Gets or sets the T+ limits for the strategy.
 
IDataFeedConnector Connector [get, set]
 Gets or sets the data feed connector for the strategy.
 

Events

PropertyChangedEventHandler PropertyChanged
 
EventHandler< StrategyStateChangedEventArgsStateChanged
 
EventHandler< StrategyNotificationEventArgsShowNotification
 
- Events inherited from ATAS.Strategies.IStrategy
EventHandler< StrategyStateChangedEventArgsStateChanged
 Occurs when the state of the strategy changes.
 
EventHandler< StrategyNotificationEventArgsShowNotification
 Occurs when the strategy needs to show a notification or alert.
 

Detailed Description

Base class for implementing trading strategies.

Constructor & Destructor Documentation

◆ Strategy()

ATAS.Strategies.Strategy.Strategy ( )
protected

Member Function Documentation

◆ CancelOrder()

async void ATAS.Strategies.Strategy.CancelOrder ( Order  order,
bool  isAutomated = true 
)

Отменить ордер.

Parameters
orderОрдер.
isAutomatedфлаг, является ли выставляемый ордером выставляемым автоматически или ордер является выставляемым юзером.

◆ CancelOrderAsync()

async Task ATAS.Strategies.Strategy.CancelOrderAsync ( Order  order,
bool  isAutomated = true 
)

Отменить ордер.

Parameters
orderОрдер.
isAutomatedфлаг, является ли выставляемый ордером выставляемым автоматически или ордер является выставляемым юзером.

◆ CanProcess() [1/2]

virtual bool ATAS.Strategies.Strategy.CanProcess ( )
protectedvirtual

Checks if the strategy can process operations in the current state.

Returns
true if the strategy can process; otherwise, false.

◆ CanProcess() [2/2]

bool ATAS.Strategies.Strategy.CanProcess ( Order  order)
protected

Checks if the specified order can be processed by this strategy.

Parameters
orderThe order to be processed.
Returns
true if the order can be processed; otherwise, false.

◆ CanUpdateCurrentPosition()

virtual bool ATAS.Strategies.Strategy.CanUpdateCurrentPosition ( Position  position)
protectedvirtual

Checks if the current position can be updated with the specified position.

Parameters
positionThe position to be compared with the current position.
Returns
true if the current position can be updated; otherwise, false.

Reimplemented in ATAS.Strategies.ATM.ATMStrategy< TStrategy >.

◆ FilterMyTrades()

ICollection< MyTrade > ATAS.Strategies.Strategy.FilterMyTrades ( IEnumerable< MyTrade trades)
protected

Filters and returns the collection of MyTrade that belong to the current portfolio and security and have occurred after the latest trade time.

Parameters
tradesThe collection of MyTrade to be filtered.
Returns
The filtered collection of MyTrade.

◆ GetOCOGroup()

string ATAS.Strategies.Strategy.GetOCOGroup ( )
protected

Generates a unique OCO (One-Cancels-the-Other) group identifier based on the current timestamp.

Returns
A unique OCO group identifier.

◆ LogParameters()

virtual void ATAS.Strategies.Strategy.LogParameters ( )
protectedvirtual

Log current parameters.

Reimplemented in ATAS.Strategies.ATM.ATMStrategy< TStrategy >.

◆ ModifyOrder()

async void ATAS.Strategies.Strategy.ModifyOrder ( Order  order,
Order  neworder,
bool  isAutomated = true 
)

Изменить ордер.

Parameters
orderОрдер, который модифицируется.
neworderОрдер с новыми параметрами.
isAutomatedфлаг, является ли выставляемый ордером выставляемым автоматически или ордер является выставляемым юзером.

◆ ModifyOrderAsync()

async Task ATAS.Strategies.Strategy.ModifyOrderAsync ( Order  order,
Order  neworder,
bool  isAutomated = true 
)

Изменить ордер.

Parameters
orderОрдер, который модифицируется.
neworderОрдер с новыми параметрами.
isAutomatedфлаг, является ли выставляемый ордером выставляемым автоматически или ордер является выставляемым юзером.

◆ OnBestBidAsk()

virtual void ATAS.Strategies.Strategy.OnBestBidAsk ( MarketDepth  depth)
protectedvirtual

Called when the best bid or ask market depth data is received.

Parameters
depthThe best bid or ask market depth data.

◆ OnCancelOrder()

virtual Task ATAS.Strategies.Strategy.OnCancelOrder ( Order  order,
bool  isAutomated 
)
protectedvirtual

Called when an order is canceled.

Parameters
orderThe order to be canceled.
isAutomatedA flag indicating whether the order was canceled automatically.

Reimplemented in ATAS.Strategies.ATM.BaseStopProfitStrategy< TStrategy, TSettings >.

◆ OnCurrentPositionChanged()

virtual void ATAS.Strategies.Strategy.OnCurrentPositionChanged ( )
protectedvirtual

Called when the volume of the current position changes.

Reimplemented in ATAS.Strategies.ATM.BaseStopProfitStrategy< TStrategy, TSettings >.

◆ OnMarketDepth()

virtual void ATAS.Strategies.Strategy.OnMarketDepth ( IEnumerable< MarketDepth depths)
protectedvirtual

Called when market depth data is received.

Parameters
depthsThe collection of MarketDepth data.

◆ OnModifyOrder()

virtual Task ATAS.Strategies.Strategy.OnModifyOrder ( Order  order,
Order  newOrder,
bool  isAutomated 
)
protectedvirtual

Called when an existing order is modified.

Parameters
orderThe original order.
newOrderThe modified order with new parameters.
isAutomatedA flag indicating whether the order was modified automatically.

Reimplemented in ATAS.Strategies.ATM.BaseStopProfitStrategy< TStrategy, TSettings >.

◆ OnNewMyTrade()

virtual void ATAS.Strategies.Strategy.OnNewMyTrade ( MyTrade  myTrade)
protectedvirtual

Called when a new trade is added to the collection of MyTrade.

Parameters
myTradeThe newly added MyTrade.

◆ OnNewOrder()

virtual void ATAS.Strategies.Strategy.OnNewOrder ( Order  order)
protectedvirtual

Called when a new order is added.

Parameters
orderThe newly added order.

Reimplemented in ATAS.Strategies.ATM.BaseStopProfitStrategy< TStrategy, TSettings >.

◆ OnNewPortfolio()

virtual void ATAS.Strategies.Strategy.OnNewPortfolio ( Portfolio  portfolio)
protectedvirtual

Called when a new portfolio is added.

Parameters
portfolioThe newly added portfolio.

◆ OnNewPosition()

virtual void ATAS.Strategies.Strategy.OnNewPosition ( Position  position)
protectedvirtual

Called when a new position is added.

Parameters
positionThe newly added position.

◆ OnNewTrade()

virtual void ATAS.Strategies.Strategy.OnNewTrade ( Trade  trade)
protectedvirtual

Called when a new trade occurs.

Parameters
tradeThe newly occurred trade.

◆ OnOpenOrder()

virtual Task ATAS.Strategies.Strategy.OnOpenOrder ( Order  order,
bool  isAutomated 
)
protectedvirtual

Called when a new order is opened.

Parameters
orderThe newly opened order.
isAutomatedA flag indicating whether the order was opened automatically.

◆ OnOrderCancelFailed()

virtual void ATAS.Strategies.Strategy.OnOrderCancelFailed ( Order  order,
string  message 
)
protectedvirtual

Called when an order cancellation fails.

Parameters
orderThe order that failed to cancel.
messageThe error message.

◆ OnOrderChanged()

virtual void ATAS.Strategies.Strategy.OnOrderChanged ( Order  order)
protectedvirtual

Called when an existing order is changed.

Parameters
orderThe changed order.

Reimplemented in ATAS.Strategies.ATM.BaseStopProfitStrategy< TStrategy, TSettings >.

◆ OnOrderModifyFailed()

virtual void ATAS.Strategies.Strategy.OnOrderModifyFailed ( Order  order,
Order  newOrder,
string  message 
)
protectedvirtual

Called when an order modification fails.

Parameters
orderThe order that failed to modify.
newOrderThe modified order with new parameters.
messageThe error message.

◆ OnOrderRegisterFailed()

virtual void ATAS.Strategies.Strategy.OnOrderRegisterFailed ( Order  order,
string  message 
)
protectedvirtual

Called when an order registration fails.

Parameters
orderThe order that failed to register.
messageThe error message.

◆ OnPnLChanged()

virtual void ATAS.Strategies.Strategy.OnPnLChanged ( int  ticks)
protectedvirtual

Called when the profit and loss (PnL) changes.

Parameters
ticksThe number of ticks by which the PnL changes.

◆ OnPositionChanged()

virtual void ATAS.Strategies.Strategy.OnPositionChanged ( Position  position)
protectedvirtual

Called when an existing position is changed.

Parameters
positionThe changed position.

◆ OnStarted()

virtual Task ATAS.Strategies.Strategy.OnStarted ( )
protectedvirtual

Called when the strategy is started from StrategyStates.Stopped state.

Reimplemented in ATAS.Strategies.ATM.BaseStopProfitStrategy< TStrategy, TSettings >.

◆ OnStartedFromWatch()

virtual Task ATAS.Strategies.Strategy.OnStartedFromWatch ( )
protectedvirtual

Called when the strategy is started from StrategyStates.Watch state.

Reimplemented in ATAS.Strategies.ATM.BaseStopProfitStrategy< TStrategy, TSettings >.

◆ OnStopped()

virtual Task ATAS.Strategies.Strategy.OnStopped ( )
protectedvirtual

Called when the strategy is stopped.

◆ OnStopping()

virtual Task ATAS.Strategies.Strategy.OnStopping ( )
protectedvirtual

Called when the strategy is stopping.

Reimplemented in ATAS.Strategies.ATM.BaseStopProfitStrategy< TStrategy, TSettings >.

◆ OnUpdateStrategyState()

virtual void ATAS.Strategies.Strategy.OnUpdateStrategyState ( )
protectedvirtual

Called when the strategy state needs to be updated.

◆ OpenOrder()

async void ATAS.Strategies.Strategy.OpenOrder ( Order  order,
bool  isAutomated = true 
)

Открыть ордер.

Parameters
orderОрдер.
isAutomatedфлаг, является ли выставляемый ордером выставляемым автоматически или ордер является выставляемым юзером

◆ OpenOrderAsync()

async Task ATAS.Strategies.Strategy.OpenOrderAsync ( Order  order,
bool  isAutomated = true 
)

Открыть ордер.

Parameters
orderОрдер.
isAutomatedфлаг, является ли выставляемый ордером выставляемым автоматически или ордер является выставляемым юзером

◆ RaisePropertyChanged()

void ATAS.Strategies.Strategy.RaisePropertyChanged ( string  propertyName)
protected

Raises the PropertyChanged event with the specified property name.

Parameters
propertyNameThe name of the property that changed.

◆ RaiseShowNotification()

void ATAS.Strategies.Strategy.RaiseShowNotification ( string  message,
string  title = null,
bool  isError = false 
)
protected

Raises the ShowNotification event with the specified message, title, and error flag.

Parameters
messageThe notification message.
titleThe notification title (optional).
isErrorA flag indicating whether the notification is an error.

◆ ResetErrorState()

void ATAS.Strategies.Strategy.ResetErrorState ( )
protected

Reset error state.

◆ SetErrorState()

void ATAS.Strategies.Strategy.SetErrorState ( StrategyErrorTypes  type,
string[]  errorDescriptions 
)
protected

Set StrategyStates.Error state.

Parameters
typeError type.
errorDescriptionsError descriptions.

◆ SetProperty< TValue >()

bool ATAS.Strategies.Strategy.SetProperty< TValue > ( ref TValue  storage,
TValue  newValue,
string  propertyName,
Action< TValue, TValue >  onChanged = null 
)
protected

Sets the property with the specified name to the new value and raises the PropertyChanged event if the value has changed.

Template Parameters
TValueThe type of the property value.
Parameters
storageA reference to the storage for the property value.
newValueThe new value of the property.
propertyNameThe name of the property.
onChangedAn optional action to execute when the property value changes.
Returns
true if the property value has changed; otherwise, false.

◆ SetState()

void ATAS.Strategies.Strategy.SetState ( StrategyStates  state)
protected

Set strategy state.

Parameters
stateNew state.

◆ Start()

void ATAS.Strategies.Strategy.Start ( )

◆ StartAsync()

async Task ATAS.Strategies.Strategy.StartAsync ( )

Starts the strategy, allowing it to execute its trading logic.

Implements ATAS.Strategies.IStrategy.

◆ StartFromWatchAsync()

async Task ATAS.Strategies.Strategy.StartFromWatchAsync ( )

◆ Stop()

void ATAS.Strategies.Strategy.Stop ( )

◆ StopAsync()

async Task ATAS.Strategies.Strategy.StopAsync ( )

Stops the strategy, terminating its execution and releasing any resources.

Implements ATAS.Strategies.IStrategy.

◆ UpdateCurrentPosition()

void ATAS.Strategies.Strategy.UpdateCurrentPosition ( )
protected

Update thr CurrentPosition and AveragePrice values.

◆ WatchAsync()

async Task ATAS.Strategies.Strategy.WatchAsync ( )

Property Documentation

◆ AveragePrice

decimal ATAS.Strategies.Strategy.AveragePrice
get

Gets the average price of the strategy's trades.

Implements ATAS.Strategies.IStrategy.

◆ BestAsk

MarketDepth ATAS.Strategies.Strategy.BestAsk
get

◆ BestBid

MarketDepth ATAS.Strategies.Strategy.BestBid
get

◆ ClosedPnL

decimal ATAS.Strategies.Strategy.ClosedPnL
get

Gets the closed profit and loss of the strategy.

Implements ATAS.Strategies.IStrategy.

◆ Connector

IDataFeedConnector ATAS.Strategies.Strategy.Connector
getset

Gets or sets the data feed connector for the strategy.

Implements ATAS.Strategies.IStrategy.

◆ CurrentPosition

decimal ATAS.Strategies.Strategy.CurrentPosition
get

Gets the current position volume of the strategy.

Implements ATAS.Strategies.IStrategy.

◆ MyTrades

IEnumerable<MyTrade> ATAS.Strategies.Strategy.MyTrades
get

◆ Name

string ATAS.Strategies.Strategy.Name
getset

Gets or sets the name of the strategy.

Implements ATAS.Strategies.IStrategy.

◆ OpenPnL

decimal ATAS.Strategies.Strategy.OpenPnL
get

Gets the open profit and loss of the strategy.

Implements ATAS.Strategies.IStrategy.

◆ OpenTicksPnL

int ATAS.Strategies.Strategy.OpenTicksPnL
get

◆ Orders

IEnumerable<Order> ATAS.Strategies.Strategy.Orders
get

◆ Portfolio

Portfolio ATAS.Strategies.Strategy.Portfolio
getset

Gets or sets the portfolio associated with the strategy.

Implements ATAS.Strategies.IStrategy.

◆ Position

Position ATAS.Strategies.Strategy.Position
getset

◆ Security

Security ATAS.Strategies.Strategy.Security
getset

Gets or sets the security associated with the strategy.

Implements ATAS.Strategies.IStrategy.

◆ State

StrategyStates ATAS.Strategies.Strategy.State
getprotected set

Gets the current state of the strategy.

Implements ATAS.Strategies.IStrategy.

◆ StateDescription

StrategyStateDescription ATAS.Strategies.Strategy.StateDescription
get

◆ TPlusLimit

TPlusLimits? ATAS.Strategies.Strategy.TPlusLimit
getset

Gets or sets the T+ limits for the strategy.

Implements ATAS.Strategies.IStrategy.

Event Documentation

◆ PropertyChanged

PropertyChangedEventHandler ATAS.Strategies.Strategy.PropertyChanged

◆ ShowNotification

EventHandler<StrategyNotificationEventArgs> ATAS.Strategies.Strategy.ShowNotification

◆ StateChanged

EventHandler<StrategyStateChangedEventArgs> ATAS.Strategies.Strategy.StateChanged

The documentation for this class was generated from the following file: