/// <inheritdoc /> public async Task <IOrder> DeletePositionAsync( DeletePositionRequest request, CancellationToken cancellationToken = default) => await _httpClient.DeleteAsync <IOrder, JsonOrder>( await request.EnsureNotNull(nameof(request)).Validate() .GetUriBuilderAsync(_httpClient).ConfigureAwait(false), cancellationToken).ConfigureAwait(false);
/// <summary> /// Liquidate an open position at market price using Alpaca REST API endpoint. /// </summary> /// <param name="request">Position deletion request parameters.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The <see cref="IOrder"/> object that represents the position liquidation order (for tracking).</returns> public async Task <IOrder> DeletePositionAsync( DeletePositionRequest request, CancellationToken cancellationToken = default) { request.EnsureNotNull(nameof(request)); await _alpacaRestApiThrottler.WaitToProceed(cancellationToken).ConfigureAwait(false); return(await _httpClient.DeleteSingleObjectAsync <IOrder, JsonOrder>( _alpacaRestApiThrottler, $"positions/{request.Symbol}", cancellationToken) .ConfigureAwait(false)); }
/// <inheritdoc /> public Task <IOrder> DeletePositionAsync( DeletePositionRequest request, CancellationToken cancellationToken = default) => _httpClient.DeleteAsync <IOrder, JsonOrder>( request.EnsureNotNull(nameof(request)).Validate().GetUriBuilder(_httpClient), cancellationToken);