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) Union[BarSet, Dict[str, Any]]#

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

Parameters

request_params (CryptoBarsRequest) – The parameters for the request.

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: CryptoQuotesRequest) Union[QuoteSet, Dict[str, Any]]#

Returns Quote level 1 data over a given time period for a cryptocurrency or list of cryptocurrencies.

Parameters

request_params (CryptoQuotesRequest) – The parameters for the request.

Returns

The quote data either in raw or wrapped form

Return type

Union[QuoteSet, RawData]

Get Crypto Trades#

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

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

Parameters

request_params (CryptoTradesRequest) – The parameters for the request.

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) Union[Dict[str, Quote], Dict[str, Any]]#

Returns the latest quote for a coin.

Parameters

request_params (CryptoLatestQuoteRequest) – The parameters for the request.

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) Union[Dict[str, Trade], Dict[str, Any]]#

Returns the latest trade for a coin.

Parameters

request_params (CryptoLatestTradeRequest) – The parameters for the request.

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) Union[Dict[str, Bar], Dict[str, Any]]#

Returns the latest minute bar for a coin.

Parameters

request_params (CryptoLatestBarRequest) – The parameters for the request.

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) 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

request_params (CryptoSnapshotRequest) – The parameters for the snapshot request.

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) 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.

Returns

The orderbook data either in raw or wrapped form.

Return type

Union[Dict[str, Orderbook], RawData]