CCXT

alpaca

alpaca cryptocurrency exchange — CCXT unified API: methods, parameters and endpoints.

alpaca

Kind: global class
Extends: Exchange

fetchTime

fetches the current integer timestamp in milliseconds from the exchange server

Kind: instance method of alpaca
Returns: int - the current integer timestamp in milliseconds from the exchange server

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.fetchTime (params?)

fetchMarkets

retrieves data on all markets for alpaca

Kind: instance method of alpaca
Returns: Array<object> - an array of objects representing market data

See: https://docs.alpaca.markets/reference/get-v2-assets

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange api endpoint
alpaca.fetchMarkets (params?)

fetchTrades

get the list of most recent trades for a particular symbol

Kind: instance method of alpaca
Returns: Array<Trade> - a list of trade structures

See

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch trades for
sinceintNotimestamp in ms of the earliest trade to fetch
limitintNothe maximum amount of trades to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
params.locstringNocrypto location, default: us
params.methodstringNomethod, default: marketPublicGetV1beta3CryptoLocTrades
alpaca.fetchTrades (symbol, since?, limit?, params?)

fetchOrderBook

fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data

Kind: instance method of alpaca
Returns: object - A dictionary of order book structures indexed by market symbols

See: https://docs.alpaca.markets/reference/cryptolatestorderbooks

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the order book for
limitintNothe maximum amount of order book entries to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.locstringNocrypto location, default: us
alpaca.fetchOrderBook (symbol, limit?, params?)

fetchOHLCV

fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

Kind: instance method of alpaca
Returns: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume

See

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch OHLCV data for
timeframestringYesthe length of time each candle represents
sinceintNotimestamp in ms of the earliest candle to fetch
limitintNothe maximum amount of candles to fetch
paramsobjectNoextra parameters specific to the alpha api endpoint
params.locstringNocrypto location, default: us
params.methodstringNomethod, default: marketPublicGetV1beta3CryptoLocBars
alpaca.fetchOHLCV (symbol, timeframe, since?, limit?, params?)

fetchTicker

fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

Kind: instance method of alpaca
Returns: object - a ticker structure

See: https://docs.alpaca.markets/reference/cryptosnapshots-1

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.locstringNocrypto location, default: us
alpaca.fetchTicker (symbol, params?)

fetchTickers

fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

Kind: instance method of alpaca
Returns: object - a dictionary of ticker structures

See: https://docs.alpaca.markets/reference/cryptosnapshots-1

ParamTypeRequiredDescription
symbolsArray<string>Yesunified symbols of the markets to fetch tickers for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.locstringNocrypto location, default: us
alpaca.fetchTickers (symbols, params?)

createMarketOrderWithCost

create a market order by providing the symbol, side and cost

Kind: instance method of alpaca
Returns: object - an order structure

See: https://docs.alpaca.markets/reference/postorder

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to create an order in
sidestringYes'buy' or 'sell'
costfloatYeshow much you want to trade in units of the quote currency
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.createMarketOrderWithCost (symbol, side, cost, params?)

createMarketBuyOrderWithCost

create a market buy order by providing the symbol and cost

Kind: instance method of alpaca
Returns: object - an order structure

See: https://docs.alpaca.markets/reference/postorder

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to create an order in
costfloatYeshow much you want to trade in units of the quote currency
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.createMarketBuyOrderWithCost (symbol, cost, params?)

createMarketSellOrderWithCost

create a market sell order by providing the symbol and cost

Kind: instance method of alpaca
Returns: object - an order structure

See: https://docs.alpaca.markets/reference/postorder

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to create an order in
costfloatYeshow much you want to trade in units of the quote currency
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.createMarketSellOrderWithCost (symbol, cost, params?)

createOrder

create a trade order

Kind: instance method of alpaca
Returns: object - an order structure

See: https://docs.alpaca.markets/reference/postorder

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to create an order in
typestringYes'market', 'limit' or 'stop_limit'
sidestringYes'buy' or 'sell'
amountfloatYeshow much of currency you want to trade in units of base currency
pricefloatNothe price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
paramsobjectNoextra parameters specific to the exchange API endpoint
params.triggerPricefloatNoThe price at which a trigger order is triggered at
params.costfloatNomarket orders only the cost of the order in units of the quote currency
alpaca.createOrder (symbol, type, side, amount, price?, params?)

