Back to Ccxt

Alpaca

wiki/exchanges/alpaca.md

4.5.5228.3 KB
Original Source

<a name="alpaca" id="alpaca"></a>

alpaca{docsify-ignore}

Kind: global class
Extends: <code>Exchange</code>

<a name="fetchTime" id="fetchtime"></a>

fetchTime{docsify-ignore}

fetches the current integer timestamp in milliseconds from the exchange server

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

ParamTypeRequiredDescription
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.fetchTime ([params])

<a name="fetchMarkets" id="fetchmarkets"></a>

fetchMarkets{docsify-ignore}

retrieves data on all markets for alpaca

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

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

ParamTypeRequiredDescription
params<code>object</code>Noextra parameters specific to the exchange api endpoint
javascript
alpaca.fetchMarkets ([params])

<a name="fetchTrades" id="fetchtrades"></a>

fetchTrades{docsify-ignore}

get the list of most recent trades for a particular symbol

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

See

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified symbol of the market to fetch trades for
since<code>int</code>Notimestamp in ms of the earliest trade to fetch
limit<code>int</code>Nothe maximum amount of trades to fetch
params<code>object</code>Noextra parameters specific to the exchange API endpoint
params.loc<code>string</code>Nocrypto location, default: us
params.method<code>string</code>Nomethod, default: marketPublicGetV1beta3CryptoLocTrades
javascript
alpaca.fetchTrades (symbol[, since, limit, params])

<a name="fetchOrderBook" id="fetchorderbook"></a>

fetchOrderBook{docsify-ignore}

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

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

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified symbol of the market to fetch the order book for
limit<code>int</code>Nothe maximum amount of order book entries to return
params<code>object</code>Noextra parameters specific to the exchange API endpoint
params.loc<code>string</code>Nocrypto location, default: us
javascript
alpaca.fetchOrderBook (symbol[, limit, params])

<a name="fetchOHLCV" id="fetchohlcv"></a>

fetchOHLCV{docsify-ignore}

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

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

See

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified symbol of the market to fetch OHLCV data for
timeframe<code>string</code>Yesthe length of time each candle represents
since<code>int</code>Notimestamp in ms of the earliest candle to fetch
limit<code>int</code>Nothe maximum amount of candles to fetch
params<code>object</code>Noextra parameters specific to the alpha api endpoint
params.loc<code>string</code>Nocrypto location, default: us
params.method<code>string</code>Nomethod, default: marketPublicGetV1beta3CryptoLocBars
javascript
alpaca.fetchOHLCV (symbol, timeframe[, since, limit, params])

<a name="fetchTicker" id="fetchticker"></a>

fetchTicker{docsify-ignore}

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

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - a ticker structure

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified symbol of the market to fetch the ticker for
params<code>object</code>Noextra parameters specific to the exchange API endpoint
params.loc<code>string</code>Nocrypto location, default: us
javascript
alpaca.fetchTicker (symbol[, params])

<a name="fetchTickers" id="fetchtickers"></a>

fetchTickers{docsify-ignore}

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

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - a dictionary of ticker structures

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

ParamTypeRequiredDescription
symbols<code>Array<string></code>Yesunified symbols of the markets to fetch tickers for
params<code>object</code>Noextra parameters specific to the exchange API endpoint
params.loc<code>string</code>Nocrypto location, default: us
javascript
alpaca.fetchTickers (symbols[, params])

<a name="createMarketOrderWithCost" id="createmarketorderwithcost"></a>

createMarketOrderWithCost{docsify-ignore}

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

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - an order structure

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified symbol of the market to create an order in
side<code>string</code>Yes'buy' or 'sell'
cost<code>float</code>Yeshow much you want to trade in units of the quote currency
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.createMarketOrderWithCost (symbol, side, cost[, params])

<a name="createMarketBuyOrderWithCost" id="createmarketbuyorderwithcost"></a>

createMarketBuyOrderWithCost{docsify-ignore}

create a market buy order by providing the symbol and cost

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - an order structure

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified symbol of the market to create an order in
cost<code>float</code>Yeshow much you want to trade in units of the quote currency
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.createMarketBuyOrderWithCost (symbol, cost[, params])

<a name="createMarketSellOrderWithCost" id="createmarketsellorderwithcost"></a>

createMarketSellOrderWithCost{docsify-ignore}

create a market sell order by providing the symbol and cost

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - an order structure

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified symbol of the market to create an order in
cost<code>float</code>Yeshow much you want to trade in units of the quote currency
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.createMarketSellOrderWithCost (symbol, cost[, params])

<a name="createOrder" id="createorder"></a>

createOrder{docsify-ignore}

