CLOBster is a terminal user interface (TUI) framework for Polymarket prediction markets. Built with Rust, ratatui, and polymarket-rs.
- π₯οΈ Modern TUI β Beautiful terminal interface with vim-style navigation
- π Real-time Data β Live market updates via WebSocket
- π€ Programmable Strategies β Build and deploy custom trading strategies
- β‘ High Performance β Built in Rust for speed and reliability
- π‘οΈ Risk Management β Built-in guards and position limits
- βοΈ Configurable β TOML-based configuration with sensible defaults
- Rust 1.85+ (2024 edition)
- A Polymarket account with API credentials
cargo install clobstergit clone https://github.com/thiras/clobster.git
cd clobster
cargo build --releaseThe binary will be at target/release/clobster.
- Create a configuration file at
~/.config/clobster/config.toml:
[api]
base_url = "https://clob.polymarket.com"
ws_url = "wss://ws-subscriptions-clob.polymarket.com/ws"
timeout_secs = 30
[ui]
tick_rate_ms = 100
mouse_support = true
unicode_symbols = true
[keybindings]
up = "k"
down = "j"
left = "h"
right = "l"
quit = "q"
help = "?"
refresh = "r"- Run CLOBster:
clobster- Enable debug logging (optional):
RUST_LOG=clobster=debug clobsterCLOBster follows a unidirectional data flow pattern (Redux/Elm-inspired):
Events β Actions β Store (reduce) β UI renders from Store
| Module | Purpose |
|---|---|
app |
Event loop, terminal setup, async action handling |
state |
Centralized state with Store, Action enum, and domain states |
ui |
Ratatui rendering, layout, widgets |
events |
Input handling, key bindings β Action dispatch |
api |
Polymarket API wrapper via polymarket-rs |
strategy |
Programmable trading strategies with signals and risk management |
- User presses key β
EventHandler::handle_key()returnsAction App::handle_action()processes async actions (API calls) or delegates toStore::reduce()Store::reduce()updates state immutablyUi::render()reads fromStoreand draws widgets
CLOBster provides a powerful framework for building automated trading strategies.
use clobster::strategy::{Strategy, StrategyContext, Signal};
use rust_decimal_macros::dec;
struct MyStrategy {
threshold: Decimal,
}
impl Strategy for MyStrategy {
fn name(&self) -> &str { "my_strategy" }
fn evaluate(&mut self, ctx: &StrategyContext) -> Vec<Signal> {
let mut signals = vec![];
for market in ctx.markets() {
if let Some(outcome) = market.outcomes.first() {
if outcome.price < self.threshold {
signals.push(Signal::buy(
market.id.clone(),
outcome.token_id.clone(),
dec!(0.10),
));
}
}
}
signals
}
}- Momentum β Trend-following based on price movement
- Mean Reversion β Capitalize on price deviations from historical averages
- Spread β Market-making by capturing bid-ask spreads
All strategies pass through a risk guard before execution:
pub struct RiskConfig {
pub max_position_size: Decimal,
pub max_order_size: Decimal,
pub max_daily_loss: Decimal,
pub max_open_orders: usize,
}cargo build # Debug build
cargo build --release # Optimized release build
cargo test # Run all tests
cargo clippy # Run lints
cargo doc --open # Generate and view documentationRUST_LOG=clobster=debug cargo runsrc/
βββ app.rs # Application lifecycle
βββ lib.rs # Public API exports
βββ main.rs # Entry point
βββ error.rs # Error types
βββ api/ # Polymarket API client
βββ config/ # Configuration management
βββ events/ # Input handling
βββ state/ # State management (Store, Actions)
βββ strategy/ # Trading strategy framework
β βββ strategies/ # Built-in strategy implementations
βββ ui/ # Terminal UI rendering
βββ widgets/ # Reusable UI components
Full documentation is available at thiras.github.io/clobster or build locally:
cd docs
mdbook serveContributions are welcome! Please follow Conventional Commits for commit messages:
feat:new featuresfix:bug fixesrefactor:code restructuringtest:test additionsdocs:documentation
CLOBster is licensed under the MIT License.
- ratatui β Terminal UI framework
- polymarket-rs β Polymarket API client
- Polymarket β Prediction market platform