I am using Python. I have placed a trade to buy a stock. The trade filled. I am getting the order data back to see what price it filled at. I am using that price to generate a sell price.
The issue is, I don't know how to sift through the data and extract the fill price. I don't know enough about coding to even know what to call it so here is the data. I am trying to extract that 29.42 in filled_avg_price.
Order({ 'asset_class': 'us_equity',
'asset_id': 'b49cfcfc-b0f7-4bf0-aff8-a33ffe6f0073',
'canceled_at': None,
'client_order_id': 'ENPH4',
'created_at': '2020-04-01T19:27:23.641068Z',
'expired_at': None,
'extended_hours': False,
'failed_at': None,
'filled_at': '2020-04-01T19:27:23.768187Z',
'filled_avg_price': '29.42',
'filled_qty': '1',
'id': 'a58e92a2-35d5-4d6e-9fcb-03c4c1ee8c65',
'legs': None,
'limit_price': '32',
'order_class': '',
'order_type': 'limit',
'qty': '1',
'replaced_at': None,
'replaced_by': None,
'replaces': None,
'side': 'buy',
'status': 'filled',
'stop_price': None,
'submitted_at': '2020-04-01T19:27:23.184461Z',
'symbol': 'ENPH',
'time_in_force': 'day',
'type': 'limit',
'updated_at': '2020-04-01T19:27:23.783736Z'})
I am using import alpaca_trade_api If you need to install it to check things out.
Here is the Order class from there
class Order(Entity):
def __init__(self, raw):
super().__init__(raw)
try:
self.legs = [Order(o) for o in self.legs]
except Exception:
# No order legs existed
pass