Historical Data#

CryptoHistoricalDataClient#

class alpaca.data.historical.crypto.CryptoHistoricalDataClient(api_key: Optional[str] = None, secret_key: Optional[str] = None, oauth_token: Optional[str] = None, raw_data: bool = False, url_override: Optional[str] = None)#

A REST client for retrieving crypto market data.

This client does not need any authentication to use. You can instantiate it with or without API keys.

However, authenticating increases your data rate limit.

Learn more about crypto historical data here: https://alpaca.markets/docs/api-references/market-data-api/crypto-pricing-data/historical/

__init__(api_key: Optional[str] = None, secret_key: Optional[str] = None, oauth_token: Optional[str] = None, raw_data: bool = False, url_override: Optional[str] = None) None#

Instantiates a Historical Data Client for Crypto Data.

Parameters:
  • api_key (Optional[str], optional) – Alpaca API key. Defaults to None.

  • secret_key (Optional[str], optional) – Alpaca API secret key. Defaults to None.

  • oauth_token (Optional[str]) – The oauth token if authenticating via OAuth. Defaults to None.

  • raw_data (bool, optional) – If true, API responses will not be wrapped and raw responses will be returned from methods. Defaults to False. This has not been implemented yet.

  • url_override (Optional[str], optional) – If specified allows you to override the base url the client points to for proxy/testing.

Get Crypto Bars#

CryptoHistoricalDataClient.get_crypto_bars(request_params: CryptoBarsRequest, feed: CryptoFeed = CryptoFeed.US) Union[BarSet, Dict[str, Any]]#

Gets bar/candle data for a cryptocurrency or list of cryptocurrencies.

Parameters:
Returns:

The crypto bar data either in raw or wrapped form

Return type:

Union[BarSet, RawData]

Get Crypto Trades#

CryptoHistoricalDataClient.get_crypto_trades(request_params: CryptoTradesRequest, feed: CryptoFeed = CryptoFeed.US) Union[TradeSet, Dict[str, Any]]#

Returns the price and sales history over a given time period for a cryptocurrency or list of cryptocurrencies.

Parameters:
Returns:

The trade data either in raw or wrapped form

Return type:

Union[TradeSet, RawData]

Get Crypto Latest Quote#

CryptoHistoricalDataClient.get_crypto_latest_quote(request_params: CryptoLatestQuoteRequest, feed: CryptoFeed = CryptoFeed.US) Union[Dict[str, Quote], Dict[str, Any]]#

Returns the latest quote for a coin.

Parameters:
Returns:

The latest quote in raw or wrapped format

Return type:

Union[Dict[str, Quote], RawData]

Get Crypto Latest Trade#

CryptoHistoricalDataClient.get_crypto_latest_trade(request_params: CryptoLatestTradeRequest, feed: CryptoFeed = CryptoFeed.US) Union[Dict[str, Trade], Dict[str, Any]]#

Returns the latest trade for a coin.

Parameters:
Returns:

The latest trade in raw or wrapped format

Return type:

Union[Dict[str, Trade], RawData]

Get Crypto Latest Bar#

CryptoHistoricalDataClient.get_crypto_latest_bar(request_params: CryptoLatestBarRequest, feed: CryptoFeed = CryptoFeed.US) Union[Dict[str, Bar], Dict[str, Any]]#

Returns the latest minute bar for a coin.

Parameters:
  • request_params (CryptoLatestBarRequest) – The parameters for the request.

  • feed (CryptoFeed) – The data feed for the latest crypto bar.

Returns:

The latest bar in raw or wrapped format

Return type:

Union[Dict[str, Bar], RawData]

Get Crypto Snapshot#

CryptoHistoricalDataClient.get_crypto_snapshot(request_params: CryptoSnapshotRequest, feed: CryptoFeed = CryptoFeed.US) Union[Snapshot, Dict[str, Any]]#

Returns snapshots of queried crypto symbols. Snapshots contain latest trade, latest quote, latest minute bar, latest daily bar and previous daily bar data for the queried symbols.

Parameters:
Returns:

The snapshot data either in raw or wrapped form

Return type:

Union[SnapshotSet, RawData]

Get Crypto Latest Orderbook#

CryptoHistoricalDataClient.get_crypto_latest_orderbook(request_params: CryptoLatestOrderbookRequest, feed: CryptoFeed = CryptoFeed.US) Union[Dict[str, Orderbook], Dict[str, Any]]#

Returns the latest orderbook state for the queried crypto symbols.

Parameters:
  • request_params (CryptoOrderbookRequest) – The parameters for the orderbook request.

  • feed (CryptoFeed) – The data feed for the latest crypto orderbook.

Returns:

The orderbook data either in raw or wrapped form.

Return type:

Union[Dict[str, Orderbook], RawData]