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.

相关推荐
杨荧几秒前
【JAVA毕业设计】基于Vue和SpringBoot的服装商城系统学科竞赛管理系统
java·开发语言·vue.js·spring boot·spring cloud·java-ee·kafka
minDuck2 分钟前
ruoyi-vue集成tianai-captcha验证码
java·前端·vue.js
为将者,自当识天晓地。21 分钟前
c++多线程
java·开发语言
daqinzl29 分钟前
java获取机器ip、mac
java·mac·ip
激流丶1 小时前
【Kafka 实战】如何解决Kafka Topic数量过多带来的性能问题?
java·大数据·kafka·topic
Themberfue1 小时前
Java多线程详解⑤(全程干货!!!)线程安全问题 || 锁 || synchronized
java·开发语言·线程·多线程·synchronized·
时差9531 小时前
【面试题】Hive 查询:如何查找用户连续三天登录的记录
大数据·数据库·hive·sql·面试·database
让学习成为一种生活方式1 小时前
R包下载太慢安装中止的解决策略-R语言003
java·数据库·r语言
晨曦_子画1 小时前
编程语言之战:AI 之后的 Kotlin 与 Java
android·java·开发语言·人工智能·kotlin
南宫生2 小时前
贪心算法习题其三【力扣】【算法学习day.20】
java·数据结构·学习·算法·leetcode·贪心算法