[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-116217":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":10,"pushedAt":25,"updatedAt":26,"readmeContent":27,"aiSummary":28,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":29,"discoverSource":30},116217,"hft-for-dummies","bulletxyz\u002Fhft-for-dummies","bulletxyz","Companion code for the HFT for dummies series: a SOL-USD market maker on Bullet, built up one post at a time","https:\u002F\u002Fapp.bullet.xyz\u002Ftrade?r=HFT4DUMMIES",null,"Rust",63,17,4,5,0,2,8,52.49,"Apache License 2.0",false,"master",true,[],"2026-11-03 02:45:44","2026-11-23 16:46:19","# HFT for dummies\n\nCode for the *HFT for dummies* series: a market maker that quotes SOL-USD on\n[Bullet](https:\u002F\u002Fapp.bullet.xyz\u002Ftrade?r=HFT4DUMMIES), priced off Binance's SOL\nperpetual future (perp). Each post is one change to this repo.\n\n> Market making can lose money. The bot starts in **dry run**: no key, no\n> orders.\n\n## What we're building\n\n```mermaid\nflowchart LR\n    BIN[\"\u003Cb>Binance\u003C\u002Fb>\u003Cbr\u002F>market data WS\u003Cbr\u002F>\u003Ci>Parts 4, 5, 10\u003C\u002Fi>\"]\n    subgraph BOT[\"Your bot\"]\n        direction LR\n        RX[\"\u003Cb>Receive + parse\u003C\u002Fb>\u003Cbr\u002F>typed events\u003Cbr\u002F>\u003Ci>Parts 5, 9\u003C\u002Fi>\"]\n        FAIR[\"\u003Cb>Fair price\u003C\u002Fb>\u003Cbr\u002F>Binance mid + basis\u003Cbr\u002F>\u003Ci>Part 2\u003C\u002Fi>\"]\n        STRAT[\"\u003Cb>Strategy\u003C\u002Fb>\u003Cbr\u002F>quotes + inventory skew\u003Cbr\u002F>\u003Ci>Parts 2, 9\u003C\u002Fi>\"]\n        EXEC[\"\u003Cb>Executor\u003C\u002Fb>\u003Cbr\u002F>non-blocking submit\u003Cbr\u002F>\u003Ci>Parts 6, 7, 11\u003C\u002Fi>\"]\n    end\n    BUL[\"\u003Cb>Bullet\u003C\u002Fb>\u003Cbr\u002F>order API (HTTPS)\u003Cbr\u002F>\u003Ci>Parts 4, 10\u003C\u002Fi>\"]\n    BOOK[\"\u003Cb>Bullet book\u003C\u002Fb>\u003Cbr\u002F>venue mid \u002F trades\u003Cbr\u002F>\u003Ci>Part 5\u003C\u002Fi>\"]\n    FILLS[\"\u003Cb>Acks + fills\u003C\u002Fb>\u003Cbr\u002F>event listener\u003Cbr\u002F>\u003Ci>Parts 5, 6\u003C\u002Fi>\"]\n    STATE[\"\u003Cb>Inventory \u002F state\u003C\u002Fb>\u003Cbr\u002F>feeds Strategy\u003Cbr\u002F>\u003Ci>Part 2\u003C\u002Fi>\"]\n\n    BIN -- WS --> RX --> FAIR --> STRAT --> EXEC -- orders --> BUL\n    BUL --> BOOK\n    BOOK -. \"book WS (secondary)\" .-> RX\n    BUL -- \"acks \u002F fills\" --> FILLS --> STATE -- state --> STRAT\n\n    classDef ref stroke:#58a6ff,stroke-width:2px\n    classDef venue stroke:#3fb950,stroke-width:2px\n    classDef bot stroke:#bc8cff,stroke-width:2px\n    classDef state stroke:#d29922,stroke-width:2px\n    class BIN,RX,FAIR ref\n    class BUL,BOOK,FILLS venue\n    class STRAT,EXEC bot\n    class STATE state\n```\n\nBinance moves, we reprice, requote on Bullet, and fills feed back into\ninventory. The series makes that loop fast: from a Binance update to our new\norder resting on Bullet.\n\n## Run it\n\nNeeds [Rust](https:\u002F\u002Frust-lang.org\u002Finstall.html). Tested on Mac and Linux.\n\n```sh\ncargo run\n```\n\nAfter a minute of warm-up it quotes, on paper:\n\n```text\nquoting\npaper: place side=Buy price=100.556 size=0.05\npaper: place side=Sell price=100.758 size=0.05\nbullet mid 100.656 | fair 100.6573 | our bid 100.556 ask 100.758 | position 0 | pnl $0 (fees $0)\n```\n\nSettings are in `bot.toml`. Using a coding agent? Ask it to *\"set me up and\nrun the bot\"*; `AGENTS.md` has its instructions.\n\n## Going live\n\n1. **Deposit $20 USDC** on [Bullet](https:\u002F\u002Fapp.bullet.xyz\u002Ftrade?r=HFT4DUMMIES)\n   (referral code `HFT4DUMMIES`).\n2. **Make the bot a key:** `cargo run -- keygen`. It writes `bot.key`\n   (git-ignored) and prints a link to\n   [Delegate Accounts](https:\u002F\u002Fapp.bullet.xyz\u002Fdelegate-accounts) with the\n   key filled in: click **Confirm Delegation**. A delegate can trade but\n   never withdraw.\n3. **Run it live:** `cargo run -- --live`. Two orders appear either side of\n   the price, marked ▸ in the app's order book (set its\n   granularity to 0.1 or finer). Ctrl-C cancels them.\n\nLimits in `bot.toml`: at most 0.1 SOL held, stops after a $2 loss. Stopping\ndoesn't close your position, and the bot cancels any SOL-USD orders you\nplace by hand on the same account.\n\n## The code\n\nFeeds turn the world into **events**, the market maker answers with\n**intents**, an executor carries them out.\n\n| File | |\n|------|--|\n| `src\u002Fevents.rs` | Every `Event` in and `Intent` out. Start here. |\n| `src\u002Fbot.rs` | The loop that wires it together |\n| `src\u002Fbinance.rs`, `src\u002Fbullet.rs` | Feeds; `bullet.rs` also sends orders |\n| `src\u002Fbook.rs` | Our copy of the Bullet order book |\n| `src\u002Ffair_value.rs` | Binance mid + average Binance→Bullet gap |\n| `src\u002Fstrategy.rs` | Bid and ask prices: spread, skew, limits |\n| `src\u002Fmarket_maker.rs` | Events in, intents out. No I\u002FO, fully tested |\n| `src\u002Finventory.rs` | Position and PnL, changed only by fills |\n| `src\u002Fexecutor.rs` | Live orders, or paper ones in dry run |\n\n## Following along\n\nEach part is one PR on `master`, tagged `part-N`, with a short guide in\n[`docs\u002Fparts\u002F`](docs\u002Fparts\u002F). `git checkout part-N` runs the bot as of that post.\n\n| Part | Post | Guide |\n|------|------|------|\n| 1 | Introduction: the tick-to-trade loop | — |\n| 2 | Hello World | [guide](docs\u002Fparts\u002F02-hello-world.md) · [`part-2`](https:\u002F\u002Fgithub.com\u002Fbulletxyz\u002Fhft-for-dummies\u002Ftree\u002Fpart-2) |\n| 3 | Telemetry and latency measurement | [guide](docs\u002Fparts\u002F03-telemetry.md) · [`part-3`](https:\u002F\u002Fgithub.com\u002Fbulletxyz\u002Fhft-for-dummies\u002Ftree\u002Fpart-3) |\n| 4 | Colocation on AWS | [guide](docs\u002Fparts\u002F04-colocation.md) · [`part-4`](https:\u002F\u002Fgithub.com\u002Fbulletxyz\u002Fhft-for-dummies\u002Ftree\u002Fpart-4) |\n| 5 | Streaming market data | [guide](docs\u002Fparts\u002F05-streaming.md) · [`part-5`](https:\u002F\u002Fgithub.com\u002Fbulletxyz\u002Fhft-for-dummies\u002Ftree\u002Fpart-5) |\n| 6 | Order execution | [guide](docs\u002Fparts\u002F06-execution.md) · [`part-6`](https:\u002F\u002Fgithub.com\u002Fbulletxyz\u002Fhft-for-dummies\u002Ftree\u002Fpart-6) |\n| 7 | Rate limits | coming |\n| 8 | Linux tuning | coming |\n| 9 | Optimising the hot path | coming |\n| 10 | Network optimisation on AWS | coming |\n| 11 | Nonce management | coming |\n\n## Scoreboard\n\nThe [standard benchmark](docs\u002Fparts\u002F03-telemetry.md#the-scoreboard) at the end\nof each part, live with `bench-live.toml`: Part 3 on a laptop, the rest on the\nTokyo server over Bullet's direct endpoint. It splits one trip around the loop:\n\n```text\n Binance update ──► reaches us ──► waits in our queue ──► we decide ──► order to Bullet ──► our order is open\n                   binance→us         queue             tick-to-trade    order-to-live\n └─────────────────────────────────────── end-to-end ───────────────────────────────────────┘\n```\n\n| Part | end-to-end p50 \u002F p99 | Binance → us p50 | tick-to-trade p50 | order-to-live p50 \u002F p99 | queue p99 \u002F max |\n|---|---|---|---|---|---|\n| 3 (laptop baseline) | 211 \u002F 369 ms | (clock off) | 6 µs | (clock off) | 337 \u002F 657 ms |\n| 4 | 26.8 \u002F 110 ms | 1.6 ms | 1 µs | 24.6 \u002F 89 ms | 93 \u002F 350 ms |\n| 5 | 25.5 \u002F 121 ms | 1.6 ms | 1 µs | 23.2 \u002F 119 ms | 100 \u002F 540 ms |\n| 6 | 5.6 \u002F 71 ms | 1.5 ms | 2 µs | 3.9 \u002F 70 ms | 0.01 \u002F 20 ms |\n\nEvery server run used the same machine, Part 8's 4-core c8g.xlarge (Part 4\nsets up a c8g.large). Parts 4 and 5 are single 10-minute runs.\n\nParts 6-11 are each the median of three 5-minute runs, taken in rotation so\nevery part saw the same conditions at Bullet. One run after another, Bullet's\nspeed drifted more over an evening than these parts change it. p99 is noisy from run to run.\n\n## Incidents\n\nThings that went wrong while building this live, and what each taught us.\nDetails in each part's guide.\n\n| Part | Incident | Lesson |\n|------|----------|--------|\n| 2 | Binance socket went silent, no error | Silence isn't \"nothing happened\": time out and reconnect |\n| 2 | Bullet's websocket dropped a fill | Streams notify, records are truth: reconcile fills |\n| 2 | An order filled during shutdown | Check fills once more before reporting |\n| 2 | A cancel raced a fill | \"Order not found\" is normal: plan for it (Part 6 avoids it) |\n| 3 | Laptop clock 288 ms behind: messages \"from the future\" | Sync clocks before measuring across machines |\n| 4 | Our latency probe was timing DNS lookups | Know exactly what your tool measures |\n| 5 | A 3 s heartbeat timeout fired falsely on wifi | Timeouts trade false alarms against reaction time |\n| 6 | Order confirmations arrived before our own request returned | Without waiting, expect any order of events |\n\n## License\n\nApache-2.0. Not financial advice.\n","这是一个面向初学者的高频做市教学项目，实现了一个在Bullet交易所对SOL-USD交易对进行自动报价的做市机器人。核心功能包括：实时订阅Binance永续合约行情并计算公允价格、基于库存偏差动态调整买卖价差与挂单量、通过非阻塞HTTP API向Bullet提交订单，并闭环处理成交与状态更新；技术上采用Rust构建，强调类型安全、低延迟事件处理与清晰的模块分层（接收、定价、策略、执行）。项目默认以模拟模式运行，支持平滑过渡到实盘，适用于算法交易学习、加密市场微观结构实践及做市逻辑原型验证。","2026-11-24 04:53:11","CREATED_QUERY"]