Learning to trade on the exchange. Part one: setting up a test environment


In this series of articles, we will create an environment for working with a test exchange and messaging with it, we will understand the basic exchange terms and consolidate knowledge in practice.


UPD : The main goal of this series of articles is to comprehensively consider the structure of the exchange and basic concepts (transactions, futures, etc.) as part of the work with the FIX protocol . There will be no binding to any particular exchange, we will use a ready-made server example (exchange simulator) and in the future we will implement a client that can be modified to interact with a real exchange interesting to you.


To configure everything you need, you will need only basic programming knowledge and the ability to use Git.


To test the messages we need:


  • implementation of the FIX protocol: for example, QuickFix is ​​an open implementation in C ++ (there is also QuickFix in Java (QuickFix / J), C # (QuickFix / N) and Go (QuickFix / Go));
  • , ( Open Source Java – QuikFIX/J);
  • ( , , MiniFIX).

FIX, . FIX 4.2.


FIX

FIX , . , . FIX 4.2. FIX- / , .


FIX-: ( tag=value) XML.


FIX- , , , ASCII- SOH (0x01). , , Market 10000 Microsoft ( SOH ):


8=FIX.4.2 9=103 35=D 34=3 49=BANZAI 52=20121105-23:24:42 56=EXEC 11=1352157882577 21=1 38=10000 40=1 54=1 55=MSFT 59=0 10=062.


FIX-: (Message Header), (Message Body) (Message Trailer).



– <8>BeginString, FIX- (8=FIX.4.2). <9> BodyLength <35> MsgType. , D (35=D), β€” V (35=V).


, :


  • <49> SenderCompID – (, );
  • <56> TargetCompID – ;
  • <56> SendingTime – UTC- ( YYYYMMDD-HH:MM:SS YYYYMMDD-HH:MM:SS.sss);
  • <34> MsgSeqNum – ( 1 ).

MsgSeqNum 1, .


, : , , .. , .


FIX-. , .

– (<10> CheckSum), . . , .



FIX initiator executor/acceptor . , QuikFIX/J quickfixj-examples: quickfix.examples.executor .


:



resources/quickfix/examples/executor/executor.cfg, :


[default]
ConnectionType=acceptor // ,    
SenderCompID=EXEC //  
TargetCompID=BANZAI //  

[session]
BeginString=FIX.4.2 //   - FIX4.2
SocketAcceptPort=9878 //   

MINIFIX_CLIENT ( ).


MiniFIX . Session :



ID – MINIFIX_CLIENT – EXEC. (FIX 4.2) .


  • : , , ; , , ;
  • : Logon (MsgType = A) ; .

Connect . 4.2 9878, , localhost:9878:



, localhost IP- .

Logon- Logon-:



β€œ ”, , :


MiniFIX Transactions , ( , New):



( β€” , β€” ).


– New Order Single (35=D).

, MiniFIX , , , New, Edit, Delete. , 38=1000 . 200:



Send, , :



  • – SocketConnectPort;
  • – , SenderCompID TargetCompID ;
  • – ;
  • – ; Reset Sequence MiniFIX, ;
  • (, ); <3> Reject 58:


  • MiniFIX: ” – , β€œβ€ ;
  • MiniFIX: Logon- – , , Logon.

Now you can test the sending of various types of messages using MiniFIX. Of course, to work directly with a real exchange it is better to write your own client implementation (for example, in Java or Go) or use a trading terminal. But in order to understand the specification of messages and understand how to compose them correctly, such a working environment is quite enough. In the next part I will tell you what financial instruments are traded on the stock exchange and how to correctly specify the parameters for these instruments when placing a trading order. For those who are interested in technical details and writing their own client, I plan to write a separate article.


All Articles