Create a one-shot TypeScript bot that reads the book, places a limit order, monitors it, and cancels the remainder.
This guide builds a deliberately small bot that places one credit-funded limit order and cleans up any unfilled quantity. It demonstrates the API lifecycle without hiding order state or precision handling behind an SDK.
The example can create a real order on your PaperDrill account, but it only uses simulated funds.
Review the selected symbol, side, price, and quantity before running it.
The bot uses scaled integers to move one price tick below the current best bid and submits the smallest quantity allowed by the market’s precision. That makes an immediate fill less likely, but another order can still match it at any time.
Run it
bun run bot.ts
The script prints the created order, polls it for roughly ten seconds, and cancels any remaining open quantity. Pressing Ctrl+C also attempts cancellation before exit.
Make it production-ready
Before turning this example into a long-running strategy: