bybit-ws
An MCP server that enables AI agents to scan the market, manage positions, and retrieve trading metrics for Bybit through natural language commands.
README
bybit-ws — AI-Native Trading Engine
Bollinger Grid + 8 strategies. REST API + MCP. Built for AI agents.
What is it?
A production-grade trading monitor for Bybit that runs 24/7, scans for opportunities, enters positions, manages risk, and logs everything — all accessible through an HTTP API designed for AI agents.
Not a bot. An engine. Your AI agent calls /scan, picks signals, calls /enter. The engine handles execution, SL/TP, risk limits, and reporting.
Quick Start (for AI Agents)
git clone https://github.com/poliakarmai/bybit-ws.git
cd bybit-ws
cp config.example.yaml ~/.config/bybit-ws/config.yaml
# Set BYBIT_API_KEY and BYBIT_API_SECRET
python3 -m bybit_ws.main
from bybit_ws_sdk import Monitor
m = Monitor("http://localhost:8766")
signals = m.scan(mode="long", limit=5)
for s in signals["signals"]:
if s["score"] >= 7.0:
m.enter(s["symbol"], "Buy", s["qty"])
Strategies
| # | Strategy | Leverage | Trigger |
|---|---|---|---|
| 1 | BB Grid LONG | 3x | BB < 25% Daily, scoring ≥ 5.5 |
| 2 | BB Grid SHORT | 3x | BB > 85% Daily, Tier A/B |
| 3 | Junk SHORT | 3x | Daily pump ≥ 80%, no SL, hard stop |
| 4 | SL Re-entry | 3x | Ladder after stop-loss (-5%, -10%, -15%) |
| 5 | BB Scalp M5 ⚡ | 10x | BB touch M5 + RSI filter |
| 6 | Mean Revert ⚡ | 10x | BB% < 5% or > 95% Daily |
| 7 | Funding Momentum ⚡ | 10x | Extreme funding + BB + trend |
| 8 | DCA | 3x | Add to losing positions at lower levels |
All strategies with parameters →
Architecture
AI Agent (Claude Code / Codex / Cursor / Hermes)
│
├── REST API (port 8766): scan, enter, close, health
├── MCP Server: scan_market, get_positions, get_metrics
└── Python SDK: Monitor + WebhookHandler classes
│
bybit-ws (30s cycle, systemd or Docker)
├── 8 strategies with scoring + risk checks
├── Position sizing: dynamic % of deposit
├── Correlation check: block entries >0.8
├── X10 safety: daily loss stop, ATR validation
├── Auto SL/TP via trading-stop
└── Dashboard: SVG with winrate, margin, regime
Risk Management
- Position sizing: dynamic margin = deposit × risk% / positions × score
- Drawdown guard: auto-close all at -15% from peak
- Daily loss stop: halt at -$50/day
- Correlation block: reject entries if ≥2 positions correlated >0.8
- X10 limits: max 3 losing x10 trades → 24h cooldown
- Cascade protection: market-close if price 2x closer to liquidation than SL
- Banned symbols: config-driven permanent ban
Files
| File | For |
|---|---|
QUICKSTART.md |
5-minute setup |
DESIGN.md |
Full architecture for devs & agents |
STRATEGIES.md |
All 8 strategies + roadmap |
ERRORS.md |
Error reference: what + fix |
WEBHOOKS.md |
Alert payloads & parsing |
CHANGELOG.md |
Version history |
openapi.yaml |
OpenAPI 3.0 spec |
bybit_ws_sdk.py |
Python SDK |
config.example.yaml |
Full config with comments |
Requirements
- Python 3.11+
- Bybit Unified Trading Account with API keys
- Linux server (VPS $5/mo works) or Docker
License
MIT — see LICENSE.
Built for AI agents. Ready for yours.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.