create a trade order

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - an order structure

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified symbol of the market to create an order in
type<code>string</code>Yes'market', 'limit' or 'stop_limit'
side<code>string</code>Yes'buy' or 'sell'
amount<code>float</code>Yeshow much of currency you want to trade in units of base currency
price<code>float</code>Nothe price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
params<code>object</code>Noextra parameters specific to the exchange API endpoint
params.triggerPrice<code>float</code>NoThe price at which a trigger order is triggered at
params.cost<code>float</code>Nomarket orders only the cost of the order in units of the quote currency
javascript
alpaca.createOrder (symbol, type, side, amount[, price, params])

<a name="cancelOrder" id="cancelorder"></a>

cancelOrder{docsify-ignore}

cancels an open order

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - An order structure

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

ParamTypeRequiredDescription
id<code>string</code>Yesorder id
symbol<code>string</code>Yesunified symbol of the market the order was made in
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.cancelOrder (id, symbol[, params])

<a name="cancelAllOrders" id="cancelallorders"></a>

cancelAllOrders{docsify-ignore}

cancel all open orders in a market

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

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesalpaca cancelAllOrders cannot setting symbol, it will cancel all open orders
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.cancelAllOrders (symbol[, params])

<a name="fetchOrder" id="fetchorder"></a>

fetchOrder{docsify-ignore}

fetches information on an order made by the user

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - An order structure

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

ParamTypeRequiredDescription
id<code>string</code>Yesthe order id
symbol<code>string</code>Yesunified symbol of the market the order was made in
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.fetchOrder (id, symbol[, params])

<a name="fetchOrders" id="fetchorders"></a>

fetchOrders{docsify-ignore}

fetches information on multiple orders made by the user

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

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified market symbol of the market orders were made in
since<code>int</code>Nothe earliest time in ms to fetch orders for
limit<code>int</code>Nothe maximum number of order structures to retrieve
params<code>object</code>Noextra parameters specific to the exchange API endpoint
params.until<code>int</code>Nothe latest time in ms to fetch orders for
javascript
alpaca.fetchOrders (symbol[, since, limit, params])

<a name="fetchOpenOrders" id="fetchopenorders"></a>

fetchOpenOrders{docsify-ignore}

fetch all unfilled currently open orders

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

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified market symbol of the market orders were made in
since<code>int</code>Nothe earliest time in ms to fetch orders for
limit<code>int</code>Nothe maximum number of order structures to retrieve
params<code>object</code>Noextra parameters specific to the exchange API endpoint
params.until<code>int</code>Nothe latest time in ms to fetch orders for
javascript
alpaca.fetchOpenOrders (symbol[, since, limit, params])

<a name="fetchClosedOrders" id="fetchclosedorders"></a>

fetchClosedOrders{docsify-ignore}

fetches information on multiple closed orders made by the user

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

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified market symbol of the market orders were made in
since<code>int</code>Nothe earliest time in ms to fetch orders for
limit<code>int</code>Nothe maximum number of order structures to retrieve
params<code>object</code>Noextra parameters specific to the exchange API endpoint
params.until<code>int</code>Nothe latest time in ms to fetch orders for
javascript
alpaca.fetchClosedOrders (symbol[, since, limit, params])

<a name="editOrder" id="editorder"></a>

editOrder{docsify-ignore}

edit a trade order

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - an order structure

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

ParamTypeRequiredDescription
id<code>string</code>Yesorder id
symbol<code>string</code>Nounified symbol of the market to create an order in
type<code>string</code>No'market', 'limit' or 'stop_limit'
side<code>string</code>No'buy' or 'sell'
amount<code>float</code>Nohow much of the currency you want to trade in units of the base currency
price<code>float</code>Nothe price for the order, in units of the quote currency, ignored in market orders
params<code>object</code>Noextra parameters specific to the exchange API endpoint
params.triggerPrice<code>string</code>Nothe price to trigger a stop order
params.timeInForce<code>string</code>Nofor crypto trading either 'gtc' or 'ioc' can be used
params.clientOrderId<code>string</code>Noa unique identifier for the order, automatically generated if not sent
javascript
alpaca.editOrder (id[, symbol, type, side, amount, price, params])

<a name="fetchMyTrades" id="fetchmytrades"></a>

fetchMyTrades{docsify-ignore}

fetch all trades made by the user

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

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

ParamTypeRequiredDescription
symbol<code>string</code>Nounified market symbol
since<code>int</code>Nothe earliest time in ms to fetch trades for
limit<code>int</code>Nothe maximum number of trade structures to retrieve
params<code>object</code>Noextra parameters specific to the exchange API endpoint
params.until<code>int</code>Nothe latest time in ms to fetch trades for
params.page_token<code>string</code>Nopage_token - used for paging
javascript
alpaca.fetchMyTrades ([symbol, since, limit, params])

<a name="fetchDepositAddress" id="fetchdepositaddress"></a>

fetchDepositAddress{docsify-ignore}

