UPetit / python-binance-profit

Script to submit a buy order followed by an automatic sell OCO order
MIT License
47 stars 15 forks source link
automation bot crypto cryptocurrency trading

Welcome to python-binance-profit GitHub repository!

Notes

The script allows you to place a buy order and automatically place an OCO order to secure (and exit) your trade. It's using the binance API python wrapper from @sammchardy python-binance. If you want to create Binance account, here's my referral link: earn 10% commission on the fees from my trades.

Disclaimer

Even if the scripts are easy to understand, errors exists that's why the Issues section is important to report any bug that you may find. I recommend to use the latest release because it has been tested multiple times compared to the other branches.

Requirements

Note: If you're using Windows, you might need to install Microsoft Visual C++ 14.0+

Installation

⚠️ Please not that if the quantity and/or price formats are not following Binance rules, your Limit buy order won't be validated and the script will stop before submitting to order to the market.

How to know the prices formats ? Go to the Binance market of your symbol you want to trade, check the current prices and quantities going through the market to know how many decimals you can use for both of them. For instance for BTCUSDT: the BTC quantity is using 6 decimals and the USDT price is using 2 decimals.

  1. Run the script using the parameters you've just defined by replacing with your values: Limit buy order followed by an OCO sell order:
    python execute_orders.py --symbol YOUR_SYMBOL --buy_type limit --quantity YOUR_QUANTITY --price YOUR_PRICE --profit YOUR_PROFIT --loss YOUR_LOSS

    Example: If you want to trade BTC against USDT, buy 0.251897 BTC at 31488.69 USDT (per BTC) and then you want to sell it to make a 4% profit and a potential loss of 1%, you'll execute the script like this:

    python execute_orders.py --symbol BTCUSDT --buy_type limit --quantity 0.251897 --price 31488.69 --profit 4 --loss 1

    Market buy order followed by an OCO sell order:

    python execute_orders.py --symbol YOUR_SYMBOL --buy_type market --total TOTAL_AMOUNT --profit YOUR_PROFIT --loss YOUR_LOSS 

    Example: If you want to trade BTC against USDT, buy 100 USDT of BTC and then you want to sell it to make a 4% profit and a potential loss of 1%, you'll execute the script like this:

    python execute_orders.py --symbol BTCUSDT --buy_type market --total 100.0 --profit 4 --loss 1 

    Enjoy! Don't hesitate to send me feedbacks and report issues :) Thank you!