Jib.jl icon indicating copy to clipboard operation
Jib.jl copied to clipboard

Update wrapper.jl - overload Base.merge for Wrapper type

Open uniment opened this issue 1 year ago • 2 comments

Allows a Wrapper to be splatted, so that only a small handful of new functions need be defined, enabling patterns like this:

d, sw = simple_wrap()
function tickByTickAllLast(a, b, c, d, e, f, g, h) 
    #= =# 
end
w = Wrapper(; sw..., tickByTickAllLast) 
# `w` is exactly like `sw` but with a custom `tickByTickAllLast` callback

uniment avatar Jan 09 '24 20:01 uniment

Thanks for the interest. I'd like to point out that it's already possible to build or modify a Wrapper incrementally:

d, sw = simple_wrap()
function mycallback(a, b, c, d, e, f, g, h) 
    #= =# 
end

sw.tickByTickAllLast = mycallback

or, starting from scratch:

w = Jib.Wrapper()

w.tickPrice = function(a,b,c,d)
                #= =#
              end

lbilli avatar Jan 09 '24 22:01 lbilli

Good point. This idea is rather more useful for constructing a type-stable NamedTuple wrapper instead:

d, sw = simple_wrap()
w = (; sw..., 
    updateMktDepth = function(args...) #= =# end,
    tickByTickAllLast = function(args...) #= =# end
)

uniment avatar Jan 10 '24 14:01 uniment