Real time tracker of cryptocurrency prices between different markets with telegram notifications, database writer and web interface.
- Easy addition of new markets
- Easy addition of new cryptocurrency
- Web interface
- Telegram notifications
- Custom notification functions
- Database writer
For now tracker is connected to 8 different markets 'Binance', 'Bybit', 'kuCoin', 'Kraken', 'Deepcoin', 'DigiFinex', 'CoinBase', 'oKex' using WebSocket to obtain market data on different currency pairs on each market.
- Replace the value of the PRICE_GAP in data.py with a new one. Default to 5.
- Add cryptocurrency pairs in data.py in the following format: 'BTC_USDT', 'ETH_USDT'
- Now these pairs are tracked if they are available on the markets
- Add market to the date.py file
- Add function to request data through web sockets.
- Messages transmitted via socket can be given in a dict format or a list.
- Market name in decorator should be the same as in data.py file
- Usage example:
@market_registrator.on('Binance')
def binance_handler(name):
currency = currency_pairs.copy()
currency = [''.join(pair.split('_')).lower() for pair in currency]
uri = 'wss://stream.binance.com/stream'
params = [f'{val}@trade' for val in currency]
mes = {'method': 'SUBSCRIBE', 'id': 2, 'params': [*params]} # subscribe to trades
return Market(name, uri, mes)
- Add function to process responses from markets
- Market name in decorator should be the same as in data.py file
- It should return data in the following format {name: name, price: price, seller: seller, pair: pair}
- Usage example:
@request.add('Binance')
def binance(res) -> dict|None:
js = json.loads(res)
if js.get('stream', '1').endswith ('trade'):
seller = True if js['data']['m'] is True else False
return {'name': 'Binance', 'price': js['data']['p'], 'seller': seller, 'pair': js['data']['s']}
return None
- Now you can use the registered market as in the example folder
- The examples/run.py shows an example of using the program
- notification func - any function that accepts parameters in the following format: param1:list = [{name: '', price: '', seller: '', pair: ''}, ...] param2: float = price gap
- web - True or False - to activate web interface. Run from web_interface\main_interface.html
- tg_notification - True or False - to receive notification in Telegram, when price gap is more than the gap
- database_writer - True or False - to write data in database, when price gap is more than the gap. By default, data is saved in the sql\test.db.
- gap - price gap - when price gap between currency pairs on different markets is more than the value of the gap
- notifications in telegram and in notification function are send and the data is written to the database
- Add the bot token to the utils/tg_const.py
- Set tg_notification to True