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, Bybit, Gateio, Kraken, Kucoin and OKX.
Requires Python 3.8+
Installation
pip install topbid
Usage
>>> from topbid.orderbook import OrderBook
# Instanciate OrderBook.
>>> orderbook = OrderBook()
# 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-3.0.2.tar.gz
(5.5 kB
view details)
Built Distribution
File details
Details for the file topbid-3.0.2.tar.gz
.
File metadata
- Download URL: topbid-3.0.2.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc1ef64313bac453313c7518ddd8781c9190c3303cd87f12e1dcaa654a444fda |
|
MD5 | f52295e01a39862801a3e78dcde4fbe7 |
|
BLAKE2b-256 | f6377767023ca6ae278b2cfcf65ced2b60772321ab950641febef771e955dc2a |
File details
Details for the file topbid-3.0.2-py3-none-any.whl
.
File metadata
- Download URL: topbid-3.0.2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9290838f2865c9d1f267952abf99a7918f70b3b9570671f53d6fa284bf79c77a |
|
MD5 | 81546a9a25c421288bff02560ab314ef |
|
BLAKE2b-256 | ea061d60f2a0304e39f71bfa3d56faadefbc79bd420eeaa1d3d79d6c0565dd16 |