Skip to content

Commit

Permalink
Update to API v163
Browse files Browse the repository at this point in the history
  • Loading branch information
lbilli committed Sep 22, 2021
1 parent f276526 commit 9f8c738
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Jib"
uuid = "f310f2d2-a263-11e8-3998-47bd686f18f7"
authors = ["Luca Billi <[email protected]>"]
version = "0.12.4"
version = "0.13.0"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
14 changes: 7 additions & 7 deletions data/wrapper_signatures.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tickPrice= function(tickerId::Int, field::String, price::Float64, size::Int, attrib::TickAttrib)
tickPrice= function(tickerId::Int, field::String, price::Float64, size::Float64, attrib::TickAttrib)

tickSize= function(tickerId::Int, field::String, size::Int)
tickSize= function(tickerId::Int, field::String, size::Float64)

tickOptionComputation= function(tickerId::Int, tickType::String, tickAttrib::Union{Int,Nothing}, impliedVol::Union{Float64,Nothing}, delta::Union{Float64,Nothing}, optPrice::Union{Float64,Nothing}, pvDividend::Union{Float64,Nothing}, gamma::Union{Float64,Nothing}, vega::Union{Float64,Nothing}, theta::Union{Float64,Nothing}, undPrice::Union{Float64,Nothing})

Expand Down Expand Up @@ -38,9 +38,9 @@ execDetailsEnd= function(reqId::Int)

error= function(id::Union{Int,Nothing}, errorCode::Union{Int,Nothing}, errorString::String)

updateMktDepth= function(id::Int, position::Int, operation::Int, side::Int, price::Float64, size::Int)
updateMktDepth= function(id::Int, position::Int, operation::Int, side::Int, price::Float64, size::Float64)

updateMktDepthL2= function(id::Int, position::Int, marketMaker::String, operation::Int, side::Int, price::Float64, size::Int, isSmartDepth::Bool)
updateMktDepthL2= function(id::Int, position::Int, marketMaker::String, operation::Int, side::Int, price::Float64, size::Float64, isSmartDepth::Bool)

updateNewsBulletin= function(msgId::Int, msgType::Int, newsMessage::String, originExch::String)

Expand All @@ -54,7 +54,7 @@ scannerParameters= function(xml::String)

scannerData= function(reqId::Int, rank::Vector{Int}, contractDetails::Vector{ContractDetails}, distance::Vector{String}, benchmark::Vector{String}, projection::Vector{String}, legsStr::Vector{String})

realtimeBar= function(reqId::Int, time::Int, open::Float64, high::Float64, low::Float64, close::Float64, volume::Int, wap::Float64, count::Int)
realtimeBar= function(reqId::Int, time::Int, open::Float64, high::Float64, low::Float64, close::Float64, volume::Float64, wap::Float64, count::Int)

currentTime= function(time::Int)

Expand Down Expand Up @@ -144,9 +144,9 @@ historicalTicksBidAsk= function(reqId::Int, ticks::DataFrame, done::Bool)

historicalTicksLast= function(reqId::Int, ticks::DataFrame, done::Bool)

tickByTickAllLast= function(reqId::Int, tickType::Int, time::Int, price::Float64, size::Int, attribs::TickAttribLast, exchange::String, specialConditions::String)
tickByTickAllLast= function(reqId::Int, tickType::Int, time::Int, price::Float64, size::Float64, attribs::TickAttribLast, exchange::String, specialConditions::String)

tickByTickBidAsk= function(reqId::Int, time::Int, bidPrice::Float64, askPrice::Float64, bidSize::Int, askSize::Int, attribs::TickAttribBidAsk)
tickByTickBidAsk= function(reqId::Int, time::Int, bidPrice::Float64, askPrice::Float64, bidSize::Float64, askSize::Float64, attribs::TickAttribBidAsk)

tickByTickMidPoint= function(reqId::Int, time::Int, midPoint::Float64)

Expand Down
42 changes: 22 additions & 20 deletions src/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
tickerId::Int,
ticktype::Int,
price::Float64,
size::Int,
size::Float64,
mask::Int = it

w.tickPrice(tickerId, tickname(ticktype), price, size, unmask(TickAttrib, mask))
Expand All @@ -98,7 +98,7 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?

tickerId::Int,
ticktype::Int,
size::Int = it
size::Float64 = it

w.tickSize(tickerId, tickname(ticktype), size)
end,
Expand Down Expand Up @@ -320,6 +320,8 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
:realExpirationDate,
:stockType), it)

ver Client.FRACTIONAL_SIZE_SUPPORT && (cd.sizeMinTick = pop(it))

w.contractDetails(reqId, cd)
end,

Expand All @@ -338,10 +340,10 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
end,

# MARKET_DEPTH
12 => (it, w, ver) -> w.updateMktDepth(slurp((Int,Int,Int,Int,Float64,Int), it)...),
12 => (it, w, ver) -> w.updateMktDepth(slurp((Int,Int,Int,Int,Float64,Float64), it)...),

