Getting old order data, Python API

Can I somehow find out when a particular symbol was first traded/entered? E.g.,

def get_orders():
r = requests.get(ORDERS_URL, headers=HEADERS)
return json.loads(r.content)

positions = get_orders()

Great, now I have a list of positions…I want to go through that list and determine the date when each positions was initially traded. I currently have to log everything in a pickle file and that kinda sucks. Maybe there’s something in the API I’ve missed?

Thanks so much in advance

Jimmy

Ah, a post suggested by Alpaca’s AI led me to the right code example:

import alpaca_trade_api as tradeapi

api = tradeapi.REST()

Get the last 100 of our closed orders

closed_orders = api.list_orders(
status=‘closed’,
limit=100
)

Get only the closed orders for a particular stock

closed_aapl_orders = [o for o in closed_orders if o.symbol == ‘AAPL’]
print(closed_aapl_orders)

1 Like

Nice, thanks for updating with the finding

1 Like