Historical Data

CryptoHistoricalDataClient

class alpaca.data.historical.crypto.CryptoHistoricalDataClient(api_key: str | None = None, secret_key: str | None = None, oauth_token: str | None = None, raw_data: bool = False, url_override: str | None = None, use_basic_auth: bool = False, sandbox: bool = False)

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: str | None = None, secret_key: str | None = None, oauth_token: str | None = None, raw_data: bool = False, url_override: str | None = None, use_basic_auth: bool = False, sandbox: bool = False) → 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.

  • use_basic_auth (bool, optional) – If true, API requests will use basic authorization headers. Set to true if using broker api sandbox credentials

  • sandbox (bool) – True if using sandbox mode. Defaults to False.

Get Crypto Bars

CryptoHistoricalDataClient.get_crypto_bars(request_params: CryptoBarsRequest, feed: CryptoFeed = CryptoFeed.US) → 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 Quotes

CryptoHistoricalDataClient.get_crypto_quotes(request_params: CryptoQuoteRequest, feed: CryptoFeed = CryptoFeed.US) → QuoteSet | Dict[str, Any]

Returns the quote data for a cryptocurrency or list of cryptocurrencies.

Parameters:
Returns:

The crypto quote data either in raw or wrapped form

Return type:

Union[QuoteSet, RawData]

Get Crypto Trades

CryptoHistoricalDataClient.get_crypto_trades(request_params: CryptoTradesRequest, feed: CryptoFeed = CryptoFeed.US) → 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) → 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) → 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) → 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) → 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) → 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]