{"id":21578288,"url":"https://github.com/stephanakkerman/binance-trailing-stop-loss","last_synced_at":"2025-07-30T10:42:54.479Z","repository":{"id":157307866,"uuid":"358579579","full_name":"StephanAkkerman/binance-trailing-stop-loss","owner":"StephanAkkerman","description":"A simple trailing stop loss for spot holdings written in Python. It can also send Telegram messages if your stop loss has been hit.","archived":false,"fork":false,"pushed_at":"2021-12-21T10:18:17.000Z","size":42,"stargazers_count":20,"open_issues_count":4,"forks_count":10,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-24T15:11:15.665Z","etag":null,"topics":["binance","price","stoploss","telegram","trailing-stoploss"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/StephanAkkerman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-04-16T11:39:29.000Z","updated_at":"2025-03-21T14:58:45.000Z","dependencies_parsed_at":"2024-02-14T18:26:43.079Z","dependency_job_id":null,"html_url":"https://github.com/StephanAkkerman/binance-trailing-stop-loss","commit_stats":null,"previous_names":["stephanakkerman/binance-trailing-stop-loss"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanAkkerman%2Fbinance-trailing-stop-loss","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanAkkerman%2Fbinance-trailing-stop-loss/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanAkkerman%2Fbinance-trailing-stop-loss/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/StephanAkkerman%2Fbinance-trailing-stop-loss/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/StephanAkkerman","download_url":"https://codeload.github.com/StephanAkkerman/binance-trailing-stop-loss/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261993,"owners_count":21074229,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binance","price","stoploss","telegram","trailing-stoploss"],"created_at":"2024-11-24T13:10:04.118Z","updated_at":"2025-04-10T17:33:23.398Z","avatar_url":"https://github.com/StephanAkkerman.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Binance Trailing Stop Loss\n[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![MIT License](https://img.shields.io/github/license/StephanAkkerman/Binance_Trailing_Stop_Loss.svg?color=brightgreen)](https://opensource.org/licenses/MIT)\n\n---\n\nAs the name suggests this code is made for having an automated stop loss for trading spot on Binance.\n\n# How to set up\nAdd your public and private API keys in the src/keys.py file.\n\n## Dependencies\nThe required packages to run this code can be found in the `requirements.txt` file. To run this file, execute the following code block:\n```\n$ pip install -r requirements.txt \n```\nAlternatively, you can install the required packages manually like this:\n```\n$ pip install \u003cpackage\u003e\n```\n\n## Telegram messages\nIf you would like to get messages via Telegram if your stop loss is hit, follow the link in src/keys.py\n\n## How it works\nThere 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.\nThis first stop loss is then used as a reference for further stop loss percentages.\n\n## OS issues\n### Linux\nThere is a problem where the sockets can be closed or restarted once they have started running.\nUnfortunately, the developer of python-binance has not fixed this problem yet.\nSo to fix this problem, you need to run `$ python Linux/run.py` which will restart the trailing stop loss program every 24 hours.\nThat way the sockets won't get disconnected and you won't have any issues.\n\n### Windows \u0026 MacOS\nThese OSes do not have the problem that Linux based system have. If you just run `$ python src/main.py`, it should work without issues.\n\n# Example\n- Market buy 1000 DOGE/USDT at 0,295$.\n- Place a stop loss at 0,26$.\n- Procentual difference is calculated: 13,46%.\n- If the price rises, the difference between current close price and stop price will stay 13,46%.\n- If the price drops, stop loss price will stay where it is.\n\n# Old Version (BinanceAlert)\nThe old version is called BinanceAlert and needs to use run.py as well.\nThe difference between this version and the new one is that it also sends messages based on key levels and technical analysis.\nUnfortunately there were some issues and I only needed it for the trailing stop loss function, that is why I made this new version.\n\n## BinanceAlertV3.py setup\nChange the 'publicKey' and 'privateKey' in Client and altClient on lines 19, 22, 593 and 594 to your Binance API keys.\naltClient 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.\nrun.py is necessary if you want to run it on Linux, which is what I am currently doing. \n\n## BinanceAlert use cases\nBinanceAlert 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.\n\n## Note\nCurrently BinanceAlert only support the USDT pairs, adding BTC pairs might be done later.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanakkerman%2Fbinance-trailing-stop-loss","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephanakkerman%2Fbinance-trailing-stop-loss","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephanakkerman%2Fbinance-trailing-stop-loss/lists"}