📜 ⬆️ ⬇️

Financial Transmission Ways # 3: Plaza II Protocol



In addition to international standards and financial information transfer protocols such as FIX and FAST , which we described earlier, the so-called “native” financial data transfer protocols operate on the stock market. They are used to obtain the necessary information by both private traders and brokerage companies - such native protocols are more functional than the generally accepted standards (such as the same FIX) that attract brokers.

The exchanges of MICEX and RTS that existed in Russia, which now merged into the Moscow Exchange, also developed their own native protocols. Today we will talk about the Plaza II protocol project, which was created by RTS specialists.
')

Plaza II Infrastructure


For communication between the exchange trading system (it is called Spectra) and client software, the so-called Plaza II gateway is used - a special software that receives and sends data using the appropriate protocol. The gateway is installed on a computer that must have a connection to the corporate network of the exchange, and to the network where the user's client application is located.



As a rule, traders install their servers either directly into the data center of the exchange, or place them in the data centers of their brokers , which are connected to the exchange by dedicated communication channels - this allows you to save money (colocation in the exchange data center is expensive), while maintaining a high level of exchange rate data.

SPECTRA Plaza-2 gateway includes two software components:


The P2ClientGate library exists in two versions that support different COM streaming models: STA and MTA models.
In addition, the P2ClientGate library is available for 32-bit and 64-bit Windows systems (similarly for CGate).



The exchange has a special document , which describes in detail the requirements for hardware and software for the normal operation of applications. For example, if we need to save data to a disk, then the requirements will sound like this: 4 GB operating memory, SAS controller with write-back caching mode, at least 4 disks in RAID10, etc.).

Data transfer


The main method of data distribution on the Plaza II platform is replication - the data is transmitted by the server to the clients in the push mode (that is, the client does not explicitly request data changes). The data is translated as a sequence of changes in relational tables, that is, replication data streams.

The client software subscribes to the necessary data based on the name of the stream (at the stream level the rights to access specific data are also set).

A stream can be in several states, including receiving snapshots (history of data changes), online mode (updating data in real-time mode) and error mode (this means that for some reason the stream cannot be opened).

When opening a stream, the developer of a trading application can set its mode of operation, which is selected based on the goals pursued (receiving snapshots, receiving and updating data, or receiving only data from the current time).

Each replicable table has in its structure the first three fields of a fixed type i8, designed to provide a replication mechanism:



Plaza Types IIString representation
i1, i2, i4, i8Signed whole
u1, u2, u4, u8Unsigned integer
d sSigned fixed-point number of the form [sign] nnnn.mmmm
tDate and time in the format YYYY / MM / DD HH: NN: SS.XXX
cCharacter string with a zero at the end
aOne character string
fSigned floating-point number of the form [sign] dddd.dddd

After the implementation of data schema matching, the client application sends to the server the maximum values ​​of the replRev fields for each table. The initial synchronization consists in the transfer of all data with checks (“revision”) by the server to the client, larger than those indicated by the client.

After the initial synchronization, the stream goes online (for all tables, the maximum client revolutions coincided with the maximum server revolutions).

This means that the data in the tables after receiving the StreamDataEnd notification and before receiving the next StreamDataBegin notification is consistent.

Data change notifications can arrive only in the interval between the StreamDataBegin and the StreamDataEnd and in this interval the data in the table are not consistent.

Presentation of information


All data passing through the Plaza II gateway is divided into several logical groups:


In order to carry out operations in the markets operating on the Spectra trading system, the user’s system must receive on-line a schedule of sessions (session) and a tool directory (fut_sess_contents, opt_sess_contents).

Data streams


Consider the specific data streams of the Plaza II protocol. For example, the FORTS_FUTTRADE_REPL stream contains information on bids and futures transactions on the Moscow Exchange derivatives market (FORTS).
The stream data schema includes the tables:

The orders_log table looks like this:

FieldType ofDescription
replIDi8Replication subsystem service field
replRevi8Replication subsystem service field
replActi8Replication subsystem service field
id_deali8Transaction number
sess_idi4Session Id
isin_idi4Unique numeric identifier of the instrument
priced16.5Price
amounti4Volume, number of instrument units
momenttTime of the transaction
code_sellc7Seller Code
code_buyc7Buyer Code
id_ord_selli8Seller’s Request Number
ext_id_selli4External number from the application of the seller
comment_sellc20Comment from the seller’s application
trust_selli1Sign of remote control (trust management) from the seller’s application
status_selli4Status of the transaction by the seller
id_ord_buyi8Buyer Application Number
ext_id_buyi4External number from the application of the buyer
trust_buyi1Sign of the trust (trust management) from the application of the buyer
status_buyi4Status of the transaction by the buyer
posi4The number of positions on the instrument in the market after the transaction
nosystemi1Sign of a non-system transaction
hedge_selli1Merchant hedge sign
hedge_buyi1Sign of a hedge deal by the buyer
login_sellc20Seller username
login_buyc20Buyer User Login
code_rts_buyc7Buyer RTS Code
code_rts_sellc7Seller's RTS Code
free_selld26.2Seller transaction fee
free_buyd26.2Buyer transaction fee
id_deal_multilegi8Transaction number for the bundle

There are other data streams:


Also, the client can subscribe to receive data from streams of aggregated glasses:

Each of these data streams has its own table schema, they are described in more detail in a special document for developers of trading software.

With the help of the Plaza II protocol, not only information is received, but also commands are transmitted for performing operations in the stock market. For example, adding an application is carried out using a special method (FutAddOrder), which is represented by a separate table (for the CGate library, the names of the tables may differ).

The table for the result of the action is as follows:

Parameter nameType ofDefault valueDescription
codei4Return code
messagec255Message text
order_idi8Application code in the system

The success of the operation is described by code 0, any other value indicates an error. Similarly, the removal of the application or the movement of applications.

Work with Plaza II


With the help of the Plaza II protocol, it is possible to work in different ways with the stock exchange: for example, there is a viewing mode, which is used only to get data, but not to make transactions with securities. To work in the system in different modes, special logins of different types are used.

You can connect to trades using this native protocol through brokers whose systems are certified by the exchange (ITinvest is included in this list).

Other protocols


In addition to the Plaza II protocol, which was developed by employees of the RTS Exchange, there is a protocol for work created on the MICEX Stock Exchange (as mentioned above, these two sites later merged into the Moscow Exchange). ASTS Bridge (TEAP) bidirectional gateway is used to carry out trading operations and obtain stock exchange data on the foreign exchange and stock markets - it will be discussed in one of our following materials. In addition, we will talk about the protocol Simple Binary Encoding, which, to a certain extent, is the successor of the FIX case.

Today, thank you for your attention, we will be happy to answer questions in the comments.

PS If you notice a typo or mistake - write a personal message, and we will fix everything promptly.

Source: https://habr.com/ru/post/261709/


All Articles