Skip to main content

Helper library to fetch current best bid/ask from crypto exchanges orderbook APIs

Project description

topbid

Python 3.8 Code style: black

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.

Some information is currently retrieved from CoinGecko public API. Rate limit is between 10-30 requests/minute, which limits the number of new market pairs that can be added every minute.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

topbid-2.0.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

topbid-2.0.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file topbid-2.0.0.tar.gz.

File metadata

  • Download URL: topbid-2.0.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for topbid-2.0.0.tar.gz
Algorithm Hash digest
SHA256 5e39550e92ca5f7975877fd4066ccc3f42c9038b21e55e87f13ca57b540c3f33
MD5 e025087195dfd087efc63e65c25d55f6
BLAKE2b-256 895b71705330dc19c35f652ec42f1d07d8948caf90c9e6568f075c94c7e7ce55

See more details on using hashes here.

File details

Details for the file topbid-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: topbid-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for topbid-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cea44b578e59f8083334d5b6a0e2186fb6193806f983a3bfd0a732a5f5da1665
MD5 f10153cfbd59df40e93747250ffabc0f
BLAKE2b-256 7c04ec8ee1851b0f6a698ce0e486909b95cbc73bf3e004b839565ac26428c0d7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page