- Saved searches
- Use saved searches to filter your results more quickly
- License
- szferguson/Binance-Trailing-Stop-Loss
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- Saved searches
- Use saved searches to filter your results more quickly
- gabroliveros/Trailing-stop-loss-for-python-binance
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Saved searches
- Use saved searches to filter your results more quickly
- License
- StephanAkkerman/Binance_Trailing_Stop_Loss
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Provides a dynamic stop-loss that automatically adjusts as the price increases or decreases (depending on mode specified)
License
szferguson/Binance-Trailing-Stop-Loss
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Binance Trailing Stop-Loss
Provides a dynamic stop-loss that automatically adjusts as the price increases or decreases (depending on mode specified)
Clone the repository
git clone https://github.com/sf04/Binance-Trailing-Stop-Loss
Install required libraries
apt-get install python-pip -y pip install ccxt
Then modify config.py and insert your API key and secret
$ python main.py --help usage: main.py [-h] --symbol SYMBOL --size SIZE --type TYPE [--interval INTERVAL] optional arguments: -h, --help show this help message and exit --symbol SYMBOL Market Symbol (Ex: NEO/BTC - NEO/USDT) --size SIZE How many satoshis (or USD) the stop loss should be placed above or below current price --type TYPE Specify whether the trailing stop loss should be in buying or selling mode. (Ex: 'buy' or 'sell') --interval INTERVAL How often the bot should check for price changes
Important note
If you are running in sell mode, it is assumed that you have already purchased the coins. If you are running in buy mode, it will use the total available balance in the base (USDT, BTC, etc). I will likely add an option later to specify investment ratio.
If the buy option is set, the bot will initially place a stop-loss size satoshis (or USD) above the current market price. As the price goes lower, the stop-loss will get dragged with it, staying no higher than the size specified. Once the price crosses the stop-loss price, a buy order is executed.
If the sell option is set, the bot will initially place a stop-loss size satoshis (or USD) below the current market price. As the price goes higher, the stop-loss will get dragged with it, staying no lower than the size specified. Once the price crosses the stop-loss price, a sell order is executed.
This is the amount in satoshis (or USD) you would like the stop-loss to be retained at. The difference between the current price and stop-loss will never be larger than this amount.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A simple and efective trailing stop-loss for the Binance API with dinamic adjust to the amplittude of the market.
gabroliveros/Trailing-stop-loss-for-python-binance
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
This is a simple trailing stop-loss for the Binance API that helps you avoid losses by automatically shifting the profit margin.
The use of this code is your complete responsibility when you decide to clone it and use it. The author of the code is exempt from liability for any loss of money that you may have in trading operations. Please review the code thoroughly before implementing it and put it to the test before executing actual operations.
Why is it better than other trailing systems?
- You can use it for any cryptocurrency. You are not limited to a specific pair.
- The trailing margin or loss margin that you decide to accept in case of a decrease in price is dynamically adjusted according to the size of the market (last 14 candles).
- You can adjust the percentage of the trailing stop-loss to the values you want.
The function is ready to implement in your own project.
Do not forget to be gentle and leave a star if it is useful to you.
Un simple Trailing stop-loss para la API de Binance que te ayuda a evitar pérdidas desplazando automáticamente el margen de ganancia.
Descargo de responsabilidad:
La utilización de este código es de tu completa responsabilidad cuando decides clonarlo y utilizarlo. El autor del código queda excento de responsabilidad ante cualquier pérdida de dinero que pudieras tener en operaciones de trading. Por favor, revisa bien el código antes de implementarlo y ponlo a prueba antes de ejecutar operaciones reales.
¿Por qué es mejor que otros sistemas de trailing?
- Lo puedes utilizar para cualquier criptomoneda. No estás limitado a un par en específico.
- El margen de trailing o margen de pérdida que decides aceptar en caso de disminuir el precio se ajusta de forma dinámica según la amplitud del mercado (últimas 14 velas).
- Puedes ajustar el porcentaje del Trailing stop-loss a los valores que desees.
La función está lista para implementar en tu propio proyecto.
No olvides ser gentil y dejar una estrella si te resulta de utilidad.
About
A simple and efective trailing stop-loss for the Binance API with dinamic adjust to the amplittude of the market.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A simple trailing stop loss for spot holdings written in Python. It can also send Telegram messages if your stop loss has been hit.
License
StephanAkkerman/Binance_Trailing_Stop_Loss
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Binance Trailing Stop Loss
As the name suggests this code is made for having an automated stop loss for trading spot on Binance.
Add your public and private API keys in the src/keys.py file.
The required packages to run this code can be found in the requirements.txt file. To run this file, execute the following code block:
$ pip install -r requirements.txt
Alternatively, you can install the required packages manually like this:
If you would like to get messages via Telegram if your stop loss is hit, follow the link in src/keys.py
There is no user interaction necessary. If you place a stop loss order after buying a coin on Binance, the program will calculate the percentual difference between the buying price and the first stop loss. This first stop loss is then used as a reference for further stop loss percentages.
There is a problem where the sockets can be closed or restarted once they have started running. Unfortunately, the developer of python-binance has not fixed this problem yet. So to fix this problem, you need to run $ python Linux/run.py which will restart the trailing stop loss program every 24 hours. That way the sockets won’t get disconnected and you won’t have any issues.
These OSes do not have the problem that Linux based system have. If you just run $ python src/main.py , it should work without issues.
- Market buy 1000 DOGE/USDT at 0,295$.
- Place a stop loss at 0,26$.
- Procentual difference is calculated: 13,46%.
- If the price rises, the difference between current close price and stop price will stay 13,46%.
- If the price drops, stop loss price will stay where it is.
The old version is called BinanceAlert and needs to use run.py as well. The difference between this version and the new one is that it also sends messages based on key levels and technical analysis. Unfortunately there were some issues and I only needed it for the trailing stop loss function, that is why I made this new version.
Change the ‘publicKey’ and ‘privateKey’ in Client and altClient on lines 19, 22, 593 and 594 to your Binance API keys. altClient might not be necessary if you change some settings, but I use it to make sure it won’t stop because it is exceeding the max requests. run.py is necessary if you want to run it on Linux, which is what I am currently doing.
BinanceAlert provides alerts on the USDT pairs. These alerts are based on multiple factors, such as technical analysis, new listings on Binance and changes in your stop-loss.
Currently BinanceAlert only support the USDT pairs, adding BTC pairs might be done later.
About
A simple trailing stop loss for spot holdings written in Python. It can also send Telegram messages if your stop loss has been hit.