Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lob-stream

A real-time LOB (live order book) reconstruction tool written in pure C, using WebSockets to stream live market data from centralized exchanges like Binance.

Features

  • Real-time LOB Assembly: Reconstructs the order book from WebSocket depth update streams
  • Live Display: Prints the top-of-book levels to the screen in real-time
  • Data Persistence: Writes LOB snapshots to local CSV files in LOBSTER format
  • Efficient Hash Table Management: Uses uthash for O(1) hash table operations on price levels
  • REST API Integration: Fetches initial depth snapshots via Binance REST API, then applies delta updates from WebSocket streams

Compilation

clang -o lob-stream ini.c lob-stream.c -v -L/usr/local/lib -I/usr/local/opt/openssl/include -Wall -Wextra -lwebsockets -lcurl -lcjson -pthread

With address sanitizer for memory debugging:

clang -o lob-stream ini.c lob-stream.c -fsanitize=address -L/usr/local/lib -I/usr/local/opt/openssl/include -Wall -Wextra -lwebsockets -lcurl -lcjson -pthread

Configuration

Edit config.ini to set WebSocket connection details and asset parameters:

  • port: WebSocket server port
  • address: WebSocket server address
  • path: WebSocket stream path
  • depth_snapshot_url: REST API endpoint for initial depth snapshot
  • symbol: Trading pair (e.g., BTCUSDT)
  • stream: Stream type (e.g., FUTURES, SPOT)
  • num_levels: Number of price levels to track

Dependencies

Memory Analysis

To check for memory leaks:

leaks -atExit -- ./lob-stream > report.txt

About

A real-time LOB (Live Order Book) reconstruction tool written in pure C

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages