Alpaca Trading SDK¶
- class src.boatwright.External_Interfaces.Alpaca.Alpaca_Trading_API.AlpacaAuth(api_key, secret_key)¶
- class src.boatwright.External_Interfaces.Alpaca.Alpaca_Trading_API.AlpacaTrading(api_key, api_secret, paper=False, debug=False)¶
HTTP/REST Client for Alpaca Trading API The rate limit is 200 requests every minute per API key.
- cancel_order(order_id)¶
Attempts to cancel an open order. If the order is no longer cancelable (example: status = filled), the server will respond with status 422, and reject the request. Upon acceptance of the cancel request, it returns status 204. https://docs.alpaca.markets/reference/cancel-an-order-by-id
- delete(path_url, params=None)¶
“generic delete request structure
- get(path_url, params=None)¶
“generic post request structure
- get_all_open_positions()¶
Retrieves a list of the account’s open positions https://docs.alpaca.markets/reference/getallopenpositions
- get_an_open_position(symbol_or_asset_id)¶
Retrieves the account’s open position for the given symbol or assetId. https://docs.alpaca.markets/reference/getopenposition
- get_asset_by_id(symbol_or_asset_id)¶
https://docs.alpaca.markets/reference/retrieving-an-asset-by-id-or-symbol
- get_order_by_client_id(client_order_id)¶
gets order by client order_id https://docs.alpaca.markets/reference/retrieve-an-order-by-id
- get_order_by_id(order_id)¶
gets order by broker order_id https://docs.alpaca.markets/reference/retrieve-an-order-by-id
- post(path_url, data)¶
“generic post request structure
- post_order(symbol, side, type, time_in_force, qty=None, notional=None, limit_price=None, stop_price=None, trail_price=None, trail_percent=None, extended_hours=False, client_order_id=None, order_class=None, take_profit=None, stop_loss=None)¶
Places a new order for the given account. An order request may be rejected if the account is not authorized for trading, or if the tradable balance is insufficient to fill the order. https://docs.alpaca.markets/reference/submit-an-order https://docs.alpaca.markets/docs/orders-at-alpaca
- Parameters:
symbol (str)
side (str)
type (str)
time_in_force (str)
qty (str)
notional (str)
limit_price (str)
stop_price (str)
trail_price (str)
trail_percent (str)
extended_hours (bool)
client_order_id (str)
order_class (str)
take_profit (dict)
stop_loss (dict)
- retrieve_account()¶