Coder Social home page Coder Social logo

erfaniaa / binance-futures-trading-bot Goto Github PK

View Code? Open in Web Editor NEW
373.0 9.0 93.0 70 KB

Easy-to-use multi-strategic automatic trading for Binance Futures with Telegram integration

License: GNU General Public License v3.0

Python 100.00%
crypto python binance bot cryptocurrency futures trading trading-bot algo-trading bitcoin binance-api binance-bot cryptocurrency-trading-bot auto-trading binance-futures python3 telegram telegram-bot robot trading-robot

binance-futures-trading-bot's Introduction

Binance Futures Trading Bot

Easy-to-use multi-strategic automatic trading for Binance Futures with Telegram integration

Features

  • You can run it fast and it's easy to use.
  • This project can handle multiple strategies at the same time.
  • There are no complexities and no database usage in this project. Even dependencies are a few.
  • It's easy to modify and customize.
  • It automatically stores recent candles that can be used for machine learning model input.
  • You can read the code for educational purposes.
  • You can be notified with Telegram messages

Run

  1. Clone the repository.
  2. Generate a Binance API key (with Futures access) and put it in credentials.py.
  3. Run pip3 install -r requirements.txt.
  4. Run python3 init_indicators_dict.py.
  5. Run python3 init_orders_dict.py.
  6. Run python3 main.py.

This will run an example bot on trading Bitcoin with 4 strategies simultaneously.

Config

To write custom bots you can:

  • Set an initial indicators setting in init_indicators_dict.py (because we are handling indicators in the client side with pickle files).
  • Set an initial orders setting in init_orders_dict.py (because we are handling orders in the client side with pickle files).
  • Define new indicators in indicators.py.
  • Define a new strategy in main.py (especially inside is_it_time_to_open_long_position and is_it_time_to_open_short_position functions).
  • Config your bot settings in config.py.

Note: If you define any machine learning model, you can use recent_prices_list as its input.

Warning: Binance has a maximum limit of 10 take-profit and stop-loss open orders, therefore do not use more than 5 strategies at the same time.

Telegram Config

  1. Firstly, you need to create a Telegram bot, so talk to @botfather.
  2. Secondly, need to know your own Telegram user ID, so the bot will know who to send messages to. Talk to @userinfobot to get this information.
  3. Thirdly, you have to /start your bot. Open up a private message with your bot by searching its username, then hit the start button.
  4. Finally, set TELEGRAM_API_KEY and TELEGRAM_USER_ID in credentials.py, and SEND_TELEGRAM_MESSAGE in config.py.

To-do

  • Import modules, not variables.
  • Use classes and make main.py smaller.
  • Add more indicators to indicators.py.
  • Find a better way to handle error codes.
  • Unify get candles functions.

See Also

  • Crypto Trading Strategy Backtester
  • Binance Spot Trading Bot
  • Finestel: Our automated trading bot can be used on Finestel & Finestel Pro: a crypto copy trading platform where pro traders & asset managers can connect their exchange accounts and manage their clients and communities of investors’ assets by using Finestel/Finestel Pro in conjunction with our Binance futures bot. Investors have the opportunity to profit the same as you while learning from more experienced traders.

Credits

Erfan Alimohammadi and Amir Reza Shahmiri

binance-futures-trading-bot's People

Contributors

erfaniaa avatar mo1ein avatar 0xnima avatar ricardospinoza avatar smzerehpoush avatar xeonbloomfield avatar

Stargazers

 avatar  avatar dgo2dance avatar  avatar Keith Grahams avatar  avatar  avatar Omar Nagy avatar IMED KHED  avatar Statanis 123 avatar  avatar  avatar  avatar Adrian_1967 avatar Syarif Ridhohidayatulloh avatar Grobu avatar Amir M Pirhosseinloo avatar Murat Bee avatar Dmitriy Zaviyalov avatar  avatar Ivan avatar  avatar  avatar  avatar  avatar  avatar  avatar mohamed ahmed avatar  avatar Ali Barati avatar Mario J. Pinheiro avatar Artur Kutsevol avatar Changhwan Joe avatar zhenglou avatar  avatar  avatar dddd avatar Matheus Genehr Rodrigues da Silva avatar  avatar  avatar  avatar  avatar John Owen Nixon avatar  avatar  avatar  avatar 0xrinegade avatar DaraZare avatar  avatar  avatar  avatar Guancheng Chen avatar  avatar  avatar Artin Mohammadi avatar  avatar MacBobby Chibuzor avatar BQdev avatar Min avatar Tom avatar Patrick Madden avatar Awais Ali avatar  avatar  avatar  avatar  avatar  avatar UnoBruno | CryptoCartoons avatar Aqib avatar  avatar  avatar Liam avatar  avatar G_will avatar Sicheng avatar G. Gökçe Ateş avatar Vasco Lameiras avatar  avatar Евгений Матвеев avatar Matveev avatar  avatar Andy Lee avatar  avatar Artem Zharkikh avatar max avatar Pablo Pinea avatar Miguel Enes avatar  avatar  avatar Noneplayers avatar Bilge Kağan Toprak avatar cque7 avatar Valery Asiryan avatar Robert Valentak avatar SU avatar İbrahim Dinç avatar V I avatar  avatar  avatar Daniel Law avatar

Watchers

Ababii Alexandr avatar  avatar  avatar  avatar  avatar  avatar duchu.nft avatar Bala Bsm avatar  avatar

binance-futures-trading-bot's Issues

Project structure needs improvement

Hello, I'm very interested in this project development thou I noticed that many things could be enhanced.
Among them:

  1. main.py - file structure, imports and functions should be adjusted.
  2. Some of the variables should be moved to config
is_price_increasing = False
is_price_decreasing = False
is_macd_increasing = False
is_macd_decreasing = False
is_macd_positive = False
is_macd_negative = False
account_available_balance = 0
total_account_balance = 0
is_bot_started = False
  1. Do not use star imports (as this is known to be programming anti-pattern in Python)
  2. Make project structure by decomposing logic, introducing OOP
  3. Improve logging by logging strictly in JSON formats (thus logs can be analyzed and processed by other tools)
  4. Create separate config file (in JSON format) or let the user specify variables by the .env file - for the ease of use

Plus, code style is not so good, pre-commit needs to be included in the project.
If you find my message useful, then message me an email - I can help in development by guiding and reviewing, but not so much by commits.
Best Regards, Bulat

PM WARNING ERROR/WARNING in set_position_mode (this may happen normally when position mode is unchanged): (400, -4059, 'No need to change position side.', {'Content-Type': 'application/json', 'Content-Length': '55', 'Connection': 'keep-alive', 'Date': 'Tue, 02 May 2023 09:18:20 GMT', 'Server': 'Bengine', 'X-MBX-USED-WEIGHT-1M': '43', 'x-response-time': '4ms', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 65572e59b8765f5b1f17936c65131ad6.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'SIN5-C1', 'X-Amz-Cf-Id': 'pBam6mPl-ebI87BMFNl0CLd2GXVnuAzBQPrhTLBSyn6hrBHxSCnWLQ=='})

Having issue like this, any solution to solve this?

multiple pair

hi, does this support multiple pair or just 1 per time

how ti fix error

PS C:\Users\yhon\Downloads\binance-futures-trading-bot-main\binance-futures-trading-bot-main> python main.py
Traceback (most recent call last):
File "C:\Users\yhon\Downloads\binance-futures-trading-bot-main\binance-futures-trading-bot-main\main.py", line 61, in
start_datetime: datetime.datetime,
AttributeError: type object 'datetime.datetime' has no attribute 'datetime'

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.