2071 lines
69 KiB
YAML
2071 lines
69 KiB
YAML
openapi: 3.0.0
|
||
info:
|
||
title: Trader API
|
||
description: |-
|
||
Alpaca's Trading API is a modern platform for algorithmic trading.
|
||
|
||
For complete documentation on the Trading API and to obtain your keys head to https://alpaca.markets/docs/api-documentation/api-v2/. Once you have your keys, head to the environments tab to quickly get started.
|
||
version: 2.0.0
|
||
contact:
|
||
name: Alpaca Support
|
||
email: support@alpaca.markets
|
||
url: 'https://alpaca.markets/support'
|
||
termsOfService: 'https://s3.amazonaws.com/files.alpaca.markets/disclosures/library/TermsAndConditions.pdf'
|
||
servers:
|
||
- url: 'https://paper-api.alpaca.markets'
|
||
description: Paper
|
||
- url: 'https://api.alpaca.markets'
|
||
description: Live
|
||
tags:
|
||
- name: Accounts
|
||
description: 'Head to https://alpaca.markets/docs/api-references/trading-api/account/ to view complete documentation on the Accounts API.'
|
||
- name: Orders
|
||
description: 'Head to https://alpaca.markets/docs/api-documentation/api-v2/orders/ to view complete documentation on the Orders API.'
|
||
- name: Positions
|
||
description: 'Head to https://alpaca.markets/docs/api-documentation/api-v2/positions/ to view complete documentation on the Positions API.'
|
||
- name: Portfolio History
|
||
description: 'Head to https://alpaca.markets/docs/api-documentation/api-v2/portfolio-history/ to view complete documentation on the Portfolio History API.'
|
||
- name: Watchlists
|
||
description: 'Head to https://alpaca.markets/docs/api-documentation/api-v2/watchlist/ to view complete documentation on the Watchlist API.'
|
||
- name: Account Configurations
|
||
description: 'Head to https://alpaca.markets/docs/api-documentation/api-v2/account-configuration/ to view complete documentation on the Account Configurations API.'
|
||
- name: Account Activities
|
||
description: 'Head to https://alpaca.markets/docs/api-references/trading-api/account-activities/ to view complete documentation on the Account Activities API.'
|
||
- name: Calendar
|
||
description: 'Head to https://alpaca.markets/docs/api-references/trading-api/calendar/ to view complete documentation on the Market Calendar API.'
|
||
- name: Clock
|
||
description: 'Head to https://alpaca.markets/docs/api-references/trading-api/clock/ to view complete documentation on the Market Clock API.'
|
||
paths:
|
||
/v2/account:
|
||
get:
|
||
summary: Get account
|
||
tags:
|
||
- Accounts
|
||
responses:
|
||
'200':
|
||
description: OK
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Account'
|
||
operationId: getAccount
|
||
parameters: []
|
||
description: Returns the account associated with the API key.
|
||
/v2/orders:
|
||
post:
|
||
tags:
|
||
- Orders
|
||
summary: Order
|
||
operationId: postOrder
|
||
description: '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..'
|
||
requestBody:
|
||
required: true
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Order'
|
||
description: ''
|
||
parameters: []
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Order'
|
||
'403':
|
||
description: |-
|
||
Forbidden
|
||
|
||
Buying power or shares is not sufficient.
|
||
'422':
|
||
description: |-
|
||
Unprocessable
|
||
|
||
Input parameters are not recognized.
|
||
get:
|
||
tags:
|
||
- Orders
|
||
summary: All Orders
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
enum:
|
||
- open
|
||
- closed
|
||
- all
|
||
example: open
|
||
in: query
|
||
name: status
|
||
description: 'Order status to be queried. open, closed or all. Defaults to open.'
|
||
- schema:
|
||
type: integer
|
||
in: query
|
||
name: limit
|
||
description: The maximum number of orders in response. Defaults to 50 and max is 500.
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
name: after
|
||
description: The response will include only ones submitted after this timestamp (exclusive.)
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
name: until
|
||
description: The response will include only ones submitted until this timestamp (exclusive.)
|
||
- schema:
|
||
type: string
|
||
enum:
|
||
- asc
|
||
- desc
|
||
in: query
|
||
name: direction
|
||
description: The chronological order of response based on the submission time. asc or desc. Defaults to desc.
|
||
- schema:
|
||
type: boolean
|
||
in: query
|
||
name: nested
|
||
description: 'If true, the result will roll up multi-leg orders under the legs field of primary order.'
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
name: symbols
|
||
description: '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”).'
|
||
responses:
|
||
'200':
|
||
description: |-
|
||
Successful response
|
||
|
||
An array of Order objects
|
||
content:
|
||
application/json:
|
||
schema:
|
||
type: array
|
||
items:
|
||
$ref: '#/components/schemas/Order'
|
||
operationId: getAllOrders
|
||
description: 'Retrieves a list of orders for the account, filtered by the supplied query parameters.'
|
||
x-internal: false
|
||
delete:
|
||
tags:
|
||
- Orders
|
||
summary: All Orders
|
||
parameters: []
|
||
responses:
|
||
'207':
|
||
description: |-
|
||
Multi-Status with body.
|
||
|
||
an array of objects that include the order id and http status code for each status request.
|
||
content:
|
||
application/json:
|
||
schema:
|
||
type: array
|
||
items:
|
||
$ref: '#/components/schemas/CanceledOrderResponse'
|
||
'500':
|
||
description: Failed to cancel order.
|
||
operationId: deleteAllOrders
|
||
description: 'Attempts to cancel all open orders. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request.'
|
||
'/v2/orders/{order_id}':
|
||
get:
|
||
tags:
|
||
- Orders
|
||
summary: Order by Order ID
|
||
parameters:
|
||
- schema:
|
||
type: boolean
|
||
in: query
|
||
name: nested
|
||
description: 'If true, the result will roll up multi-leg orders under the legs field of primary order.'
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Order'
|
||
operationId: getOrderByOrderID
|
||
description: Retrieves a single order for the given order_id.
|
||
patch:
|
||
tags:
|
||
- Orders
|
||
summary: Order
|
||
description: |
|
||
Replaces a single order with updated parameters. Each parameter overrides the corresponding attribute of the existing order. The other attributes remain the same as the existing order.
|
||
|
||
A success return code from a replaced order does NOT guarantee the existing open order has been replaced. If the existing open order is filled before the replacing (new) order reaches the execution venue, the replacing (new) order is rejected, and these events are sent in the trade_updates stream channel.
|
||
|
||
While an order is being replaced, buying power is reduced by the larger of the two orders that have been placed (the old order being replaced, and the newly placed order to replace it). If you are replacing a buy entry order with a higher limit price than the original order, the buying power is calculated based on the newly placed order. If you are replacing it with a lower limit price, the buying power is calculated based on the old order.
|
||
requestBody:
|
||
required: true
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/PatchOrderRequest'
|
||
responses:
|
||
'200':
|
||
description: |-
|
||
Successful response
|
||
|
||
The new Order object with the new order ID.
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Order'
|
||
operationId: patchOrderByOrderId
|
||
delete:
|
||
tags:
|
||
- Orders
|
||
summary: Order by Order ID
|
||
parameters: []
|
||
responses:
|
||
'204':
|
||
description: No Content
|
||
'422':
|
||
description: The order status is not cancelable.
|
||
operationId: deleteOrderByOrderID
|
||
description: 'Attempts to cancel an Open Order. If the order is no longer cancelable, the request will be rejected with status 422; otherwise accepted with return status 204.'
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
format: uuid
|
||
name: order_id
|
||
in: path
|
||
required: true
|
||
description: order id
|
||
/v2/positions:
|
||
get:
|
||
tags:
|
||
- Positions
|
||
summary: All Open Positions
|
||
parameters: []
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
type: array
|
||
items:
|
||
$ref: '#/components/schemas/Position'
|
||
operationId: getAllOpenPositions
|
||
description: |-
|
||
The positions API provides information about an account’s current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated. Once a position is closed, it will no longer be queryable through this API
|
||
|
||
Retrieves a list of the account’s open positions
|
||
delete:
|
||
tags:
|
||
- Positions
|
||
summary: All Positions
|
||
parameters:
|
||
- schema:
|
||
type: boolean
|
||
in: query
|
||
name: cancel_orders
|
||
description: 'If true is specified, cancel all open orders before liquidating all positions.'
|
||
responses:
|
||
'207':
|
||
description: |-
|
||
Multi-Status with body.
|
||
|
||
an array of PositionClosed responses
|
||
content:
|
||
application/json:
|
||
schema:
|
||
type: array
|
||
items:
|
||
$ref: '#/components/schemas/PositionClosedReponse'
|
||
'500':
|
||
description: Failed to liquidate
|
||
operationId: deleteAllOpenPositions
|
||
description: 'Closes (liquidates) all of the account’s open long and short positions. A response will be provided for each order that is attempted to be cancelled. If an order is no longer cancelable, the server will respond with status 500 and reject the request.'
|
||
'/v2/positions/{symbol_or_asset_id}':
|
||
get:
|
||
tags:
|
||
- Positions
|
||
summary: Open Position
|
||
description: Retrieves the account’s open position for the given symbol or assetId.
|
||
parameters: []
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Position'
|
||
operationId: getOpenPosition
|
||
delete:
|
||
tags:
|
||
- Positions
|
||
summary: Position
|
||
parameters:
|
||
- schema:
|
||
type: number
|
||
in: query
|
||
name: qty
|
||
description: the number of shares to liquidate. Can accept up to 9 decimal points. Cannot work with percentage
|
||
- schema:
|
||
type: number
|
||
in: query
|
||
name: percentage
|
||
description: percentage of position to liquidate. Must be between 0 and 100. Would only sell fractional if position is originally fractional. Can accept up to 9 decimal points. Cannot work with qty
|
||
responses:
|
||
'200':
|
||
description: |-
|
||
Successful response
|
||
|
||
Returns the order created to close out this position
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Order'
|
||
description: Closes (liquidates) the account’s open position for the given symbol. Works for both long and short positions.
|
||
operationId: deleteOpenPosition
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
name: symbol_or_asset_id
|
||
in: path
|
||
required: true
|
||
description: symbol or assetId
|
||
/v2/account/portfolio/history:
|
||
get:
|
||
tags:
|
||
- Portfolio History
|
||
summary: Account Portfolio History
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
name: period
|
||
description: 'The duration of the data in <number> + <unit>, such as 1D, where <unit> can be D for day, W for week, M for month and A for year. Defaults to 1M.'
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
name: timeframe
|
||
description: 'The resolution of time window. 1Min, 5Min, 15Min, 1H, or 1D. If omitted, 1Min for less than 7 days period, 15Min for less than 30 days, or otherwise 1D.'
|
||
- schema:
|
||
type: string
|
||
format: date
|
||
example: '2022-05-15'
|
||
in: query
|
||
name: date_end
|
||
description: 'The date the data is returned up to, in “YYYY-MM-DD” format. Defaults to the current market date (rolls over at the market open if extended_hours is false, otherwise at 7am ET)'
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
name: extended_hours
|
||
description: 'If true, include extended hours in the result. This is effective only for timeframe less than 1D.'
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/PortfolioHistory'
|
||
operationId: getAccountPortfolioHistory
|
||
description: Returns timeseries data about equity and profit/loss (P/L) of the account in requested timespan.
|
||
/v2/watchlists:
|
||
get:
|
||
tags:
|
||
- Watchlists
|
||
summary: Watchlists
|
||
parameters: []
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
examples:
|
||
example-1:
|
||
value:
|
||
- id: 3174d6df-7726-44b4-a5bd-7fda5ae6e009
|
||
account_id: abe25343-a7ba-4255-bdeb-f7e013e9ee5d
|
||
created_at: '2022-01-31T21:49:05.14628Z'
|
||
updated_at: '2022-01-31T21:49:05.14628Z'
|
||
name: Primary Watchlist
|
||
schema:
|
||
type: array
|
||
items:
|
||
$ref: '#/components/schemas/Watchlist'
|
||
operationId: getWatchlists
|
||
description: Returns the list of watchlists registered under the account.
|
||
post:
|
||
tags:
|
||
- Watchlists
|
||
summary: Watchlist
|
||
description: Create a new watchlist with initial set of assets.
|
||
requestBody:
|
||
required: true
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/UpdateWatchlistRequest'
|
||
parameters: []
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Watchlist'
|
||
operationId: postWatchlist
|
||
'/v2/watchlists/{watchlist_id}':
|
||
get:
|
||
tags:
|
||
- Watchlists
|
||
summary: Get Watchlist by ID
|
||
parameters: []
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Watchlist'
|
||
operationId: getWatchlistById
|
||
description: Returns a watchlist identified by the ID.
|
||
put:
|
||
tags:
|
||
- Watchlists
|
||
summary: Update Watchlist By Id
|
||
requestBody:
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/UpdateWatchlistRequest'
|
||
parameters: []
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Watchlist'
|
||
operationId: updateWatchlistById
|
||
description: Update the name and/or content of watchlist
|
||
post:
|
||
tags:
|
||
- Watchlists
|
||
summary: Add Asset to Watchlist
|
||
requestBody:
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/AddAssetToWatchlistRequest'
|
||
parameters: []
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Watchlist'
|
||
operationId: addAssetToWatchlist
|
||
description: Append an asset for the symbol to the end of watchlist asset list
|
||
delete:
|
||
tags:
|
||
- Watchlists
|
||
summary: Delete Watchlist By Id
|
||
parameters: []
|
||
responses:
|
||
'204':
|
||
description: No Content
|
||
operationId: deleteWatchlistById
|
||
description: Delete a watchlist. This is a permanent deletion.
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
format: uuid
|
||
name: watchlist_id
|
||
in: path
|
||
required: true
|
||
description: watchlist id
|
||
'/v2/watchlists:by_name':
|
||
get:
|
||
tags:
|
||
- Watchlists
|
||
summary: Get Watchlist by Name
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
name: name
|
||
required: true
|
||
description: name of the watchlist
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Watchlist'
|
||
operationId: getWatchlistByName
|
||
description: Returns a watchlist by name
|
||
put:
|
||
tags:
|
||
- Watchlists
|
||
summary: Update Watchlist By Name
|
||
requestBody:
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/UpdateWatchlistRequest'
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
name: name
|
||
required: true
|
||
description: name of the watchlist
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Watchlist'
|
||
operationId: updateWatchlistByName
|
||
description: Update the name and/or content of watchlist
|
||
post:
|
||
tags:
|
||
- Watchlists
|
||
summary: Add Asset to Watchlist By Name
|
||
requestBody:
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/AddAssetToWatchlistRequest'
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
name: name
|
||
required: true
|
||
description: name of the watchlist
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Watchlist'
|
||
operationId: addAssetToWatchlistByName
|
||
description: Append an asset for the symbol to the end of watchlist asset list
|
||
delete:
|
||
tags:
|
||
- Watchlists
|
||
summary: Delete Watchlist By Name
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
name: name
|
||
required: true
|
||
description: name of the watchlist
|
||
responses:
|
||
'204':
|
||
description: No Content
|
||
operationId: deleteWatchlistByName
|
||
description: Delete a watchlist. This is a permanent deletion.
|
||
parameters: []
|
||
'/v2/watchlists/{watchlist_id}/{symbol}':
|
||
delete:
|
||
tags:
|
||
- Watchlists
|
||
summary: Symbol from Watchlist
|
||
parameters: []
|
||
responses:
|
||
'200':
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Watchlist'
|
||
description: Returns the updated watchlist
|
||
operationId: removeAssetFromWatchlist
|
||
description: Delete one entry for an asset by symbol name
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
format: uuid
|
||
name: watchlist_id
|
||
in: path
|
||
required: true
|
||
description: Watchlist ID
|
||
- schema:
|
||
type: string
|
||
name: symbol
|
||
in: path
|
||
required: true
|
||
description: symbol name to remove from the watchlist content
|
||
/v2/account/configurations:
|
||
get:
|
||
tags:
|
||
- Account Configurations
|
||
summary: Account Configurations
|
||
parameters: []
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/AccountConfigurations'
|
||
operationId: getAccountConfig
|
||
description: gets the current account configuration values
|
||
patch:
|
||
tags:
|
||
- Account Configurations
|
||
summary: Account Configurations
|
||
parameters: []
|
||
requestBody:
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/AccountConfigurations'
|
||
responses:
|
||
'200':
|
||
description: Successful response
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/AccountConfigurations'
|
||
operationId: patchAccountConfig
|
||
description: Updates and returns the current account configuration values
|
||
/v2/account/activities:
|
||
get:
|
||
summary: Get account activities of one type
|
||
tags:
|
||
- Account Activities
|
||
responses:
|
||
'200':
|
||
description: returns an array of Account activities
|
||
content:
|
||
application/json:
|
||
schema:
|
||
type: array
|
||
items:
|
||
anyOf:
|
||
- $ref: '#/components/schemas/TradingActivities'
|
||
- $ref: '#/components/schemas/NonTradeActivities'
|
||
description: Will be a mix of TradingActivity or NonTradeActivity objects based on what is passed in the activity_types parameter
|
||
operationId: getAccountActivities
|
||
description: Returns account activity entries for many types of activities.
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
format: date-time
|
||
in: query
|
||
name: date
|
||
description: The date for which you want to see activities.
|
||
- schema:
|
||
type: string
|
||
format: date-time
|
||
in: query
|
||
description: The response will contain only activities submitted before this date. (Cannot be used with date.)
|
||
name: until
|
||
- schema:
|
||
type: string
|
||
format: date-time
|
||
in: query
|
||
description: The response will contain only activities submitted after this date. (Cannot be used with date.)
|
||
name: after
|
||
- schema:
|
||
type: string
|
||
enum:
|
||
- asc
|
||
- desc
|
||
example: desc
|
||
in: query
|
||
name: direction
|
||
description: asc or desc (default desc if unspecified.)
|
||
- schema:
|
||
type: integer
|
||
in: query
|
||
name: page_size
|
||
description: The maximum number of entries to return in the response. (See the section on paging above.)
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
description: 'The ID of the end of your current page of results. '
|
||
name: page_token
|
||
- schema:
|
||
type: string
|
||
example: FILL
|
||
in: query
|
||
name: activity_types
|
||
description: 'A comma-separated list of the activity types to include in the response. If unspecified, activities of all types will be returned. See ActivityType model for values'
|
||
'/v2/account/activities/{activity_type}':
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
name: activity_type
|
||
in: path
|
||
description: The activity type you want to view entries for. A list of valid activity types can be found at the bottom of this page.
|
||
required: true
|
||
get:
|
||
summary: Get account activities of one type
|
||
tags:
|
||
- Account Activities
|
||
responses:
|
||
'200':
|
||
description: returns an array of Account activities
|
||
content:
|
||
application/json:
|
||
schema:
|
||
type: array
|
||
items:
|
||
oneOf:
|
||
- $ref: '#/components/schemas/TradingActivities'
|
||
- $ref: '#/components/schemas/NonTradeActivities'
|
||
description: Will be one of a TradingActivity or NonTradeActivity based on activity_type used in path
|
||
operationId: getAccountActivitiesByActivityType
|
||
description: Returns account activity entries for a specific type of activity.
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
format: date-time
|
||
in: query
|
||
name: date
|
||
description: The date for which you want to see activities.
|
||
- schema:
|
||
type: string
|
||
format: date-time
|
||
in: query
|
||
description: The response will contain only activities submitted before this date. (Cannot be used with date.)
|
||
name: until
|
||
- schema:
|
||
type: string
|
||
format: date-time
|
||
in: query
|
||
description: The response will contain only activities submitted after this date. (Cannot be used with date.)
|
||
name: after
|
||
- schema:
|
||
type: string
|
||
enum:
|
||
- asc
|
||
- desc
|
||
example: desc
|
||
in: query
|
||
name: direction
|
||
description: asc or desc (default desc if unspecified.)
|
||
- schema:
|
||
type: integer
|
||
in: query
|
||
name: page_size
|
||
description: The maximum number of entries to return in the response. (See the section on paging above.)
|
||
- schema:
|
||
type: string
|
||
in: query
|
||
description: 'The ID of the end of your current page of results. '
|
||
name: page_token
|
||
/v2/calendar:
|
||
get:
|
||
summary: Get Market Calendar info
|
||
tags:
|
||
- Calendar
|
||
parameters:
|
||
- schema:
|
||
type: string
|
||
format: date-time
|
||
in: query
|
||
name: start
|
||
description: The first date to retrieve data for (inclusive)
|
||
- schema:
|
||
type: string
|
||
format: date-time
|
||
in: query
|
||
name: end
|
||
description: The last date to retrieve data for (inclusive)
|
||
responses:
|
||
'200':
|
||
description: OK
|
||
content:
|
||
application/json:
|
||
schema:
|
||
type: array
|
||
items:
|
||
$ref: '#/components/schemas/Calendar'
|
||
operationId: getCalendar
|
||
description: Returns the market calendar.
|
||
/v2/clock:
|
||
get:
|
||
summary: Get Market Clock info
|
||
parameters: []
|
||
responses:
|
||
'200':
|
||
description: OK
|
||
content:
|
||
application/json:
|
||
schema:
|
||
$ref: '#/components/schemas/Clock'
|
||
operationId: getClock
|
||
description: |-
|
||
The clock API serves the current market timestamp, whether or not the market is currently open, as well as the times of the next market open and close.
|
||
|
||
Returns the market clock.
|
||
tags:
|
||
- Clock
|
||
components:
|
||
securitySchemes:
|
||
API_Key:
|
||
name: APCA-API-KEY-ID
|
||
type: apiKey
|
||
in: header
|
||
description: ''
|
||
API_Secret:
|
||
name: APCA-API-SECRET-KEY
|
||
type: apiKey
|
||
in: header
|
||
description: ''
|
||
schemas:
|
||
Account:
|
||
title: Account
|
||
type: object
|
||
description: |
|
||
The account API serves important information related to an account, including account status, funds available for trade, funds available for withdrawal, and various flags relevant to an account’s ability to trade. An account maybe be blocked for just for trades (trades_blocked flag) or for both trades and transfers (account_blocked flag) if Alpaca identifies the account to engaging in any suspicious activity. Also, in accordance with FINRA’s pattern day trading rule, an account may be flagged for pattern day trading (pattern_day_trader flag), which would inhibit an account from placing any further day-trades. Please note that cryptocurrencies are not eligible assets to be used as collateral for margin accounts and will require the asset be traded using cash only.
|
||
x-examples:
|
||
example-1:
|
||
account_blocked: false
|
||
account_number: 010203ABCD
|
||
buying_power: '262113.632'
|
||
cash: '-23140.2'
|
||
created_at: '2019-06-12T22:47:07.99658Z'
|
||
currency: USD
|
||
daytrade_count: 0
|
||
daytrading_buying_power: '262113.632'
|
||
equity: '103820.56'
|
||
id: e6fe16f3-64a4-4921-8928-cadf02f92f98
|
||
initial_margin: '63480.38'
|
||
last_equity: '103529.24'
|
||
last_maintenance_margin: '38000.832'
|
||
long_market_value: '126960.76'
|
||
maintenance_margin: '38088.228'
|
||
multiplier: '4'
|
||
pattern_day_trader: false
|
||
portfolio_value: '103820.56'
|
||
regt_buying_power: '80680.36'
|
||
short_market_value: '0'
|
||
shorting_enabled: true
|
||
sma: '0'
|
||
status: ACTIVE
|
||
trade_suspended_by_user: false
|
||
trading_blocked: false
|
||
transfers_blocked: false
|
||
properties:
|
||
id:
|
||
type: string
|
||
description: |
|
||
Account Id.
|
||
format: uuid
|
||
account_number:
|
||
type: string
|
||
description: Account number.
|
||
status:
|
||
$ref: '#/components/schemas/AccountStatus'
|
||
currency:
|
||
type: string
|
||
description: |
|
||
USD
|
||
example: USD
|
||
cash:
|
||
description: |
|
||
Cash Balance
|
||
type: string
|
||
portfolio_value:
|
||
description: Total value of cash + holding positions (This field is deprecated. It is equivalent to the equity field.)
|
||
type: string
|
||
pattern_day_trader:
|
||
type: boolean
|
||
description: Whether or not the account has been flagged as a pattern day trader
|
||
trade_suspended_by_user:
|
||
type: boolean
|
||
description: 'User setting. If true, the account is not allowed to place orders.'
|
||
trading_blocked:
|
||
type: boolean
|
||
description: |
|
||
If true, the account is not allowed to place orders.
|
||
transfers_blocked:
|
||
type: boolean
|
||
description: 'If true, the account is not allowed to request money transfers.'
|
||
account_blocked:
|
||
type: boolean
|
||
description: 'If true, the account activity by user is prohibited.'
|
||
created_at:
|
||
type: string
|
||
description: |
|
||
Timestamp this account was created at
|
||
format: date-time
|
||
shorting_enabled:
|
||
type: boolean
|
||
description: Flag to denote whether or not the account is permitted to short
|
||
long_market_value:
|
||
description: |
|
||
Real-time MtM value of all long positions held in the account
|
||
type: string
|
||
short_market_value:
|
||
description: Real-time MtM value of all short positions held in the account
|
||
type: string
|
||
equity:
|
||
description: Cash + long_market_value + short_market_value
|
||
type: string
|
||
last_equity:
|
||
description: 'Equity as of previous trading day at 16:00:00 ET'
|
||
type: string
|
||
multiplier:
|
||
description: 'Buying power multiplier that represents account margin classification; valid values 1 (standard limited margin account with 1x buying power), 2 (reg T margin account with 2x intraday and overnight buying power; this is the default for all non-PDT accounts with $2,000 or more equity), 4 (PDT account with 4x intraday buying power and 2x reg T overnight buying power)'
|
||
type: string
|
||
buying_power:
|
||
description: 'Current available $ buying power; If multiplier = 4, this is your daytrade buying power which is calculated as (last_equity - (last) maintenance_margin) * 4; If multiplier = 2, buying_power = max(equity – initial_margin,0) * 2; If multiplier = 1, buying_power = cash'
|
||
type: string
|
||
initial_margin:
|
||
description: Reg T initial margin requirement (continuously updated value)
|
||
type: string
|
||
maintenance_margin:
|
||
description: Maintenance margin requirement (continuously updated value)
|
||
type: string
|
||
sma:
|
||
type: string
|
||
description: Value of special memorandum account (will be used at a later date to provide additional buying_power)
|
||
daytrade_count:
|
||
type: integer
|
||
description: The current number of daytrades that have been made in the last 5 trading days (inclusive of today)
|
||
last_maintenance_margin:
|
||
description: Your maintenance margin requirement on the previous trading day
|
||
type: string
|
||
daytrading_buying_power:
|
||
description: Your buying power for day trades (continuously updated value)
|
||
type: string
|
||
regt_buying_power:
|
||
description: |
|
||
Your buying power under Regulation T (your excess equity - equity minus margin value - times your margin multiplier)
|
||
type: string
|
||
required:
|
||
- id
|
||
- status
|
||
AccountStatus:
|
||
type: string
|
||
title: AccountStatus
|
||
enum:
|
||
- ONBOARDING
|
||
- SUBMISSION_FAILED
|
||
- SUBMITTED
|
||
- ACCOUNT_UPDATED
|
||
- APPROVAL_PENDING
|
||
- ACTIVE
|
||
- REJECTED
|
||
description: |-
|
||
An enum representing the various possible account status values.
|
||
|
||
Most likely, the account status is ACTIVE unless there is any problem. The account status may get in ACCOUNT_UPDATED when personal information is being updated from the dashboard, in which case you may not be allowed trading for a short period of time until the change is approved.
|
||
|
||
- ONBOARDING
|
||
The account is onboarding.
|
||
- SUBMISSION_FAILED
|
||
The account application submission failed for some reason.
|
||
- SUBMITTED
|
||
The account application has been submitted for review.
|
||
- ACCOUNT_UPDATED
|
||
The account information is being updated.
|
||
- APPROVAL_PENDING
|
||
The final account approval is pending.
|
||
- ACTIVE
|
||
The account is active for trading.
|
||
- REJECTED
|
||
The account application has been rejected.
|
||
x-examples:
|
||
example-1: ACTIVE
|
||
example: ACTIVE
|
||
AccountConfigurations:
|
||
title: AccountConfigurations
|
||
type: object
|
||
x-examples:
|
||
example-1:
|
||
dtbp_check: entry
|
||
trade_confirm_email: all
|
||
suspend_trade: false
|
||
no_shorting: false
|
||
fractional_trading: true
|
||
max_margin_multiplier: '4'
|
||
pdt_check: entry
|
||
description: The account configuration API provides custom configurations about your trading account settings. These configurations control various allow you to modify settings to suit your trading needs.
|
||
properties:
|
||
dtbp_check:
|
||
type: string
|
||
description: 'both, entry, or exit. Controls Day Trading Margin Call (DTMC) checks.'
|
||
enum:
|
||
- both
|
||
- entry
|
||
- exit
|
||
trade_confirm_email:
|
||
type: string
|
||
description: 'all or none. If none, emails for order fills are not sent.'
|
||
suspend_trade:
|
||
type: boolean
|
||
description: 'If true, new orders are blocked.'
|
||
no_shorting:
|
||
type: boolean
|
||
description: 'If true, account becomes long-only mode.'
|
||
fractional_trading:
|
||
type: boolean
|
||
description: 'If true, account is able to participate in fractional trading'
|
||
max_margin_multiplier:
|
||
type: string
|
||
description: Can be "1" or "2"
|
||
pdt_check:
|
||
type: string
|
||
example: entry
|
||
TradingActivities:
|
||
title: AccountTradingActivities
|
||
type: object
|
||
x-examples:
|
||
example-1:
|
||
id: '20220202135509981::2d7be4ff-d1f3-43e9-856a-0f5cf5c5088e'
|
||
activity_type: FILL
|
||
transaction_time: '2022-02-02T18:55:09.981482Z'
|
||
type: fill
|
||
price: '174.78'
|
||
qty: '2'
|
||
side: buy
|
||
symbol: AAPL
|
||
leaves_qty: '0'
|
||
order_id: b5abe576-6a8a-49f3-a353-46b72c1ccae9
|
||
cum_qty: '2'
|
||
order_status: filled
|
||
properties:
|
||
activity_type:
|
||
$ref: '#/components/schemas/ActivityType'
|
||
id:
|
||
type: string
|
||
description: 'An id for the activity. Always in “::” format. Can be sent as page_token in requests to facilitate the paging of results.'
|
||
cum_qty:
|
||
description: The cumulative quantity of shares involved in the execution.
|
||
type: string
|
||
leaves_qty:
|
||
type: string
|
||
description: |
|
||
For partially_filled orders, the quantity of shares that are left to be filled.
|
||
price:
|
||
type: string
|
||
description: The per-share price that the trade was executed at.
|
||
qty:
|
||
type: string
|
||
description: The number of shares involved in the trade execution.
|
||
side:
|
||
type: string
|
||
description: buy or sell
|
||
symbol:
|
||
type: string
|
||
description: The symbol of the security being traded.
|
||
example: AAPL
|
||
transaction_time:
|
||
type: string
|
||
description: The time at which the execution occurred.
|
||
format: date-time
|
||
order_id:
|
||
type: string
|
||
description: The id for the order that filled.
|
||
format: uuid
|
||
type:
|
||
type: string
|
||
description: fill or partial_fill
|
||
enum:
|
||
- fill
|
||
- partial_fill
|
||
example: fill
|
||
order_status:
|
||
$ref: '#/components/schemas/OrderStatus'
|
||
NonTradeActivities:
|
||
title: AccountNonTradeActivities
|
||
type: object
|
||
properties:
|
||
activity_type:
|
||
$ref: '#/components/schemas/ActivityType'
|
||
id:
|
||
type: string
|
||
description: 'An ID for the activity, always in “::” format. Can be sent as page_token in requests to facilitate the paging of results.'
|
||
date:
|
||
type: string
|
||
description: The date on which the activity occurred or on which the transaction associated with the activity settled.
|
||
format: date-time
|
||
net_amount:
|
||
type: string
|
||
description: The net amount of money (positive or negative) associated with the activity.
|
||
symbol:
|
||
type: string
|
||
description: The symbol of the security involved with the activity. Not present for all activity types.
|
||
qty:
|
||
type: string
|
||
description: |
|
||
For dividend activities, the number of shares that contributed to the payment. Not present for other activity types.
|
||
per_share_amount:
|
||
type: string
|
||
description: 'For dividend activities, the average amount paid per share. Not present for other activity types.'
|
||
x-examples:
|
||
example-1:
|
||
activity_type: DIV
|
||
id: '20190801011955195::5f596936-6f23-4cef-bdf1-3806aae57dbf'
|
||
date: '2019-08-01'
|
||
net_amount: '1.02'
|
||
symbol: T
|
||
qty: '2'
|
||
per_share_amount: '0.51'
|
||
ActivityType:
|
||
type: string
|
||
title: ActivityType
|
||
description: |-
|
||
- FILL
|
||
Order fills (both partial and full fills)
|
||
|
||
- TRANS
|
||
Cash transactions (both CSD and CSW)
|
||
|
||
- MISC
|
||
Miscellaneous or rarely used activity types (All types except those in TRANS, DIV, or FILL)
|
||
|
||
- ACATC
|
||
ACATS IN/OUT (Cash)
|
||
|
||
- ACATS
|
||
ACATS IN/OUT (Securities)
|
||
|
||
- CFEE
|
||
Crypto fee
|
||
|
||
- CSD
|
||
Cash deposit(+)
|
||
|
||
- CSW
|
||
Cash withdrawal(-)
|
||
|
||
- DIV
|
||
Dividends
|
||
|
||
- DIVCGL
|
||
Dividend (capital gain long term)
|
||
|
||
- DIVCGS
|
||
Dividend (capital gain short term)
|
||
|
||
- DIVFEE
|
||
Dividend fee
|
||
|
||
- DIVFT
|
||
Dividend adjusted (Foreign Tax Withheld)
|
||
|
||
- DIVNRA
|
||
Dividend adjusted (NRA Withheld)
|
||
|
||
- DIVROC
|
||
Dividend return of capital
|
||
|
||
- DIVTW
|
||
Dividend adjusted (Tefra Withheld)
|
||
|
||
- DIVTXEX
|
||
Dividend (tax exempt)
|
||
|
||
- FEE
|
||
Fee denominated in USD
|
||
|
||
- INT
|
||
Interest (credit/margin)
|
||
|
||
- INTNRA
|
||
Interest adjusted (NRA Withheld)
|
||
|
||
- INTTW
|
||
Interest adjusted (Tefra Withheld)
|
||
|
||
- JNL
|
||
Journal entry
|
||
|
||
- JNLC
|
||
Journal entry (cash)
|
||
|
||
- JNLS
|
||
Journal entry (stock)
|
||
|
||
- MA
|
||
Merger/Acquisition
|
||
|
||
- NC
|
||
Name change
|
||
|
||
- OPASN
|
||
Option assignment
|
||
|
||
- OPEXP
|
||
Option expiration
|
||
|
||
- OPXRC
|
||
Option exercise
|
||
|
||
- PTC
|
||
Pass Thru Charge
|
||
|
||
- PTR
|
||
Pass Thru Rebate
|
||
|
||
- REORG
|
||
Reorg CA
|
||
|
||
- SC
|
||
Symbol change
|
||
|
||
- SSO
|
||
Stock spinoff
|
||
|
||
- SSP
|
||
Stock split
|
||
enum:
|
||
- FILL
|
||
- TRANS
|
||
- MISC
|
||
- ACATC
|
||
- ACATS
|
||
- CSD
|
||
- CSW
|
||
- DIV
|
||
- DIVCGL
|
||
- DIVCGS
|
||
- DIVFEE
|
||
- DIVFT
|
||
- DIVNRA
|
||
- DIVROC
|
||
- DIVTW
|
||
- DIVTXEX
|
||
- INT
|
||
- INTNRA
|
||
- INTTW
|
||
- JNL
|
||
- JNLC
|
||
- JNLS
|
||
- MA
|
||
- NC
|
||
- OPASN
|
||
- OPEXP
|
||
- OPXRC
|
||
- PTC
|
||
- PTR
|
||
- REORG
|
||
- SC
|
||
- SSO
|
||
- SSP
|
||
- CFEE
|
||
- FEE
|
||
x-examples:
|
||
example-1: FILL
|
||
Order:
|
||
description: |-
|
||
The Orders API allows a user to monitor, place and cancel their orders with Alpaca.
|
||
|
||
Each order has a unique identifier provided by the client. This client-side unique order ID will be automatically generated by the system if not provided by the client, and will be returned as part of the order object along with the rest of the fields described below. Once an order is placed, it can be queried using the client-side order ID to check the status.
|
||
|
||
Updates on open orders at Alpaca will also be sent over the streaming interface, which is the recommended method of maintaining order state.
|
||
type: object
|
||
x-examples:
|
||
example-1:
|
||
id: 61e69015-8549-4bfd-b9c3-01e75843f47d
|
||
client_order_id: eb9e2aaa-f71a-4f51-b5b4-52a6c565dad4
|
||
created_at: '2021-03-16T18:38:01.942282Z'
|
||
updated_at: '2021-03-16T18:38:01.942282Z'
|
||
submitted_at: '2021-03-16T18:38:01.937734Z'
|
||
filled_at: null
|
||
expired_at: null
|
||
canceled_at: null
|
||
failed_at: null
|
||
replaced_at: null
|
||
replaced_by: null
|
||
replaces: null
|
||
asset_id: b0b6dd9d-8b9b-48a9-ba46-b9d54906e415
|
||
symbol: AAPL
|
||
asset_class: us_equity
|
||
notional: '500'
|
||
qty: null
|
||
filled_qty: '0'
|
||
filled_avg_price: null
|
||
order_class: ''
|
||
order_type: market
|
||
type: market
|
||
side: buy
|
||
time_in_force: day
|
||
limit_price: null
|
||
stop_price: null
|
||
status: accepted
|
||
extended_hours: false
|
||
legs: null
|
||
trail_percent: null
|
||
trail_price: null
|
||
hwm: null
|
||
title: Order
|
||
properties:
|
||
id:
|
||
type: string
|
||
description: Order ID
|
||
client_order_id:
|
||
type: string
|
||
description: Client unique order ID
|
||
maxLength: 48
|
||
created_at:
|
||
type: string
|
||
format: date-time
|
||
updated_at:
|
||
type: string
|
||
format: date-time
|
||
nullable: true
|
||
submitted_at:
|
||
type: string
|
||
format: date-time
|
||
nullable: true
|
||
filled_at:
|
||
type: string
|
||
format: date-time
|
||
nullable: true
|
||
expired_at:
|
||
type: string
|
||
format: date-time
|
||
nullable: true
|
||
canceled_at:
|
||
type: string
|
||
format: date-time
|
||
nullable: true
|
||
failed_at:
|
||
type: string
|
||
format: date-time
|
||
nullable: true
|
||
replaced_at:
|
||
type: string
|
||
format: date-time
|
||
nullable: true
|
||
replaced_by:
|
||
type: string
|
||
format: uuid
|
||
description: The order ID that this order was replaced by
|
||
nullable: true
|
||
replaces:
|
||
type: string
|
||
format: uuid
|
||
description: The order ID that this order replaces
|
||
nullable: true
|
||
asset_id:
|
||
type: string
|
||
format: uuid
|
||
description: Asset ID
|
||
symbol:
|
||
type: string
|
||
minLength: 1
|
||
description: Asset symbol
|
||
asset_class:
|
||
$ref: '#/components/schemas/AssetClass'
|
||
notional:
|
||
type: string
|
||
minLength: 1
|
||
description: 'Ordered notional amount. If entered, qty will be null. Can take up to 9 decimal points.'
|
||
nullable: true
|
||
qty:
|
||
type: string
|
||
minLength: 1
|
||
description: 'Ordered quantity. If entered, notional will be null. Can take up to 9 decimal points.'
|
||
nullable: true
|
||
filled_qty:
|
||
type: string
|
||
minLength: 1
|
||
description: Filled quantity
|
||
filled_avg_price:
|
||
type: string
|
||
description: Filled average price
|
||
nullable: true
|
||
order_class:
|
||
$ref: '#/components/schemas/OrderClass'
|
||
order_type:
|
||
type: string
|
||
deprecated: true
|
||
description: 'Deprecated in favour of the field "type" '
|
||
type:
|
||
$ref: '#/components/schemas/OrderType'
|
||
side:
|
||
$ref: '#/components/schemas/OrderSide'
|
||
time_in_force:
|
||
$ref: '#/components/schemas/TimeInForce'
|
||
limit_price:
|
||
type: string
|
||
description: Limit price
|
||
nullable: true
|
||
stop_price:
|
||
description: Stop price
|
||
type: string
|
||
nullable: true
|
||
status:
|
||
$ref: '#/components/schemas/OrderStatus'
|
||
extended_hours:
|
||
type: boolean
|
||
description: 'If true, eligible for execution outside regular trading hours.'
|
||
legs:
|
||
type: array
|
||
description: 'When querying non-simple order_class orders in a nested style, an array of Order entities associated with this order. Otherwise, null.'
|
||
nullable: true
|
||
items:
|
||
$ref: '#/components/schemas/Order'
|
||
trail_percent:
|
||
type: string
|
||
description: The percent value away from the high water mark for trailing stop orders.
|
||
trail_price:
|
||
type: string
|
||
description: The dollar value away from the high water mark for trailing stop orders.
|
||
hwm:
|
||
type: string
|
||
description: The highest (lowest) market price seen since the trailing stop order was submitted.
|
||
required:
|
||
- symbol
|
||
- notional
|
||
- qty
|
||
- type
|
||
- side
|
||
- time_in_force
|
||
OrderType:
|
||
type: string
|
||
enum:
|
||
- market
|
||
- limit
|
||
- stop
|
||
- stop_limit
|
||
- trailing_stop
|
||
example: stop
|
||
description: |-
|
||
Represents the types of orders Alpaca currently supports
|
||
|
||
- market
|
||
- limit
|
||
- stop
|
||
- stop_limit
|
||
- trailing_stop
|
||
title: OrderType
|
||
OrderSide:
|
||
type: string
|
||
enum:
|
||
- buy
|
||
- sell
|
||
example: buy
|
||
title: OrderSide
|
||
description: |-
|
||
Represents which side this order was on:
|
||
|
||
- buy
|
||
- sell
|
||
OrderClass:
|
||
type: string
|
||
enum:
|
||
- simple
|
||
- bracket
|
||
- oco
|
||
- oto
|
||
- ''
|
||
example: bracket
|
||
description: 'This will either be the empty string "", "simple", "bracket", "oco", or "oto".'
|
||
title: OrderClass
|
||
OrderStatus:
|
||
type: string
|
||
title: OrderStatus
|
||
description: |-
|
||
An order executed through Alpaca can experience several status changes during its lifecycle. The most common statuses are described in detail below:
|
||
|
||
- new
|
||
The order has been received by Alpaca, and routed to exchanges for execution. This is the usual initial state of an order.
|
||
|
||
- partially_filled
|
||
The order has been partially filled.
|
||
|
||
- filled
|
||
The order has been filled, and no further updates will occur for the order.
|
||
|
||
- done_for_day
|
||
The order is done executing for the day, and will not receive further updates until the next trading day.
|
||
|
||
- canceled
|
||
The order has been canceled, and no further updates will occur for the order. This can be either due to a cancel request by the user, or the order has been canceled by the exchanges due to its time-in-force.
|
||
|
||
- expired
|
||
The order has expired, and no further updates will occur for the order.
|
||
|
||
- replaced
|
||
The order was replaced by another order, or was updated due to a market event such as corporate action.
|
||
|
||
- pending_cancel
|
||
The order is waiting to be canceled.
|
||
|
||
- pending_replace
|
||
The order is waiting to be replaced by another order. The order will reject cancel request while in this state.
|
||
|
||
Less common states are described below. Note that these states only occur on very rare occasions, and most users will likely never see their orders reach these states:
|
||
|
||
- accepted
|
||
The order has been received by Alpaca, but hasn’t yet been routed to the execution venue. This could be seen often out side of trading session hours.
|
||
|
||
- pending_new
|
||
The order has been received by Alpaca, and routed to the exchanges, but has not yet been accepted for execution. This state only occurs on rare occasions.
|
||
|
||
- accepted_for_bidding
|
||
The order has been received by exchanges, and is evaluated for pricing. This state only occurs on rare occasions.
|
||
|
||
- stopped
|
||
The order has been stopped, and a trade is guaranteed for the order, usually at a stated price or better, but has not yet occurred. This state only occurs on rare occasions.
|
||
|
||
- rejected
|
||
The order has been rejected, and no further updates will occur for the order. This state occurs on rare occasions and may occur based on various conditions decided by the exchanges.
|
||
|
||
- suspended
|
||
The order has been suspended, and is not eligible for trading. This state only occurs on rare occasions.
|
||
|
||
- calculated
|
||
The order has been completed for the day (either filled or done for day), but remaining settlement calculations are still pending. This state only occurs on rare occasions.
|
||
|
||
|
||
An order may be canceled through the API up until the point it reaches a state of either filled, canceled, or expired.
|
||
enum:
|
||
- new
|
||
- partially_filled
|
||
- filled
|
||
- done_for_day
|
||
- canceled
|
||
- expired
|
||
- replaced
|
||
- pending_cancel
|
||
- pending_replace
|
||
- accepted
|
||
- pending_new
|
||
- accepted_for_bidding
|
||
- stopped
|
||
- rejected
|
||
- suspended
|
||
- calculated
|
||
example: new
|
||
TimeInForce:
|
||
type: string
|
||
title: TimeInForce
|
||
description: |-
|
||
Note: For Crypto Trading, Alpaca supports the following Time-In-Force designations: day, gtc, ioc and fok. OPG and CLS are not supported.
|
||
|
||
Alpaca supports the following Time-In-Force designations:
|
||
|
||
- day
|
||
A day order is eligible for execution only on the day it is live. By default, the order is only valid during Regular Trading Hours (9:30am - 4:00pm ET). If unfilled after the closing auction, it is automatically canceled. If submitted after the close, it is queued and submitted the following trading day. However, if marked as eligible for extended hours, the order can also execute during supported extended hours.
|
||
|
||
- gtc
|
||
The order is good until canceled. Non-marketable GTC limit orders are subject to price adjustments to offset corporate actions affecting the issue. We do not currently support Do Not Reduce(DNR) orders to opt out of such price adjustments.
|
||
|
||
- opg
|
||
Use this TIF with a market/limit order type to submit “market on open” (MOO) and “limit on open” (LOO) orders. This order is eligible to execute only in the market opening auction. Any unfilled orders after the open will be cancelled. OPG orders submitted after 9:28am but before 7:00pm ET will be rejected. OPG orders submitted after 7:00pm will be queued and routed to the following day’s opening auction. On open/on close orders are routed to the primary exchange. Such orders do not necessarily execute exactly at 9:30am / 4:00pm ET but execute per the exchange’s auction rules.
|
||
|
||
- cls
|
||
Use this TIF with a market/limit order type to submit “market on close” (MOC) and “limit on close” (LOC) orders. This order is eligible to execute only in the market closing auction. Any unfilled orders after the close will be cancelled. CLS orders submitted after 3:50pm but before 7:00pm ET will be rejected. CLS orders submitted after 7:00pm will be queued and routed to the following day’s closing auction. Only available with API v2.
|
||
|
||
- ioc
|
||
An Immediate Or Cancel (IOC) order requires all or part of the order to be executed immediately. Any unfilled portion of the order is canceled. Only available with API v2. Most market makers who receive IOC orders will attempt to fill the order on a principal basis only, and cancel any unfilled balance. On occasion, this can result in the entire order being cancelled if the market maker does not have any existing inventory of the security in question.
|
||
|
||
- fok
|
||
A Fill or Kill (FOK) order is only executed if the entire order quantity can be filled, otherwise the order is canceled. Only available with API v2.
|
||
enum:
|
||
- day
|
||
- gtc
|
||
- opg
|
||
- cls
|
||
- ioc
|
||
- fok
|
||
example: day
|
||
Assets:
|
||
description: |
|
||
The assets API serves as the master list of assets available for trade and data consumption from Alpaca. Assets are sorted by asset class, exchange and symbol. Some assets are only available for data consumption via Polygon, and are not tradable with Alpaca. These assets will be marked with the flag tradable=false.
|
||
type: object
|
||
x-examples:
|
||
example-1:
|
||
id: b0b6dd9d-8b9b-48a9-ba46-b9d54906e415
|
||
class: us_equity
|
||
exchange: NASDAQ
|
||
symbol: AAPL
|
||
name: Apple Inc. Common Stock
|
||
status: active
|
||
tradable: true
|
||
marginable: true
|
||
shortable: true
|
||
easy_to_borrow: true
|
||
fractionable: true
|
||
title: Assets
|
||
properties:
|
||
id:
|
||
type: string
|
||
format: uuid
|
||
description: Asset ID
|
||
class:
|
||
$ref: '#/components/schemas/AssetClass'
|
||
exchange:
|
||
$ref: '#/components/schemas/Exchange'
|
||
symbol:
|
||
type: string
|
||
description: The symbol of the asset
|
||
example: AAPL
|
||
name:
|
||
type: string
|
||
minLength: 1
|
||
description: The official name of the asset
|
||
status:
|
||
type: string
|
||
description: active or inactive
|
||
example: active
|
||
enum:
|
||
- active
|
||
- inactive
|
||
tradable:
|
||
type: boolean
|
||
description: Asset is tradable on Alpaca or not
|
||
marginable:
|
||
type: boolean
|
||
description: Asset is marginable or not
|
||
shortable:
|
||
type: boolean
|
||
description: Asset is shortable or not
|
||
easy_to_borrow:
|
||
type: boolean
|
||
description: Asset is easy-to-borrow or not (filtering for easy_to_borrow = True is the best way to check whether the name is currently available to short at Alpaca).
|
||
fractionable:
|
||
type: boolean
|
||
description: Asset is fractionable or not
|
||
required:
|
||
- id
|
||
- class
|
||
- exchange
|
||
- symbol
|
||
- name
|
||
- status
|
||
- tradable
|
||
- marginable
|
||
- shortable
|
||
- easy_to_borrow
|
||
- fractionable
|
||
AssetClass:
|
||
type: string
|
||
title: AssetClass
|
||
enum:
|
||
- us_equity
|
||
- crypto
|
||
example: us_equity
|
||
description: Represents what class of asset this is. Currently only supports `us_equity` or `crypto`
|
||
x-examples:
|
||
example-1: us_equity
|
||
Position:
|
||
description: 'The positions API provides information about an account’s current open positions. The response will include information such as cost basis, shares traded, and market value, which will be updated live as price information is updated. Once a position is closed, it will no longer be queryable through this API.'
|
||
type: object
|
||
x-examples:
|
||
example-1:
|
||
asset_id: 904837e3-3b76-47ec-b432-046db621571b
|
||
symbol: AAPL
|
||
exchange: NASDAQ
|
||
asset_class: us_equity
|
||
avg_entry_price: '100.0'
|
||
qty: '5'
|
||
qty_available: '4'
|
||
side: long
|
||
market_value: '600.0'
|
||
cost_basis: '500.0'
|
||
unrealized_pl: '100.0'
|
||
unrealized_plpc: '0.20'
|
||
unrealized_intraday_pl: '10.0'
|
||
unrealized_intraday_plpc: '0.0084'
|
||
current_price: '120.0'
|
||
lastday_price: '119.0'
|
||
change_today: '0.0084'
|
||
example-2:
|
||
asset_id: b0b6dd9d-8b9b-48a9-ba46-b9d54906e415
|
||
symbol: AAPL
|
||
exchange: NASDAQ
|
||
asset_class: us_equity
|
||
asset_marginable: false
|
||
qty: '2'
|
||
qty_available: '2'
|
||
avg_entry_price: '174.78'
|
||
side: long
|
||
market_value: '348.58'
|
||
cost_basis: '349.56'
|
||
unrealized_pl: '-0.98'
|
||
unrealized_plpc: '-0.0028035244307129'
|
||
unrealized_intraday_pl: '-0.98'
|
||
unrealized_intraday_plpc: '-0.0028035244307129'
|
||
current_price: '174.29'
|
||
lastday_price: '174.61'
|
||
change_today: '-0.0018326556325525'
|
||
title: Position
|
||
properties:
|
||
asset_id:
|
||
type: string
|
||
description: Asset ID
|
||
format: uuid
|
||
symbol:
|
||
type: string
|
||
description: Symbol name of the asset
|
||
example: AAPL
|
||
exchange:
|
||
$ref: '#/components/schemas/Exchange'
|
||
asset_class:
|
||
$ref: '#/components/schemas/AssetClass'
|
||
avg_entry_price:
|
||
type: string
|
||
minLength: 1
|
||
description: Average entry price of the position
|
||
qty:
|
||
type: string
|
||
minLength: 1
|
||
description: The number of shares
|
||
qty_available:
|
||
type: string
|
||
minLength: 1
|
||
description: Total number of shares available minus open orders
|
||
side:
|
||
type: string
|
||
minLength: 1
|
||
description: “long”
|
||
market_value:
|
||
type: string
|
||
minLength: 1
|
||
description: Total dollar amount of the position
|
||
cost_basis:
|
||
type: string
|
||
minLength: 1
|
||
description: Total cost basis in dollar
|
||
unrealized_pl:
|
||
type: string
|
||
minLength: 1
|
||
description: Unrealized profit/loss in dollars
|
||
unrealized_plpc:
|
||
type: string
|
||
minLength: 1
|
||
description: Unrealized profit/loss percent (by a factor of 1)
|
||
unrealized_intraday_pl:
|
||
type: string
|
||
minLength: 1
|
||
description: Unrealized profit/loss in dollars for the day
|
||
unrealized_intraday_plpc:
|
||
type: string
|
||
minLength: 1
|
||
description: Unrealized profit/loss percent (by a factor of 1)
|
||
current_price:
|
||
type: string
|
||
minLength: 1
|
||
description: Current asset price per share
|
||
lastday_price:
|
||
type: string
|
||
minLength: 1
|
||
description: Last day’s asset price per share based on the closing value of the last trading day
|
||
change_today:
|
||
type: string
|
||
minLength: 1
|
||
description: Percent change from last day price (by a factor of 1)
|
||
asset_marginable:
|
||
type: boolean
|
||
required:
|
||
- asset_id
|
||
- symbol
|
||
- exchange
|
||
- asset_class
|
||
- avg_entry_price
|
||
- qty
|
||
- side
|
||
- market_value
|
||
- cost_basis
|
||
- unrealized_pl
|
||
- unrealized_plpc
|
||
- unrealized_intraday_pl
|
||
- unrealized_intraday_plpc
|
||
- current_price
|
||
- lastday_price
|
||
- change_today
|
||
- asset_marginable
|
||
Watchlist:
|
||
description: |
|
||
The watchlist API provides CRUD operation for the account’s watchlist. An account can have multiple watchlists and each is uniquely identified by id but can also be addressed by user-defined name. Each watchlist is an ordered list of assets.
|
||
type: object
|
||
x-examples:
|
||
example-1:
|
||
id: 3174d6df-7726-44b4-a5bd-7fda5ae6e009
|
||
account_id: abe25343-a7ba-4255-bdeb-f7e013e9ee5d
|
||
created_at: '2022-01-31T21:49:05.14628Z'
|
||
updated_at: '2022-01-31T21:49:05.14628Z'
|
||
name: Primary Watchlist
|
||
assets:
|
||
- id: 8ccae427-5dd0-45b3-b5fe-7ba5e422c766
|
||
class: us_equity
|
||
exchange: NASDAQ
|
||
symbol: TSLA
|
||
name: 'Tesla, Inc. Common Stock'
|
||
status: active
|
||
tradable: true
|
||
marginable: true
|
||
shortable: true
|
||
easy_to_borrow: true
|
||
fractionable: true
|
||
title: Watchlist
|
||
properties:
|
||
id:
|
||
type: string
|
||
format: uuid
|
||
description: watchlist id
|
||
account_id:
|
||
type: string
|
||
format: uuid
|
||
description: account ID
|
||
created_at:
|
||
type: string
|
||
format: date-time
|
||
updated_at:
|
||
type: string
|
||
format: date-time
|
||
name:
|
||
type: string
|
||
minLength: 1
|
||
description: user-defined watchlist name (up to 64 characters)
|
||
assets:
|
||
type: array
|
||
description: 'the content of this watchlist, in the order as registered by the client'
|
||
items:
|
||
$ref: '#/components/schemas/Assets'
|
||
required:
|
||
- id
|
||
- account_id
|
||
- created_at
|
||
- updated_at
|
||
- name
|
||
Calendar:
|
||
description: ''
|
||
type: object
|
||
x-examples:
|
||
example-1:
|
||
date: '2022-02-01'
|
||
open: '09:30'
|
||
close: '16:00'
|
||
session_open: '0700'
|
||
session_close: '1900'
|
||
title: Calendar
|
||
properties:
|
||
date:
|
||
type: string
|
||
minLength: 1
|
||
description: Date string in “%Y-%m-%d” format
|
||
open:
|
||
type: string
|
||
minLength: 1
|
||
description: 'The time the market opens at on this date in “%H:%M” format'
|
||
close:
|
||
type: string
|
||
minLength: 1
|
||
description: 'The time the market closes at on this date in “%H:%M” format'
|
||
session_open:
|
||
type: string
|
||
minLength: 1
|
||
session_close:
|
||
type: string
|
||
minLength: 1
|
||
required:
|
||
- date
|
||
- open
|
||
- close
|
||
- session_open
|
||
- session_close
|
||
Clock:
|
||
title: Clock
|
||
type: object
|
||
properties:
|
||
timestamp:
|
||
type: string
|
||
description: |
|
||
Current timestamp
|
||
format: date-time
|
||
is_open:
|
||
type: boolean
|
||
description: |
|
||
Whether or not the market is open
|
||
next_open:
|
||
type: string
|
||
description: Next Market open timestamp
|
||
format: date-time
|
||
next_close:
|
||
type: string
|
||
description: Next market close timestamp
|
||
format: date-time
|
||
x-examples:
|
||
example-1:
|
||
timestamp: '2019-08-24T14:15:22Z'
|
||
is_open: true
|
||
next_open: '2019-08-24T14:15:22Z'
|
||
next_close: '2019-08-24T14:15:22Z'
|
||
PortfolioHistory:
|
||
title: PortfolioHistory
|
||
type: object
|
||
properties:
|
||
timestamp:
|
||
type: array
|
||
description: 'time of each data element, left-labeled (the beginning of time window)'
|
||
items:
|
||
type: integer
|
||
equity:
|
||
type: array
|
||
description: equity value of the account in dollar amount as of the end of each time window
|
||
items:
|
||
type: number
|
||
profit_loss:
|
||
type: array
|
||
description: profit/loss in dollar from the base value
|
||
items:
|
||
type: number
|
||
profit_loss_pct:
|
||
type: array
|
||
description: profit/loss in percentage from the base value
|
||
items:
|
||
type: number
|
||
base_value:
|
||
type: number
|
||
description: basis in dollar of the profit loss calculation
|
||
timeframe:
|
||
type: string
|
||
description: time window size of each data element
|
||
example: 15Min
|
||
Exchange:
|
||
title: Exchange
|
||
type: string
|
||
description: |-
|
||
Represents the current exchanges Alpaca supports. List is currently:
|
||
|
||
- AMEX
|
||
- ARCA
|
||
- BATS
|
||
- NYSE
|
||
- NASDAQ
|
||
- NYSEARCA
|
||
- OTC
|
||
enum:
|
||
- AMEX
|
||
- ARCA
|
||
- BATS
|
||
- NYSE
|
||
- NASDAQ
|
||
- NYSEARCA
|
||
- OTC
|
||
example: NYSE
|
||
CanceledOrderResponse:
|
||
title: CanceledOrderResponse
|
||
type: object
|
||
x-examples:
|
||
example-1:
|
||
id: d56ba3ea-6d04-48ce-8175-817e242ee608
|
||
status: 200
|
||
description: Represents the result of a request to cancel and order
|
||
properties:
|
||
id:
|
||
type: string
|
||
format: uuid
|
||
description: orderId
|
||
status:
|
||
type: integer
|
||
description: http response code
|
||
example: 200
|
||
PatchOrderRequest:
|
||
title: PatchOrderRequest
|
||
type: object
|
||
description: Represents a request to patch an order.
|
||
properties:
|
||
qty:
|
||
type: string
|
||
description: number of shares to trade
|
||
time_in_force:
|
||
$ref: '#/components/schemas/TimeInForce'
|
||
limit_price:
|
||
type: string
|
||
description: required if original order type is limit or stop_limit
|
||
stop_price:
|
||
type: string
|
||
description: required if original order type is limit or stop_limit
|
||
trail:
|
||
type: string
|
||
description: the new value of the trail_price or trail_percent value (works only for type=“trailing_stop”)
|
||
client_order_id:
|
||
type: string
|
||
description: A unique identifier for the order. Automatically generated if not sent.
|
||
maxLength: 48
|
||
PositionClosedReponse:
|
||
title: PositionClosedReponse
|
||
type: object
|
||
description: 'Represents the result of asking the api to close a position. '
|
||
properties:
|
||
symbol:
|
||
type: string
|
||
description: Symbol name of the asset
|
||
status:
|
||
type: string
|
||
description: Http status code for the attempt to close this position
|
||
body:
|
||
$ref: '#/components/schemas/Order'
|
||
required:
|
||
- symbol
|
||
- status
|
||
x-examples:
|
||
example-1:
|
||
symbol: AAPL
|
||
status: 200
|
||
body:
|
||
id: f7f25e89-939a-4587-aaf6-414a6b3c341d
|
||
client_order_id: 52f8574c-96d5-49b6-94c1-2570a268434e
|
||
created_at: '2022-02-04T16:53:29.53427917Z'
|
||
updated_at: '2022-02-04T16:53:29.53427917Z'
|
||
submitted_at: '2022-02-04T16:53:29.533738219Z'
|
||
filled_at: null
|
||
expired_at: null
|
||
canceled_at: null
|
||
failed_at: null
|
||
replaced_at: null
|
||
replaced_by: null
|
||
replaces: null
|
||
asset_id: b0b6dd9d-8b9b-48a9-ba46-b9d54906e415
|
||
symbol: AAPL
|
||
asset_class: us_equity
|
||
notional: null
|
||
qty: '2'
|
||
filled_qty: '0'
|
||
filled_avg_price: null
|
||
order_class: ''
|
||
order_type: market
|
||
type: market
|
||
side: sell
|
||
time_in_force: day
|
||
limit_price: null
|
||
stop_price: null
|
||
status: accepted
|
||
extended_hours: false
|
||
legs: null
|
||
trail_percent: null
|
||
trail_price: null
|
||
hwm: null
|
||
UpdateWatchlistRequest:
|
||
title: PostWatchlistRequest
|
||
type: object
|
||
description: Request format used for creating a new watchlist or updating an existing watchlist with a set of assets and name.
|
||
properties:
|
||
name:
|
||
type: string
|
||
symbols:
|
||
type: array
|
||
items:
|
||
type: string
|
||
nullable: true
|
||
required:
|
||
- name
|
||
AddAssetToWatchlistRequest:
|
||
title: AddAssetToWatchlistRequest
|
||
type: object
|
||
description: Append an asset for the symbol to the end of watchlist asset list
|
||
properties:
|
||
symbol:
|
||
type: string
|
||
example: AAPL
|
||
description: symbol name to append to watchlist
|
||
security:
|
||
- API_Key: []
|
||
API_Secret: []
|