fix
| Kind | kit |
|---|---|
| Categories | network finance |
| Keywords | fix trading finance protocol hft |
FIX protocol (Financial Information eXchange) implementation for Kit
Files
| File | Description |
|---|---|
kit.toml | Package manifest with metadata and dependencies |
src/main.kit | Session management, message encoding, and order types |
tests/fix.test.kit | Version, error type, and trait implementation tests |
examples/market-data.kit | Market data subscription and quote processing |
examples/simple-client.kit | Order submission and execution report handling |
LICENSE | MIT license file |
Dependencies
No Kit package dependencies.
Installation
kit add gitlab.com/kit-lang/packages/kit-fix.gitUsage
import Kit.FixLicense
MIT License - see LICENSE for details.
Exported Functions & Types
FIXVersion
Supported FIX protocol versions.
Variants
FIX42FIX44FIX50FIXError
FIX protocol error type for typed error handling.
Variants
FIXConnectionError {message}FIXSessionError {message}FIXLogonError {message}FIXLogoutError {message}FIXSendError {message}FIXRecvError {message}FIXParseError {message}FIXChecksumError {expected, actual}FIXSequenceError {expected, received}FIXTimeoutError {message}FIXRejectError {ref-seq-num, reason}FIXGapError {begin-seq, end-seq}tags
Standard FIX field tags. See https://www.onixs.biz/fix-dictionary.html for complete reference.
msg-types
FIX message type codes.
Side
Order side enumeration.
Variants
BuySellBuyMinusSellPlusSellShortSellShortExemptside-to-fix
Convert side to FIX value.
Side -> String
fix-to-side
Parse side from FIX value.
String -> Option Side
OrderType
Order type enumeration.
Variants
MarketLimitStopStopLimitMarketOnCloseWithOrWithoutLimitOrBetterLimitWithOrWithoutorder-type-to-fix
Convert order type to FIX value.
OrderType -> String
fix-to-order-type
Parse order type from FIX value.
String -> Option OrderType
TimeInForce
Time in force enumeration.
Variants
DayGTCAtTheOpeningIOCFOKGoodTillCrossingGoodTillDateAtTheClosetif-to-fix
Convert time in force to FIX value.
TimeInForce -> String
fix-to-tif
Parse time in force from FIX value.
String -> Option TimeInForce
ExecType
Execution type enumeration.
Variants
ExecNewPartialFillFillDoneForDayCanceledReplacedPendingCancelStoppedRejectedSuspendedPendingNewCalculatedExpiredPendingReplaceTradeTradeCorrectTradeCancelOrderStatusfix-to-exec-type
Parse execution type from FIX value.
String -> Option ExecType
OrdStatus
Order status enumeration.
Variants
OrdNewPartiallyFilledFilledDoneForDayCanceledReplacedPendingCancelStoppedRejectedSuspendedPendingNewCalculatedExpiredAcceptedForBiddingPendingReplacefix-to-ord-status
Parse order status from FIX value.
String -> Option OrdStatus
MDUpdateAction
MD Update Action enumeration.
Variants
MDNewMDChangeMDDeletefix-to-md-update-action
Parse MD update action from FIX value.
String -> Option MDUpdateAction
SessionStatus
Session status for state machine.
Variants
DisconnectedSocketConnectedLogonSentLoggedOnResendRequestedLogoutSentLogoutReceivedFIXMessage
FIX message algebraic data type.
Variants
Logon {encrypt-method, heartbeat-int, reset-seq-num, username, password}Logout {text}Heartbeat {test-req-id}TestRequest {test-req-id}ResendRequest {begin-seq-no, end-seq-no}SequenceReset {gap-fill, new-seq-no}Reject {ref-seq-num, ref-tag-id, ref-msg-type, session-reject-reason, text}NewOrderSingle {cl-ord-id, account, symbol, side, order-qty, price, stop-px, ord-type, time-in-force, min-qty, max-floor, ex-destination, transact-time}OrderCancelRequest {cl-ord-id, orig-cl-ord-id, order-id, symbol, side, order-qty, transact-time}OrderCancelReplaceRequest {cl-ord-id, orig-cl-ord-id, order-id, account, symbol, side, order-qty, price, stop-px, ord-type, time-in-force, transact-time}OrderStatusRequest {cl-ord-id, order-id, symbol, side}ExecutionReport {order-id, secondary-order-id, cl-ord-id, orig-cl-ord-id, exec-id, exec-type, ord-status, ord-rej-reason, account, symbol, side, order-qty, ord-type, price, stop-px, time-in-force, last-px, last-qty, leaves-qty, cum-qty, avg-px, transact-time, text}OrderCancelReject {order-id, cl-ord-id, orig-cl-ord-id, ord-status, cxl-rej-response-to, cxl-rej-reason, text}MarketDataRequest {md-req-id, subscription-type, market-depth, md-update-type, aggregated-book, symbols, entry-types}MarketDataSnapshot {md-req-id, symbol, entries}MarketDataIncremental {md-req-id, entries}MarketDataRequestReject {md-req-id, md-req-rej-reason, text}RawMessage {msg-type, fields}Market data entry.
Message store for tracking sent messages (needed for resend).
message-store-new
Create a new message store.
Int -> MessageStore
message-store-add
Store a sent message.
MessageStore -> Int -> String -> MessageStore
message-store-get-range
Get messages for resend.
MessageStore -> Int -> Int -> List String
FIX session configuration.
default-config
Default session configuration.
FIX session state.
calculate-checksum
Calculate FIX checksum.
String -> Int
timestamp
Get current timestamp in FIX format (YYYYMMDD-HH:MM:SS.sss).
String
encode
Encode a FIX message to wire format.
SessionState -> FIXMessage -> String
decode
Decode a FIX message from wire format.
String -> Result FIXMessage FIXError
disconnect
Disconnect from a FIX session.
SessionState -> Unit
send
Send a FIX message.
SessionState -> FIXMessage -> Result SessionState FIXError
recv
Receive a FIX message with admin message handling.
SessionState -> Result (FIXMessage, SessionState) FIXError
recv-timeout
Receive a FIX message with timeout.
SessionState -> Int -> Result (FIXMessage, SessionState) FIXError
check-heartbeat
Check and send heartbeat if needed.
SessionState -> Result SessionState FIXError
is-active?
Check if session is active.
SessionState -> Bool
status
Get session status.
SessionState -> SessionStatus
out-seq-num
Get outbound sequence number.
SessionState -> Int
in-seq-num
Get inbound sequence number.
SessionState -> Int
new-order-single
Create a new order single message.
{cl-ord-id: String, account: Option String, symbol: String, side: Side, order-qty: Float, price: Option Float, stop-px: Option Float, ord-type: Option OrderType, time-in-force: Option TimeInForce, min-qty: Option Float, max-floor: Option Float, ex-destination: Option String} -> FIXMessage
cancel-order
Create an order cancel request message.
{cl-ord-id: String, orig-cl-ord-id: String, order-id: Option String, symbol: String, side: Side, order-qty: Float} -> FIXMessage
replace-order
Create an order cancel/replace request message.
{cl-ord-id: String, orig-cl-ord-id: String, order-id: Option String, account: Option String, symbol: String, side: Side, order-qty: Float, price: Option Float, stop-px: Option Float, ord-type: Option OrderType, time-in-force: Option TimeInForce} -> FIXMessage
order-status
Create an order status request message.
{cl-ord-id: Option String, order-id: Option String, symbol: String, side: Side} -> FIXMessage
market-data-request
Create a market data request message. Note: Due to Kit type inference bug with variant constructors containing List fields, this function must be implemented manually by the user for now. Use: MarketDataRequest { md-req-id: ..., subscription-type: ..., market-depth: ..., md-update-type: ..., aggregated-book: ..., symbols: ..., entry-types: ... }
{md-req-id: String, symbols: List String, subscription-type: Option Int, market-depth: Option Int, md-update-type: Option Int, aggregated-book: Option Bool, entry-types: Option (List Int)} -> FIXMessage
market-data-unsubscribe
Unsubscribe from market data.
String -> FIXMessage
HeartbeatMsg
Heartbeat monitor message types.
Variants
TickUpdateSentTime {time, seq-num}UpdateRecvTime {time}Stopstop-heartbeat-monitor
Stop the heartbeat monitor.
Ptr -> Unit
tick-heartbeat-monitor?
Manually tick the heartbeat monitor. Call this periodically (e.g., once per second) to check heartbeat timing.
Ptr -> Unit
notify-sent?
Notify the heartbeat monitor that a message was sent. Call this after every FIX.send to keep timing accurate.
Ptr -> SessionState -> Unit
notify-recv?
Notify the heartbeat monitor that a message was received. Call this after every FIX.recv to reset the timeout.
Ptr -> Unit
heartbeat-alive?
Check if the heartbeat monitor detected a dead connection.
Ptr -> Bool
Enhanced session state with automatic heartbeat.
disconnect-auto
Disconnect an auto-heartbeat session.
AutoSession -> Unit
send-auto
Send a message via an auto-heartbeat session.
AutoSession -> FIXMessage -> Result AutoSession FIXError
recv-auto
Receive a message via an auto-heartbeat session.
AutoSession -> Result (FIXMessage, AutoSession) FIXError
recv-timeout-auto
Receive with timeout via an auto-heartbeat session.
AutoSession -> Int -> Result (FIXMessage, AutoSession) FIXError
is-healthy?
Check if the auto-session's heartbeat monitor is still alive.
AutoSession -> Bool