laisee/rektbitmex
bot tracking liquidations on Bitmex exchange (www.bitmex.com). Stores records of each liquidation and publishes to twitter
๐ฅ Rekt @ BitMEX Bot
rektbitmex tracks liquidation events on BitMEX and stores
information about each event in a local SQLite database. When configured with
Twitter credentials it tweets a short summary of the liquidation.
Features
- Polls the BitMEX
order/liquidationsAPI endpoint - Persists liquidation information to
rekt.sqlite - Optional Twitter posting using Tweepy
- PID file handling to avoid multiple running instances
- Simple commands to initialise the database tables
Requirements
- Python 3.8 or newer
- Dependencies listed in
requirements.txt
Installation
pip install -r requirements.txtUsage
Initialise the database tables:
python add_sql_rekt.pyRun the bot:
python rektrunner.pySet the following environment variables if you want the bot to tweet:
TWITTER_APP_KEY, TWITTER_APP_SECRET, TWITTER_ACCESS_TOKEN and
TWITTER_ACCESS_TOKEN_SECRET.
Supported Versions
The project is actively tested with Python 3.8 and later.
Database Schema
Two tables are created in rekt.sqlite:
- rekkage: stores liquidation events
rekt_keyTEXT primary keyrekt_symbolTEXTrekt_qtyINTEGERrekt_priceREALrekt_positionTEXTrekt_sideTEXTrekt_tsTEXT (timestamp of insertion)
- rekt_PID: tracks the running process ID
rekt_PIDTEXT primary key
Configuration
config.py defines the BitMEX API base URL. The database path can be passed to
functions in rektrunner.py if you wish to store it elsewhere. Twitter
credentials are read from environment variables as noted above.
Test Coverage
Unit tests are located in the tests directory and can be executed with
pytest and the pytest-cov plugin:
pytest --cov=./There are four tests covering database initialisation, record insertion and the
basic helper functions. Coverage results are uploaded to Codecov and displayed in the badge above.