Skip to content

24.3.0

Choose a tag to compare

@evgrmn evgrmn released this 22 Mar 13:07
· 1212 commits to main since this release
53baf79

Preparing the program to connect to different exchanges

This release includes changes for the simultaneous connection of several crypto exchanges on the Tmatic platform, which will allow you to receive exchange data from two or more exchanges, manage orders manually and automatically within one program. Connecting several exchanges on one platform will make trading more flexible, for example, allowing you to trade one strategy on different marketplaces. Simultaneous control of exchange prices and accounts of different trading platforms makes it possible to create arbitrage strategies between exchanges. List of main changes:

  1. The api folder contains all the code that is responsible for connecting via websockets and exchanging data with exchanges.

  2. Each exchange has its own folder with the appropriate name, for example, api/Bitmex. Such a folder must contain at least four required files: 1) ws.py - creates a websocket instance, 2) http.py - processing REST requests, 3) path.py - urls, 4) agent.py - an intermediary that receives exchange data in a format specific to a particular API and converts it into a standardized format understandable by Tmatic.

  3. The api/variabales.py file contains general variables that inherit from websocket classes, for example: accounts - the state of currency wallets, positions - information about open positions for subscribed instruments, ticker - the best buy/sell price, instruments - information on all exchange instruments , frames - candlesticks data on subscribed instruments, robots - bots of a given exchange and their data.

  4. The file api/websockets.py is a dictionary through which websocket instances are addressed.

  5. File api/init.py - preparing some variables before initializing the websocket.

  6. File api/api.py - contains the WS class, which distributes REST requests by the name of the exchange, using the 'name' variable.

  7. Possible problem of duplicate tickers. Exchange instruments belong to the following categories: "linear", "inverse", "quanto", "spot", "option". So far we have not encountered such a problem, but it can be assumed that the exchange can use the same symbol name for different categories. To avoid conflicts, the keys for the 'instruments', 'positions' dictionaries are converted from string to tuple and have the form (SYMBOL, CATEGORY). The corresponding fields have been added to the database tables.

  8. Environment variables are in the .env file.

MARKET_LIST = "Bitmex"
MYSQL_HOST = "localhost"
MYSQL_USER = "root"
MYSQL_PASSWORD = "your password"
MYSQL_DATABASE = "your database name"
ORDER_BOOK_DEPTH = "orderBook10"
REFRESH_RATE = "5"
TESTNET = "True"

where, new variables:

MARKET_LIST - a list of exchanges
TESTNET - select test or main network

  1. Settings for each exchange are located in separate files, for example, for Bitmex in the .env.Bitmex file:

LINEAR_SYMBOLS = "XBTUSDT, ADAH24, SOLUSDT"
INVERSE_SYMBOLS = "XBTUSD"
QUANTO_SYMBOLS = "ETHUSD"
SPOT_SYMBOLS = ""
OPTION_SYMBOLS = ""
CURRENCIES = "XBt, USDt"
HTTP_URL = "https://www.bitmex.com/api/v1/"
WS_URL = "wss://ws.bitmex.com/realtime"
API_KEY = "your API key"
API_SECRET = "your API secret"
TESTNET_HTTP_URL = "https://testnet.bitmex.com/api/v1/"
TESTNET_WS_URL = "wss://testnet.bitmex.com/realtime"
TESTNET_API_KEY = "your testnet API key"
TESTNET_API_SECRET = "your testnet API secret"

  1. Changes affected the graphical interface. In particular, the table with funding is combined with the table of transactions through bookmarks. The information from these tables has been converted from text to tabular, for which the new ListBoxTable class is responsible.

  2. The design is optimized for macOS, with a choice of light and dark themes. For Linux and Windows, only the light theme is still available.

Full Changelog: https://github.com/evgrmn/tmatic/commits/24.3.0