# MARKET_DEPTH_L2
13 => (it, w, ver) -> w.updateMktDepthL2(slurp((Int,Int,String,Int,Int,Float64,Int,Bool), it)...),
13 => (it, w, ver) -> w.updateMktDepthL2(slurp((Int,Int,String,Int,Int,Float64,Float64,Bool), it)...),

# NEWS_BULLETINS
14 => (it, w, ver) -> w.updateNewsBulletin(slurp((Int,Int,String,String), it)...),
Expand All @@ -362,7 +364,7 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?

n::Int = pop(it)

df = fill_df([String,Float64,Float64,Float64,Float64,Int,Float64,Int],
df = fill_df([String,Float64,Float64,Float64,Float64,Float64,Float64,Int],
[:time, :open, :high, :low, :close, :volume, :wap, :count],
n, it)

Expand Down Expand Up @@ -508,7 +510,7 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
end,

# REAL_TIME_BARS
50 => (it, w, ver) -> w.realtimeBar(slurp((Int,Int,Float64,Float64,Float64,Float64,Int,Float64,Int), it)...),
50 => (it, w, ver) -> w.realtimeBar(slurp((Int,Int,Float64,Float64,Float64,Float64,Float64,Float64,Int), it)...),

# FUNDAMENTAL_DATA
51 => (it, w, ver) -> w.fundamentalData(slurp((Int,String), it)...),
Expand Down Expand Up @@ -731,7 +733,7 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
reqId::Int,
n::Int = it

df = fill_df([Float64,Int], [:price, :size], n, it)
df = fill_df([Float64,Float64], [:price, :size], n, it)

w.histogramData(reqId, df)
end,
Expand All @@ -748,7 +750,7 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
:high,
:low,
:wap,
:volume)}(slurp((Int,String,Float64,Float64,Float64,Float64,Float64,Int), it))
:volume)}(slurp((Int,String,Float64,Float64,Float64,Float64,Float64,Float64), it))

w.historicalDataUpdate(reqId, bar)
end,
Expand Down Expand Up @@ -801,11 +803,11 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
reqId::Int,
n::Int = it

df = fill_df([Int,Int,Float64,Int], [:time, :ignore, :price, :size], n, it)
df = fill_df([Int,Int,Float64,Float64], [:time, :ignore, :price, :size], n, it)

select!(df, Not(:ignore))

# TODO: Convert df[:time] to [Zoned]DateTime
# TODO: Convert df.time to [Zoned]DateTime

done::Bool = pop(it)

Expand All @@ -818,10 +820,10 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
reqId::Int,
n::Int = it

df = fill_df([Int,Int,Float64,Float64,Int,Int], [:time, :mask, :priceBid, :priceAsk, :sizeBid, :sizeAsk], n, it)
df = fill_df([Int,Int,Float64,Float64,Float64,Float64], [:time, :mask, :priceBid, :priceAsk, :sizeBid, :sizeAsk], n, it)

# TODO: Convert df[:time] to [Zoned]DateTime
# TODO: Unmask df[:mask]
# TODO: Convert df.time to [Zoned]DateTime
# TODO: Unmask df.mask

done::Bool = pop(it)

Expand All @@ -834,10 +836,10 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
reqId::Int,
n::Int = it

df = fill_df([Int,Int,Float64,Int,String,String], [:time, :mask, :price, :size, :exchange, :specialConditions], n, it)
df = fill_df([Int,Int,Float64,Float64,String,String], [:time, :mask, :price, :size, :exchange, :specialConditions], n, it)

# TODO: Convert df[:time] to [Zoned]DateTime
# TODO: Unmask df[:mask]
# TODO: Convert df.time to [Zoned]DateTime
# TODO: Unmask df.mask

done::Bool = pop(it)

Expand All @@ -851,12 +853,12 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
ticktype::Int,
time::Int = it

mask::Int = 0 # To avoid "multiple type declarations" error
local mask::Int # To avoid "multiple type declarations" error

if ticktype (1, 2)

price::Float64,
size::Int,
size::Float64,
mask,
exchange::String,
specialConditions::String = it
Expand All @@ -867,8 +869,8 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?

bidPrice::Float64,
askPrice::Float64,
bidSize::Int,
askSize::Int,
bidSize::Float64,
askSize::Float64,
mask = it

