TwapAlgo

StockSharp.Algo.PositionManagement

Time-Weighted Average Price (TWAP). Splits the total volume into SliceCount equal slices and sends one child order per slice at the configured interval - slice 1 at start, slice 2 at start + interval, ... - until the time window StartAt .. EndAt elapses. Each slice is a Market order by default (immediate execution). Setting LimitPrice sends every slice as a Limit order at that price, wherever the market is at the time - the algo does not move the price to follow it. Outstanding child orders are tracked by the caller; this algo only emits Register actions when the current slice is due and reports finished once the total volume is exhausted or EndAt has passed. What a slice failed to execute is folded into the slices that are still to come; once every one of them has been dispatched, what is left goes out on its own while the window is still open.

Implementa: IPositionModifyAlgo, IDisposable

Construtores

TwapAlgo
public TwapAlgo(Sides side, decimal totalVolume, int sliceCount, DateTime startAt, DateTime endAt, decimal? limitPrice)
twapAlgo = TwapAlgo(side, totalVolume, sliceCount, startAt, endAt, limitPrice)

Initializes a new instance of the TwapAlgo.

side
Order side.
totalVolume
Total volume to execute.
sliceCount
How many slices the volume is cut into.
startAt
When the algo may start.
endAt
When the algo must be done.
limitPrice
Price limit, or to send market orders.

Propriedades

EndAt
public DateTime EndAt { get; }
value = twapAlgo.EndAt

When the algo must be done.

IsFinished
public bool IsFinished { get; }
value = twapAlgo.IsFinished

Whether the algorithm has finished.

LimitPrice
public decimal? LimitPrice { get; }
value = twapAlgo.LimitPrice

Price limit, or when slices go out as market orders.

RemainingVolume
public decimal RemainingVolume { get; }
value = twapAlgo.RemainingVolume

Remaining volume to execute.

Side
public Sides Side { get; }
value = twapAlgo.Side

Order side.

SliceCount
public int SliceCount { get; }
value = twapAlgo.SliceCount

How many slices the volume is cut into.

StartAt
public DateTime StartAt { get; }
value = twapAlgo.StartAt

When the algo may start.

Métodos

Cancel
public void Cancel()
twapAlgo.Cancel()

Cancel the current algo execution.

Dispose
public void Dispose()
twapAlgo.Dispose()

Disposes of items in the pool that implement IDisposable.

GetNextAction
public PositionModifyAction GetNextAction()
result = twapAlgo.GetNextAction()

Get the next action to take. The call advances the algorithm: a returned Register counts as dispatched, so the caller places it and reports back through Decimal), OnOrderFailed or Decimal). An action that is discarded leaves the algorithm waiting for a report that never comes.

OnOrderCanceled
public void OnOrderCanceled(decimal matchedVolume)
twapAlgo.OnOrderCanceled(matchedVolume)

Notify that an order was canceled.

matchedVolume
Volume that traded since the previous notification and before cancellation.
OnOrderFailed
public void OnOrderFailed()
twapAlgo.OnOrderFailed()

Notify that an order failed. Nothing traded.

OnOrderMatched
public void OnOrderMatched(decimal matchedVolume)
twapAlgo.OnOrderMatched(matchedVolume)

Notify that an order was matched.

matchedVolume
Volume that traded since the previous notification for this order: a caller reporting every partial fill passes the increment, one reporting only the end passes the whole traded volume. The same volume is never reported twice.
UpdateMarketData
public void UpdateMarketData(DateTime time, decimal? price, decimal? volume)
twapAlgo.UpdateMarketData(time, price, volume)

Update market data.

time
Current time.
price
Last trade price.
volume
Last trade volume.
UpdateOrderBook
public void UpdateOrderBook(IOrderBookMessage depth)
twapAlgo.UpdateOrderBook(depth)

Update order book data.

depth
Order book.