Alpaca

App · 20 actions

Read Alpaca trading account activity and manage orders, positions and watchlists.

Actions

ActionWhat it does
Cancel an orderCancel an order.
Create a watchlistCreate a watchlist.
Delete a watchlistDelete a watchlist.
Get a watchlistGet a watchlist.
Get account portfolio historyGet account portfolio history.
Get an assetGet an asset.
Get an open positionGet an open position.
Get an orderGet an order.
Get an order by client IDGet an order by client ID.
Get the trading accountGet the trading account.
Get the US market clockGet the US market clock.
Get trading account settingsGet trading account settings.
List account activitiesList account activities.
List open positionsList open positions.
List ordersList orders.
List tradable assetsList tradable assets.
List US market daysList US market days.
List watchlistsList watchlists.
Submit an orderSubmit an order.
Update a watchlistUpdate a watchlist.

Cancel an order

Cancel an order.

Inputs

Order IDorder_idtextRequired
order id

Outputs

dataobject
The response from Alpaca.
Example output
{
  "data": {}
}

Create a watchlist

Create a watchlist.

Inputs

NamenametextRequired
The watchlist name.
Symbolssymbolslist
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

Watchlistwatchlist_idtextRequired
watchlist id

Outputs

dataobject
The response from Alpaca.
Example output
{
  "data": {}
}

Get a watchlist

Get a watchlist.

Inputs

Watchlistwatchlist_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

Periodperiodtext
The total duration of history being requested defined as `number` + `unit`.
Timeframetimeframetext
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.
Startstarttext
The first timestamp of the timeseries.
Endendtext
The last timestamp of the timeseries.
Extended hoursextended_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 IDsymbol_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 IDsymbol_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 IDorder_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 IDclient_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 typesactivity_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.
Datedatedate 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.
Untiluntildate and time
Get activities created before this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.
Afterafterdate and time
Get activities created after this date. Both formats YYYY-MM-DD and YYYY-MM-DDTHH:MM:SSZ are supported.
Directiondirectiontext
The chronological order of response based on the activity datetime.One of: asc, desc.
Page sizepage_sizenumber
The maximum number of entries to return in the response.From 1 to 100.
Page tokenpage_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

Statusstatustext
Order status to be queried. open, closed or all. Defaults to open.One of: open, closed, all.
Limitlimitnumber
The maximum number of orders in response. Defaults to 50 and max is 500.
Afteraftertext
The response will include only ones submitted after this timestamp (exclusive.)
Untiluntiltext
The response will include only ones submitted until this timestamp (exclusive.)
Directiondirectiontext
The chronological order of response based on the submission time. asc or desc. Defaults to desc.One of: asc, desc.
Symbolssymbolslist
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").
Sidesidetext
Filters down to orders that have a matching side field set.
After order IDafter_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

Statusstatustext
e.g. "active". By default, all statuses are included.
Asset classasset_classtext
Defaults to us_equity.
Exchangeexchangetext
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

Startstartdate
The first date to retrieve data for (inclusive).
Endenddate
The last date to retrieve data for (inclusive).
Date typedate_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 IDclient_order_idtext
A unique identifier for the order. Automatically generated if not sent. (<= 128 characters)
Extended hoursextended_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 pricelimit_pricetext
Required if type is `limit` or `stop_limit`.
Notionalnotionaltext
dollar amount to trade. Cannot work with `qty`. Can only work for market order types and day for time in force.
Qtyqtytext
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.
SidesidetextRequired
Represents which side this order was on:One of: buy, sell.
Stop pricestop_pricetext
required if type is `stop` or `stop_limit`
SymbolsymboltextRequired
symbol, asset ID, or currency pair to identify the asset to trade, required for all order classes except for `mleg`.
Time in forcetime_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.
TypetypetextRequired
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

Watchlistwatchlist_idtextRequired
watchlist id
Namenametext
New name for the watchlist.
Symbolssymbolslist
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"
  }
}

On this page