All projects Personal project · Event-driven Python

Cryptobot: an automated trading system

A long-running service that scores assets with an LLM, invests within strict risk limits, watches live order books and sells when conditions are met. It is built as a production system, with modes for safe testing before any real money is involved.

Context
Personal project
Role
Solo: architecture & implementation
Exchange
Binance (testnet / live)
Runtime
Docker · SQLite · Grafana
Two real positions from a testnet run, under the same rules: ETH climbs to +3% and is sold by the trailing stop, FET slides to −6% and is cut by the stop-loss.
Overview

At a glance

~3k
lines of Python across 7 core modules
3
modes: paper, testnet, live
Real-time
order-book streams over WebSockets
LLM
asset scoring backed by web sources
Architecture

Score, invest, monitor, exit

ScoreLLM + web
Investrisk limits
Monitororder books
Exitsell signals
ReportGrafana

Asset scoring

On a schedule, the bot takes the tradable pairs from the exchange and queries a search-augmented LLM about each asset concurrently with asyncio. It requires a minimum number of cited sources and extracts a numeric score from each answer.

Investment with risk limits

Capital is allocated to the best-scored assets under configurable constraints: a maximum share of total equity exposed at once and a fixed budget per trade.

Broker layer

A wrapper around the exchange API that handles the unglamorous details correctly: lot sizes, step rounding, minimum notional checks and market-order filters.

Real-time monitoring

Open positions are tracked through multiplexed WebSocket order-book streams. The expected sell price is computed from actual bid depth rather than the last trade price. Positions are locked before selling to prevent duplicate orders.

State & observability

Positions, signals and equity snapshots live in SQLite, which Grafana reads to show portfolio value and activity over time.

Engineering

Built to run unattended

Safe by default

Paper mode simulates orders, testnet uses real endpoints with fake funds, and live mode has to be enabled explicitly.

Config-driven

Exchange, market, cadence, risk limits and LLM prompts all live in a single YAML file.

Resilient connections

WebSocket connections are rebuilt and state is reconciled with the exchange when positions change.

Containerised

Docker Compose runs the bot and its Grafana monitoring together.

Stack

Tools & techniques

Core
  • Python
  • asyncio
  • httpx
  • WebSockets
Data
  • SQLite
  • YAML config
  • Binance API
AI
  • Search-augmented LLM
  • Prompt engineering
  • Output parsing
Ops
  • Docker Compose
  • Grafana
  • Logging
Back to the start

Data-driven crash optimisation