fetch the deposit address for a currency associated with this account

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - an address structure

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

ParamTypeRequiredDescription
code<code>string</code>Yesunified currency code
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.fetchDepositAddress (code[, params])

<a name="withdraw" id="withdraw"></a>

withdraw{docsify-ignore}

make a withdrawal

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - a transaction structure

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

ParamTypeRequiredDescription
code<code>string</code>Yesunified currency code
amount<code>float</code>Yesthe amount to withdraw
address<code>string</code>Yesthe address to withdraw to
tag<code>string</code>Yesa memo for the transaction
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.withdraw (code, amount, address, tag[, params])

<a name="fetchDepositsWithdrawals" id="fetchdepositswithdrawals"></a>

fetchDepositsWithdrawals{docsify-ignore}

fetch history of deposits and withdrawals

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - a list of transaction structure

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

ParamTypeRequiredDescription
code<code>string</code>Nounified currency code for the currency of the deposit/withdrawals, default is undefined
since<code>int</code>Notimestamp in ms of the earliest deposit/withdrawal, default is undefined
limit<code>int</code>Nomax number of deposit/withdrawals to return, default is undefined
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.fetchDepositsWithdrawals ([code, since, limit, params])

<a name="fetchDeposits" id="fetchdeposits"></a>

fetchDeposits{docsify-ignore}

fetch all deposits made to an account

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

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

ParamTypeRequiredDescription
code<code>string</code>Nounified currency code
since<code>int</code>Nothe earliest time in ms to fetch deposits for
limit<code>int</code>Nothe maximum number of deposit structures to retrieve
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.fetchDeposits ([code, since, limit, params])

<a name="fetchWithdrawals" id="fetchwithdrawals"></a>

fetchWithdrawals{docsify-ignore}

fetch all withdrawals made from an account

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

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

ParamTypeRequiredDescription
code<code>string</code>Nounified currency code
since<code>int</code>Nothe earliest time in ms to fetch withdrawals for
limit<code>int</code>Nothe maximum number of withdrawal structures to retrieve
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.fetchWithdrawals ([code, since, limit, params])

<a name="fetchBalance" id="fetchbalance"></a>

fetchBalance{docsify-ignore}

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

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - a balance structure

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

ParamTypeRequiredDescription
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.fetchBalance ([params])

<a name="watchTicker" id="watchticker"></a>

watchTicker{docsify-ignore}

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

Kind: instance method of <code>alpaca</code>
Returns: <code>object</code> - a ticker structure

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified symbol of the market to fetch the ticker for
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.watchTicker (symbol[, params])

<a name="watchOHLCV" id="watchohlcv"></a>

watchOHLCV{docsify-ignore}

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

Kind: instance method of <code>alpaca</code>
Returns: <code>Array<Array<int>></code> - 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
symbol<code>string</code>Yesunified symbol of the market to fetch OHLCV data for
timeframe<code>string</code>Yesthe length of time each candle represents
since<code>int</code>Notimestamp in ms of the earliest candle to fetch
limit<code>int</code>Nothe maximum amount of candles to fetch
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.watchOHLCV (symbol, timeframe[, since, limit, params])

<a name="watchOrderBook" id="watchorderbook"></a>

watchOrderBook{docsify-ignore}

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

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

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified symbol of the market to fetch the order book for
limit<code>int</code>Nothe maximum amount of order book entries to return.
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.watchOrderBook (symbol[, limit, params])

<a name="watchTrades" id="watchtrades"></a>

watchTrades{docsify-ignore}

watches information on multiple trades made in a market

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

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified market symbol of the market trades were made in
since<code>int</code>Nothe earliest time in ms to fetch orders for
limit<code>int</code>Nothe maximum number of trade structures to retrieve
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.watchTrades (symbol[, since, limit, params])

<a name="watchMyTrades" id="watchmytrades"></a>

watchMyTrades{docsify-ignore}

watches information on multiple trades made by the user

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

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified market symbol of the market trades were made in
since<code>int</code>Nothe earliest time in ms to fetch trades for
limit<code>int</code>Nothe maximum number of trade structures to retrieve
params<code>object</code>Noextra parameters specific to the exchange API endpoint
params.unifiedMargin<code>boolean</code>Nouse unified margin account
javascript
alpaca.watchMyTrades (symbol[, since, limit, params])

<a name="watchOrders" id="watchorders"></a>

watchOrders{docsify-ignore}

watches information on multiple orders made by the user

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

ParamTypeRequiredDescription
symbol<code>string</code>Yesunified market symbol of the market orders were made in
since<code>int</code>Nothe earliest time in ms to fetch orders for
limit<code>int</code>Nothe maximum number of order structures to retrieve
params<code>object</code>Noextra parameters specific to the exchange API endpoint
javascript
alpaca.watchOrders (symbol[, since, limit, params])