This project implements an automated trading bot using the Binance API. It analyzes moving averages to identify buying and selling opportunities for assets, operating continuously.
The bot performs the following steps:
-
Data Retrieval:
- Uses the Binance API's
get_klines
function to fetch the price history (candlesticks) of a specified asset. - Converts the data into a pandas DataFrame for easier indicator calculations.
- Uses the Binance API's
-
Strategy:
- Calculates two moving averages: a short-term one (7 periods) and a long-term one (40 periods).
- Compares the moving averages:
- If the short-term average exceeds the long-term average, the bot buys the asset.
- If the short-term average falls below the long-term average, the bot sells the asset.
-
Order Execution:
- Operates through market orders, buying or selling the specified amount.
-
Continuous Loop:
- Repeats the above steps every hour, ensuring real-time operations.
To run this project, you need the following environment:
- Operating System: Windows, macOS, or Linux
- Python: Version 3.8 or higher
- Required Libraries:
pandas
python-binance
python-dotenv
Make sure to install the dependencies using the command:
pip install -r requirements.txt
Important: Never expose your API private keys in public repositories, such as GitHub. Use .env
files to securely store your credentials. This project uses the python-dotenv
library to load keys directly from the .env
file. Example configuration:
.env
:
KEY_BINANCE=YourAPIKey
SECRET_BINANCE=YourSecretKey
This bot is not an investment recommendation. It was created for educational purposes only. The cryptocurrency market is volatile and carries significant risks. Before using this code, ensure you understand the risks involved.
We suggest taking the course offered by the Varos platform for a better understanding of this bot's functionality and trading strategies.
This project is distributed under the MIT License. See the LICENSE
file for more details.