I’m seeing a price difference between my recorded price and the paper account, this can be easily explained since I’m recording a “dumb” price (ignoring the market order fill dynamics), but I was wondering is it possible to pull all trades executed in my account for the day?
I found this code snipped in the docs:
import alpaca_trade_api as tradeapi
api = tradeapi.REST()
# Get the last 100 closed orders
closed_orders = api.list_orders(
status='closed',
limit=100,
nested=True # show nested multi-leg orders
)
# 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)
But I’m curious if it’s possible with just the alpaca-py package so I don’t have to add another dependency into my project?
Edit: I found this code snippet on another alpaca documentation site (why are there two? Is one deprecated now?)
from alpaca.trading.client import TradingClient
from alpaca.trading.requests import GetAssetsRequest
from alpaca.trading.enums import AssetClass
trading_client = TradingClient('api-key', 'secret-key')
# search for crypto assets
search_params = GetAssetsRequest(asset_class=AssetClass.CRYPTO)
assets = trading_client.get_all_assets(search_params)
I suspect this will work however I haven’t tested it yet but it uses alpaca-py at least…
Edit: Oh I’m dumb, this is code to get all assets… not orders