BinanceSpot
BinanceSpot is a TheoryCraft library for downloading and streaming historical an live market data from Binance Spot.
Access free historical data for all Binance Spot trading pairs including trades, aggregate trades, and klines.
Warning
This library is under active development and the API is subject to frequent changes.
Breaking changes may occur between releases as we refine the interface and add new features.
Installation
Add binance_spot to your list of dependencies in mix.exs:
def deps do
[
{:binance_spot, github: "theorycraft-trading/binance_spot"}
]
endElixir API
Search Instruments
alias BinanceSpot.Instruments
# Get all symbols
Instruments.all()
# => ["1000BONKUSDT", "1000CATUSDT", ..., "BTCUSDT", "ETHUSDT", ...]
# Search symbols
Instruments.search("BTC")
# => ["BTCUSDT", "ETHBTC", "WBTCBTC", ...]
# Lookup instrument details
Instruments.lookup!("BTCUSDT")
# => %{symbol: "BTCUSDT", base_asset: "BTC", quote_asset: "USDT", ...}DataFeed (TheoryCraft Integration)
Use BinanceSpot.DataFeed with TheoryCraft's MarketSource to build trading pipelines:
alias TheoryCraft.MarketSource
opts = [
symbol: "BTCUSDT",
source: :agg_trade,
from: ~D[2024-01-01],
to: ~D[2024-01-31]
]
market =
%MarketSource{}
|> MarketSource.add_data({BinanceSpot.DataFeed, opts}, name: "BTCUSDT")
|> MarketSource.resample("m5", name: "BTCUSDT_m5")
|> MarketSource.resample("h1", name: "BTCUSDT_h1")
for event <- MarketSource.stream(market) do
IO.inspect(event)
endDevelopment
# Run tests
mix test
# Run CI checks (format + credo + tests)
mix ci
# Run dialyzer
mix dialyzer
# Update instrument metadata from Binance API
mix binance_spot.gen.instrumentsLicense
Copyright (C) 2025 TheoryCraft Trading
Licensed under the Apache License, Version 2.0. See LICENSE for details.