cancelOrder

cancels an open order

Kind: instance method of alpaca
Returns: object - An order structure

See: https://docs.alpaca.markets/reference/deleteorderbyorderid

ParamTypeRequiredDescription
idstringYesorder id
symbolstringYesunified symbol of the market the order was made in
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.cancelOrder (id, symbol, params?)

cancelAllOrders

cancel all open orders in a market

Kind: instance method of alpaca
Returns: Array<object> - a list of order structures

See: https://docs.alpaca.markets/reference/deleteallorders

ParamTypeRequiredDescription
symbolstringYesalpaca cancelAllOrders cannot setting symbol, it will cancel all open orders
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.cancelAllOrders (symbol, params?)

fetchOrder

fetches information on an order made by the user

Kind: instance method of alpaca
Returns: object - An order structure

See: https://docs.alpaca.markets/reference/getorderbyorderid

ParamTypeRequiredDescription
idstringYesthe order id
symbolstringYesunified symbol of the market the order was made in
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.fetchOrder (id, symbol, params?)

fetchOrders

fetches information on multiple orders made by the user

Kind: instance method of alpaca
Returns: Array<Order> - a list of order structures

See: https://docs.alpaca.markets/reference/getallorders

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market orders were made in
sinceintNothe earliest time in ms to fetch orders for
limitintNothe maximum number of order structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNothe latest time in ms to fetch orders for
alpaca.fetchOrders (symbol, since?, limit?, params?)

fetchOpenOrders

fetch all unfilled currently open orders

Kind: instance method of alpaca
Returns: Array<Order> - a list of order structures

See: https://docs.alpaca.markets/reference/getallorders

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market orders were made in
sinceintNothe earliest time in ms to fetch orders for
limitintNothe maximum number of order structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNothe latest time in ms to fetch orders for
alpaca.fetchOpenOrders (symbol, since?, limit?, params?)

fetchClosedOrders

fetches information on multiple closed orders made by the user

Kind: instance method of alpaca
Returns: Array<Order> - a list of order structures

See: https://docs.alpaca.markets/reference/getallorders

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market orders were made in
sinceintNothe earliest time in ms to fetch orders for
limitintNothe maximum number of order structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNothe latest time in ms to fetch orders for
alpaca.fetchClosedOrders (symbol, since?, limit?, params?)

editOrder

edit a trade order

Kind: instance method of alpaca
Returns: object - an order structure

See: https://docs.alpaca.markets/reference/patchorderbyorderid-1

ParamTypeRequiredDescription
idstringYesorder id
symbolstringNounified symbol of the market to create an order in
typestringNo'market', 'limit' or 'stop_limit'
sidestringNo'buy' or 'sell'
amountfloatNohow much of the currency you want to trade in units of the base currency
pricefloatNothe price for the order, in units of the quote currency, ignored in market orders
paramsobjectNoextra parameters specific to the exchange API endpoint
params.triggerPricestringNothe price to trigger a stop order
params.timeInForcestringNofor crypto trading either 'gtc' or 'ioc' can be used
params.clientOrderIdstringNoa unique identifier for the order, automatically generated if not sent
alpaca.editOrder (id, symbol?, type?, side?, amount?, price?, params?)

fetchMyTrades

fetch all trades made by the user

Kind: instance method of alpaca
Returns: Array<Trade> - a list of trade structures

See: https://docs.alpaca.markets/reference/getaccountactivitiesbyactivitytype-1

ParamTypeRequiredDescription
symbolstringNounified market symbol
sinceintNothe earliest time in ms to fetch trades for
limitintNothe maximum number of trade structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNothe latest time in ms to fetch trades for
params.page_tokenstringNopage_token - used for paging
alpaca.fetchMyTrades (symbol?, since?, limit?, params?)

fetchDepositAddress

fetch the deposit address for a currency associated with this account

Kind: instance method of alpaca
Returns: object - an address structure

See: https://docs.alpaca.markets/reference/listcryptofundingwallets

