Helper library to fetch current best bid/ask from crypto exchanges orderbook APIs
Project description
topbid
Helper library to fetch and store current orderbook top bid/ask price and volume from crypto exchanges APIs. Currently supports Binance, Gateio, Kraken and Kucoin.
Requires Python 3.8+
Installation
pip install topbid
Usage
>>> from topbid.orderbook import OrderBook
# Instanciate OrderBook with your CMP API key and exchanges you'll be using.
# Tickers mappings will be retrieved.
>>> orderbook = OrderBook("cryptocompare-api-key", ["binance", "kucoin"])
2023-01-01 13:37:00,000 - topbid_orderbook - INFO - Saved mappings from CryptoCompare API for exchange binance
2023-01-01 13:37:00,000 - topbid_orderbook - INFO - Saved mappings from CryptoCompare API for exchange kucoin
# Add one or more market pairs to be fetched from an exchange REST API.
>>> orderbook.add("binance", "BTC/USDT")
>>> orderbook.add("kucoin", ["BTC/USDT", "ETH/USDT"])
# Start the background thread fetching prices and volume (here, every 2 seconds).
>>> orderbook.start(update_every=2)
# Retrieve the highest bid on the orderbook.
>>> orderbook.get_orderbook_top_bid("binance", "BTC/USDT")
(23130.41, 0.0584)
# Retrieve the lowest ask on the orderbook.
>>> orderbook.get_orderbook_top_ask("binance", "BTC/USDT")
(23130.43, 0.0214)
# Removes a pair from being fetched.
>>> orderbook.delete("binance", "BTC/USDT")
# Stop the background thread and removes all watched pairs.
# It must be called before exiting your own application.
>>> orderbook.stop()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
topbid-1.2.2.tar.gz
(5.8 kB
view details)
Built Distribution
File details
Details for the file topbid-1.2.2.tar.gz
.
File metadata
- Download URL: topbid-1.2.2.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 828af4251003c1bbf2f212234c891b25133cddfb9d6fae11a0ebef50fd236491 |
|
MD5 | e92988a3c512c79b5bf397fbb7b8f0fd |
|
BLAKE2b-256 | 99bb2c29101ccfd35f30388aaa396279aad78bef0cd386d5e640997bf76b1d47 |
File details
Details for the file topbid-1.2.2-py3-none-any.whl
.
File metadata
- Download URL: topbid-1.2.2-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02ef42a18bbdd5800dd4fa2cb12253c3266eaa1ffe0cd0bff987bde8212f94b7 |
|
MD5 | 3bf96be37dfc4a6d4849588a79d19fa0 |
|
BLAKE2b-256 | 64437aac9c608abc643c767a08f7610e1603a909ebe99a8688cf47b98cee2485 |