Code in Python to return all open positions in paper trading

Jupyter Notebook



*Hello, I am trying to return my current open positions in a List with my current Paper Trading account in Alpaca within Python (using Jupyter Notebook). However, my code is just returning a blank list. Has anyone run into this issue? *

Paper or Live Tradng?
Paper Trading

Example Code

import alpaca_trade_api as tradeapi

api = tradeapi.REST(API_KEY, SECRET_KEY)

# Get a list of all of our positions.
portfolio = api.list_positions()```
1 Like

I have the same issue. I can’t figure it out.

check_orders = api.list_orders(status=‘open’)

Will return list of open orders as well as info about them. However I wish to have a int that could tell me simply the number of open orders rather then getting a huge list… but I can’t see to figure that out.