ParamTypeRequiredDescription
codestringYesunified currency code
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.fetchDepositAddress (code, params?)

withdraw

make a withdrawal

Kind: instance method of alpaca
Returns: object - a transaction structure

See: https://docs.alpaca.markets/reference/createcryptotransferforaccount

ParamTypeRequiredDescription
codestringYesunified currency code
amountfloatYesthe amount to withdraw
addressstringYesthe address to withdraw to
tagstringYesa memo for the transaction
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.withdraw (code, amount, address, tag, params?)

fetchDepositsWithdrawals

fetch history of deposits and withdrawals

Kind: instance method of alpaca
Returns: object - a list of transaction structure

See: https://docs.alpaca.markets/reference/listcryptofundingtransfers

ParamTypeRequiredDescription
codestringNounified currency code for the currency of the deposit/withdrawals, default is undefined
sinceintNotimestamp in ms of the earliest deposit/withdrawal, default is undefined
limitintNomax number of deposit/withdrawals to return, default is undefined
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.fetchDepositsWithdrawals (code?, since?, limit?, params?)

fetchDeposits

fetch all deposits made to an account

Kind: instance method of alpaca
Returns: Array<object> - a list of transaction structures

See: https://docs.alpaca.markets/reference/listcryptofundingtransfers

ParamTypeRequiredDescription
codestringNounified currency code
sinceintNothe earliest time in ms to fetch deposits for
limitintNothe maximum number of deposit structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.fetchDeposits (code?, since?, limit?, params?)

fetchWithdrawals

fetch all withdrawals made from an account

Kind: instance method of alpaca
Returns: Array<object> - a list of transaction structures

See: https://docs.alpaca.markets/reference/listcryptofundingtransfers

ParamTypeRequiredDescription
codestringNounified currency code
sinceintNothe earliest time in ms to fetch withdrawals for
limitintNothe maximum number of withdrawal structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.fetchWithdrawals (code?, since?, limit?, params?)

fetchBalance

query for balance and get the amount of funds available for trading or funds locked in orders

Kind: instance method of alpaca
Returns: object - a balance structure

See: https://docs.alpaca.markets/reference/getaccount-1

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.fetchBalance (params?)

watchTicker

watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

Kind: instance method of alpaca
Returns: object - a ticker structure

See: https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#quotes

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.watchTicker (symbol, params?)

watchOHLCV

watches historical candlestick data containing the open, high, low, and close price, and the volume of a market

Kind: instance method of alpaca
Returns: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume

See: https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#bars

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch OHLCV data for
timeframestringYesthe length of time each candle represents
sinceintNotimestamp in ms of the earliest candle to fetch
limitintNothe maximum amount of candles to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.watchOHLCV (symbol, timeframe, since?, limit?, params?)

watchOrderBook

watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data

Kind: instance method of alpaca
Returns: object - A dictionary of order book structures indexed by market symbols

See: https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#orderbooks

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the order book for
limitintNothe maximum amount of order book entries to return.
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.watchOrderBook (symbol, limit?, params?)

watchTrades

watches information on multiple trades made in a market

Kind: instance method of alpaca
Returns: Array<object> - a list of trade structures

See: https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#trades

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market trades were made in
sinceintNothe earliest time in ms to fetch orders for
limitintNothe maximum number of trade structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.watchTrades (symbol, since?, limit?, params?)

watchMyTrades

watches information on multiple trades made by the user

Kind: instance method of alpaca
Returns: Array<object> - a list of trade structures

See: https://docs.alpaca.markets/docs/websocket-streaming#trade-updates

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market trades were made in
sinceintNothe earliest time in ms to fetch trades for
limitintNothe maximum number of trade structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.unifiedMarginbooleanNouse unified margin account
alpaca.watchMyTrades (symbol, since?, limit?, params?)

watchOrders

watches information on multiple orders made by the user

Kind: instance method of alpaca
Returns: Array<object> - a list of order structures

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market orders were made in
sinceintNothe earliest time in ms to fetch orders for
limitintNothe maximum number of order structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
alpaca.watchOrders (symbol, since?, limit?, params?)

On this page