FIX Procotol

FIX 协议简介

FIX(Financial Information eXchange Protocol,金融信息交换协议)是由国际FIX协会组织提供的一个开放式协议,目的是推动国际贸易电子化进程,在各类参与者之间,包括投资经理、经纪人、买方、卖方建立起实时的电子化通讯协议。

FIX协议的目标是把各类证券金融业务需求流程格式化,成为一个可用计算机语言描述的功能流程,并在每个业务功能接口上统一交换格式,方便各个功能模块的连接。

消息格式

FIX 协议消息均由多个 "key=value" 组成。其中 key 可以是协议规定的字段,或自定义字段。协议规定的key可查询 FIX 协议字典,【不同版本的 FIX 协议均有其字典,用于开发的库一般也有自带;也可参考第三方,如 wireshark】例如 8 代表 begin string,34 代表消息的序列号,52 代表时间戳等。自定义字段不与规定的 key 重复,供金融机构定制,开发时需要向对应金融机构获取其专有字段的字典。只要有了对应的字典,就可以读懂 FIX 数据包的内容。

一般来说,一个 消息由"头部 + 消息体 + 尾部"构成。头部包含一些必要的字段,例如 BeginString (8)、BodyLength (9)、MsgType (35)、MsgSeqNum (34)、SenderCompID (49) 等,尾部包含的必要字段是 CheckSum (10)。

FIX 登陆消息示例("^"是分隔符):

8=FIX.4.3^9=65^35=A^34=1^49=TESTACC^52=20130703-15:55:08.609^56=EXEC^98=0^108=30^10=225^

对照字典可知,BeginString (8) 是 FIX.4.3;BodyLength (9) 是 65 字节;MsgType (35) 是 A,A 对应 logon 操作;MsgSeqNum (34) 是 1,即这是我方发送的第 1 个消息。

FIX 参考网站

FIX Reference:

www.onixs.biz/fix-diction...

FIX Parser:

fixparser.targetcompid.com/

FIX 常用tag

Tag: <1> Account

Tag: <8> BeginString

Tag: <10> CheckSum

Tag: <11> ClOrderID

Unique identifier for Order as assigned by institution (identified by SenderCompID <49>)

Tag: <15> Currency

Tag: <17> ExecID

Unique identifier of execution message as assigned by broker

Tag: <31> LastPx

Tag: <32> LastShares

Tag: <34> MsgSeqNum

Tag: <35> MsgType

0 = Heartbeat <0>

5 = Logout <5>

8 = Execution Report <8>

9 = Order Cancel Reject <9>

A = Logon
D = Order - Single
F = Order Cancel Request
G= Order Cancel/Replace Request

Tag: <37>OrderID

Tag: <38> OrderQty

Tag: <39> OrdStatus

Tag: <40> OrdType

1 = Market

2 = Limit

Tag: <41> OrigClOrdID

ClOrdID <11> of the previous order (NOT the initial order of the day) as assigned by the institution, used to identify the previous order in cancel and cancel/replace requests.

Tag: <44> Price

Tag: <48> SecurityID

Tag: <49> SenderCompID

Assigned value used to identify firm sending message

Tag: <52> SendingTime

Tag: <54> Side

1 = Buy

2 = Sell

5 = Sell Short

6 = Sell Short exempt

Tag: <55> Symbol

Ticker symbol

Tag: <56> TargetCompID

Tag: <59> TimeInForce

0 = Day

1 = Good Till Cancel (GTC)

2 = At the Opening (OPG)

3 = Immediate or Cancel (IOC)

4 = Fill or Kill (FOK)

Tag: <60> TransactTime

Time of execution/order creation (expressed in UTC (Universal Time Coordinated, also known as 'GMT')

Tag: <77> OpenClose

O=Open

C=Close

Tag: <150> ExecType

0 = New

1 = Partial fill

2 = Fill

4 = Canceled

5 = Replaced

A = Pending New

Tag: <151> LeavesQty

LeavesQty <151> = OrderQty <38> - CumQty <14>

Tag: <167> SecurityType

CS = Common Stock

FUT = Future

OPT = Option

WAR = Warrant

Tag: <375> ContraBroker

Identifies contra broker. Standard NASD market-maker mnemonic is preferred.

Used per application:

Tag: <6> AvgPx

Tag: <14> CumQty

Repeating Group:

Tag: <453> NoPartyIDs

Tag: <448> PartyID

Party identifier/code

Tag: <447> PartyIDSource

D = Proprietary/Custom code

Tag: <452> PartyRole

5 = Investor ID

e.g.

453=2448=BCAN_id447=D452=5448=BrokerId447=D452=1

Other documents:

Reason Text List from HKEX

FIX Engine

What is FIX Engine:

Fix engines are a program written in any programming language like Java, C++ which is used to facilitate online trading using FIX Protocol. it's an implementation of FIX protocol and a single piece of software required to establish FIX connectivity.

FIX messages which carry stocks trading orders electronically in the form of tag and value is composed, parse and understand by FIX engines. FIX engines are also responsible for establishing FIX connectivity between client and broker or client and exchange.

In a simple FIX connectivity setup, we have two FIX engines running one at the client-side and other at the broker or exchange side. These FIX engines first establish FIX sessions between each other and then transmit application-level messages(electronic stock order, cancels and order amendments etc). In Short FIX engine is an essential piece of software your company will require building electronic trading infrastructure.

What does FIX Engine do:

here is a short summary of what is the responsibility of FIX engine and what does fix engine do:

  1. Establish Fix Connectivity by sending session level messages.

  2. manage FIX Session

  3. recover if FIX session lost

  4. creating, sending, parsing FIX messages for electronic trading.

  5. handles replay

  6. supports different FIX (Financial information exchange) protocol version and tags.

Popular FIX Engine:

  1. NYFIX Appia

by far most used, flexible, robust, and easy to maintain and support. what is the best feature of Appia is that it provides you to create a new FIX session on the fly and manage fix sessions without downtime in the FIX engine?

  1. B2Bits

B2Bits offers fix engines and fix solutions in Java, .NET, and C++.

  1. QuickFIX

this is an open course FIX Engine which has an implementation in Java, known as QuickFIXJ as well as implementation in C++ and other programming languages. If you are looking for a free-of-cost FIX engine, then QuickFIX is a good choice.

  1. Chronicle FIX Engine

Chronicle FIX is quick. While QuickFIX struggles to be under 50 micro-seconds to parse + generate, Chronicle FIX is comfortably under two micro-seconds to do both, most of the time.

相关推荐
天使day5 分钟前
Maven
java·maven
汇匠源8 分钟前
共享无人系统,从出行到生活全面覆盖
java·生活
开发者每周简报1 小时前
求职市场变化
人工智能·面试·职场和发展
小灰灰要减肥1 小时前
装饰者模式
java
张铁铁是个小胖子1 小时前
MyBatis学习
java·学习·mybatis
Yan.love2 小时前
开发场景中Java 集合的最佳选择
java·数据结构·链表
椰椰椰耶2 小时前
【文档搜索引擎】搜索模块的完整实现
java·搜索引擎
大G哥2 小时前
java提高正则处理效率
java·开发语言
智慧老师2 小时前
Spring基础分析13-Spring Security框架
java·后端·spring
lxyzcm3 小时前
C++23新特性解析:[[assume]]属性
java·c++·spring boot·c++23