alpacahq / alpacahq/alpaca-trade-api-csharp
[BUG]: Exception on TradeUpdate
- Linguagem predominante
- C#
- Estrelas
- 301
- Forks
- 96
- Merge médio
- 4d 5h
- PRs com merge (30d)
- 5
Descrição
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Current Behavior
I always get the following exception in StreamingClient OnError event when Alpaca automatically closes some of ITM options spread positions at 3:45PM and in the TradeUpdate event, it is a 2-Let order, so the AssetClass of the root order of the legs is empty and serializer throws the exception.
It seems like it is an exception from the SDK package. Please take a look at it.
Newtonsoft.Json.JsonSerializationException: Error converting value "" to type 'Alpaca.Markets.AssetClass'. Path 'data.order.asset_class', line 1, position 677.
---> System.ArgumentException: Must specify valid information for parsing in the string.
at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum(Type enumType, NamingStrategy namingStrategy, String value, Boolean disallowNumber)
at Newtonsoft.Json.Converters.StringEnumConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
--- End of inner exception stack trace ---
at Newtonsoft.Json.Converters.StringEnumConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)
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.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
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.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject[T]()
at Alpaca.Markets.ActionExtensions.DeserializeAndInvoke[TApi,TJson](Action`1 eventHandler, JToken eventArg)
at Alpaca.Markets.AlpacaStreamingClient.handleTradeUpdate(JToken token)
at Alpaca.Markets.StreamingClientBase`1.<>c__DisplayClass28_0`1.b__0()
at Alpaca.Markets.SynchronizationQueue.processingTask()
### Expected Behavior
AssetClass should not be empty or can be deserialized with empty value.
### Steps To Reproduce
```markdown
1. Add StreamingClient OnError and TradeUpdate events
2. Place options spread orders and wait for being filled
3. Wait for options positions to be in the money and 3:45PM so system automatically close these positions with 2-Leg order
4. OnError event will be triggered with the exception
```
### Environment
```markdown
- SDK Version: 7.2.0
- OS (version, bitness): Windows 11
- .NET SDK (version): 8.0
- target process .NET version/bitness: 8.0
```
### Anything else?
_No response_
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.