Skip to main content

Intro

  • Monitors the entire crypto market kline (candlestick) data, showing 20 symbols only below for illustration
  • Other tools

Usage

pip install crypto-monitor
  • You can either react to individual symbol updates by defining a callback on_change as shown below
  • Or define a task like plot_task below that handles all symbols (x.data) repeatedly
    x.data: Dict[str, np.ndarray]
    x.update_time: Dict[str, int]
    print(x.data["BTCUSDT"], x.update_time["BTCUSDT"])
    
import asyncio
from typing import List

import numpy as np
from crypto_data_downloader.binance import ALL_COLUMNS
from crypto_data_downloader.utils import format_date, plot_crypto_data, timestamp
from PIL import Image

from crypto_monitor.binance import CryptoMonitor
from crypto_monitor.utils import safe_exit, save_gif


async def main():
    async def on_change(sym: str, arr: np.ndarray, e_time: int):
        if sym == "BTCUSDT":
            f = format_date
            print(
                f"BTC. my time: {f(timestamp())}, event time: {f(e_time)}, price: {arr[-1, 1]}"
            )

    x = CryptoMonitor()
    x.quote = "USDT"  # Quote asset
    x.interval = "5m"  # Kline time interval
    x.columns = ["open_time", "close"]  # Data columns to include
    print(f"All data columns: {ALL_COLUMNS}")
    x.kline_lim = 10  # Only show 10 time steps for clearer visualization
    x.market = ["SPOT", "MARGIN"][1]
    x.max_num = 20  # Only show 20 symbols for visualization
    x.on_change = on_change

    async def plot_task():
        frames: List[Image.Image] = []
        while True:
            await asyncio.sleep(2)
            safe_exit.check()
            if len(x.data):
                id = "data/CryptoMonitor"
                plot_crypto_data(x.data, id)
                frames.append(Image.open(f"{id}.png").copy())
                assert len(frames) < 150, save_gif(frames, id, fps=5)

    await asyncio.gather(x.watch(), plot_task())


asyncio.run(main())
  • Output
All data columns: ['open_time', 'open', 'high', 'low', 'close', 'volume', 'close_time', 'quote_volume', 'n_trades', 'taker_buy_base_volume', 'taker_buy_quote_volume', 'unused']
weight lim: 5000/6000, USDT symbols: 599, spot: 559, margin: 403
BTC. my time: 2025-08-07 04:10:22, event time: 2025-08-07 04:10:22, price: 114639.92
BTC. my time: 2025-08-07 04:10:24, event time: 2025-08-07 04:10:24, price: 114639.91
BTC. my time: 2025-08-07 04:10:26, event time: 2025-08-07 04:10:26, price: 114639.92
...

Metadata

Release files for crypto-live-trader 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crypto-live-trader 0.0.1
File Size Uploaded
crypto_live_trader-0.0.1.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for crypto-live-trader 0.0.1
File Interpreter ABI Platform
crypto_live_trader-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 5.8 kB

Release files / crypto_live_trader-0.0.1.tar.gz

Download URL crypto_live_trader-0.0.1.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3f352f53e695092841172ec15efaa565573fb57780bdcab5fef6dd4e6bb98441
BLAKE2b-256 checksum
How to use checksums
cefd043309da99b66e24f2a52b6a8aa591adc788c4cec06dafaa299e9e48198d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / crypto_live_trader-0.0.1-py3-none-any.whl

Download URL crypto_live_trader-0.0.1-py3-none-any.whl
Size 3.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2fabbe526f69059a21e8c8236bd6bd5c8628f8dea4513aa77a234060aef1c26
BLAKE2b-256 checksum
How to use checksums
03fd2e3a50adf77f23c89b38d4f0e746ec6d2257d2b9df8c214c67bcbc9b495c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page