当前位置:网站首页>Development of trading system (x) -- fix agreement
Development of trading system (x) -- fix agreement
2022-06-25 04:01:00 【Tianshan old demon】
One 、FIX Protocol Brief
1、FIX Protocol Brief
FIX(Financial Information eXchange Protocol, Financial information exchange agreement ) By international FIX An open protocol provided by the Association , The purpose is to promote the electronic process of international trade , Between all kinds of participants , Including investment managers 、 agent 、 Buyer 、 The seller establishes a real-time electronic communication protocol .
FIX The goal of the agreement is to format the demand process of various securities and financial business , Become a functional process that can be described in computer language , And unify the exchange format on each business function interface , Facilitate the connection of various functional modules .
2006 year 10 month ,FPL(FIX Protocol Ltd) Released FIX5.0,FIX5.0 introduce TI(the transport independence ) Transport independent framework .TI take FIX The session layer is separated from the application layer protocol . stay TI Within the framework of , Application layer protocol messages can be transmitted through any suitable transmission technology ,FIX The session layer protocol is FIX One of the optional transport protocols for application layer messages . The version annotations of the two protocol layers will be different ,FIX X.Y by FIX Application layer protocol version , The application layer protocol defines the business data structure related to financial activities ;FIXT X.Y by FIX Session layer protocol version number , The session layer protocol defines the protocols related to data communication .
2、FAST agreement
In order to solve FIX The redundancy of protocol transmission market data is high , Large bandwidth requirements , The Chicago Mercantile Exchange (CME) stay 2003 Annual direction FPL(FIX Protocol Ltd) Submitted a solution ,FPL stay 2004 The market data optimization working group was established in (MDOWG),2005 year MDOWG Start according to some POC(Prove of Concept) The results of the protocol standards , And in 2006 At the beginning of the year FAST(FIX Adapted for Streaming) V1.0,2006 year 12 Month completed FAST V1.1.
FAST The core of the protocol is a compression algorithm , Will be in accordance with the FIX The data defined by the specification is compressed , Transmission can be greatly reduced 、 Bandwidth of both receiving parties .
FAST The advantage of the protocol is high compression ratio , Low resource consumption , The algorithm is simple and efficient , Millions of messages per second .
3、STEP agreement
STEP(Securities trading exchange protocol, Stock exchange data exchange protocol ) Is based on FIX4.4 edition FIX The Chinese localization made by the agreement FIX Protocol version , It is China's national financial industry standard , It has become the de facto standard for securities data , Its syntax is simple, its definition is flexible and easy to extend , The data is relatively redundant .
4、Binary agreement
Binary Binary protocol , The fields of various messages are defined 、 Encoding and decoding rules, etc . In Shenzhen Stock Exchange Binary Agreement , All the news has 3 Part of it is made up of : The message header , Message body and message tail . The message header has 8 Bytes , Include integers MsgType And integer BodyLen,MsgType Indicates the type of message ,BodyLen Indicates the length of the message body ; The message body is based on BodyLen Size to read ; The message ends with 4 Bytes of checksum.
5、FIX The advantages and disadvantages of the agreement
FIX The protocol has the advantage of using key-value Yes , It is easy to view the message content and expand new fields , International , Strong adaptability .
FIX The disadvantage of the protocol is that it is slow .
Two 、FIX How the protocol works
1、FIX Application mode
FIX Yes Initiator and Acceptor Two application types ,Initiator It is the originator of communication , By sending the initial Logon Message initiation Session;Acceptor yes FIX Session The recipient of , Responsible for performing the first level of authentication and transmission Logon The message response confirms that the formal connection request is accepted .
FIX Provisions of the agreement Initiator It is the originator of communication ,Acceptor For the recipient .FIX The standard application mode is based on the gateway Acceptor, The client is Initiator.
2、FIX Connection
FIX Connection from 3 Part of it is made up of :logon Sign in ,message exchange Message transmission ,logout Cancellation .
3、Fix Session
FIX Session By one or more FIX Connection form , One FIX Session You can log in multiple times .
One FIX Session It is defined as a two-way transmission stream of ordered messages with continuous serial numbers between the two sides of the connection . Single FIX Session Ability to span multiple contiguous ( Not in parallel ) The physical connection of . In a FIX Session in , Participants can connect and disconnect multiple times . The connected participants must be based on the requirements of a single system and time area , Public consultation Session The beginning and the end of .
Suggest a new one FIX The conversation is on every 24 Set up once every hour , Can sustain 24 Hours of connection and through settings in Logon In the news ResetSeqNumFlag Create a new set of serial numbers .
Every FIX Party must be FIX Session Maintain two serial numbers , One is the receiving serial number , One is to send the serial number , Both are building FIX Session Initialize to... At the beginning 1. Each message is assigned a unique serial number value , And increment after the message is sent . Besides , Each received message has a unique serial number , The receive serial number counter will be incremented after each message is received .
When the receiving serial number does not have to be matched with the desired correct serial number , Corrective measures must be taken .
4、 Serial number
Every one of them FIX Messages are identified by a unique serial number , The serial number is in each FIX Session It is initialized to 1, And in the whole Session Period increment . Monitoring the serial number enables Session Participants identify and process lost messages , When in a FIX Session Fast application synchronization when reconnecting in .
Every Session A set of independent receiving and transmitting sequences will be established .Session The participant will maintain a sequence assigned to the sending message and a message block gap sequence number that monitors the receiving message .
5、 heartbeat
During message interaction ,FIX The application will periodically generate Heartbeat Heartbeat message . The heartbeat message can monitor the communication link status and identify the receiving serial number gap .Heartbeat The message cycle interval is determined by Session The initiator uses in Logon In the news HeartBtInt Domain .
Heartbeat The heartbeat message interval should be reset after each message is sent , That is, after sending a message , If no other message is sent within a given interval, a message is sent Heartbeat Heartbeat message .HeartBtInt The value should be Session Both parties agree that , from Session Defined by the originator and Session The recipient passes Logon Confirm the message . The same HeartBtInt By Session The two sides —— The initiator of the login and the recipient of the login are used together .
6、 Data integrity verification
The integrity of message data content can be verified in two ways : Message length and check code .
The program passes the calculation BodyLength Domain to CheckSum Mark (“10=”) The number of characters of the delimiter , Domain BodyLength The message length of the identifier is compared to complete the integrity verification .
ChekSum Integrity check , From the domain by calculation “8=” in “8” Start , Including following closely CheckSum Mark the delimiter of the field 2 Base and are the same CheckSum Compare and get .
One FIX The message checksum is calculated to ChechSum Domain ( barring ) Each byte of the message and get . then , The checksum is converted to modulo 256 The number of is used for transmission and comparison . The checksum is computed after all encryption operations .
FIX Examples of messages are as follows :
8=FIX.4.29=7335=A34=149=CLIENT52=20181119-10:42:48.76856=SERVER98=0108=30141=Y10=208
The length of the message :9=73, The identified message body is as follows :
35=A34=149=CLIENT52=20181119-10:42:48.76856=SERVER98=0108=30141=Y
7、 Message confirmation
FIX The protocol does not support the acknowledgement of a single message , The method of monitoring message time slot is used for message recovery and verification .
Ordinary data transmission ( No single message acknowledgement ) Error identification through message sequence gaps . Each message is identified by a unique serial number . The receiving application is responsible for monitoring the received message sequence number to identify the message gap and generate a retransmission request .
8、 encryption
The encryption algorithm is negotiated by both parties .
Any one of a message Field Can be encrypted and placed in SecureData Field in . However , Some displayed flag fields must be transmitted in clear text . To ensure integrity , The plaintext domain can be in SecureData Duplicate in field .
When using encryption , It is recommended that all message bodies be encrypted . If part of the circular group data in a message needs to be encrypted , The loop group must all be encrypted .
The pre negotiated encryption algorithm is Logon In the message .
9、 Custom fields
FIX The protocol provides users with maximum flexibility , It allows the user to customize the domain . Custom fields are implemented between identified participants 、 application , Therefore, attention should be paid to avoid conflicts .
FIX Provisions of the agreement ,Tag stay 5000 To 9999 Reserved for user-defined fields , For information exchange of enterprise alliance , Can pass FIX Website registration ;Tag stay 10000 The above is reserved for internal use in a single enterprise , No registration .
10、 Orderly message processing
FIX The protocol assumes that messages are transmitted in complete order among all participants . The implementer of the protocol should consider the sequential transmission assumption when designing the message gap filling process . There are two ways to handle message gaps . The first is , The message required to be received is the subsequent message of the last received message or when maintaining an ordered sequence of all new messages , Request specific missing messages . such as : The receiver is missing 5 The second of the message blocks , The program can ignore the 3 To the first 5 A message , Generate a pair of messages 2 To the news 5 The retransmission request for , Or from the message 2 Retransmission request to infinite message number . The second way is , Temporarily store messages 3 To the news 5, Only message retransmission is required 2.
11、 Repeat the message
When one FIX Whether the engine successfully receives a message from the specified destination or responds to a retransmission request , There will be a possible message replication . The duplicate message will be retransmitted with the same serial number , At this point in the head PossDupFlag The domain will be set to ‘Y’. The receiving program is responsible for processing the retransmission message , Can be processed as a new message , Or ignore the message according to the actual situation .
The response message of all retransmission requests will contain a value of ‘Y’ Of PossDupFlag Domain . No, PossDupFlag Domain or PossDupFlag Domain is ‘N’ The message of should be treated as the initial delivery message .PossDupFlag The value is ‘Y’ The retransmission message of needs to recalculate its CheckSum value . Domains that have changed in replication messages include :CheckSum,OrigSendingTime,SendingTime,BodyLength and PossDupFlag, Encrypt related domains (SecureDataLen and SecureData) It must also be reconstructed .
12、 Resend the message
Vague application layer messages may accompany PossResend The flag is retransmitted . This method is very useful when an instruction is not confirmed within a specified length of time or when the end user suspends the instruction and does not transmit it . The receiving program must recognize this flag , And challenge its internal domain to determine whether the instruction has been received before . The retransmission message will contain the same data body as the original message , But it includes PossResend Logo and a new serial number . Besides ,CheckSum And encryption related domain values need to be reconstructed .
3、 ... and 、 Message type
1、 Manage messages
Manage messages (Adminitrative Message) It is a control used to make the information exchange process more smooth and consistent , Including login 、 heartbeat 、 Inspection request 、 Resend request 、 Refuse ( The exchange process ) Sequence reset and cancellation, etc .
2、 Application messages
Application messages (Application Messages) Is the data of the transaction , Include the following data :
Notice : Announce the completed transaction information .
Important note : Advise that securities traded by brokers are owned by a private company limited by shares , Or is it held by an agent , And holdings .
news : It is the general free-form information transmitted between brokers and institutions , With identification information urgency and trade name subject word classification marks .
E-mail : Its format and purpose are the same as that of message information , But they prefer to be used by both parties privately .
Request for quotation : Some markets require brokers to quote before each order .
Quotation and multiple quotations : Respond to RFQ information and use it to post unsolicited quotes .
Request for confirmation of multiple quotations : Mark with quote response level , Selectively support the confirmation of quotation .
Quotation cancellation : The quotation initiator is used to cancel the quotation .
Request for quotation status : The organization is used to generate execution reports .
Quotation confirmation : For quotation 、 Multiple quotations 、 Quotation cancellation and quotation request , Respond .
Market data request : Through this request, we can obtain the quotation data of the specified securities and foreign exchange trading quotations .
Market data — snapshot 、 Full refresh : Used to send the order register of both parties 、 Quotation list 、 List of transactions 、 Index value 、 Opening price 、 Closing price 、 Unit price 、 Highest price 、 Lowest price and variable weighted average price, etc .
Market data — Add refresh : Used to add refresh requests .
Quote data request rejected : Used when the broker does not accept the quotation data request due to trading or technical reasons .
Securities definition request : Used for trading a specified security with a second party .
Definition of securities : Accept or reject the securities requested in the securities definition information , List of securities and types returned .
Securities status request : Used to make requests about the status of securities .
Securities status : Provide a report on changes in the status of securities .
Order status request : Ask for information about market conditions .
Trading position : Provide information about market conditions .
New order : Institutions provide brokers with orders for securities or foreign exchange .
Perform the report : Confirm receipt of order or order change information , Transfer order status or order closing information , Report the cost of the transaction .
Unknown transaction : Notify the participant , The order received has been executed .
Order cancellation 、 Replacement request : Change the parameters of the order .
Order cancellation rejection : A message sent by a broker when he cannot accept the cancellation request message received .
Order status request : The agency requires the broker to generate and display information about the status of the order .
transfer : Specify how to subdivide an order or a group of orders into one or more accounts .
Transfer confirmation : Confirm receipt of the transfer information and status sent by the institution .
Settlement instructions : The order of a broker or institution to settle transactions .
Bid request : In the private and public markets , The usage is different due to different market rules .
Bid response : Because the two market rules are different , There are different usages .
New order — detailed list : It varies according to the rules of the two markets .
Knock pricing : Strike price of exchange principal transaction .
Status list : The seller actively sends the response status list request information .
List execution : Information used by institutions to instruct brokers to start executing securities orders that have been submitted .
List revocation request : Used when an institution wishes to execute a trading order before or during , Cancellation of securities orders that have been submitted .
Status list request : Used by the institution to instruct the broker to generate information about a status list .
Breakdown of list order information : Use and others FIX Same information method , Support information decomposition in program transactions .
Transaction information rejected : Reject application level information that cannot be rejected in other ways due to compliance with trading order rules .
Four 、FIX agreement
1、 data type
FIX The data types of the protocol include integers int, Floating point numbers float, character char, Boolean Boolean, character string String, data data.
2、Field
Field from Tag、Value and Delimeter form ,Delimeter Used to separate different Field, Such as 8=FIX4.1SOH,tag by 8,value by FIX4.1,Delimeter by SOH(0x01).
common Field as follows :
Tag | FieldName | Description |
8 | BeginString | Starting string ,FIX Protocol version |
9 | BodyLength | The length of the message |
35 | MsgType | Message type : for example F=Order Cancel Request, Cancellation of order |
11 | ClOrdID | Client order ID |
37 | OrderID | Service side order ID |
41 | OrigClOrdID | Original client order ID |
54 | Side | Type of business . for example :1 = Buy,2 = Sell |
55 | Symbol | Stock code . for example :YRD |
10 | CheckSum | Check code |
3、 news
FIX The message consists of multiple Field form , Including headers 、 Message body 、 The last three parts of the message .
Before the message header 3 individual Field The order of cannot be changed , Starting string (Tag=8)、 Message body length (Tag=9)、 Message type (Tag=35).
The last one at the end of the message Field Must be a checksum Field(Tag=10).
8=FIX.4.49=6335=034=115849=SAMPLESENDER52=20150201-00:22:34.99556=SAMPLETARGET10=114
In the loop group ,Field The order of occurrence should follow the order in which the loop group is defined in the message or component ; In one FIX In the news , Except for the cycle group Field Any other Field It can't be repeated .
because FIX It is possible for messages to be transmitted and exchanged on the public network or an insecure network , Therefore, it is necessary to encrypt the relevant sensitive data , The specific encryption method depends on the agreement reached by both parties .
FIX In the message, except for some that need to be publicly identified Field It is transmitted in Ming Dynasty , Anything else Field Can encrypt and place the ciphertext data field (SecureData) Inside , Encrypted Field It is also possible to preserve the representation of plaintext .
When deciding to use an encryption scheme , It can be done to FIX All in the message body Field encryption . If there is part of the loop group of the message that needs to be encrypted , Then it is required to encrypt the whole cycle group .
FIX The agreement also provides some Field To support digital signature 、 Key exchange, text encryption and other security technologies .
4、 The message header
Each session or application message has a header , The message header indicates the message type 、 Message body length 、 Send to 、 Message number 、 Sending start point and sending time .
Tag | domain name | It's necessary | explain |
8 | BeginString | Y | Starting string , Value :FIX.4.2( Unencrypted , The first field of the message ) |
9 | BodyLength | Y | Message body length ( Unencrypted , The second field of the message ) |
35 | MsgType | Y | Message type ( Unencrypted , The third field of the message ) |
49 | SenderCompID | Y | Sender code ( Unencrypted , Sender identifier ) |
59 | TargetCompID | Y | Receiver code ( Unencrypted , Receiver identifier ) |
115 | OnBehalfOfCompID | N | Initial sender identifier ( It can be encrypted ), Used to send... Via a third party . |
128 | DeliverToCompID | N | Final receiver identifier ( It can be encrypted ), Used to send... Via a third party . |
90 | SecureDataLen | N | Ciphertext data length |
91 | SecureData | N | Ciphertext data ( Following the ciphertext data length field ) |
34 | MsgSeqNum | Y | Message number ( It can be encrypted ), If the parties to the transaction do not adopt FIX conversation Mechanism , The tag Set to a fixed value , for example 0. |
50 | SenderSubID | N | Sender sub identifier ( It can be encrypted ) |
142 | SenderLocationID | N | Sender bearing identifier ( It can be encrypted ) |
57 | TargetSubID | N | Receiver sub identifier ( It can be encrypted ) |
143 | TargetLocationID | N | Receiver location identifier ( It can be encrypted ) |
116 | OnBehalfOfSubID | N | Initial sender sub identifier ( It can be encrypted ) |
144 | OnBehalfOfLocationID | N | Initial sender bearing identifier ( It can be encrypted ) |
129 | DeliverToSubID | N | Final receiver sub identifier ( It can be encrypted ) |
145 | DeliverToLocationID | N | Final receiver bearing identifier ( It can be encrypted ) |
43 | PossDupFlag | N | May repeat the sign , When sending repeatedly , Make this mark .( It can be encrypted ) |
97 | PossResend | N | Possible retransmission flag .( It can be encrypted ) |
52 | SendingTime | Y | Send time ( It can be encrypted ) |
122 | OrigSendingTime | N | Original sending time ( It can be encrypted ) |
347 | MessageEncoding | N | In the news Encoded The character encoding type of the field ( Not ASCII code ) |
369 | LastMsgSeqNumProcesse d | N | The sequence number of the last processed message ( It can be encrypted ) |
370 | OnBehalfOfSendingTime | N | Initial send time ( use UTC Time ) |
5、 Message tail
Every message ( Session or application messages ) There is a message tail , And thereby terminate . The message tail can be used to separate multiple messages , contains 3 Checksum value of digits .
Tag | domain name | It's necessary | explain |
93 | SignatureLength | N | Digital signature length ( Unencrypted ) |
89 | Signature | N | digital signature ( Unencrypted ) |
10 | CheckSum | Y | The checksum , The last field of the message .( Unencrypted ) |
6、 New order message
For setting in the message header PossResend Order message for flag , The transaction client order number should be used (ClOrdID) Verify that the order has been received , The order parameters should also be checked during specific implementation ( Business direction 、 Stock code 、 Quantity, etc ) Verify . If you have received this order before , The order status should be responded with an execution report message . If not received before , Then an execution report message is used to respond to the order confirmation .
7、 Execute report message
Order receipt includes order confirmation 、 Order status change confirmation ( Such as cancellation confirmation )、 Transaction return 、
Order rejected .
8、 Order status request message
Order status request is used to request the status of an order from the transaction service provider , The transaction service party returns the order status through the execution report message .
9、 Cancellation message
The cancellation message is used to cancel the remaining quantity of all orders .
The cancellation message is also given a ClOrdID, If rejected , Cancellation rejection message ClOrdID Place the cancellation message ClOrdID, And the original order ClOrdID Put in OrigClOrdID Domain .ClOrdID Make sure that the only one .
10、 Cancellation rejection message
This message is used to reject the cancellation message .
The transaction service provider finds that the cancellation cannot be executed after receiving it ( The completed order cannot be changed ), Cancellation rejection will be sent .
When the cancellation is refused , Cancellation rejection message application ClOrdID Indicating cancellation ClOrdID, use OrigClOrdID Indicates the last order accepted before ( Unless the reason for rejection is “ Unknown order ”).
Tag | domain name | It's necessary | explain |
Standard headers | Y | MsgType=9 | |
37 | OrderID | Y | Commission no. of futures company , The same trading day must be guaranteed to be unique |
11 | ClOrdID | Y | Transaction customer order number |
41 | OrigClOrdID | Y | Original transaction customer order number , Indicates the... Of the cancelled order ClOrdID |
39 | OrdStatus | Y | The order status |
109 | ClientID | Y | Customer fund account number |
1 | Account | Y | Customer transaction code |
60 | TransactTime | N | Order initiation time |
434 | CxlRejResponseTo | N | Cancellation rejection response type |
102 | CxlRejReason | N | Cancellation rejection reason |
58 | Text | N | |
10 | Standard message tail | Y |
5、 ... and 、FIX Engine
(1)QuickFIX
QuickFIX Is a C++ Open source implementation FIX engine , At the same time provide Python、Ruby Language implementation .
(2)FIX 8
FIX8 Is a C++ Open source high performance FIX engine .
https://www.fix8.org/
OnixS FIX Engines yes OnixS A commercial FIX engine , Support C#、C++、Python、Java.
(4)Chronicle FIX Engine
Chronicle FIX Engine yes Chronicle The company's high-performance FIX engine .
边栏推荐
- BSC parsing input data of transaction
- opencv是开源的吗?
- ZABBIX installation pit avoidance Guide
- Jilin University 22 spring March "career design" assignment assessment-00072
- Work assessment of pharmacotherapeutics of Jilin University in March of the 22nd spring -00064
- 严重的PHP缺陷可导致QNAP NAS 设备遭RCE攻击
- Work assessment of pharmaceutical polymer materials of Jilin University in March of the 22nd spring -00025
- 完美洗牌问题
- TC object structure and abbreviation
- Winxp kernel driver debugging
猜你喜欢
Peking University has a new president! Gongqihuang, academician of the Chinese Academy of Sciences, took over and was admitted to the Physics Department of Peking University at the age of 15
Two common OEE monitoring methods for equipment utilization
Intel 13代酷睿首次露出真面目:68MB缓存提升明显
9 necessary soft skills for program ape career development
老叶的祝福
The more AI evolves, the more it resembles the human brain! Meta found the "prefrontal cortex" of the machine. AI scholars and neuroscientists were surprised
A new generation of cascadable Ethernet Remote i/o data acquisition module
AI越进化越跟人类大脑像!Meta找到了机器的“前额叶皮层”,AI学者和神经科学家都惊了...
Mstp+vrrp+ospf implements a three-tier architecture
Musk was sued for $258billion in MLM claims. TSMC announced the 2nm process. The Chinese Academy of Sciences found that the lunar soil contained water in the form of hydroxyl. Today, more big news is
随机推荐
Jilin University 22 spring March "official document writing" assignment assessment-00034
Wechat development related
Qt编译数据库插件通用步骤说明
Winxp kernel driver debugging
Void* pointer
About PLSQL error initialization failure
墨天轮访谈 | IvorySQL王志斌—IvorySQL,一个基于PostgreSQL的兼容Oracle的开源数据库
Sun Wu plays Warcraft? There is a picture and a truth
Crawler crawls Sina Weibo data
Trading system development (IV) - trading counter system
MySQL根据表前缀批量修改、删除表
Comprehensive assignment of thesis writing instruction of Dongcai
TC object structure and abbreviation
opencv是开源的吗?
中国天眼发现地外文明可疑信号,马斯克称星舰7月开始轨道试飞,网信办:APP不得强制要求用户同意处理个人信息,今日更多大新闻在此...
Development of trading system (III) - risk control system
Development of trading system (VIII) -- Construction of low delay network
Two common OEE monitoring methods for equipment utilization
Break the memory wall with CPU scheme? Learn from PayPal stack to expand capacity, and the volume of missed fraud transactions can be reduced to 1/30
论一个优秀红队人员的自我修养