## alpaca{docsify-ignore} **Kind**: global class **Extends**: Exchange * [fetchTime](#fetchtime) * [fetchMarkets](#fetchmarkets) * [fetchTrades](#fetchtrades) * [fetchOrderBook](#fetchorderbook) * [fetchOHLCV](#fetchohlcv) * [fetchTicker](#fetchticker) * [fetchTickers](#fetchtickers) * [createMarketOrderWithCost](#createmarketorderwithcost) * [createMarketBuyOrderWithCost](#createmarketbuyorderwithcost) * [createMarketSellOrderWithCost](#createmarketsellorderwithcost) * [createOrder](#createorder) * [cancelOrder](#cancelorder) * [cancelAllOrders](#cancelallorders) * [fetchOrder](#fetchorder) * [fetchOrders](#fetchorders) * [fetchOpenOrders](#fetchopenorders) * [fetchClosedOrders](#fetchclosedorders) * [editOrder](#editorder) * [fetchMyTrades](#fetchmytrades) * [fetchDepositAddress](#fetchdepositaddress) * [withdraw](#withdraw) * [fetchDepositsWithdrawals](#fetchdepositswithdrawals) * [fetchDeposits](#fetchdeposits) * [fetchWithdrawals](#fetchwithdrawals) * [fetchBalance](#fetchbalance) * [watchTicker](#watchticker) * [watchOHLCV](#watchohlcv) * [watchOrderBook](#watchorderbook) * [watchTrades](#watchtrades) * [watchMyTrades](#watchmytrades) * [watchOrders](#watchorders) ### fetchTime{docsify-ignore} fetches the current integer timestamp in milliseconds from the exchange server **Kind**: instance method of [alpaca](#alpaca) **Returns**: int - the current integer timestamp in milliseconds from the exchange server | Param | Type | Required | Description | | --- | --- | --- | --- | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.fetchTime ([params]) ``` ### fetchMarkets{docsify-ignore} retrieves data on all markets for alpaca **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<object> - an array of objects representing market data **See**: https://docs.alpaca.markets/reference/get-v2-assets | Param | Type | Required | Description | | --- | --- | --- | --- | | params | object | No | extra parameters specific to the exchange api endpoint | ```javascript alpaca.fetchMarkets ([params]) ``` ### fetchTrades{docsify-ignore} get the list of most recent trades for a particular symbol **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<Trade> - a list of [trade structures](https://docs.ccxt.com/#/?id=public-trades) **See** - https://docs.alpaca.markets/reference/cryptotrades - https://docs.alpaca.markets/reference/cryptolatesttrades | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified symbol of the market to fetch trades for | | since | int | No | timestamp in ms of the earliest trade to fetch | | limit | int | No | the maximum amount of trades to fetch | | params | object | No | extra parameters specific to the exchange API endpoint | | params.loc | string | No | crypto location, default: us | | params.method | string | No | method, default: marketPublicGetV1beta3CryptoLocTrades | ```javascript alpaca.fetchTrades (symbol[, since, limit, params]) ``` ### fetchOrderBook{docsify-ignore} fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - A dictionary of [order book structures](https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure) indexed by market symbols **See**: https://docs.alpaca.markets/reference/cryptolatestorderbooks | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified symbol of the market to fetch the order book for | | limit | int | No | the maximum amount of order book entries to return | | params | object | No | extra parameters specific to the exchange API endpoint | | params.loc | string | No | crypto location, default: us | ```javascript alpaca.fetchOrderBook (symbol[, limit, params]) ``` ### 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 [alpaca](#alpaca) **Returns**: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume **See** - https://docs.alpaca.markets/reference/cryptobars - https://docs.alpaca.markets/reference/cryptolatestbars | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified symbol of the market to fetch OHLCV data for | | timeframe | string | Yes | the length of time each candle represents | | since | int | No | timestamp in ms of the earliest candle to fetch | | limit | int | No | the maximum amount of candles to fetch | | params | object | No | extra parameters specific to the alpha api endpoint | | params.loc | string | No | crypto location, default: us | | params.method | string | No | method, default: marketPublicGetV1beta3CryptoLocBars | ```javascript alpaca.fetchOHLCV (symbol, timeframe[, since, limit, params]) ``` ### 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 [alpaca](#alpaca) **Returns**: object - a [ticker structure](https://docs.ccxt.com/#/?id=ticker-structure) **See**: https://docs.alpaca.markets/reference/cryptosnapshots-1 | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified symbol of the market to fetch the ticker for | | params | object | No | extra parameters specific to the exchange API endpoint | | params.loc | string | No | crypto location, default: us | ```javascript alpaca.fetchTicker (symbol[, params]) ``` ### fetchTickers{docsify-ignore} fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - a dictionary of [ticker structures](https://docs.ccxt.com/#/?id=ticker-structure) **See**: https://docs.alpaca.markets/reference/cryptosnapshots-1 | Param | Type | Required | Description | | --- | --- | --- | --- | | symbols | Array<string> | Yes | unified symbols of the markets to fetch tickers for | | params | object | No | extra parameters specific to the exchange API endpoint | | params.loc | string | No | crypto location, default: us | ```javascript alpaca.fetchTickers (symbols[, params]) ``` ### createMarketOrderWithCost{docsify-ignore} create a market order by providing the symbol, side and cost **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - an [order structure](https://docs.ccxt.com/#/?id=order-structure) **See**: https://docs.alpaca.markets/reference/postorder | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified symbol of the market to create an order in | | side | string | Yes | 'buy' or 'sell' | | cost | float | Yes | how much you want to trade in units of the quote currency | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.createMarketOrderWithCost (symbol, side, cost[, params]) ``` ### createMarketBuyOrderWithCost{docsify-ignore} create a market buy order by providing the symbol and cost **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - an [order structure](https://docs.ccxt.com/#/?id=order-structure) **See**: https://docs.alpaca.markets/reference/postorder | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified symbol of the market to create an order in | | cost | float | Yes | how much you want to trade in units of the quote currency | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.createMarketBuyOrderWithCost (symbol, cost[, params]) ``` ### createMarketSellOrderWithCost{docsify-ignore} create a market sell order by providing the symbol and cost **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - an [order structure](https://docs.ccxt.com/#/?id=order-structure) **See**: https://docs.alpaca.markets/reference/postorder | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified symbol of the market to create an order in | | cost | float | Yes | how much you want to trade in units of the quote currency | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.createMarketSellOrderWithCost (symbol, cost[, params]) ``` ### createOrder{docsify-ignore} create a trade order **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - an [order structure](https://docs.ccxt.com/#/?id=order-structure) **See**: https://docs.alpaca.markets/reference/postorder | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified symbol of the market to create an order in | | type | string | Yes | 'market', 'limit' or 'stop_limit' | | side | string | Yes | 'buy' or 'sell' | | amount | float | Yes | how much of currency you want to trade in units of base currency | | price | float | No | the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders | | params | object | No | extra parameters specific to the exchange API endpoint | | params.triggerPrice | float | No | The price at which a trigger order is triggered at | | params.cost | float | No | *market orders only* the cost of the order in units of the quote currency | ```javascript alpaca.createOrder (symbol, type, side, amount[, price, params]) ``` ### cancelOrder{docsify-ignore} cancels an open order **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - An [order structure](https://docs.ccxt.com/#/?id=order-structure) **See**: https://docs.alpaca.markets/reference/deleteorderbyorderid | Param | Type | Required | Description | | --- | --- | --- | --- | | id | string | Yes | order id | | symbol | string | Yes | unified symbol of the market the order was made in | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.cancelOrder (id, symbol[, params]) ``` ### cancelAllOrders{docsify-ignore} cancel all open orders in a market **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<object> - a list of [order structures](https://docs.ccxt.com/#/?id=order-structure) **See**: https://docs.alpaca.markets/reference/deleteallorders | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | alpaca cancelAllOrders cannot setting symbol, it will cancel all open orders | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.cancelAllOrders (symbol[, params]) ``` ### fetchOrder{docsify-ignore} fetches information on an order made by the user **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - An [order structure](https://docs.ccxt.com/#/?id=order-structure) **See**: https://docs.alpaca.markets/reference/getorderbyorderid | Param | Type | Required | Description | | --- | --- | --- | --- | | id | string | Yes | the order id | | symbol | string | Yes | unified symbol of the market the order was made in | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.fetchOrder (id, symbol[, params]) ``` ### fetchOrders{docsify-ignore} fetches information on multiple orders made by the user **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<Order> - a list of [order structures](https://docs.ccxt.com/#/?id=order-structure) **See**: https://docs.alpaca.markets/reference/getallorders | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified market symbol of the market orders were made in | | since | int | No | the earliest time in ms to fetch orders for | | limit | int | No | the maximum number of order structures to retrieve | | params | object | No | extra parameters specific to the exchange API endpoint | | params.until | int | No | the latest time in ms to fetch orders for | ```javascript alpaca.fetchOrders (symbol[, since, limit, params]) ``` ### fetchOpenOrders{docsify-ignore} fetch all unfilled currently open orders **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<Order> - a list of [order structures](https://docs.ccxt.com/#/?id=order-structure) **See**: https://docs.alpaca.markets/reference/getallorders | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified market symbol of the market orders were made in | | since | int | No | the earliest time in ms to fetch orders for | | limit | int | No | the maximum number of order structures to retrieve | | params | object | No | extra parameters specific to the exchange API endpoint | | params.until | int | No | the latest time in ms to fetch orders for | ```javascript alpaca.fetchOpenOrders (symbol[, since, limit, params]) ``` ### fetchClosedOrders{docsify-ignore} fetches information on multiple closed orders made by the user **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<Order> - a list of [order structures](https://docs.ccxt.com/#/?id=order-structure) **See**: https://docs.alpaca.markets/reference/getallorders | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified market symbol of the market orders were made in | | since | int | No | the earliest time in ms to fetch orders for | | limit | int | No | the maximum number of order structures to retrieve | | params | object | No | extra parameters specific to the exchange API endpoint | | params.until | int | No | the latest time in ms to fetch orders for | ```javascript alpaca.fetchClosedOrders (symbol[, since, limit, params]) ``` ### editOrder{docsify-ignore} edit a trade order **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - an [order structure](https://docs.ccxt.com/#/?id=order-structure) **See**: https://docs.alpaca.markets/reference/patchorderbyorderid-1 | Param | Type | Required | Description | | --- | --- | --- | --- | | id | string | Yes | order id | | symbol | string | No | unified symbol of the market to create an order in | | type | string | No | 'market', 'limit' or 'stop_limit' | | side | string | No | 'buy' or 'sell' | | amount | float | No | how much of the currency you want to trade in units of the base currency | | price | float | No | the price for the order, in units of the quote currency, ignored in market orders | | params | object | No | extra parameters specific to the exchange API endpoint | | params.triggerPrice | string | No | the price to trigger a stop order | | params.timeInForce | string | No | for crypto trading either 'gtc' or 'ioc' can be used | | params.clientOrderId | string | No | a unique identifier for the order, automatically generated if not sent | ```javascript alpaca.editOrder (id[, symbol, type, side, amount, price, params]) ``` ### fetchMyTrades{docsify-ignore} fetch all trades made by the user **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<Trade> - a list of [trade structures](https://docs.ccxt.com/#/?id=trade-structure) **See**: https://docs.alpaca.markets/reference/getaccountactivitiesbyactivitytype-1 | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | No | unified market symbol | | since | int | No | the earliest time in ms to fetch trades for | | limit | int | No | the maximum number of trade structures to retrieve | | params | object | No | extra parameters specific to the exchange API endpoint | | params.until | int | No | the latest time in ms to fetch trades for | | params.page_token | string | No | page_token - used for paging | ```javascript alpaca.fetchMyTrades ([symbol, since, limit, params]) ``` ### fetchDepositAddress{docsify-ignore} fetch the deposit address for a currency associated with this account **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - an [address structure](https://docs.ccxt.com/#/?id=address-structure) **See**: https://docs.alpaca.markets/reference/listcryptofundingwallets | Param | Type | Required | Description | | --- | --- | --- | --- | | code | string | Yes | unified currency code | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.fetchDepositAddress (code[, params]) ``` ### withdraw{docsify-ignore} make a withdrawal **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - a [transaction structure](https://docs.ccxt.com/#/?id=transaction-structure) **See**: https://docs.alpaca.markets/reference/createcryptotransferforaccount | Param | Type | Required | Description | | --- | --- | --- | --- | | code | string | Yes | unified currency code | | amount | float | Yes | the amount to withdraw | | address | string | Yes | the address to withdraw to | | tag | string | Yes | a memo for the transaction | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.withdraw (code, amount, address, tag[, params]) ``` ### fetchDepositsWithdrawals{docsify-ignore} fetch history of deposits and withdrawals **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - a list of [transaction structure](https://docs.ccxt.com/#/?id=transaction-structure) **See**: https://docs.alpaca.markets/reference/listcryptofundingtransfers | Param | Type | Required | Description | | --- | --- | --- | --- | | code | string | No | unified currency code for the currency of the deposit/withdrawals, default is undefined | | since | int | No | timestamp in ms of the earliest deposit/withdrawal, default is undefined | | limit | int | No | max number of deposit/withdrawals to return, default is undefined | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.fetchDepositsWithdrawals ([code, since, limit, params]) ``` ### fetchDeposits{docsify-ignore} fetch all deposits made to an account **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<object> - a list of [transaction structures](https://docs.ccxt.com/#/?id=transaction-structure) **See**: https://docs.alpaca.markets/reference/listcryptofundingtransfers | Param | Type | Required | Description | | --- | --- | --- | --- | | code | string | No | unified currency code | | since | int | No | the earliest time in ms to fetch deposits for | | limit | int | No | the maximum number of deposit structures to retrieve | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.fetchDeposits ([code, since, limit, params]) ``` ### fetchWithdrawals{docsify-ignore} fetch all withdrawals made from an account **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<object> - a list of [transaction structures](https://docs.ccxt.com/#/?id=transaction-structure) **See**: https://docs.alpaca.markets/reference/listcryptofundingtransfers | Param | Type | Required | Description | | --- | --- | --- | --- | | code | string | No | unified currency code | | since | int | No | the earliest time in ms to fetch withdrawals for | | limit | int | No | the maximum number of withdrawal structures to retrieve | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.fetchWithdrawals ([code, since, limit, params]) ``` ### fetchBalance{docsify-ignore} query for balance and get the amount of funds available for trading or funds locked in orders **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - a [balance structure](https://docs.ccxt.com/#/?id=balance-structure) **See**: https://docs.alpaca.markets/reference/getaccount-1 | Param | Type | Required | Description | | --- | --- | --- | --- | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.fetchBalance ([params]) ``` ### 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 [alpaca](#alpaca) **Returns**: object - a [ticker structure](https://docs.ccxt.com/#/?id=ticker-structure) **See**: https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#quotes | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified symbol of the market to fetch the ticker for | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.watchTicker (symbol[, params]) ``` ### 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 [alpaca](#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 | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified symbol of the market to fetch OHLCV data for | | timeframe | string | Yes | the length of time each candle represents | | since | int | No | timestamp in ms of the earliest candle to fetch | | limit | int | No | the maximum amount of candles to fetch | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.watchOHLCV (symbol, timeframe[, since, limit, params]) ``` ### watchOrderBook{docsify-ignore} watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data **Kind**: instance method of [alpaca](#alpaca) **Returns**: object - A dictionary of [order book structures](https://docs.ccxt.com/#/?id=order-book-structure) indexed by market symbols **See**: https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#orderbooks | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified symbol of the market to fetch the order book for | | limit | int | No | the maximum amount of order book entries to return. | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.watchOrderBook (symbol[, limit, params]) ``` ### watchTrades{docsify-ignore} watches information on multiple trades made in a market **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<object> - a list of [trade structures](https://docs.ccxt.com/#/?id=trade-structure) **See**: https://docs.alpaca.markets/docs/real-time-crypto-pricing-data#trades | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified market symbol of the market trades were made in | | since | int | No | the earliest time in ms to fetch orders for | | limit | int | No | the maximum number of trade structures to retrieve | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.watchTrades (symbol[, since, limit, params]) ``` ### watchMyTrades{docsify-ignore} watches information on multiple trades made by the user **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<object> - a list of [trade structures](https://docs.ccxt.com/#/?id=trade-structure) **See**: https://docs.alpaca.markets/docs/websocket-streaming#trade-updates | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified market symbol of the market trades were made in | | since | int | No | the earliest time in ms to fetch trades for | | limit | int | No | the maximum number of trade structures to retrieve | | params | object | No | extra parameters specific to the exchange API endpoint | | params.unifiedMargin | boolean | No | use unified margin account | ```javascript alpaca.watchMyTrades (symbol[, since, limit, params]) ``` ### watchOrders{docsify-ignore} watches information on multiple orders made by the user **Kind**: instance method of [alpaca](#alpaca) **Returns**: Array<object> - a list of [order structures](https://docs.ccxt.com/#/?id=order-structure) | Param | Type | Required | Description | | --- | --- | --- | --- | | symbol | string | Yes | unified market symbol of the market orders were made in | | since | int | No | the earliest time in ms to fetch orders for | | limit | int | No | the maximum number of order structures to retrieve | | params | object | No | extra parameters specific to the exchange API endpoint | ```javascript alpaca.watchOrders (symbol[, since, limit, params]) ```