RU
Interface: SimpleTradeBot — an open-source grid bot
The dashboard: bot status, grid levels, live orders and the event feed.

How it works

This is the grid algorithm from my own trading system, pulled out into an open project of its own. The bot runs a single instrument — a Bybit perpetual: it builds a ladder of limit orders from the current price, gives every filled level its own take-profit, and holds the whole position under a position-wide take-profit, stop-loss and trailing stop.

There is no database: all state lives in the memory of the process. That is a deliberate simplification rather than a gap — code like this reads start to finish, with no migrations, queues or background services. Two rules follow from it: on start the bot cancels its own leftover orders, and it will not take over a position it did not open.

Orders go to the exchange over REST, order states and executions arrive over the private socket, and the public trade stream feeds the strategy. Before every close the position is reconciled with the exchange: if it is already flat there, the close is cancelled — otherwise the order would not close a position but open an opposite one.

What it does

  • A ladder of levels from the current price: step in percent or in ticks, with progressions for both step and size.
  • A take-profit on every filled level — this is what a grid earns on in a flat market.
  • A position-wide take-profit, stop-loss and trailing stop.
  • Limits: how many orders to keep working and how large the position may grow.
  • A web interface: start, stop, close the position, grid levels, live orders and an event feed.
  • Demo trading, testnet and a live account switch with a single setting.
  • Every parameter lives in one configuration file; keys live in environment variables.
  • 51 unit tests over the grid maths, the position book and the whole trading cycle.

Technology

  • C#
  • .NET 9
  • ASP.NET Core
  • Bybit API V5
  • WebSocket
  • Docker
  • xUnit
  • GitHub Actions

Running it yourself

Six steps from an empty folder to a working bot. Run every command from the project root unless stated otherwise.

What you need

  • .NET 9 SDK or Docker
  • A Bybit account and an API key with the Trade permission
  • Any operating system: Windows, macOS or Linux
  1. Get the code

    git clone https://github.com/Snake0369/SimpleTradeBot.git

    The whole project is four small C# assemblies. No database, no message queue, no external services to install.

  2. Create a key on Bybit

    In the demo trading section create an API key with the Trade permission. A demo account runs on the real market with virtual money — that is where to start.

  3. Store the key

    dotnet user-secrets set "Bybit:ApiKey" "ваш-ключ"

    Run it from the src/SimpleTradeBot.Web folder; the secret goes in the same way under Bybit:ApiSecret. Keys do not belong in the configuration file: it lives in the repository, and a secret has no business being there. With Docker the keys are passed as environment variables — .env.example shows the shape.

  4. Set the instrument and the grid

    src/SimpleTradeBot.Web/appsettings.json

    The instrument, the direction, the grid step, the number of levels, the size, the take-profit, the stop-loss and the cap on position size all live in one file. Every parameter is documented in the project README.

  5. Run it

    dotnet run --project src/SimpleTradeBot.Web

    The interface opens at http://localhost:5080. With Docker it is the same: copy .env.example to .env, fill in the keys and run docker compose up --build.

  6. Press Start

    The bot builds a grid from the current price and goes to work. Two buttons sit next to it: “Close position” rebuilds the grid from the new price, “Stop” cancels the orders and closes the position at market.

Start on a demo account. The bot places real orders, and the settings shipped with it are an illustration, not a recommendation: the grid step, the size and the position cap have to be chosen for your instrument and your deposit. Trading perpetual contracts carries risk, and past results promise nothing.

All the code on GitHub

15 % for every client you refer

Know someone who needs a bot? Refer them — I pay 15 % of what they pay me. Across everything I build.

How it works

Have an idea or a task?

Tell me about it — let’s figure out the best way to make it happen.

Contact me