Git Product home page Git Product logo

binance-spot-trading-bot's Introduction

Binance Spot Trading Bot (EMA Crossover Strategy)

This bot automates spot trading on Binance based on Exponential Moving Average (EMA) crossovers. When the short-term EMA crosses above the long-term EMA, it's an indication of upward momentum, and the bot places a buy order. Conversely, when the short-term EMA crosses below the long-term EMA, signaling potential downward momentum, the bot places a sell order.

How It Works:

In a continuous loop, the bot fetches the latest price for the given symbol and calculates the short and long EMAs.

Buy Order Logic:

If the short EMA is greater than the long EMA (indicating potential upward price movement) and the last action wasn't a buy, the bot places a buy order. After placing the buy order, the bot checks if the order was fully executed (FILLED status) before updating its last action.

Sell Order Logic:

If the short EMA is less than the long EMA (indicating potential downward price movement) and the last action wasn't a sell, the bot places a sell order. After placing the sell order, it checks if the order was fully executed before updating its last action.

Exception Handling:

If there's a timeout when communicating with Binance's API, the bot catches the exception and continues operation, ensuring the script doesn't terminate unexpectedly.

Usage

This bot is executed from the command line and requires the trading pair symbol, data-fetching interval, and the periods for the short and long EMAs as arguments. The bot then continually checks the EMA values and makes decisions based on the crossover strategy.

Requirments

  • Python3.x
  • Pip

Installation

pip install python-binance

Run

python run_bot.py <Symbol> <Interval> <Short EMA Period> <Long EMA Period>

Example: python run_bot.py BTCUSDT 1d 8 20

To Run in Background nohup python run_bot.py BTCUSDT 1d 8 20 &


The Above script was only tested on Ubuntu 18.04.6 LTS Distribution

Risk Warning

Remember, while the EMA crossover strategy is popular, it's essential to combine it with other indicators or methods for more robust trading signals. Always ensure you are comfortable with the risks before running any trading bot live.

Support This Project

First off, thank you for taking the time to consider supporting this project. It's built with a lot of hard work, dedication, and countless hours of coding.

If you've found any value in my work, and would like to support its continued development, consider making a donation. Every little bit helps in maintaining the project, covering costs, and encouraging further enhancements. Donate with Bitcoin (BTC)

Donate with BTC

Scan the QR code or send your donation to the address below:

BTC QR Code

BTC Address:

15AZJpmYEV2Q9fvf7DvQgTHcFgmNg2UcPz

Your generosity and support will always be appreciated!

binance-spot-trading-bot's People

Contributors

tahaabbas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.