Crypto-Pandas: The Easiest Solution for Working with Crypto Exchanges¶

In [18]:
import pandas as pd
import numpy as np
import ccxt
from crypto_pandas import CCXTPandasExchange
import plotly.graph_objects as go
import plotly.express as px

exchange = ccxt.binance()
pandas_exchange = CCXTPandasExchange(exchange=exchange)
symbol = "BNB/USDT:USDT"

OHLCV in 1 Line of Code¶

In [9]:
df = pandas_exchange.fetch_ohlcv(
    symbol=symbol, 
    timeframe="1h", 
    limit=100
)

# Create Plotly candlestick chart
fig = go.Figure(data=go.Candlestick(
    x=df["timestamp"],
    open=df["open"],
    high=df["high"],
    low=df["low"],
    close=df["close"]
))
fig.update_layout(
    title="BNB/USDT:USDT OHLCV (Binance)",
    xaxis_title="Time",
    yaxis_title="Price (USDT)",
    xaxis_rangeslider_visible=False,
    template="plotly_dark"
)
fig.show()

Public trades in 1 Line of Code¶

In [19]:
df = pandas_exchange.fetch_trades(symbol=symbol)
df["amount"] = np.log1p(df["amount"]) * 10  # log scale size

fig = px.scatter(
    df,
    x="timestamp",
    y="price",
    size="amount",
    color="side",
    template="plotly_dark"
)
fig.show()