{"id":29072744,"url":"https://github.com/praying/binance-grid-bot-go","last_synced_at":"2025-10-16T00:09:34.960Z","repository":{"id":299246968,"uuid":"1002261412","full_name":"Praying/binance-grid-bot-go","owner":"Praying","description":"A high-frequency grid trading bot for Binance Futures, written in Go.","archived":false,"fork":false,"pushed_at":"2025-06-23T15:37:03.000Z","size":114,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-23T16:54:15.701Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Praying.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-15T04:28:10.000Z","updated_at":"2025-06-23T15:37:06.000Z","dependencies_parsed_at":"2025-06-15T15:45:48.280Z","dependency_job_id":"a178bb00-5785-420c-a87e-39b63821ad89","html_url":"https://github.com/Praying/binance-grid-bot-go","commit_stats":null,"previous_names":["praying/binance-grid-bot-go"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Praying/binance-grid-bot-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Praying%2Fbinance-grid-bot-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Praying%2Fbinance-grid-bot-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Praying%2Fbinance-grid-bot-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Praying%2Fbinance-grid-bot-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Praying","download_url":"https://codeload.github.com/Praying/binance-grid-bot-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Praying%2Fbinance-grid-bot-go/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262270426,"owners_count":23285165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-27T14:08:47.674Z","updated_at":"2025-10-16T00:09:34.955Z","avatar_url":"https://github.com/Praying.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Binance Futures Grid Trading Bot\n\n[![Go Version](https://img.shields.io/badge/Go-1.23+-blue.svg)](https://golang.org/dl/)\n[![License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Praying/binance-grid-bot-go)](https://goreportcard.com/report/github.com/Praying/binance-grid-bot-go)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA high-frequency grid trading bot for Binance Futures, written in Go. It supports both live trading and historical data backtesting to help you develop and verify your trading strategies.\n\n## Features\n\n- **Live Trading Mode**: Connects to Binance API to trade in real-time.\n- **Backtesting Mode**: Test your strategy on historical K-line data.\n- **Automatic Data Downloader**: Automatically downloads historical data for backtesting.\n- **State Persistence**: Saves the bot's state (grid orders) for graceful restarts in live mode.\n- **Detailed Configuration**: Highly configurable via a `config.json` file.\n- **Structured Logging**: Uses `zap` for structured, leveled logging.\n- **Backtest Reporting**: Generates a performance report after each backtest run.\n\n## Architecture\n\nThe bot's workflow is divided into two main modes: Live Trading and Backtesting.\n\n```mermaid\ngraph TD\n    A[Start Application] --\u003e B{Choose Mode?};\n    B -- Live Mode --\u003e C[Run Live Bot];\n    B -- Backtest Mode --\u003e D[Run Backtest];\n\n    subgraph Live Trading\n        C --\u003e C1[Load Config];\n        C1 --\u003e C2[Initialize Live Exchange];\n        C2 --\u003e C3[Load State ];\n        C3 --\u003e C4[Start Bot Logic];\n        C4 --\u003e C5[Listen to WebSocket];\n        C5 --\u003e C6[Place/Cancel Orders];\n        C6 --\u003e C7[Save State on Exit];\n    end\n\n    subgraph Backtesting\n        D --\u003e D1[Load Config];\n        D1 --\u003e D2{Need to Download Data?};\n        D2 -- Yes --\u003e D3[Download Historical Data];\n        D2 -- No --\u003e D4[Load Local Data];\n        D3 --\u003e D4;\n        D4 --\u003e D5[Initialize Backtest Exchange];\n        D5 --\u003e D6[Process Data Tick-by-Tick];\n        D6 --\u003e D7[Simulate Trades];\n        D7 --\u003e D8[Generate Report];\n    end\n\n    style C fill:#c9f,stroke:#333,stroke-width:2px;\n    style D fill:#9cf,stroke:#333,stroke-width:2px;\n```\n\n## Getting Started\n\n### Prerequisites\n\n- [Go](https://golang.org/dl/) version 1.23 or higher.\n- A Binance account with API keys (for live trading).\n\n### Installation\n\n1.  Clone the repository:\n    ```bash\n    git clone https://github.com/your-username/binance-grid-bot-go.git\n    cd binance-grid-bot-go\n    ```\n\n2.  Install dependencies:\n    ```bash\n    go mod tidy\n    ```\n\n3.  Build the executable:\n    ```bash\n    go build -o grid-bot ./cmd/bot/main.go\n    ```\n\n### Configuration\n\nBefore running the bot, you need to set up your `config.json` file.\n\n1.  Rename `config.example.json` to `config.json` (or create a new one).\n2.  Edit the parameters:\n\n| Parameter         | Type    | Description                                                                                             |\n| ----------------- | ------- | ------------------------------------------------------------------------------------------------------- |\n| `APIKey`          | string  | Your Binance API Key.                                                                                   |\n| `SecretKey`       | string  | Your Binance Secret Key.                                                                                |\n| `IsTestnet`       | boolean | Set to `true` to use the Binance Testnet, `false` for the production environment.                       |\n| `Symbol`          | string  | The trading symbol (e.g., \"BTCUSDT\"). This is the default for live mode.                                |\n| `GridSpacing`     | float64 | The spacing between grid lines (e.g., 0.005 for 0.5%).                                                  |\n| `GridValue`       | float64 | The value (in quote currency) for each grid order.                                                      |\n| `Leverage`        | int     | The leverage to use for trading.                                                                        |\n| `ReturnRate`      | float64 | The expected price return ratio that triggers the bot to reset its grid (e.g., 0.2 for 20%).            |\n| `MaxActiveGrids`  | int     | The maximum number of active buy and sell orders at any time.                                           |\n| `LogConfig`       | object  | Configuration for logging (`Level`, `Path`, `MaxSize`, `MaxBackups`, `MaxAge`, `Compress`).               |\n\n## Usage\n\nThe bot can be started via the command line with different flags to control its operation.\n\n### Live Trading Mode\n\nThis is the default mode. It will connect to Binance and start trading based on your configuration.\n\n```bash\n./grid-bot --config config.json --mode live\n```\n\nThe bot will save its state to `grid_state.json` upon graceful shutdown (Ctrl+C).\n\n### Backtesting Mode\n\nThe backtest mode allows you to test your strategy on historical data.\n\n#### Option 1: Auto-Download Data\n\nThe bot can download the required K-line data for you. Specify the symbol, start date, and end date.\n\n```bash\n./grid-bot --mode backtest --symbol BNBUSDT --start 2024-01-01 --end 2024-02-01\n```\nThe data will be saved as a `.csv` file in the `data/` directory.\n\n#### Option 2: Use Local Data\n\nIf you already have a `.csv` file with historical data, you can use the `--data` flag. The symbol will be automatically inferred from the filename (e.g., `BNBUSDT-2024-01-01-2024-02-01.csv` -\u003e `BNBUSDT`).\n\n```bash\n./grid-bot --mode backtest --data data/BNBUSDT-2024-01-01-2024-02-01.csv\n```\n\nAfter the backtest is complete, a detailed performance report will be printed to the console.\n\n## Development\n\nContributions are welcome! Please feel free to submit a pull request or open an issue.\n\n## Disclaimer\n\nTrading cryptocurrencies involves high risk and may not be suitable for all investors. The use of trading bots can result in substantial financial losses. Use this software at your own risk. The authors are not responsible for any financial losses you may incur.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpraying%2Fbinance-grid-bot-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpraying%2Fbinance-grid-bot-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpraying%2Fbinance-grid-bot-go/lists"}