Skip to content

Commit

Permalink
Update to API v164
Browse files Browse the repository at this point in the history
  • Loading branch information
lbilli committed Oct 21, 2021
1 parent 10039b0 commit dc93110
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 21 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.14.0"
version = "0.14.1"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
3 changes: 2 additions & 1 deletion src/decoder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ function decode(msg, w, ver)
id::Int = pop(it)

# The second field (version) is ignored for id < 75 and != 3, 5, 11, 17, 21
if id < 75 && id (3, 5, 11, 17, 21)
if id < 75 && id (3, 5, 10, 11, 17, 18, 21) ||
id (10, 18) && ver < Client.SIZE_RULES
pop(it)
end

Expand Down
41 changes: 27 additions & 14 deletions src/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
:discretionaryAmt,
:goodAfterTime), it)

pop(it) # Deprecated sharesAllocation
pop(it) # deprecated sharesAllocation

slurp!(o, (:faGroup,
:faMethod,
Expand All @@ -157,9 +157,9 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
:minQty,
:ocaType), it)

pop(it) # Deprecated eTradeOnly
pop(it) # Deprecated firmQuoteOnly
pop(it) # Deprecated nbboPriceCap
pop(it) # deprecated eTradeOnly
pop(it) # deprecated firmQuoteOnly
pop(it) # deprecated nbboPriceCap

slurp!(o, (:parentId,
:triggerMethod), it)
Expand Down Expand Up @@ -302,9 +302,11 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
cd.marketName,
cd.contract.tradingClass,
cd.contract.conId,
cd.minTick,
cd.mdSizeMultiplier,
cd.contract.multiplier = it
cd.minTick = it

ver < Client.SIZE_RULES && pop(it) # deprecated mdSizeMultiplier

cd.contract.multiplier = pop(it)

slurp!(cd, 4:8, it)
cd.contract.primaryExchange = pop(it)
Expand All @@ -320,7 +322,12 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
:realExpirationDate,
:stockType), it)

ver Client.FRACTIONAL_SIZE_SUPPORT && (cd.sizeMinTick = pop(it))
Client.FRACTIONAL_SIZE_SUPPORT ver < Client.SIZE_RULES && pop(it) # deprecated sizeMinTick

ver Client.SIZE_RULES && slurp!(cd, (:minSize,
:sizeIncrement,
:suggestedSizeIncrement,
:minCashQtySize), it)

w.contractDetails(reqId, cd)
end,
Expand Down Expand Up @@ -359,8 +366,8 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?

reqId::Int = pop(it)

pop(it) # Ignore startDate
pop(it) # Ignore endDate
pop(it) # ignore startDate
pop(it) # ignore endDate

n::Int = pop(it)

Expand Down Expand Up @@ -396,11 +403,12 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
cd.contract.currency,
cd.marketName,
cd.contract.tradingClass,
cd.contract.conId = it
cd.contract.conId,
cd.minTick = it

ver < Client.SIZE_RULES && pop(it) # deprecated mdSizeMultiplier

slurp!(cd, (:minTick,
:mdSizeMultiplier,
:orderTypes,
slurp!(cd, (:orderTypes,
:validExchanges,
:nextOptionDate,
:nextOptionType,
Expand All @@ -416,6 +424,11 @@ const process = Dict{Int,Function}( # TODO Use a Tuple instead?
cd.aggGroup,
cd.marketRuleIds = it

ver Client.SIZE_RULES && slurp!(cd, (:minSize,
:sizeIncrement,
:suggestedSizeIncrement,
:minCashQtySize), it)

w.bondContractDetails(reqId, cd)
end,

Expand Down
12 changes: 7 additions & 5 deletions src/types_private.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ mutable struct ContractDetails
liquidHours::String
evRule::String
evMultiplier::Union{Float64,Nothing}
mdSizeMultiplier::Int
aggGroup::Union{Int,Nothing}
underSymbol::String
underSecType::String
marketRuleIds::String
realExpirationDate::String
lastTradeTime::String
stockType::String
sizeMinTick::Union{Float64,Nothing}
minSize::Union{Float64,Nothing}
sizeIncrement::Union{Float64,Nothing}
suggestedSizeIncrement::Union{Float64,Nothing}
minCashQtySize::Union{Float64,Nothing}
secIdList::NamedTuple
cusip::String
ratings::String
Expand All @@ -59,9 +61,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)..., nothing, (;),
fill(ns, 5)..., false, false, nothing, false, ns,
ns, ns, ns, false, ns)
nothing, nothing, fill(ns, 6)..., nothing, nothing,
nothing, 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 @@ -7,5 +7,6 @@
WSHE_CALENDAR = 161
AUTO_CANCEL_PARENT = 162
FRACTIONAL_SIZE_SUPPORT = 163
SIZE_RULES = 164

end

0 comments on commit dc93110

Please sign in to comment.