DecomposedStrategy
The base class for all trade strategies.
Hereda de: BaseLogReceiver
Implementa: IStrategyHost, IPositionProvider, INotifyPropertyChangedEx, INotifyPropertyChanged, ITimeProvider
Constructores
DecomposedStrategy()
Initializes a new instance DecomposedStrategy.
DecomposedStrategy(IPnLManager, IStatisticManager)
Initializes a new instance DecomposedStrategy.
- pnlManager
- PnL manager.
- stats
- Statistic manager.
Propiedades
CancelOrdersWhenStopping : bool
Cancel active orders when strategy is stopping.
CommentMode : StrategyCommentModes
Comment mode.
Commission : decimal?
Total accumulated commission (from orders + trades).
Connector : IConnector
Connector (via interface for testability).
Engine : StrategyEngine
State machine + message routing.
ErrorState : LogLevels
Error state.
Orders : OrderPipeline
Order tracking and processing.
OrdersKeepTime : TimeSpan
The time for storing orders in memory.
PnLManager : IPnLManager
PnL manager.
PortfolioLookup : Subscription
Portfolio lookup subscription.
Positions : PositionPipeline
Position event handling.
PositionsList : IReadOnlyDictionary<ValueTuple<SecurityId, string>, decimal>
All tracked positions.
ProcessState : ProcessStates
Current process state.
RiskManager : IRiskManager
Risk manager.
StartedTime : DateTime
Strategy start time.
StatisticManager : IStatisticManager
Statistics manager.
Subscriptions : SubscriptionRegistry
Subscription management.
TotalWorkingTime : TimeSpan
Total working time.
Trades : TradePipeline
Trade processing and PnL.
TradingMode : StrategyTradingModes
Trading mode.
UnsubscribeOnStop : bool
Unsubscribe from market data when strategy is stopping.
WaitAllTrades : bool
Wait for all trades.
Métodos
CanAttach(Order) : bool
Whether the order can be attached (tracked) by this strategy.
- order
- Order to check.
Devuelve: if the order belongs to this strategy.
CancelActiveOrders()
Cancel all active orders.
CancelOrder(Order)
Cancel an order via the connector.
CanTrade(Security, Portfolio, Sides, decimal, string) : bool
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.
Devuelve: True if trading is allowed.
ClosePosition() : Order
Close current position.
CreateOrder(Sides, decimal, decimal?) : Order
Create an initialized order object.
- side
- Order side.
- price
- Price. 0 for market order.
- volume
- Volume. If null, Volume is used.
Devuelve: Order.
EditOrder(Order, Order)
Edit an order via the connector.
- order
- Original order.
- changes
- Order changes.
GetPositionValue(Security, Portfolio) : decimal
Get position value for specific security and portfolio.
OnCurrentPriceUpdated(SecurityId, decimal, DateTime, DateTime)
Called when current price updated from market data.
OnNewMessage(Message, CancellationToken) : ValueTask
Handle new outgoing message from connector.
OnOrderCancelFailReceived(Subscription, OrderFail)
Handle order cancellation failure from connector.
OnOrderEditFailReceived(Subscription, OrderFail)
Handle order edit failure from connector.
OnOrderReceived(Subscription, Order)
Handle order received from connector.
OnOrderRegistered(Order)
Called when order registered (transitioned from Pending to Active/Done).
- order
- Registered order.
OnOrderRegisterFailReceived(Subscription, OrderFail)
Handle order registration failure from connector.
OnPositionReceived(Subscription, Position)
Handle position received from connector.
OnTradeReceived(Subscription, MyTrade)
Handle trade received from connector.
RegisterOrder(Order)
Register an order via the connector.
ReRegisterOrder(Order, Order)
Re-register (cancel + register new) an order via the connector.
- oldOrder
- Order to cancel.
- newOrder
- New order to register.
Reset()
Reset all state (orders, trades, positions, PnL, subscriptions).
SellMarket(decimal?) : Order
Sell at market price.
Start()
Start the strategy.
StartAsync(CancellationToken) : ValueTask
Start the strategy.
StartProtection(Unit, Unit, bool, TimeSpan?, TimeSpan?, bool, bool)
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.
Stop()
Stop the strategy.
StopAsync(CancellationToken) : ValueTask
Stop the strategy.
StopAsync(Exception, CancellationToken) : ValueTask
Stop the strategy with error.
- error
- The error that caused the stop.
- cancellationToken
- Cancellation token.
Eventos
BoardReceived : Action<Subscription, ExchangeBoard>
Board value received.
CandleReceived : Action<Subscription, ICandleMessage>
Candle value received.
CommissionChanged : Action
Commission changed event.
ConnectorChanged : Action
Connector changed event.
DataTypeReceived : Action<Subscription, DataType>
Data type value received.
IsOnlineChanged : Action<DecomposedStrategy>
Online state changed.
LatencyChanged : Action
Latency changed event.
Level1Received : Action<Subscription, Level1ChangeMessage>
Level1 value received.
NewsReceived : Action<Subscription, News>
News value received.
OrderBookReceived : Action<Subscription, IOrderBookMessage>
Order book value received.
OrderCancelFailed : Action<OrderFail>
Order cancellation failed.
OrderCancelFailReceived : Action<Subscription, OrderFail>
Order cancel failure.
OrderCanceling : Action<Order>
Order is about to be canceled.
OrderEdited : Action<long, Order>
Order edited.
OrderEditFailed : Action<long, OrderFail>
Order edit failed.
OrderEditFailReceived : Action<Subscription, OrderFail>
Order edit failure.
OrderLogReceived : Action<Subscription, IOrderLogMessage>
Order log value received.
OrderReceived : Action<Subscription, Order>
Order value received.
OrderRegisterFailed : Action<OrderFail>
Order registration failed.
OrderRegisterFailReceived : Action<Subscription, OrderFail>
Order registration failure.
OrderRegistering : Action<Order>
Order is about to be registered.
OrderReRegistering : Action<Order, Order>
Order is about to be re-registered.
OwnTradeReceived : Action<Subscription, MyTrade>
Own trade value received.
ParametersChanged : Action
Strategy parameters changed event.
PnLChanged : Action
PnL changed event.
PnLReceived : Action<Subscription>
PnL received event.
PnLReceived2 : Action<Subscription, Portfolio, DateTime, decimal, decimal?, decimal?>
PnL received event.
PortfolioReceived : Action<Subscription, Portfolio>
Portfolio value received.
PositionChanged : Action
Position changed.
PositionReceived : Action<Subscription, Position>
Position value received.
PropertyChanged : PropertyChangedEventHandler
The diagram element properties value change event.
SecurityReceived : Action<Subscription, Security>
Security value received.
SlippageChanged : Action
Slippage changed event.
SubscriptionFailed : Action<Subscription, Exception, bool>
Subscription failed.
SubscriptionOnline : Action<Subscription>
Subscription is online.
SubscriptionReceived : Action<Subscription, object>
Subscription value received.
SubscriptionStarted : Action<Subscription>
Subscription is started.
SubscriptionStopped : Action<Subscription, Exception>
Subscription is stopped.
TickTradeReceived : Action<Subscription, ITickTradeMessage>
Tick trade value received.