w.tickByTickBidAsk(reqId, time, bidPrice, askPrice, bidSize, askSize, unmask(TickAttribBidAsk, mask))
Expand Down
6 changes: 4 additions & 2 deletions src/types_private.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mutable struct ContractDetails
realExpirationDate::String
lastTradeTime::String
stockType::String
sizeMinTick::Union{Float64,Nothing}
secIdList::NamedTuple
cusip::String
ratings::String
Expand All @@ -58,8 +59,9 @@ mutable struct ContractDetails
notes::String
end
ContractDetails() = ContractDetails(Contract(), ns, 0, ns, ns, 0, 0, fill(ns, 9)...,
nothing, 0, nothing, fill(ns, 6)..., (;), fill(ns, 5)...,
false, false, nothing, false, ns, ns, ns, ns, false, ns)
nothing, 0, nothing, fill(ns, 6)..., nothing, (;),
fill(ns, 5)..., false, false, nothing, false, ns,
ns, ns, ns, false, ns)


struct Execution
Expand Down
1 change: 1 addition & 0 deletions src/versions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
POST_TO_ATS = 160
WSHE_CALENDAR = 161
AUTO_CANCEL_PARENT = 162
FRACTIONAL_SIZE_SUPPORT = 163

end
14 changes: 7 additions & 7 deletions src/wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ function simple_wrap()

w = Wrapper(

tickPrice= (tickerId::Int, field::String, price::Float64, size::Int, attrib::TickAttrib) ->
tickPrice= (tickerId::Int, field::String, price::Float64, size::Float64, attrib::TickAttrib) ->
println("tickPrice: $tickerId $field $price $size $attrib"),

tickSize= (tickerId::Int, field::String, size::Int) -> println("tickSize: $tickerId $field $size"),
tickSize= (tickerId::Int, field::String, size::Float64) -> println("tickSize: $tickerId $field $size"),

tickOptionComputation= function(tickerId::Int, tickType::String, tickAttrib::Union{Int,Nothing}, impliedVol::Union{Float64,Nothing}, delta::Union{Float64,Nothing}, optPrice::Union{Float64,Nothing}, pvDividend::Union{Float64,Nothing}, gamma::Union{Float64,Nothing}, vega::Union{Float64,Nothing}, theta::Union{Float64,Nothing}, undPrice::Union{Float64,Nothing})
d[:option] = (tickType, tickAttrib, impliedVol, delta, optPrice, pvDividend, gamma, vega, theta, undPrice)
Expand Down Expand Up @@ -178,10 +178,10 @@ function simple_wrap()
something(errorCode, "NA"), " ",
errorString),

updateMktDepth= (id::Int, position::Int, operation::Int, side::Int, price::Float64, size::Int) ->
updateMktDepth= (id::Int, position::Int, operation::Int, side::Int, price::Float64, size::Float64) ->
println("mktDepth: $id $position $operation $side $price $size"),

updateMktDepthL2= (id::Int, position::Int, marketMaker::String, operation::Int, side::Int, price::Float64, size::Int, isSmartDepth::Bool) ->
updateMktDepthL2= (id::Int, position::Int, marketMaker::String, operation::Int, side::Int, price::Float64, size::Float64, isSmartDepth::Bool) ->
println("mktDepthL2: $id $position $marketMaker $operation $side $price $size $isSmartDepth"),

updateNewsBulletin= function(msgId::Int, msgType::Int, newsMessage::String, originExch::String)
Expand Down Expand Up @@ -217,7 +217,7 @@ function simple_wrap()
println("scannerData: $reqId")
end,

realtimeBar= (reqId::Int, time::Int, open::Float64, high::Float64, low::Float64, close::Float64, volume::Int, wap::Float64, count::Int) ->
realtimeBar= (reqId::Int, time::Int, open::Float64, high::Float64, low::Float64, close::Float64, volume::Float64, wap::Float64, count::Int) ->
println("realtimeBar: $reqId $time $open $high, $low $close $volume $wap $count"),

currentTime= (time::Int) -> println("currentTime: $time"),
Expand Down Expand Up @@ -360,10 +360,10 @@ function simple_wrap()
println("historicalTicksLast: $reqId $done")
end,

tickByTickAllLast= (reqId::Int, tickType::Int, time::Int, price::Float64, size::Int, attribs::TickAttribLast, exchange::String, specialConditions::String) ->
tickByTickAllLast= (reqId::Int, tickType::Int, time::Int, price::Float64, size::Float64, attribs::TickAttribLast, exchange::String, specialConditions::String) ->
println("tickByTickAllLast: $reqId $tickType $time $price $size $attribs $exchange $specialConditions"),

tickByTickBidAsk= (reqId::Int, time::Int, bidPrice::Float64, askPrice::Float64, bidSize::Int, askSize::Int, attribs::TickAttribBidAsk) ->
tickByTickBidAsk= (reqId::Int, time::Int, bidPrice::Float64, askPrice::Float64, bidSize::Float64, askSize::Float64, attribs::TickAttribBidAsk) ->
println("tickByTickBidAsk: $reqId $time $bidPrice $askPrice $bidSize $askSize $attribs"),

tickByTickMidPoint= (reqId::Int, time::Int, midPoint::Float64) ->
Expand Down

0 comments on commit 9f8c738

Please sign in to comment.