/// <summary> /// Deletes asset from watch list using Alpaca REST API endpoint by watch list identifier. /// </summary> /// <param name="request">Asset deleting 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>Updated watch list object with proper <paramref name="request.Key"/> value.</returns> public async Task <IWatchList> DeleteAssetFromWatchListByIdAsync( ChangeWatchListRequest <Guid> request, CancellationToken cancellationToken = default) { request.EnsureNotNull(nameof(request)).Validate(); await _alpacaRestApiThrottler.WaitToProceed(cancellationToken).ConfigureAwait(false); using var response = await _httpClient.DeleteAsync( new Uri ($"watchlists/{request.Key:D}/{request.Asset}", UriKind.RelativeOrAbsolute), cancellationToken) .ConfigureAwait(false); return(await response.DeserializeAsync <IWatchList, JsonWatchList>() .ConfigureAwait(false)); }
/// <summary> /// Deletes asset from watch list using Alpaca REST API endpoint by watch list name. /// </summary> /// <param name="request">Asset deleting 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>Updated watch list object with proper <paramref name="request.Key"/> value.</returns> public async Task <IWatchList> DeleteAssetFromWatchListByNameAsync( ChangeWatchListRequest <String> request, CancellationToken cancellationToken = default) { request.EnsureNotNull(nameof(request)).Validate(); var builder = new UriBuilder(_httpClient.BaseAddress) { Path = _httpClient.BaseAddress.AbsolutePath + $"watchlists:by_name/{request.Asset}", Query = new QueryBuilder() .AddParameter("name", request.Key) }; await _alpacaRestApiThrottler.WaitToProceed(cancellationToken).ConfigureAwait(false); using var response = await _httpClient.DeleteAsync(builder.Uri, cancellationToken) .ConfigureAwait(false); return(await response.DeserializeAsync <IWatchList, JsonWatchList>() .ConfigureAwait(false)); }