Skip to content

[BUG]: Exception is thrown on Alpaca.Client.ListOrdersAsync(request) #809

@KongKuchUng

Description

@KongKuchUng

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When I make a call to ListordersAsync(request), I get a deserialization issue on the GUID when Id is an empty string.

Newtonsoft.Json.JsonSerializationException: Error converting value "" to type 'System.Guid'. Path '[42].asset_id', line 1, position 37387.
---> System.ArgumentException: Could not cast or convert from System.String to System.Guid.
at Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(Object value, Type initialType, Type targetType)
at Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue, CultureInfo culture, Type targetType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
--- End of inner exception stack trace ---
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IList list, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Alpaca.Markets.HttpResponseMethodExtensions.DeserializeAsync[TApi,TJson](HttpResponseMessage response)
at Alpaca.Markets.HttpResponseMethodExtensions.DeserializeAsync[TApi,TJson](HttpResponseMessage response)
at Alpaca.Markets.HttpClientExtensions.callAndDeserializeAsync[TApi,TJson](HttpClient httpClient, HttpRequestMessage request, RateLimitHandler rateLimitHandler, CancellationToken cancellationToken)
at Alpaca.Markets.HttpClientExtensions.callAndDeserializeAsync[TApi,TJson](HttpClient httpClient, HttpMethod method, Uri endpointUri, RateLimitHandler rateLimitHandler, CancellationToken cancellationToken)
at Alpaca.Markets.AlpacaTradingClient.ListOrdersAsync(ListOrdersRequest request, CancellationToken cancellationToken)
at EspritTrade.Alpaca.AlpacaOrderSync.GetFilledOrdersAsync(HashSet`1 symbols, Int32 lookbackDays)

Expected Behavior

No response

Steps To Reproduce

You can reproduce the issue by using the the paper trading account PA3Q4Q6CCU47 and calling the following function 

var request = new ListOrdersRequest { OrderStatusFilter = OrderStatusFilter.Closed, LimitOrderNumber = 500, OrderListSorting = SortDirection.Descending };

ListordersAsync(request)

Environment

SDK Version: Alpaca 7.2.0
OS: Windows 11 x64
.NET SDK: .Net Core 10
Build Target: x64

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions