Skip to content

Commit

Permalink
Introduced a struct for error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviermilla committed Jun 7, 2024
1 parent 5470acb commit c418c49
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 82 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.22.0"
version = "0.23.0"

[deps]
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ using InteractiveBrokers

wrap = InteractiveBrokers.Wrapper(
# Customized methods go here
error= (id, errorCode, errorString, advancedOrderRejectJson) ->
println("Error: $(something(id, "NA")) $errorCode $errorString $advancedOrderRejectJson"),
error= (err) ->
println("Error: $(something($(err.id), "NA")) $(err.errorCode) $(err.errorString) $(err.advancedOrderRejectJson)"),

nextValidId= (orderId) -> println("Next OrderId: $orderId"),

Expand Down
3 changes: 2 additions & 1 deletion data/wrapper_signatures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ execDetails(reqId::Int, contract::Contract, execution::Execution)

execDetailsEnd(reqId::Int)

error(id::Union{Int,Nothing}, errorCode::Union{Int,Nothing}, errorString::String, advancedOrderRejectJson::String)
error(err::IbkrErrorMessage)
#error(id::Union{Int,Nothing}, errorCode::Union{Int,Nothing}, errorString::String, advancedOrderRejectJson::String)

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

Expand Down
1 change: 1 addition & 0 deletions src/InteractiveBrokers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ using Sockets

include("client.jl")
include("enums.jl")
include("errors.jl")
include("types.jl")
include("types_condition.jl")
include("types_mutable.jl")
Expand Down
6 changes: 6 additions & 0 deletions src/errors.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
struct IbkrErrorMessage <: Exception
id::Union{Int,Nothing}
errorCode::Union{Int,Nothing}
errorString::String
advancedOrderRejectJson::String
end
150 changes: 77 additions & 73 deletions src/process.jl

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ function simple_wrap()

execDetailsEnd= (reqId::Int) -> println("execDetailsEnd: $reqId"),

error= (id::Union{Int,Nothing}, errorCode::Union{Int,Nothing}, errorString::String, advancedOrderRejectJson::String) ->
error= (err::IbkrErrorMessage) ->
println("error: ",
something(id, "NA"), " ",
something(errorCode, "NA"), " ",
errorString, " ",
advancedOrderRejectJson),
something(err.id, "NA"), " ",
something(err.errorCode, "NA"), " ",
err.errorString, " ",
err.advancedOrderRejectJson),

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

0 comments on commit c418c49

Please sign in to comment.