https://github.com/joelibaceta/fix-protocol
FIX message classes, parsing and generation
https://github.com/joelibaceta/fix-protocol
Last synced: about 2 months ago
JSON representation
FIX message classes, parsing and generation
- Host: GitHub
- URL: https://github.com/joelibaceta/fix-protocol
- Owner: joelibaceta
- License: mit
- Created: 2015-09-14T07:30:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-01-13T12:08:28.000Z (over 10 years ago)
- Last Synced: 2025-04-14T04:00:44.872Z (about 2 months ago)
- Language: Ruby
- Size: 504 KB
- Stars: 0
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
FIX Protocol [](http://travis-ci.org/Paymium/fix-protocol) [](https://coveralls.io/r/Paymium/fix-protocol?branch=master) [](http://badge.fury.io/rb/fix-protocol)
=This FIX protocol wrapper enables one to easily parse and create messages complying with the FIX 4.4 specification.
It includes definitions for admin messages (logon, logout, reject, heartbeat, resend request, test request), for some market data messages (market data request, market data snapshot, and market data incremental refresh) as well as the ability to easily define other ones.
## Message creation example
Messages are created by instantiating the relevant message class and serialized using the `#dump` method.
````ruby
require 'fix/protocol'msg = FP::Messages::Logon.new
msg.sender_comp_id = 'MY_ID'
msg.target_comp_id = 'MY_COUNTERPARTY'
msg.msg_seq_num = 0
msg.username = 'MY_USERNAME'if msg.valid?
puts msg.dump
else
puts msg.errors.join(", ")
end
````Which would output the sample message : `8=FIX.4.4\x019=105\x0135=A\x0149=MY_ID\x0156=MY_COUNTERPARTY\x0134=0\x0152=20141021-10:33:15\x0198=0\x01108=30\x01553=MY_USERNAME\x01141=\x0110=176\x01`
## Message definition example
Complex message definition is possible using a simple DSL as shown below.
````ruby
module Fix
module Protocol
module Messagesclass MarketDataRequest < Message
SUBSCRIPTION_TYPES = {
snapshot: 0,
updates: 1,
unsubscribe: 2
}MKT_DPTH_TYPES = {
full: 0,
top: 1
}UPDATE_TYPES = {
full: 0,
incremental: 1
}unordered :body do
field :md_req_id, tag: 262, required: true
field :subscription_request_type, tag: 263, required: true, type: :integer, mapping: SUBSCRIPTION_TYPES
field :market_depth, tag: 264, required: true, type: :integer, mapping: MKT_DPTH_TYPES
field :md_update_type, tag: 265, required: true, type: :integer, mapping: UPDATE_TYPEScollection :md_entry_types, counter_tag: 267, klass: FP::Messages::MdEntryType
collection :instruments, counter_tag: 146, klass: FP::Messages::Instrument
endend
end
end
end
````