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
boolIf 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 tofalse
and the close-position order is sent to the exchange, the method does not wait and ClosePositionOrderFill updates are not generated.cancellationToken
CancellationTokenCancellation token that allows the caller to cancel the operation. This cancellation token is only used if
waitForClosePositionFill
is set totrue
and the caller can cancel waiting for the the fills of the close-position order.
Returns
Remarks
This method can be called even after DisposeAsync() is called.
Exceptions
- OperationCanceledException
Thrown if the operation was cancelled.