Downloading executed orders

most platforms have a way to easily download a CSV of all the trades.
I cannot find that on Alpaca in either the paper trading or live trading.
am i missing something or is it just not there?

Iā€™m also looking for this. Did you find a way to download to CSV?
Or did you have to go write some code?

Hi, you could use this python script to get all trades:

api = tradeapi.REST(key_id=ALPACA_API_KEY,
                    secret_key=ALPACA_SECRET_KEY)
all_closed_orders = api.list_orders(status="closed")
filled_orders = [l for l in all_closed_orders if l.status=='filled']

and you could play around with all the parameters (dates, statuses, etc) as described here:

Thanks, How to get them in Excel?

all_closed_orders = api.list_orders(status="closed")
filled_orders = [l for l in all_closed_orders if l.status=='filled']
df = pd.DataFrame(data=[r._raw for r in filled_orders], columns=filled_orders[0]._raw.keys())
df.to_csv("orders.csv")

Thank you. For users like me who has 0 knowledge about coding and running a python code is really difficult to get this done.

1 Like