├── bonk.wav ├── README.md ├── .gitignore └── tts.py /bonk.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liquiditygoblin/trading_scripts/HEAD/bonk.wav -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # trading_scripts 2 | A collection of helpful trading scripts I've hacked together 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /tts.py: -------------------------------------------------------------------------------- 1 | import pyttsx3 2 | import pygame 3 | from asyncio import run 4 | import ccxt.pro as ccxtpro 5 | import datetime 6 | from decimal import Decimal 7 | 8 | engine = pyttsx3.init() 9 | pygame.init() 10 | 11 | 12 | 13 | SMALL_TRADE = 100 14 | BIG_TRADE = 1000 15 | SYMBOL = "ARB/USDT" 16 | TICK_SIZE = Decimal('0.0001') # you could do this in code but each exchange has a diff format so cbf 17 | PAY_THROUGH_TICKS = 0 18 | 19 | 20 | pygame.mixer.music.load('bonk.wav') 21 | 22 | bonk_sound = pygame.mixer.Sound("bonk.wav") 23 | 24 | 25 | def say(text): 26 | engine.say(text) 27 | engine.runAndWait() 28 | 29 | 30 | def bonk(): 31 | pygame.mixer.Sound.play(bonk_sound) 32 | pygame.mixer.music.stop() 33 | 34 | 35 | def num_ticks(price, tick_size): 36 | return int(Decimal(price) / tick_size) 37 | 38 | 39 | async def main(): 40 | 41 | # Instantiate exchange 42 | exchange = ccxtpro.binance() # you can change this to any exchange ccxt supports 43 | 44 | 45 | while True: 46 | trades = await exchange.watch_trades(SYMBOL) 47 | 48 | time = datetime.datetime.now() 49 | 50 | buys = [] 51 | sells = [] 52 | 53 | total_buy = 0 54 | total_sell = 0 55 | 56 | for trade in trades: 57 | if trade["side"] == "buy": 58 | buys.append(trade['price']) 59 | total_buy += trade["amount"] 60 | else: 61 | sells.append(trade['price']) 62 | total_sell += trade["amount"] 63 | 64 | if len(buys) > 1 and abs(num_ticks(buys[0] - buys[-1], TICK_SIZE)) > PAY_THROUGH_TICKS: 65 | ticks = abs(num_ticks(buys[0] - buys[-1], TICK_SIZE)) 66 | print(f"[{time}] PAY THROUGH {ticks} BUY") 67 | say(f"aggressive buy {ticks} ticks") 68 | elif total_buy > BIG_TRADE: 69 | say("big buy") 70 | print(f"[{time}] BIG TRADE {total_buy} BUY") 71 | elif total_buy > SMALL_TRADE: 72 | bonk() 73 | print(f"[{time}] TRADE {total_buy} BUY") 74 | bonk() 75 | 76 | if len(sells) > 1 and abs(num_ticks(sells[0] - sells[-1], TICK_SIZE)) > PAY_THROUGH_TICKS: 77 | ticks = abs(num_ticks(sells[0] - sells[-1], TICK_SIZE)) 78 | print(f"[{time}] PAY THROUGH {ticks} SELL") 79 | say("aggressive sell, {ticks} ticks") 80 | elif total_sell > BIG_TRADE: 81 | say("big sell") 82 | print(f"[{time}] BIG TRADE {total_sell} SELL") 83 | 84 | elif total_sell > SMALL_TRADE: 85 | print(f"[{time}] TRADE {total_sell} SELL") 86 | bonk() 87 | 88 | 89 | 90 | run(main()) 91 | --------------------------------------------------------------------------------