Get OHLCV icon

Get OHLCV

Fetch OHLCV (Open, High, Low, Close, Volume) data from cryptocurrency exchanges

Overview

This node fetches OHLCV (Open, High, Low, Close, Volume) candlestick data from various cryptocurrency exchanges. It supports both spot and futures markets and allows users to specify trading pairs, timeframes, and other parameters to retrieve historical market data.

Common scenarios where this node is beneficial include:

  • Analyzing historical price movements for algorithmic trading strategies.
  • Visualizing market trends over different time intervals.
  • Backtesting trading models using real exchange data.
  • Integrating live or historical market data into automated workflows.

For example, a user can configure the node to fetch 1-hour candlestick data for BTC/USDT from Binance's spot market, limiting results to the last 50 candles, which can then be used for further analysis or decision-making in an n8n workflow.

Properties

Name Meaning
Exchange Select the cryptocurrency exchange to fetch data from. Options: Binance, Bybit, Gate.io, Kraken, KuCoin, MEXC, OKX
Mode Choose between Spot trading or Futures trading data.
Symbol Trading pair symbol, e.g., BTC/USDT or ETH/USDT.
Timeframe Interval of each candlestick. Options include: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M
Limit Maximum number of OHLCV records to return (between 1 and 1000).
Since Timestamp (in milliseconds) to start fetching OHLCV data from. Optional.
Options Additional optional settings:
- API Key API key credential for authenticated access (optional for public data).
- Secret Secret key credential for authenticated access (optional).
- Password Password for the exchange account (optional).
- Sandbox Boolean flag to use sandbox/testnet environment instead of live exchange.
- Include Timestamp Whether to include the timestamp in the output data (default true).

Output

The node outputs an array of JSON objects, each containing the following structure:

{
  "exchange": "binance",
  "mode": "spot",
  "symbol": "BTC/USDT",
  "timeframe": "1h",
  "limit": 50,
  "count": 50,
  "data": [
    [high, low, close, volume, timestamp] // or [high, low, close, volume] if timestamps excluded
  ],
  "metadata": {
    "exchangeId": "binance",
    "exchangeName": "Binance",
    "fetchTimestamp": "2024-06-xxTxx:xx:xx.xxxZ",
    "since": "2024-06-xxTxx:xx:xx.xxxZ" // optional, if 'since' parameter was set
  }
}
  • data is an array of arrays representing OHLCV candlesticks. Each inner array contains values in the order: Open, High, Low, Close, Volume, and optionally Timestamp (depending on the "Include Timestamp" option).
  • The metadata provides context about the exchange and when the data was fetched.
  • If the "Include Timestamp" option is disabled, the timestamp value is omitted from each OHLCV entry.

The node does not output binary data.

Dependencies

  • Requires connectivity to the selected cryptocurrency exchange's public or authenticated API.
  • Optionally requires API credentials (API key, secret, password) for private endpoints or higher rate limits.
  • Uses the ccxt library internally to interact with exchanges.
  • No special environment variables are required beyond providing credentials via node options.

Troubleshooting

  • Symbol is required: The node will throw an error if the trading pair symbol is missing.
  • Limit must be between 1 and 1000: Ensure the limit parameter is within this range.
  • Unsupported exchange: Occurs if the selected exchange is not supported by the node.
  • Symbol not found on exchange: Happens if the specified trading pair does not exist on the chosen exchange.
  • Network or API errors may occur if credentials are invalid or the exchange is unreachable.
  • To handle errors gracefully, enable "Continue On Fail" in the node settings to prevent workflow interruption.

Links and References

  • CCXT Library Documentation
  • Cryptocurrency exchange official API docs (e.g., Binance, Kraken, KuCoin) for details on OHLCV data and rate limits.

Discussion