alpacahq / alpaca-py

The Official Python SDK for Alpaca API
https://alpaca.markets/sdks/python/getting_started.html
Apache License 2.0
537 stars 134 forks source link

[Bug]: Asset model has pydantic validation errors #340

Closed msugas19 closed 11 months ago

msugas19 commented 11 months ago

Is there an existing issue for this?

Current Behavior

When I use the Asset model (alpaca.trading.models.Asset) to list available symbols for trading I get validation errors from pydantic for 10 assets. The trace looks like this

__root__ -> 7382 -> status
  value is not a valid enumeration member; permitted: 'active', 'inactive' (type=type_error.enum; enum_values=[<AssetStatus.ACTIVE: 'active'>, <AssetStatus.INACTIVE: 'inactive'>])
__root__ -> 7385 -> status
  value is not a valid enumeration member; permitted: 'active', 'inactive' (type=type_error.enum; enum_values=[<AssetStatus.ACTIVE: 'active'>, <AssetStatus.INACTIVE: 'inactive'>])
__root__ -> 7400 -> status
  value is not a valid enumeration member; permitted: 'active', 'inactive' (type=type_error.enum; enum_values=[<AssetStatus.ACTIVE: 'active'>, <AssetStatus.INACTIVE: 'inactive'>])
__root__ -> 7401 -> status
  value is not a valid enumeration member; permitted: 'active', 'inactive' (type=type_error.enum; enum_values=[<AssetStatus.ACTIVE: 'active'>, <AssetStatus.INACTIVE: 'inactive'>])
__root__ -> 7404 -> status
  value is not a valid enumeration member; permitted: 'active', 'inactive' (type=type_error.enum; enum_values=[<AssetStatus.ACTIVE: 'active'>, <AssetStatus.INACTIVE: 'inactive'>])
__root__ -> 7410 -> status
  value is not a valid enumeration member; permitted: 'active', 'inactive' (type=type_error.enum; enum_values=[<AssetStatus.ACTIVE: 'active'>, <AssetStatus.INACTIVE: 'inactive'>])
__root__ -> 7411 -> status
  value is not a valid enumeration member; permitted: 'active', 'inactive' (type=type_error.enum; enum_values=[<AssetStatus.ACTIVE: 'active'>, <AssetStatus.INACTIVE: 'inactive'>])
__root__ -> 7412 -> status
  value is not a valid enumeration member; permitted: 'active', 'inactive' (type=type_error.enum; enum_values=[<AssetStatus.ACTIVE: 'active'>, <AssetStatus.INACTIVE: 'inactive'>])
__root__ -> 7413 -> status
  value is not a valid enumeration member; permitted: 'active', 'inactive' (type=type_error.enum; enum_values=[<AssetStatus.ACTIVE: 'active'>, <AssetStatus.INACTIVE: 'inactive'>])
__root__ -> 7414 -> status
  value is not a valid enumeration member; permitted: 'active', 'inactive' (type=type_error.enum; enum_values=[<AssetStatus.ACTIVE: 'active'>, <AssetStatus.INACTIVE: 'inactive'>]))

Expected Behavior

When I use the trading api to call api.get_all_assets() it should successfully unmarshal into Alpaca's Asset model without pydantic validation issues

SDK Version I encountered this issue in

Latest alpaca-py. Fresh install of latest in a Docker container shows this across multiple devices

Steps To Reproduce

1. Creating Trading API client using Python SDK
2. Call `api.get_all_assets()`
3. Exceptions thrown

Filled out the Steps to Reproduce section?

Anything else?

No response

msugas19 commented 11 months ago

One last piece of context, this is client is instantiated with api = TradingClient(API_KEY, SECRET_KEY, paper=True)

0xDub commented 11 months ago

+1, Just started getting this today

alessiocastrica commented 11 months ago

@msugas19 @0xDub thanks for reporting this, I'm looking into it and I'm trying to reproduce it, could you please specify what alpaca-py and pydantic versions are you using?

alessiocastrica commented 11 months ago

I investigated and this was not related to the SDK but it was a manual error that happened some time ago when we updated some assets to Inactive instead of inactive. It was fixed already.