Skip to content

Commit

Permalink
Update to API v187
Browse files Browse the repository at this point in the history
  • Loading branch information
lbilli committed Jun 30, 2024
1 parent ea08351 commit eb96c2b
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 5 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 <noreply.section+dev@gmail.com>"]
version = "0.20.6"
version = "0.21.0"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
11 changes: 11 additions & 0 deletions src/process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ...Bar,
...Execution,
...FamilyCode,
...FaDataType,
...IneligibilityReason,
...MarketDataType,
...Order,
...OrderState,
Expand Down Expand Up @@ -276,6 +277,8 @@ const process = Dict(

ver Client.PROFESSIONAL_CUSTOMER && (o.professionalCustomer = pop(it))

ver Client.BOND_ACCRUED_INTEREST && (o.bondAccruedInterest = pop(it))

w.openOrder(o.orderId, c, o, os)
end,

Expand Down Expand Up @@ -342,6 +345,14 @@ const process = Dict(
cd.fundAssetType = fundtype(slurp(String, it))
end

if ver Client.INELIGIBILITY_REASONS
n = pop(it)

for _ 1:n
push!(cd.ineligibilityReasonList, slurp(IneligibilityReason, it))
end
end

w.contractDetails(reqId, cd)
end,

Expand Down
10 changes: 8 additions & 2 deletions src/requests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ..AbstractCondition,
..FaDataType,
..MarketDataType,
..Order,
..OrderCancel,
..ScannerSubscription,
..WshEventData

Expand Down Expand Up @@ -253,16 +254,21 @@ function placeOrder(ib::Connection, id::Int, contract::Contract, order::Order)

ib.version Client.PROFESSIONAL_CUSTOMER && o(order.professionalCustomer)

ib.version Client.RFQ_FIELDS && o(order.externalUserId,
order.manualOrderIndicator)

sendmsg(ib, o)
end

function cancelOrder(ib::Connection, id::Int, manualOrderCancelTime::String)
function cancelOrder(ib::Connection, id::Int, orderCancel::OrderCancel)

o = enc()

o(4, 1, ### CANCEL_ORDER
id,
manualOrderCancelTime)

ib.version Client.RFQ_FIELDS ? splat(orderCancel) :
orderCancel.manualOrderCancelTime)

sendmsg(ib, o)
end
Expand Down
11 changes: 11 additions & 0 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ end
SoftDollarTier() = SoftDollarTier(ns, ns, ns)


struct OrderCancel
manualOrderCancelTime::String
extOperator::String
externalUserId::String
manualOrderIndicator::Union{Int,Nothing}
end
OrderCancel(manualOrderCancelTime=ns) = OrderCancel(manualOrderCancelTime, ns, ns, nothing)
OrderCancel(extOperator, externalUserId, manualOrderIndicator) =
OrderCancel(ns, extOperator, externalUserId, manualOrderIndicator)


struct WshEventData
conId::Union{Int,Nothing}
filter::String
Expand Down
5 changes: 4 additions & 1 deletion src/types_mutable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ mutable struct Order
midOffsetAtHalf::Union{Float64,Nothing}
customerAccount::String
professionalCustomer::Bool
bondAccruedInterest::String
externalUserId::String
manualOrderIndicator::Int
end
Order() = Order(0, 0, 0, ns, 0, ns, nothing, nothing, ns, ns, ns, ns, 0, ns, true, 0,
false, false, nothing, 0, false, false, ns, ns, ns, false, nothing, nothing,
Expand All @@ -180,7 +183,7 @@ Order() = Order(0, 0, 0, ns, 0, ns, nothing, nothing, ns, ns, ns, ns, 0, ns, tru
fill(nothing, 4)..., 0, nothing, [], false, false, ns, SoftDollarTier(),
nothing, ns, ns, ns, ns, false, false, false, ns, nothing, nothing,
false, ns, false, false, fill(nothing, 4)..., ns, ns,
fill(nothing, 5)..., ns, false)
fill(nothing, 5)..., ns, false, ns, ns, 2147483647)


mutable struct ScannerSubscription
Expand Down
10 changes: 9 additions & 1 deletion src/types_private.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ struct ContractDescription
end


struct IneligibilityReason
id::String
description::String
end


mutable struct ContractDetails
contract::Contract
marketName::String
Expand Down Expand Up @@ -87,12 +93,14 @@ mutable struct ContractDetails
fundBlueSkyTerritories::String
fundDistributionPolicyIndicator::String
fundAssetType::String
ineligibilityReasonList::Vector{IneligibilityReason}
end
ContractDetails() = ContractDetails(Contract(), ns, 0, ns, ns, 0, 0, fill(ns, 9)...,
nothing, nothing, fill(ns, 6)..., nothing, nothing,
nothing, (;), fill(ns, 5)..., false, false,
nothing, false, ns, ns, ns, ns, false, ns,
fill(ns, 7)..., false, false, false, fill(ns, 7)...)
fill(ns, 7)..., false, false, false, fill(ns, 7)...,
[])


struct Execution
Expand Down
3 changes: 3 additions & 0 deletions src/versions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
LAST_TRADE_DATE = 182
CUSTOMER_ACCOUNT = 183
PROFESSIONAL_CUSTOMER = 184
BOND_ACCRUED_INTEREST = 185
INELIGIBILITY_REASONS = 186
RFQ_FIELDS = 187

end

0 comments on commit eb96c2b

Please sign in to comment.