I get the following error message in Python for the call "api.get_open_position('BTCUSD')" or "api.get_open_position('BTC/USD')" (the call fails for all crypto holdings, but works fine for stocks. Note I'm running Python 3.10.8 and have just upgraded the Alpaca trade API):
Traceback (most recent call last):
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/Users/byronprice/Documents/Current-Projects/Alpaca/Stocks/PlayCryptoPortfolio.py", line 73, in
pos = api.get_open_position(stocks[ii])
File "/Users/byronprice/opt/anaconda3/envs/Alpaca/lib/python3.10/site-packages/alpaca/trading/client.py", line 256, in get_open_position
return Position(**response)
File "pydantic/main.py", line 342, in pydantic.main.BaseModel.init
pydantic.error_wrappers.ValidationError: 1 validation error for Position
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=[<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'>
Expected Behavior
The "api.get_open_position(...)" call ought to give me a Position object, which it does when I make the same call for any stock. "api.get_all_positions()" similarly fails.
SDK Version I encountered this issue in
alpaca-trade-api 3.0.0 (this is the latest version as far as I can tell, but the issue was also happening with a previous version)
Steps To Reproduce
1. Running Python 3.10.8 on a Macbook Pro with M1 chip and OS Ventura 13.0.1 . The alpaca-trade-api is 3.0.0 .
2. Get the api object: "api = TradingClient(APCA_API_KEY_ID, APCA_API_SECRET_KEY, paper=False)"
3. Try to run: "api.get_open_position('BTCUSD')" or "api.get_open_position('BTC/USD')" or any other call to get a position for any crypto holding. (Note that I definitely have an open position in BTCUSD and the same call for any stock works fine, e.g. "api.get_open_position('GLD')" works and appropriately returns the Position object for that stock.)
Filled out the Steps to Reproduce section?
[X] I have entered valid steps to reproduce my issue or have attached a minimally reproducible case in code that shows my issue happening; and understand that without this my issue will be flagged as invalid and closed after 30 days.
Is there an existing issue for this?
Current Behavior
I get the following error message in Python for the call "api.get_open_position('BTCUSD')" or "api.get_open_position('BTC/USD')" (the call fails for all crypto holdings, but works fine for stocks. Note I'm running Python 3.10.8 and have just upgraded the Alpaca trade API):
Traceback (most recent call last): File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/Users/byronprice/Documents/Current-Projects/Alpaca/Stocks/PlayCryptoPortfolio.py", line 73, in
pos = api.get_open_position(stocks[ii])
File "/Users/byronprice/opt/anaconda3/envs/Alpaca/lib/python3.10/site-packages/alpaca/trading/client.py", line 256, in get_open_position
return Position(**response)
File "pydantic/main.py", line 342, in pydantic.main.BaseModel.init
pydantic.error_wrappers.ValidationError: 1 validation error for Position
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=[<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'>
Expected Behavior
The "api.get_open_position(...)" call ought to give me a Position object, which it does when I make the same call for any stock. "api.get_all_positions()" similarly fails.
SDK Version I encountered this issue in
alpaca-trade-api 3.0.0 (this is the latest version as far as I can tell, but the issue was also happening with a previous version)
Steps To Reproduce
Filled out the Steps to Reproduce section?
Anything else?
No response