Skip to content
/ FIX.jl Public

Basic implementation of Financial Information eXchange protocol in Julia

License

Notifications You must be signed in to change notification settings

DatName/FIX.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FIX.jl - WIP

FIX API client written in Julia.

Installation

julia> Pkg.clone("[email protected]:DatName/FIX.jl.git")

Overview

This package can:

  • inefficiently convert Dict{Int64, String} to FIX messages (attaching header and tail)
  • inefficiently parse incoming messages of Vector{UInt8} into Dict{Int64, String}.
  • keep track of messaging history
  • give you current (confirmed) outstanding orders
  • give you position change since the start of FIXClient
  • keep track of messaging rates

Usage

julia> using FIX
julia> sock = MbedTLS.connect("127.0.0.1", 1498)
julia> client = FIXClient(sock, message_handler, header, ratelimit)

where message_handler is a subtype of AbstractMessageHandler, header is a Dict{Int64, String} with keys 8, 49 and 56. ratelimit is an instance of RateLimit exported by FIX.jl to track order sending rates.

julia> FIX.send_message(client, Dict(1 => "a", 2 => "5"))
julia> FIX.getOpenOrders(client)

and so on.

Your custom message_handler must implement method onFIXMessage in order to handle incoming messages. For example:

struct EchoFIXHandler <: AbstractMessageHandler
end

import FIX: onFIXMessage
function onFIXMessage(this::EchoFIXHandler, msg)
  @info "received fix message" msg
end

Benchmarks

Message parsing and converting can be made much faster. But for now it is (Intel® Core™ i3-6100U CPU @ 2.30GHz × 4):

Placing order benchmark:

julia @benchmark fix.placeOrder_fake(client, "buy", "BTC-EUR", 0.0001001, 12000.0)

BenchmarkTools.Trial:
  memory estimate:  13.72 KiB
  allocs estimate:  216
  --------------
  minimum time:     16.269 μs (0.00% GC)
  median time:      23.513 μs (0.00% GC)
  mean time:        40.526 μs (33.47% GC)
  maximum time:     25.061 ms (99.50% GC)
  --------------
  samples:          10000
  evals/sample:     1

Parsing message benchmark:

julia> (msg, msg_str) = fix.placeOrder(client, "buy", "BTC-EUR", 0.0001001, 12000.0)
julia> b = [UInt8(x) for x in msg_str]
julia> @benchmark FIX.fixparse(b)

BenchmarkTools.Trial:
  memory estimate:  15.17 KiB
  allocs estimate:  350
  --------------
  minimum time:     14.758 μs (0.00% GC)
  median time:      16.224 μs (0.00% GC)
  mean time:        22.086 μs (12.82% GC)
  maximum time:     5.826 ms (98.32% GC)
  --------------
  samples:          10000
  evals/sample:     1

About

Basic implementation of Financial Information eXchange protocol in Julia

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages