UNICORN Binance Suite — Open Source Python APIs and Order Book Infrastructure for Binance

Open source Python libraries and infrastructure for building reliable applications with Binance APIs, real-time WebSocket streams, synchronized order books, automated trailing stops and production-scale DepthCache clusters.
The UNICORN Binance Suite is a modular collection of open source tools for Python developers, quantitative researchers, trading-system engineers and infrastructure teams working with Binance market data and trading APIs.
Use the individual packages independently or combine them into a complete stack:
- access the Binance REST API with Python
- consume real-time Binance WebSocket streams
- maintain synchronized local Binance order books
- detect sequence gaps and automatically resynchronize
- normalize exchange payloads with UnicornFy
- automate trailing stop-loss strategies with UBTSL
- provide redundant order books through the language-independent UBDCC REST API
- scale Binance DepthCache infrastructure on Kubernetes
All projects are published under the MIT License.
Start Here
| What do you want to build? | Recommended project |
|---|---|
| Install the complete Python toolkit | UNICORN Binance Suite |
| Access Binance REST APIs from Python | UNICORN Binance REST API — UBRA |
| Create a Binance API key and API secret | Step-by-step Binance API key guide |
| Consume Binance WebSocket streams | UNICORN Binance WebSocket API — UBWA |
| Maintain synchronized local order books | UNICORN Binance Local Depth Cache — UBLDC |
| Share redundant order books between applications | UNICORN Binance DepthCache Cluster — UBDCC |
| Monitor and manage UBDCC in a browser | UBDCC Dashboard |
| Run an automated trailing stop loss | UNICORN Binance Trailing Stop Loss — UBTSL |
| Normalize exchange API payloads | UnicornFy |
| Read all technical documentation | UNICORN Binance Suite documentation index |
| Read tutorials, architecture articles and benchmarks | UNICORN Binance Suite article series |
Installation
Install the complete UNICORN Binance Suite with pip
pip install unicorn-binance-suite
Package links:
- UNICORN Binance Suite on PyPI
- UNICORN Binance Suite on conda-forge
- UNICORN Binance Suite on GitHub
- UNICORN Binance Suite documentation
Install the complete suite with Conda
conda install -c conda-forge unicorn-binance-suite
Install individual modules
pip install unicorn-binance-websocket-api
pip install unicorn-binance-rest-api
pip install unicorn-binance-local-depth-cache
pip install unicorn-binance-trailing-stop-loss
pip install unicorn-fy
pip install ubdcc
pip install ubdcc-dashboard
Projects and Modules
UNICORN Binance Suite
The UNICORN Binance Suite is the central entry point and Python meta-package for the complete ecosystem.
It combines the core modules for Binance REST access, WebSocket streaming, local order books, payload normalization and automated trading infrastructure.
Official links
- Documentation
- Complete documentation index
- GitHub repository
- PyPI package
- Conda-forge package
- Issues
- Discussions
- Changelog
- MIT License
pip install unicorn-binance-suite
UNICORN Binance WebSocket API — UBWA
The UNICORN Binance WebSocket API is a Python SDK for receiving and managing Binance WebSocket streams and WebSocket API connections.
UBWA handles the operational details required by long-running real-time applications:
- stream creation and lifecycle management
- automatic reconnects
- stream replacement
- connection monitoring
- native asynchronous processing
- runtime subscribe and unsubscribe
- Binance WebSocket API requests
- support for Binance Spot, Margin, Futures, Options, US and TR endpoints
Official links
pip install unicorn-binance-websocket-api
UNICORN Binance REST API — UBRA
The UNICORN Binance REST API is a Python SDK for accessing Binance REST APIs through a consistent interface.
UBRA supports public market-data requests and authenticated account or trading operations across multiple Binance API environments.
Before using authenticated endpoints, follow the step-by-step guide to creating a Binance API key and API secret.
Typical use cases include:
- retrieving exchange and market information
- querying balances and account data
- creating, querying and cancelling orders
- accessing Binance Spot, Margin and Futures APIs
- accessing Binance US and Binance TR
- handling signed and authenticated REST requests
Official links
pip install unicorn-binance-rest-api
UNICORN Binance Local Depth Cache — UBLDC
The UNICORN Binance Local Depth Cache is a Python SDK for maintaining synchronized local Binance order books.
UBLDC combines an initial REST snapshot with real-time WebSocket depth updates and maintains the resulting order book locally.
It is designed to handle the difficult parts of Binance order-book synchronization:
- REST snapshot initialization
- buffered WebSocket updates
- update-ID continuity validation
- sequence-gap detection
- automatic reinitialization
- stale price-level pruning
- multiple DepthCaches in one process
- explicit out-of-sync states
Read the research behind stale price-level pruning in Your Binance DepthCache is rotting — here's the proof in 25 hours.
Official links
- Documentation
- GitHub repository
- PyPI package
- Conda-forge package
- DepthCache forensic dataset
- Issues
- Discussions
- MIT License
pip install unicorn-binance-local-depth-cache
UNICORN Binance DepthCache Cluster — UBDCC
The UNICORN Binance DepthCache Cluster moves synchronized Binance order books out of individual bots and into reusable infrastructure.
Instead of every application independently maintaining its own REST snapshot, WebSocket connection, sequence validation and recovery logic, UBDCC runs the DepthCache infrastructure once and exposes current bids and asks through a REST API.
Applications written in Python, JavaScript, TypeScript, Go, Rust, Java, C#, PHP, Ruby, Bash or any other language with an HTTP client can consume the same synchronized order-book service.
Core capabilities include:
- replicated Binance DepthCaches
- automatic failover
- load distribution
- centralized order-book infrastructure
- REST API access from any programming language
- local single-machine installation
- Kubernetes deployment with Helm
- runtime DepthCache creation and removal
- cluster health and replica monitoring
Local UBDCC quickstart
pip install ubdcc
ubdcc start
Read the complete guide: From pip install to a Redundant Binance Order Book Cluster — UBDCC + Dashboard Quickstart.
Kubernetes installation
helm repo add ubdcc https://oliver-zehentleitner.github.io/unicorn-binance-depth-cache-cluster/helm
helm repo update
helm install ubdcc ubdcc/ubdcc \
--namespace ubdcc \
--create-namespace
Read the complete guide: Install UBDCC on Kubernetes with Helm: A Redundant Binance Order Book Cluster in 20 Minutes.
Official links
- Documentation
- GitHub repository
- PyPI package
- Helm repository
- Local installation
- Kubernetes installation
- REST API documentation
- Issues
- Discussions
- MIT License
UBDCC Dashboard
The UBDCC Dashboard is a browser-based interface for monitoring and managing a running UNICORN Binance DepthCache Cluster.
The dashboard provides a visual overview of:
- running DepthCaches
- replica state
- synchronization status
- cluster errors
- individual order books
- DepthCache creation and removal
pip install ubdcc-dashboard
ubdcc-dashboard start
Official links
UNICORN Binance Trailing Stop Loss — UBTSL
The UNICORN Binance Trailing Stop Loss is a Python library and command-line tool for running automated trailing stop-loss strategies on Binance.
UBTSL supports:
- trailing stop-loss execution
- smart entry
- jump-in-and-trail workflows
- Python SDK usage
- command-line operation
- configurable profiles
- email notifications
Official links
pip install unicorn-binance-trailing-stop-loss
UnicornFy
UnicornFy is a normalization layer for transforming raw exchange API responses into consistent and well-formed Python dictionaries.
Typical uses include:
- normalizing Binance WebSocket messages
- converting raw exchange payloads
- creating consistent internal event formats
- simplifying downstream processing
- reducing exchange-specific application logic
Official links
pip install unicorn-fy
Complete Documentation Index
All module documentation is collected in the central UNICORN Binance Suite documentation index.
Python Packages
Guides, Architecture Articles and Research
The UNICORN Binance Suite article series contains tutorials, architecture explanations, production findings and reproducible benchmarks.
The Complete Binance Python API Guide (2026)
A complete guide to Binance REST APIs, WebSocket streams, local order books, trailing stops and cluster-scale market-data infrastructure.
Read The Complete Binance Python API Guide (2026)
From pip install to a Redundant Binance Order Book Cluster
Install UBDCC locally, start the cluster and UBDCC Dashboard, create a synchronized Binance DepthCache and query it through REST.
Read the UBDCC local quickstart
Install UBDCC on Kubernetes with Helm
A step-by-step guide to deploying redundant Binance order-book infrastructure with Kubernetes and Helm.
Read the UBDCC Kubernetes installation guide
UBDCC Deep-Dive: Building a Trust Layer for Binance Order Books
Learn how UBWA, UBLDC, UBDCC and the UBDCC Dashboard work together to create a trusted Binance market-data source.
Read the UBDCC architecture deep dive
Your Binance DepthCache is rotting — here's the proof in 25 hours
A 25-hour forensic experiment showing why a gap-free local Binance order book can still become increasingly incorrect when stale price levels are retained.
The complete forensic dataset is available in the binance-depthcache-forensics GitHub repository.
Read the 25-hour Binance DepthCache benchmark
2013 Binance Order Books on Kubernetes with Two Replicas
A practical test running 4,026 replicated Binance Spot and Futures DepthCaches across a Kubernetes cluster and load-testing the shared UBDCC REST API.
Read the Kubernetes scale and REST API stress test
Video Guides
Build Highly Available Binance DepthCaches in 10 Minutes
Install UBDCC, start a local cluster, connect the UBDCC Dashboard and access synchronized Binance order books through REST.
Watch the UBDCC installation and quickstart video on YouTube
Run All Binance Spot and Futures Order Books on Kubernetes
Deploy UBDCC with Helm, create thousands of replicated DepthCaches, monitor the Kubernetes cluster and access the resulting Binance order books through REST.
Watch the UBDCC Kubernetes deployment and scale-test video on YouTube
Common Use Cases
Binance WebSocket streaming with UBWA
Use the UNICORN Binance WebSocket API when your application needs real-time trades, tickers, order-book updates, account events or WebSocket API requests.
from unicorn_binance_websocket_api import BinanceWebSocketApiManager
manager = BinanceWebSocketApiManager(exchange="binance.com")
manager.create_stream(
channels="trade",
markets="btcusdt",
process_stream_data=print,
)
Read the UBWA documentation or browse the UBWA source code.
Binance REST API access with UBRA
Use the UNICORN Binance REST API for public market data, authenticated account operations and order management.
from unicorn_binance_rest_api import BinanceRestApiManager
with BinanceRestApiManager(
api_key="YOUR_API_KEY",
api_secret="YOUR_API_SECRET",
) as manager:
account = manager.get_account()
Read the UBRA documentation or browse the UBRA source code.
Synchronized local Binance order books with UBLDC
Use the UNICORN Binance Local Depth Cache when your Python process needs low-latency access to current bids and asks.
from unicorn_binance_local_depth_cache import (
BinanceLocalDepthCacheManager,
DepthCacheOutOfSync,
)
manager = BinanceLocalDepthCacheManager(exchange="binance.com")
manager.create_depthcache("BTCUSDT")
try:
asks = manager.get_asks("BTCUSDT", limit_count=10)
bids = manager.get_bids("BTCUSDT", limit_count=10)
except DepthCacheOutOfSync:
pass
Read the UBLDC documentation or browse the UBLDC source code.
Shared Binance order-book infrastructure with UBDCC
Use the UNICORN Binance DepthCache Cluster when multiple bots, services, dashboards or research tools need access to the same synchronized Binance order books.
curl "http://127.0.0.1:42081/create_depthcache?exchange=binance.com&market=BTCUSDT&desired_quantity=2"
curl "http://127.0.0.1:42081/get_asks?exchange=binance.com&market=BTCUSDT&limit_count=10"
curl "http://127.0.0.1:42081/get_bids?exchange=binance.com&market=BTCUSDT&limit_count=10"
Read the UBDCC documentation, browse the UBDCC source code or follow the local UBDCC quickstart.
Why Use the UNICORN Binance Suite?
Building directly on exchange APIs often looks simple at first. Production systems must additionally handle:
- reconnects and connection failures
- REST and WebSocket coordination
- Binance rate limits
- sequence-number validation
- missing and duplicate updates
- order-book resynchronization
- stale price levels
- process restarts
- monitoring
- failover
- scaling
- API differences between Binance environments
The UNICORN Binance Suite separates these responsibilities into focused modules that can be used independently or together.
That allows developers to spend less time rebuilding exchange infrastructure and more time working on trading logic, analytics, research and applications.
Open Source, Issues and Contributions
The UNICORN Binance Suite is developed openly on GitHub and released under the MIT License.
Contributions are welcome, including:
- bug reports through the relevant GitHub issue tracker
- architecture questions through GitHub Discussions
- documentation improvements
- reproducible test cases
- feature requests
- pull requests
- performance measurements
- platform compatibility reports
Browse all projects on the Oliver Zehentleitner GitHub profile.
Community and Support
Questions, feedback and real-world test results are welcome.
- UNICORN Binance Suite GitHub Discussions
- UNICORN Binance Suite issue tracker
- UNICORN Binance Suite on Reddit
- UNICORN Developers on Telegram
- UNICORN Binance Suite article series
- Oliver Zehentleitner on YouTube
- Oliver Zehentleitner on GitHub
- Oliver Zehentleitner on LinkedIn
- UNICORN Binance Suite on X
For module-specific bugs, use the issue tracker of the affected GitHub repository.
About the Author
The UNICORN Binance Suite was created by Oliver Zehentleitner and has been developed and maintained as open source software since 2019.
The projects focus on reliable Binance API access, asynchronous Python, WebSocket infrastructure, synchronized order books, fault detection, automated recovery and scalable market-data services.
Disclaimer
The UNICORN Binance Suite is unofficial software and is not affiliated with or endorsed by Binance.
The projects and documentation are provided for informational and technical purposes. They do not constitute financial, investment, legal or tax advice.
Trading cryptocurrencies involves substantial risk. Use the software at your own risk and thoroughly test every component before using it with real funds.

