Table of Contents

Method ClosePositionAsync

Namespace
WhalesSecret.TradeScriptLib.API.TradingV1.Orders.Brackets
Assembly
WhalesSecret.TradeScriptLib.dll

ClosePositionAsync(bool, CancellationToken)

Closes the position by sending a closing order request to the exchange.

Task ClosePositionAsync(bool waitForClosePositionFill, CancellationToken cancellationToken = default)

Parameters

waitForClosePositionFill bool

If close-position order is sent to the exchange to close the position and this is set to true, the method waits until the close-position order is filled. In this case, ClosePositionOrderFill updates are generated. If this is set to false and the close-position order is sent to the exchange, the method does not wait and ClosePositionOrderFill updates are not generated.

cancellationToken CancellationToken

Cancellation token that allows the caller to cancel the operation. This cancellation token is only used if waitForClosePositionFill is set to true and the caller can cancel waiting for the the fills of the close-position order.

Returns

Task

A Task representing the asynchronous operation.

Remarks

This method can be called even after DisposeAsync() is called.

Exceptions

OperationCanceledException

Thrown if the operation was cancelled.