CoolFace
Datasetpublic

GotThatData/kraken-trading-data

πŸ“ˆ Kraken Trading Data Collection Overview High-frequency cryptocurrency market data from Kraken exchange - perfect for algorithmic trading, time-series forecasting, and market microstructure analysis. This dataset includes real-time price, volume, and order book data for 9 major cryptocurrency trading pairs, collected via WebSocket streaming and REST API polling. πŸ“Š Included Trading Pairs Pair Asset Base Currency Typical Daily Volume… See the full description on the dataset page: https://huggingface.co/datasets/GotThatData/kraken-trading-data.

sourceHugging Faceupdated 8mo agoView on Hugging Face
6likes878downloads
Dataset Card

πŸ“ˆ Kraken Trading Data Collection

![Downloads](https://huggingface.co/datasets/GotThatData/kraken-trading-data) ![License: MIT](https://opensource.org/licenses/MIT) ![Format: CSV](https://huggingface.co/datasets/GotThatData/kraken-trading-data)

Overview

High-frequency cryptocurrency market data from Kraken exchange - perfect for algorithmic trading, time-series forecasting, and market microstructure analysis.

This dataset includes real-time price, volume, and order book data for 9 major cryptocurrency trading pairs, collected via WebSocket streaming and REST API polling.


πŸ“Š Included Trading Pairs

PairAssetBase CurrencyTypical Daily Volume
XXBTZUSDBitcoinUSD$500M - $2B
XETHZUSDEthereumUSD$200M - $800M
XXRPZUSDRipple (XRP)USD$50M - $200M
ADAUSDCardanoUSD$30M - $150M
DOGEUSDDogecoinUSD$40M - $300M
BNBUSDBinance CoinUSD$20M - $100M
SOLUSDSolanaUSD$100M - $400M
DOTUSDPolkadotUSD$15M - $80M
MATICUSDPolygonUSD$20M - $100M
LTCUSDLitecoinUSD$30M - $150M

🎯 Use Cases

1. Algorithmic Trading

  • β€”Backtesting strategies - Test mean reversion, momentum, arbitrage
  • β€”Order book analysis - Study bid-ask spreads, depth, liquidity
  • β€”Market making - Identify optimal quote placement
  • β€”High-frequency trading - Sub-second price movements

2. Time-Series Forecasting

  • β€”Price prediction - LSTM, Transformer, ARIMA models
  • β€”Volatility modeling - GARCH, stochastic volatility
  • β€”Regime detection - Bull/bear market classification
  • β€”Anomaly detection - Flash crashes, wash trading, manipulation

3. Market Microstructure Research

  • β€”Bid-ask spread dynamics - How does liquidity evolve?
  • β€”Order flow imbalance - Predict short-term price movements
  • β€”Trade execution analysis - Optimal execution strategies (TWAP, VWAP)
  • β€”Cross-exchange arbitrage - Price discrepancies with Binance, Coinbase

4. Risk Management

  • β€”Value at Risk (VaR) - Estimate portfolio risk
  • β€”Correlation analysis - How do crypto assets move together?
  • β€”Drawdown modeling - Maximum loss scenarios
  • β€”Liquidity risk - Can you exit positions without slippage?

πŸ“ Dataset Structure

kraken-trading-data/
β”œβ”€β”€ trades/                  # Individual trade executions
β”‚   β”œβ”€β”€ XXBTZUSD_trades_2024-01.csv
β”‚   β”œβ”€β”€ XETHZUSD_trades_2024-01.csv
β”‚   └── ...
β”œβ”€β”€ ohlcv/                   # OHLCV candlestick data (1min, 5min, 1h, 1d)
β”‚   β”œβ”€β”€ XXBTZUSD_1min.csv
β”‚   β”œβ”€β”€ XXBTZUSD_5min.csv
β”‚   └── ...
β”œβ”€β”€ orderbook/               # Limit order book snapshots
β”‚   β”œβ”€β”€ XXBTZUSD_orderbook_2024-01.csv
β”‚   └── ...
β”œβ”€β”€ metadata.json            # Collection timestamps, pair info
└── README.md

Data Fields

Trades (trades/)
FieldTypeDescription
timestampint64Unix timestamp (milliseconds)
pricefloat64Execution price (USD)
volumefloat64Trade volume (asset units)
sidestrbuy or sell (taker side)
trade_idstrUnique trade identifier
OHLCV (ohlcv/)
FieldTypeDescription
timestampint64Candle open time (Unix ms)
openfloat64Opening price
highfloat64Highest price in period
lowfloat64Lowest price in period
closefloat64Closing price
volumefloat64Total volume traded
trade_countint32Number of trades
Order Book (orderbook/)
FieldTypeDescription
timestampint64Snapshot time (Unix ms)
sidestrbid or ask
pricefloat64Limit order price
volumefloat64Volume available at price level
cumulative_volumefloat64Cumulative depth

πŸš€ Quick Start

Load the Dataset

python
from datasets import load_dataset

dataset = load_dataset("GotThatData/kraken-trading-data")

Example: Load Bitcoin Trades

python
import pandas as pd

# Load Bitcoin trades for January 2024
df = pd.read_csv("hf://datasets/GotThatData/kraken-trading-data/trades/XXBTZUSD_trades_2024-01.csv")

# Convert timestamp to datetime
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')

# Set as index
df = df.set_index('timestamp')

# Display first rows
print(df.head())

Output:

                             price      volume  side         trade_id
timestamp                                                            
2024-01-01 00:00:01.234  42150.5    0.025000   buy   1704067201234-1
2024-01-01 00:00:01.567  42149.8    0.100000   sell  1704067201567-2
...

Example: Resample to 1-Hour OHLCV

python
# Resample trades to hourly candles
ohlcv = df.resample('1H').agg({
    'price': ['first', 'max', 'min', 'last'],
    'volume': 'sum',
    'trade_id': 'count'
})

# Flatten column names
ohlcv.columns = ['open', 'high', 'low', 'close', 'volume', 'trade_count']
print(ohlcv.head())

Example: Calculate Moving Average Crossover

python
import matplotlib.pyplot as plt

# Load 1-minute OHLCV
df = pd.read_csv("hf://datasets/GotThatData/kraken-trading-data/ohlcv/XXBTZUSD_1min.csv")
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
df = df.set_index('timestamp')

# Calculate moving averages
df['MA_20'] = df['close'].rolling(window=20).mean()
df['MA_50'] = df['close'].rolling(window=50).mean()

# Plot
plt.figure(figsize=(14, 7))
plt.plot(df['close'], label='BTC Price', alpha=0.5)
plt.plot(df['MA_20'], label='20-period MA')
plt.plot(df['MA_50'], label='50-period MA')
plt.legend()
plt.title('Bitcoin Price with Moving Averages')
plt.show()

Example: Order Book Visualization

python
import seaborn as sns

# Load order book snapshot
ob = pd.read_csv("hf://datasets/GotThatData/kraken-trading-data/orderbook/XXBTZUSD_orderbook_2024-01.csv")

# Filter for a specific timestamp
snapshot = ob[ob['timestamp'] == ob['timestamp'].iloc[0]]

# Separate bids and asks
bids = snapshot[snapshot['side'] == 'bid'].sort_values('price', ascending=False)
asks = snapshot[snapshot['side'] == 'ask'].sort_values('price')

# Plot depth chart
plt.figure(figsize=(12, 6))
plt.step(bids['price'], bids['cumulative_volume'], where='pre', label='Bids', color='green')
plt.step(asks['price'], asks['cumulative_volume'], where='post', label='Asks', color='red')
plt.xlabel('Price (USD)')
plt.ylabel('Cumulative Volume (BTC)')
plt.title('BTC/USD Order Book Depth')
plt.legend()
plt.show()

πŸ“Š Sample Analysis: Predict Next-Hour Price Movement

python
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split

# Load hourly OHLCV
df = pd.read_csv("hf://datasets/GotThatData/kraken-trading-data/ohlcv/XXBTZUSD_1h.csv")
df['timestamp'] = pd.to_datetime(df['timestamp'], unit='ms')
df = df.set_index('timestamp')

# Feature engineering
df['returns'] = df['close'].pct_change()
df['volatility'] = df['returns'].rolling(window=24).std()
df['volume_ma'] = df['volume'].rolling(window=24).mean()

# Target: 1 if price goes up next hour, 0 otherwise
df['target'] = (df['close'].shift(-1) > df['close']).astype(int)

# Drop NaNs
df = df.dropna()

# Features and target
features = ['open', 'high', 'low', 'close', 'volume', 'returns', 'volatility', 'volume_ma']
X = df[features]
y = df['target']

# Split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, shuffle=False)

# Train model
model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(X_train, y_train)

# Evaluate
accuracy = model.score(X_test, y_test)
print(f"Accuracy: {accuracy:.2%}")

πŸ”¬ Research Applications

Published Papers Using This Dataset

(Open a PR to add your work!)

Potential Research Questions

  1. 1.Can transformers outperform LSTMs for crypto price prediction?
  2. 2.How does order book imbalance predict short-term price movements?
  3. 3.What's the optimal rebalancing frequency for a crypto portfolio?
  4. 4.Do Twitter sentiment signals correlate with price volatility?
  5. 5.Can you detect wash trading or market manipulation in the data?

πŸ“ Citation

If you use this dataset in your research, please cite:

bibtex
@dataset{daugherty2024kraken,
  author = {Bryan Daugherty},
  title = {Kraken Trading Data Collection},
  year = {2024},
  publisher = {Hugging Face},
  url = {https://huggingface.co/datasets/GotThatData/kraken-trading-data}
}

πŸ”— Related Resources


βš™οΈ Data Collection Methodology

Data was collected using:

  1. 1.Kraken WebSocket API - Real-time trade stream (sub-second latency)
  2. 2.Kraken REST API - Order book snapshots (every 10 seconds)
  3. 3.ccxt Library - Normalized OHLCV data (1min, 5min, 1h, 1d intervals)

Collection Period: January 2024 - December 2024 (ongoing updates) Update Frequency: Daily (new data added at 00:00 UTC)


πŸ“œ License

MIT License - free for academic and commercial use.

Disclaimer: This data is for research and educational purposes only. Past performance does not guarantee future results. Cryptocurrency trading involves significant risk.


πŸ™ Acknowledgments

  • β€”Kraken Exchange - For providing free, high-quality market data APIs
  • β€”ccxt Community - For building robust exchange integration tools
  • β€”Hugging Face - For hosting and serving this dataset

πŸ› Known Issues & Future Work

  • β€”Missing Data: Some gaps during exchange maintenance windows (< 0.1% of total data)
  • β€”Timezone: All timestamps are UTC
  • β€”Delisting: BNBUSD was delisted in June 2024 (data ends June 30)

Roadmap:

  • β€”[ ] Add L2 order book data (full depth, not just top 20 levels)
  • β€”[ ] Include funding rate data for perpetual futures
  • β€”[ ] Add cross-exchange arbitrage opportunities dataset
  • β€”[ ] Create Gradio Space for interactive data exploration

πŸ’¬ Feedback & Contributions

Found a bug? Want to request additional pairs or features?


"In trading, the only constant is change. Adapt or fade away." β€” Paul Tudor Jones