## alpaca{docsify-ignore}
**Kind**: global class
**Extends**: Exchange
* [fetchTime](#fetchtime)
* [fetchMarkets](#fetchmarkets)
* [fetchTrades](#fetchtrades)
* [fetchOrderBook](#fetchorderbook)
* [fetchOHLCV](#fetchohlcv)
* [createOrder](#createorder)
* [cancelOrder](#cancelorder)
* [cancelAllOrders](#cancelallorders)
* [fetchOrder](#fetchorder)
* [fetchOrders](#fetchorders)
* [fetchOpenOrders](#fetchopenorders)
* [fetchClosedOrders](#fetchclosedorders)
* [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])
```
### 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 |
```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])
```
### 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])
```