Alpaca
App · 20 actions
Read Alpaca trading account activity and manage orders, positions and watchlists.
Actions
| Action | What it does |
|---|---|
| Cancel an order | Cancel an order. |
| Create a watchlist | Create a watchlist. |
| Delete a watchlist | Delete a watchlist. |
| Get a watchlist | Get a watchlist. |
| Get account portfolio history | Get account portfolio history. |
| Get an asset | Get an asset. |
| Get an open position | Get an open position. |
| Get an order | Get an order. |
| Get an order by client ID | Get an order by client ID. |
| Get the trading account | Get the trading account. |
| Get the US market clock | Get the US market clock. |
| Get trading account settings | Get trading account settings. |
| List account activities | List account activities. |
| List open positions | List open positions. |
| List orders | List orders. |
| List tradable assets | List tradable assets. |
| List US market days | List US market days. |
| List watchlists | List watchlists. |
| Submit an order | Submit an order. |
| Update a watchlist | Update a watchlist. |
Cancel an order
Cancel an order.
Inputs
- Order ID
order_idtextRequired - order id
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {}
}Create a watchlist
Create a watchlist.
Inputs
- Name
nametextRequired - The watchlist name.
- Symbols
symbolslist - List of asset symbols to include in the watchlist.
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"account_id": "example",
"assets": [
{
"attributes": [
{}
],
"borrow_status": "example",
"class": "example",
"cusip": "example",
"exchange": "example",
"fractionable": true,
"id": "example",
"maintenance_margin_requirement": 1,
"margin_requirement_long": "example",
"margin_requirement_short": "example",
"marginable": true,
"min_order_size": "example",
"min_trade_increment": "example",
"name": "example",
"price_increment": "example",
"shortable": true,
"status": "example",
"symbol": "example",
"tradable": true
}
],
"created_at": "example",
"id": "example",
"name": "example",
"updated_at": "example"
}
}Delete a watchlist
Delete a watchlist.
Inputs
- Watchlist
watchlist_idtextRequired - watchlist id
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {}
}Get a watchlist
Get a watchlist.
Inputs
- Watchlist
watchlist_idtextRequired - watchlist id
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"assets": [
{
"id": "example",
"name": "example",
"status": "example",
"symbol": "example",
"tradable": true
}
],
"created_at": "example",
"id": "example",
"name": "example",
"updated_at": "example"
}
}Get account portfolio history
Get account portfolio history.
Inputs
- Period
periodtext - The total duration of history being requested defined as `number` + `unit`.
- Timeframe
timeframetext - The resolution of time window. 1Min, 5Min, 15Min, 1H, or 1D. If omitted, 1Min for less than 7 days period,One of:
1D,1H,15Min,5Min,1Min. - Start
starttext - The first timestamp of the timeseries.
- End
endtext - The last timestamp of the timeseries.
- Extended hours
extended_hourstext - **deprecated**: Users are strongly advised to **rely on the `intraday_reporting` query parameter** for better control
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"base_value": 1,
"base_value_asof": "example",
"cashflow": {},
"equity": [
1
],
"profit_loss": [
1
],
"profit_loss_pct": [
1
],
"timeframe": "example",
"timestamp": [
1
]
}
}Get an asset
Get an asset.
Inputs
- Symbol or asset ID
symbol_or_asset_idtextRequired - symbol or assetId. CUSIP is also accepted for US equities.
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"attributes": [
"example"
],
"borrow_status": "example",
"class": "example",
"cusip": "example",
"exchange": "example",
"fractionable": true,
"id": "example",
"maintenance_margin_requirement": 1,
"margin_requirement_long": "example",
"margin_requirement_short": "example",
"marginable": true,
"min_order_size": "example",
"min_trade_increment": "example",
"name": "example",
"price_increment": "example",
"shortable": true,
"status": "example",
"symbol": "example",
"tradable": true
}
}Get an open position
Get an open position.
Inputs
- Symbol or asset ID
symbol_or_asset_idtextRequired - symbol or assetId
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"asset_class": "example",
"asset_id": "example",
"asset_marginable": true,
"avg_entry_price": "example",
"avg_entry_swap_rate": "example",
"change_today": "example",
"cost_basis": "example",
"current_price": "example",
"exchange": "example",
"lastday_price": "example",
"market_value": "example",
"prev_swap_rate": "example",
"qty": "example",
"qty_available": "example",
"side": "example",
"swap_rate": "example",
"symbol": "example",
"unrealized_intraday_pl": "example",
"unrealized_intraday_plpc": "example",
"unrealized_pl": "example",
"unrealized_plpc": "example",
"usd": {
"avg_entry_price": "example",
"change_today": "example",
"cost_basis": "example",
"current_price": "example",
"lastday_price": "example",
"market_value": "example",
"unrealized_intraday_pl": "example",
"unrealized_intraday_plpc": "example",
"unrealized_pl": "example",
"unrealized_plpc": "example"
}
}
}Get an order
Get an order.
Inputs
- Order ID
order_idtextRequired - order id
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"client_order_id": "example",
"created_at": "example",
"filled_qty": "example",
"id": "example",
"status": "example",
"symbol": "example",
"updated_at": "example"
}
}Get an order by client ID
Get an order by client ID.
Inputs
- Client order ID
client_order_idtextRequired - The client-assigned order ID.
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"client_order_id": "example",
"created_at": "example",
"filled_qty": "example",
"id": "example",
"status": "example",
"symbol": "example",
"updated_at": "example"
}
}Get the trading account
Get the trading account.
Inputs
None.
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"account_blocked": true,
"account_number": "example",
"accrued_fees": "example",
"balance_asof": "example",
"buying_power": "example",
"cash": "example",
"created_at": "example",
"crypto_status": "example",
"currency": "example",
"equity": "example",
"id": "example",
"initial_margin": "example",
"intraday_adjustments": "example",
"last_equity": "example",
"last_maintenance_margin": "example",
"long_market_value": "example",
"maintenance_margin": "example",
"multiplier": "example",
"non_marginable_buying_power": "example",
"options_approved_level": 1,
"options_buying_power": "example",
"options_trading_level": 1,
"pending_reg_taf_fees": "example",
"pending_transfer_in": "example",
"pending_transfer_out": "example",
"portfolio_value": "example",
"regt_buying_power": "example",
"short_market_value": "example",
"shorting_enabled": true,
"sma": "example",
"status": "example",
"trade_suspended_by_user": true,
"trading_blocked": true,
"transfers_blocked": true
}
}Get the US market clock
Get the US market clock.
Inputs
None.
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"is_open": true,
"next_close": "example",
"next_open": "example",
"timestamp": "example"
}
}Get trading account settings
Get trading account settings.
Inputs
None.
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"disable_overnight_trading": true,
"fractional_trading": true,
"max_margin_multiplier": "example",
"max_options_trading_level": 1,
"no_shorting": true,
"ptp_no_exception_entry": true,
"suspend_trade": true,
"trade_confirm_email": "example"
}
}List account activities
List account activities.
Inputs
- Activity types
activity_typeslist - A comma-separated list of activity types used to filter the results.One or more of:
ACATC,ACATS,ALLOC,CFEE,CGD,CIL,CSD,CSR,CSW,DIV, and 49 more. - Date
datedate and time - Filter activities by their creation date (created_at), not the activity's settlement date. For non-trade activities such as fees, the creation date is typically the day after the trade date (in UTC). Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.
- Until
untildate and time - Get activities created before this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.
- After
afterdate and time - Get activities created after this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.
- Direction
directiontext - The chronological order of response based on the activity datetime.One of:
asc,desc. - Page size
page_sizenumber - The maximum number of entries to return in the response.From 1 to 100.
- Page token
page_tokentext - Token used for pagination. Provide the ID of the last activity from the last page to retrieve the next set of results.
Outputs
datalist- The response from Alpaca.
Example output
{
"data": [
{
"activity_type": "example",
"date": "example",
"id": "example",
"order_id": "example",
"price": "example",
"qty": "example",
"symbol": "example",
"transaction_time": "example"
}
]
}List open positions
List open positions.
Inputs
None.
Outputs
datalist- The response from Alpaca.
Example output
{
"data": [
{
"asset_class": "example",
"asset_id": "example",
"asset_marginable": true,
"avg_entry_price": "example",
"avg_entry_swap_rate": "example",
"change_today": "example",
"cost_basis": "example",
"current_price": "example",
"exchange": "example",
"lastday_price": "example",
"market_value": "example",
"prev_swap_rate": "example",
"qty": "example",
"qty_available": "example",
"side": "example",
"swap_rate": "example",
"symbol": "example",
"unrealized_intraday_pl": "example",
"unrealized_intraday_plpc": "example",
"unrealized_pl": "example",
"unrealized_plpc": "example",
"usd": {
"avg_entry_price": "example",
"change_today": "example",
"cost_basis": "example",
"current_price": "example",
"lastday_price": "example",
"market_value": "example",
"unrealized_intraday_pl": "example",
"unrealized_intraday_plpc": "example",
"unrealized_pl": "example",
"unrealized_plpc": "example"
}
}
]
}List orders
List orders.
Inputs
- Status
statustext - Order status to be queried. open, closed or all. Defaults to open.One of:
open,closed,all. - Limit
limitnumber - The maximum number of orders in response. Defaults to 50 and max is 500.
- After
aftertext - The response will include only ones submitted after this timestamp (exclusive.)
- Until
untiltext - The response will include only ones submitted until this timestamp (exclusive.)
- Direction
directiontext - The chronological order of response based on the submission time. asc or desc. Defaults to desc.One of:
asc,desc. - Symbols
symbolslist - A comma-separated list of symbols to filter by (ex. "AAPL,TSLA,MSFT"). A currency pair is required for crypto orders (ex. "BTCUSD,BCHUSD,LTCUSD,ETCUSD").
- Side
sidetext - Filters down to orders that have a matching side field set.
- After order ID
after_order_idtext - Return orders submitted after the order with this ID (exclusive).
Outputs
datalist- The response from Alpaca.
Example output
{
"data": [
{
"client_order_id": "example",
"created_at": "example",
"filled_qty": "example",
"id": "example",
"status": "example",
"symbol": "example",
"updated_at": "example"
}
]
}List tradable assets
List tradable assets.
Inputs
- Status
statustext - e.g. "active". By default, all statuses are included.
- Asset class
asset_classtext - Defaults to us_equity.
- Exchange
exchangetext - Optional comma-separated exchanges to filter `us_equity` and `us_index` assets by: AMEX, ARCA, BATS, NYSE, NASDAQ, NYSEARCA, OTC, TXSE, or INDEX. `INDEX` requires `asset_class=us_index`.
Outputs
datalist- The response from Alpaca.
Example output
{
"data": [
{
"id": "example",
"name": "example",
"status": "example",
"symbol": "example",
"tradable": true
}
]
}List US market days
List US market days.
Inputs
- Start
startdate - The first date to retrieve data for (inclusive).
- End
enddate - The last date to retrieve data for (inclusive).
- Date type
date_typetext - Indicates what start and end mean. Default: TRADING. If TRADING is specified, returns a calendar whose trading date matches start, end. If SETTLEMENT is specified, returns the calendar whose settlement date matches start and end.One of:
TRADING,SETTLEMENT.
Outputs
datalist- The response from Alpaca.
Example output
{
"data": [
{
"close": "example",
"date": "example",
"open": "example",
"session_close": "example",
"session_open": "example",
"settlement_date": "example"
}
]
}List watchlists
List watchlists.
Inputs
None.
Outputs
datalist- The response from Alpaca.
Example output
{
"data": [
{
"account_id": "example",
"created_at": "example",
"id": "example",
"name": "example",
"updated_at": "example"
}
]
}Submit an order
Submit an order.
Inputs
- Client order ID
client_order_idtext - A unique identifier for the order. Automatically generated if not sent. (<= 128 characters)
- Extended hours
extended_hourstrue/false - (default) false. If true, order will be eligible for execution in the pre-market, after-hours, and overnight sessions. Only works with type `limit` and time_in_force set to either `day` or `gtc`
- Limit price
limit_pricetext - Required if type is `limit` or `stop_limit`.
- Notional
notionaltext - dollar amount to trade. Cannot work with `qty`. Can only work for market order types and day for time in force.
- Qty
qtytext - number of shares to trade. Can be fractionable for only market and day order types. Required for `mleg` order class, represents the number of units to trade of this strategy.
- Side
sidetextRequired - Represents which side this order was on:One of:
buy,sell. - Stop price
stop_pricetext - required if type is `stop` or `stop_limit`
- Symbol
symboltextRequired - symbol, asset ID, or currency pair to identify the asset to trade, required for all order classes except for `mleg`.
- Time in force
time_in_forcetextRequired - The Time-In-Force values supported by Alpaca vary based on the order's security type. Here is a breakdown of the supported TIFs for each specific security type:One of:
day,gtc,opg,cls,ioc,fok. - Type
typetextRequired - The order types supported by Alpaca vary based on the order's security type. The following provides a comprehensive breakdown of the supported order types for each category:One of:
market,limit,stop,stop_limit(Stop limit).
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"asset_class": "example",
"asset_id": "example",
"canceled_at": "example",
"client_order_id": "example",
"created_at": "example",
"expired_at": "example",
"expires_at": "example",
"extended_hours": true,
"failed_at": "example",
"filled_at": "example",
"filled_avg_price": "example",
"filled_qty": "example",
"group_id": "example",
"group_role": "example",
"hwm": "example",
"id": "example",
"legs": [
{
"asset_class": "example",
"asset_id": "example",
"canceled_at": "example",
"client_order_id": "example",
"created_at": "example",
"expired_at": "example",
"extended_hours": true,
"failed_at": "example",
"filled_at": "example",
"filled_avg_price": "example",
"filled_qty": "example",
"group_id": "example",
"group_role": "example",
"hwm": "example",
"id": "example",
"legs": [
{}
],
"limit_price": "example",
"notional": "example",
"order_class": "example",
"order_type": "example",
"position_intent": "example",
"qty": "example",
"replaced_at": "example",
"replaced_by": "example",
"replaces": "example",
"side": "example",
"status": "example",
"stop_price": "example",
"submitted_at": "example",
"symbol": "example",
"time_in_force": "example",
"trail_percent": "example",
"trail_price": "example",
"type": "example",
"updated_at": "example"
}
],
"limit_price": "example",
"notional": "example",
"order_class": "example",
"order_type": "example",
"position_intent": "example",
"qty": "example",
"ratio_qty": "example",
"replaced_at": "example",
"replaced_by": "example",
"replaces": "example",
"side": "example",
"status": "example",
"stop_price": "example",
"submitted_at": "example",
"symbol": "example",
"time_in_force": "example",
"trail_percent": "example",
"trail_price": "example",
"type": "example",
"updated_at": "example"
}
}Update a watchlist
Update a watchlist.
Inputs
- Watchlist
watchlist_idtextRequired - watchlist id
- Name
nametext - New name for the watchlist.
- Symbols
symbolslist - List of asset symbols to include in the watchlist. The existing assets will be replaced with the new list.
Outputs
dataobject- The response from Alpaca.
Example output
{
"data": {
"account_id": "example",
"assets": [
{
"attributes": [
{}
],
"borrow_status": "example",
"class": "example",
"cusip": "example",
"exchange": "example",
"fractionable": true,
"id": "example",
"maintenance_margin_requirement": 1,
"margin_requirement_long": "example",
"margin_requirement_short": "example",
"marginable": true,
"min_order_size": "example",
"min_trade_increment": "example",
"name": "example",
"price_increment": "example",
"shortable": true,
"status": "example",
"symbol": "example",
"tradable": true
}
],
"created_at": "example",
"id": "example",
"name": "example",
"updated_at": "example"
}
}