Using wetrade’s API Client
wetrade’s API Client manages requests sent to E-Trade’s web API. In
general, you will only want a single APIClient
(or UserSession) active at one time. Most of the time,
users will include their APIClient as a parameter
when creating a new Quote, Order, or Account object (as detailed in getting started), but
advanced users can also use APIClient to interact
with the API directly.
- class wetrade.api.APIClient(session=None)
- Parameters:
session (UserSession) – (optional) supply your own UserSession for a custom configuration. By default, a new UserSession will be created automatically
- request_account_balance(account_key)
Provides details on the balance for a specified account
- Parameters:
account_key (str) – your specified account key
- request_account_list()
Provides details on all brokerage accounts connected to the active E-Trade user account
- request_account_orders(account_key, start_date='', end_date='', marker='')
Provides details on all of the orders placed by a specified account in a given time frame.
- Parameters:
account_key (str) – your specified account key
start_date (str) – the beginning date of your query; format: ‘%m%d%Y’
end_date (str) – the last date of your query; format: ‘%m%d%Y’
marker (str) – used to access multi-page results
- request_account_portfolio(account_key)
Provides details on the portfolio for a specified account
- Parameters:
account_key (str) – your specified account key
- request_options_chain(symbol, expiry_date='%Y-%m-%d', near_price=0.0, include_weekly=False, skip_adjusted=True)
Requests a list of option chains for a specific underlying instrument
- Parameters:
symbol (str) – the symbol of the underlying security
expiry_date (str) – (optional) search for options expiring on a specfic day
symbol – (optional) this isn’t required to check order status but is added to logs if provided
- request_order_cancel(account_key, order_id, symbol='')
Requests to cancel an already placed order
- Parameters:
account_key (str) – your specified account key
order_id (int) – the ID of the order you’d like to cancel
symbol (str) – (optional) this isn’t required to cancel your order but is added to logs if provided
- request_order_change_place(account_key, order_id, order_data)
Places an updated order after an order preview
- Parameters:
account_key (str) – your specified account key
order_id (int) – the ID of the order you’d like to update
order_data (dict) – a dict containing an E-Trade PlaceOrderRequest
- request_order_change_preview(account_key, order_id, order_data)
Requests an E-Trade order preview to update an already placed order. This is required before placing an updated order
- Parameters:
account_key (str) – your specified account key
order_id (int) – the ID of the order you’d like to update
order_data (dict) – a dict containing an E-Trade PreviewOrderRequest
- request_order_detail(account_key, order_id, symbol='')
Requests detailed information for an already placed order including order status
- Parameters:
account_key (str) – your specified account key
order_id (int) – the ID of your order
symbol (str) – (optional) this isn’t required to check order status but is added to logs if provided
- request_order_place(account_key, order_data)
Places an order after an order preview
- Parameters:
account_key (str) – your specified account key
order_data (dict) – a dict containing an E-Trade PlaceOrderRequest
- request_order_preview(account_key, order_data)
Requests an E-Trade order preview. This is required before placing an order
- Parameters:
account_key (str) – your specified account key
order_data (dict) – a dict containing an E-Trade PreviewOrderRequest
- request_quote(symbol)
Provides live quote details for a specified symbol
- Parameters:
symbol (str) – the symbol of your security or a URL-encoded, comma-separated string for a list of securities