Closed enicolasgomez closed 1 year ago
I can confirm the same behaviour with version 0.7 and latest version of the code, also for get_all_assets function
missing CRYPTO = "CRYPTO"
in class AssetExchange(str, Enum):
in alpaca/trading/enums.py
works just fine after adding it :)
I temporary fixed it by querying all US EQUITIES (seems the only parameter to be working) and filtering client side. This will deff produce big chunk of data being transfered as it's around 40K assets, my previous request was 10X less.
search_params = GetAssetsRequest(asset_class=AssetClass.US_EQUITY)
all_assets = self._trading_client.get_all_assets(search_params)
all_assets = [a.symbol for a in all_assets if
a.exchange in (AssetExchange.NYSE, AssetExchange.NASDAQ)
and a.marginable
and a.shortable
and a.status is AssetStatus.ACTIVE]
Im seeing this error also when calling get_all_positions
positions = trading_client.get_all_positions()
2023-04-26T13:09:45.920959+00:00 app[web.1]: File "/usr/local/lib/python3.9/site-packages/alpaca/trading/client.py", line 240, in get_all_positions
2023-04-26T13:09:45.920959+00:00 app[web.1]: return parse_obj_as(List[Position], response)
2023-04-26T13:09:45.920959+00:00 app[web.1]: File "pydantic/tools.py", line 38, in pydantic.tools.parse_obj_as
2023-04-26T13:09:45.920959+00:00 app[web.1]: File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
2023-04-26T13:09:45.920959+00:00 app[web.1]: pydantic.error_wrappers.ValidationError: 2 validation errors for ParsingModel[List[alpaca.trading.models.Position]]
2023-04-26T13:09:45.920959+00:00 app[web.1]: __root__ -> 0 -> exchange
2023-04-26T13:09:45.920959+00:00 app[web.1]: value is not a valid enumeration member; permitted: 'AMEX', 'ARCA', 'BATS', 'NYSE', 'NASDAQ', 'NYSEARCA', 'FTXU', 'CBSE', 'GNSS', 'ERSX', 'OTC' (type=type_error.enum; enum_values=[<AssetExchange.AMEX: 'AMEX'>, <AssetExchange.ARCA: 'ARCA'>, <AssetExchange.BATS: 'BATS'>, <AssetExchange.NYSE: 'NYSE'>, <AssetExchange.NASDAQ: 'NASDAQ'>, <AssetExchange.NYSEARCA: 'NYSEARCA'>, <AssetExchange.FTXU: 'FTXU'>, <AssetExchange.CBSE: 'CBSE'>, <AssetExchange.GNSS: 'GNSS'>, <AssetExchange.ERSX: 'ERSX'>, <AssetExchange.OTC: 'OTC'>])
Also getting this error when calling get_all_positions
. Traceback follows:
ValidationError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_12832/848330175.py in
5 alpaca_base_url = os.environ['APCA_API_BASE_URL_PAPER']
6 trading = TradingClient(alpaca_key_id, alpaca_secret_key, paper=True)
----> 7 trading.get_all_assets(filter=GetAssetsRequest(status='active'))
c:\Users\bourb\.conda\envs\trading\lib\site-packages\alpaca\trading\client.py in get_all_assets(self, filter)
338 return response
339
--> 340 return parse_obj_as(List[Asset], response)
341
342 def get_asset(self, symbol_or_asset_id: Union[UUID, str]) -> Union[Asset, RawData]:
c:\Users\bourb\.conda\envs\trading\lib\site-packages\pydantic\tools.cp38-win_amd64.pyd in pydantic.tools.parse_obj_as()
c:\Users\bourb\.conda\envs\trading\lib\site-packages\pydantic\main.cp38-win_amd64.pyd in pydantic.main.BaseModel.__init__()
ValidationError: 46 validation errors for ParsingModel[List[alpaca.trading.models.Asset]]
__root__ -> 11102 -> exchange
value is not a valid enumeration member; permitted: 'AMEX', 'ARCA', 'BATS', 'NYSE', 'NASDAQ', 'NYSEARCA', 'FTXU', 'CBSE', 'GNSS', 'ERSX', 'OTC' (type=type_error.enum; enum_values=[, , , , , , , , , , ])
@bourba85 This fix is available in v0.8.2
. Try upgrading with pip install -U alpaca-py
and running again.
Is there an existing issue for this?
Current Behavior
calling
TradingClient.get_all_assets(GetAssetsRequest(status=AssetStatus.ACTIVE))
results in a bunch of errors like this:Expected Behavior
No response
SDK Version I encountered this issue in
Latest
Steps To Reproduce
Filled out the Steps to Reproduce section?
Anything else?
No response