Metadata-Version: 2.4
Name: exchange-radar
Version: 2.0.0
Summary: Real-time cryptocurrency trades, history and price alerts.
License: GPL-3.0-only
License-File: LICENSE
Keywords: cryptocurrency,trades,market-data
Author: Paulo Antunes
Author-email: pjmlantunes@gmail.com
Requires-Python: >=3.12,<4.0
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Requires-Dist: click (>=8.1.5,<9.0.0)
Requires-Dist: copra (>=1.2.9,<2.0.0)
Requires-Dist: environs (>=11.0.0,<12.0.0)
Requires-Dist: huey (>=2.5.0,<3.0.0)
Requires-Dist: jinja2 (>=3.1.2,<4.0.0)
Requires-Dist: pika (>=1.3.2,<2.0.0)
Requires-Dist: pybit (>=5.6.2,<6.0.0)
Requires-Dist: pydantic (>=2.0,<3.0)
Requires-Dist: pymexc (>=1.2.0,<2.0.0)
Requires-Dist: python-binance (>=1.0.17,<2.0.0)
Requires-Dist: python-kucoin (>=2.1.3,<3.0.0)
Requires-Dist: python-okx (>=0.2.6,<0.3.0)
Requires-Dist: python-telegram-bot (>=21.1.1,<22.0.0)
Requires-Dist: pywebpush (>=2.0.3,<3)
Requires-Dist: redis-om (>=0.3.5,<0.4)
Requires-Dist: requests (>=2.31.0,<3.0.0)
Requires-Dist: starlette (>=1.3.1,<2)
Requires-Dist: twisted (>=26.10,<27)
Requires-Dist: types-requests (==2.31.0.0)
Requires-Dist: urllib3 (>=2.8,<3)
Requires-Dist: uvicorn[standard] (>=0.49,<1)
Project-URL: Homepage, https://radar.pauloantunes.com
Description-Content-Type: text/markdown

# Exchange Radar

Real-time cryptocurrency trades, filtered feeds, trade history and price alerts.
Supports Binance, Coinbase, Kraken, KuCoin, OKX, Bybit, Bitstamp, MEXC and HTX.

[Live website](https://radar.pauloantunes.com)

## Install

Requires Python 3.12+, RabbitMQ and Redis with **JSON and Search** support.
Installing the package does not install these services.

```bash
python -m venv .venv
source .venv/bin/activate
python -m pip install exchange-radar
```

## Run locally

This example monitors BTC/USDT on Binance. Start Redis on port 6379 and RabbitMQ
on port 5672, accessible only from your machine.

Save the following as `.env`. Set your RabbitMQ credentials and generate
`INTERNAL_API_TOKEN` with `python -c 'import secrets; print(secrets.token_urlsafe(32))'`.

```bash
export DEBUG=false REDIS_OM_URL=redis://localhost:6379/0
export REDIS_EXPIRATION=90 REDIS_MAX_ROWS=256
export RABBITMQ_HOST=localhost RABBITMQ_PORT=5672 RABBITMQ_DEFAULT_VHOST=/
export RABBITMQ_DEFAULT_USER=radar RABBITMQ_DEFAULT_PASS='replace-me'
export RABBITMQ_EXCHANGE=radar
export RABBITMQ_CONNECTION_HEARTBEAT=60 RABBITMQ_BLOCKED_CONNECTION_TIMEOUT=30
export INTERNAL_API_TOKEN='replace-with-generated-token'
export TRADES_HOST_URL='http://127.0.0.1:9000/api/feed/{coin}'
export TRADES_WHALES_HOST_URL='http://127.0.0.1:9000/api/feed/{coin}/whales'
export TRADES_DOLPHINS_HOST_URL='http://127.0.0.1:9000/api/feed/{coin}/dolphins'
export TRADES_OCTOPUSES_HOST_URL='http://127.0.0.1:9000/api/feed/{coin}/octopuses'
export BINANCE=BTC BINANCE_COINS=BTCUSDT
export COINBASE= KRAKEN= KUCOIN= OKX= BYBIT= BITSTAMP= MEXC= HTX=
export COINBASE_COINS= KRAKEN_COINS= KUCOIN_COINS= OKX_COINS=
export BYBIT_COINS= BITSTAMP_COINS= MEXC_COINS= HTX_COINS=
```

Load the settings and create the RabbitMQ exchange and queues once. The broker
user needs permission to configure, write and read these resources.

```bash
source .env
python - <<'PY'
import os
import pika

connection = pika.BlockingConnection(pika.ConnectionParameters(
    host=os.environ['RABBITMQ_HOST'], port=int(os.environ['RABBITMQ_PORT']),
    virtual_host=os.environ['RABBITMQ_DEFAULT_VHOST'],
    credentials=pika.PlainCredentials(
        os.environ['RABBITMQ_DEFAULT_USER'], os.environ['RABBITMQ_DEFAULT_PASS']),
))
channel = connection.channel()
exchange = os.environ['RABBITMQ_EXCHANGE']
channel.exchange_declare(exchange=exchange, exchange_type='topic', durable=True)
for suffix, key in [('', 'all'), ('-whales', 'whales'),
                    ('-dolphins', 'dolphins'), ('-octopuses', 'octopuses')]:
    queue = 'trades' + suffix
    channel.queue_declare(queue=queue, durable=True)
    channel.queue_bind(queue=queue, exchange=exchange, routing_key='trades.' + key)
connection.close()
PY
```

In **four terminals**, activate `.venv` and run `source .env` in each.
Then run one command per terminal, in this order:

```bash
# 1. Web interface
uvicorn exchange_radar.web.src.main:app --host 127.0.0.1 --port 9000

# 2. Deliver trades to the web interface
consumer

# 3. Price alerts and reference prices
scheduler

# 4. Collect trades
producer --exchange binance BTCUSDT
```

Open [BTC trades](http://127.0.0.1:9000/BTC). Add `/whales`, `/dolphins` or
`/octopuses` for filtered feeds. Stop each process with Ctrl+C.

Browser push notifications require additional configuration and are off by default.
License: GPL-3.0-only.

