Alpaca SDK Version
Summary: Alpaca API python client
Other Environment Details
list_orders function does not list all the orders for the day.
I used list_orders to check the buys for the day in order not to close a position on same day, since i do not want to day trade.
list_orders misses the positions filled causing the PDT protection to trigger.
Please fix this or let me know the correct usage of the call.
To reproduce the problem, buy bunch of stocks (~100), run the below code gist.
Wait for the orders to get filled,run the below code gist again.
Transact the same stocks for sell, you will find that PDT gets triggered and order_list will have missing stocks.
Note status = ‘all’ also produces the same results.
Paper or Live Tradng?
from datetime import datetime
import alpaca_trade_api as alpaca
api = alpaca.REST(KEYID, SECRETKEY, ‘https://paper-api.alpaca.markets’, ‘v2’)
order_list = api.list_orders(status=‘closed’, after = datetime.today().date())
daybuys = [x.symbol for x in order_list if x.side ==‘buy’]