Skip to content

Commit

Permalink
Update to API v187
Browse files Browse the repository at this point in the history
  • Loading branch information
lbilli authored and oliviermilla committed Jul 11, 2024
1 parent 18765a1 commit 40d3a93
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "InteractiveBrokers"
uuid = "f310f2d2-a263-11e8-3998-47bd686f18f7"
authors = ["Luca Billi <[email protected]>", "Olivier Milla <[email protected]>"]
version = "0.25.1"
version = "0.26"

[deps]
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
Expand Down
62 changes: 36 additions & 26 deletions src/process.jl
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import ...Bar,
...ComboLeg,
...CommissionReport,
...ConditionType,
...Contract,
...ContractDescription,
...ContractDetails,
...DeltaNeutralContract,
...Execution,
...FamilyCode,
...FaDataType,
...MarketDataType,
...Order,
...OrderState,
...SoftDollarTier,
...TickAttrib,
...TickAttribLast,
...TickAttribBidAsk,
...condition_map,
...funddist,
...fundtype,
...ns,
...IbkrErrorMessage
...ComboLeg,
...CommissionReport,
...ConditionType,
...Contract,
...ContractDescription,
...ContractDetails,
...DeltaNeutralContract,
...Execution,
...FamilyCode,
...FaDataType,
...IneligibilityReason,
...MarketDataType,
...Order,
...OrderState,
...SoftDollarTier,
...TickAttrib,
...TickAttribLast,
...TickAttribBidAsk,
...condition_map,
...funddist,
...fundtype,
...ns

import InteractiveBrokers

Expand Down Expand Up @@ -280,7 +280,9 @@ const process = Dict(

ver Client.CUSTOMER_ACCOUNT && (o.customerAccount = pop(it))

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

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

InteractiveBrokers.forward(w, :openOrder, o.orderId, c, o, os)
end,
Expand Down Expand Up @@ -344,9 +346,17 @@ const process = Dict(

slurp!(cd, 44:58, it)

cd.fundDistributionPolicyIndicator = funddist(slurp(String, it))
cd.fundAssetType = fundtype(slurp(String, it))
end
cd.fundDistributionPolicyIndicator = funddist(slurp(String, it))
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

InteractiveBrokers.forward(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

2 comments on commit 40d3a93

@oliviermilla
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

  • Updated to API v187 from upstream.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/110899

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.26.0 -m "<description of version>" 40d3a934f6ef60272e15d03a1b96041536586d07
git push origin v0.26.0

Please sign in to comment.