back to home

ccxt / binance-trade-bot

Automated cryptocurrency trading bot

8,623 stars
2,317 forks
190 issues
PythonDockerfileProcfile

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing ccxt/binance-trade-bot in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/ccxt/binance-trade-bot)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

Binance Trade Bot > An automated cryptocurrency trading bot for Binance Author Created by **Eden Gaon** Project Status Quick Deploy Community Join our growing community on Telegram to discuss strategies, get help, or just chat! Community Telegram Chat https://t.me/binancetradebotchat Why? This project was inspired by the observation that all cryptocurrencies pretty much behave in the same way. When one spikes, they all spike, and when one takes a dive, they all do. _Pretty much_. Moreover, all coins follow Bitcoin's lead; the difference is their phase offset. So, if coins are basically oscillating with respect to each other, it seems smart to trade the rising coin for the falling coin, and then trade back when the ratio is reversed. How? The trading is done in the Binance market platform, which of course, does not have markets for every altcoin pair. The workaround for this is to use a bridge currency that will complement missing pairs. The default bridge currency is Tether (USDT), which is stable by design and compatible with nearly every coin on the platform. Coin A → USDT → Coin B The way the bot takes advantage of the observed behaviour is to always downgrade from the "strong" coin to the "weak" coin, under the assumption that at some point the tables will turn. It will then return to the original coin, ultimately holding more of it than it did originally. This is done while taking into consideration the trading fees. Coin A → USDT → Coin B Coin B → USDT → Coin C ... Coin C → USDT → Coin A The bot jumps between a configured set of coins on the condition that it does not return to a coin unless it is profitable in respect to the amount held last. This means that we will never end up having less of a certain coin. The risk is that one of the coins may freefall relative to the others all of a sudden, attracting our reverse greedy algorithm. Binance Setup • Create a Binance account (Includes my referral link, I'll be super grateful if you use it). • Enable Two-factor Authentication. • Create a new API key. • Get a cryptocurrency. If its symbol is not in the default list, add it. Tool Setup Install Python dependencies Run the following line in the terminal: . Create user configuration Create a .cfg file named based off , then add your API keys and current coin. **The configuration file consists of the following fields:** • **api_key** - Binance API key generated in the Binance account setup stage. • **api_secret_key** - Binance secret key generated in the Binance account setup stage. • **testnet** - Default is false, whether to use the testnet or not • **current_coin** - This is your starting coin of choice. This should be one of the coins from your supported coin list. If you want to start from your bridge currency, leave this field empty - the bot will select a random coin from your supported coin list and buy it. • **bridge** - Your bridge currency of choice. Notice that different bridges will allow different sets of supported coins. For example, there may be a Binance particular-coin/USDT pair but no particular-coin/BUSD pair. • **tld** - 'com' or 'us', depending on your region. Default is 'com'. • **hourToKeepScoutHistory** - Controls how many hours of scouting values are kept in the database. After the amount of time specified has passed, the information will be deleted. • **scout_sleep_time** - Controls how many seconds are waited between each scout. • **use_margin** - 'yes' to use scout_margin. 'no' to use scout_multiplier. • **scout_multiplier** - Controls the value by which the difference between the current state of coin ratios and previous state of ratios is multiplied. For bigger values, the bot will wait for bigger margins to arrive before making a trade. • **scout_margin** - Minimum percentage coin gain per trade. 0.8 translates to a scout multiplier of 5 at 0.1% fee. • **strategy** - The trading strategy to use. See for more information • **buy_timeout/sell_timeout** - Controls how many minutes to wait before cancelling a limit order (buy/sell) and returning to "scout" mode. 0 means that the order will never be cancelled prematurely. • **scout_sleep_time** - Controls how many seconds bot should wait between analysis of current prices. Since the bot now operates on websockets this value should be set to something low (like 1), the reasons to set it above 1 are when you observe high CPU usage by bot or you got api errors about requests weight limit. Environment Variables All of the options provided in can also be configured using environment variables. Paying Fees with BNB You can use BNB to pay for any fees on the Binance platform, which will reduce all fees by 25%. In order to support this benefit, the bot will always perform the following operations: • Automatically detect that you have BNB fee payment enabled. • Make sure that you have enough BNB in your account to pay the fee of the inspected trade. • Take into consideration the discount when calculating the trade threshold. Notifications with Apprise Apprise allows the bot to send notifications to all of the most popular notification services available such as: Telegram, Discord, Slack, Amazon SNS, Gotify, etc. To set this up you need to create a apprise.yml file in the config directory. There is an example version of this file to get you started. If you are interested in running a Telegram bot, more information can be found at Telegram's official documentation. Run the bot Run the server that returns the information Docker The official image is available here and will update on every new change. If you only want to start the SQLite browser Backtesting You can test the bot on historic data to see how it performs. Feel free to modify that file to test and compare different settings and time periods Developing To make sure your code is properly formatted before making a pull request, remember to install pre-commit: The scouting algorithm is unlikely to be changed. If you'd lik…