lbilli/rib

How to modify callback methods

Closed this issue · 2 comments

Hello,

First, let me thank you for creating this package. It is very well written and seems to be truly feature complete, which is great.

Alas, i have a problem. I am trying to modify the IBWrapSimple class to include more complex logic with respect to the various callback methods (mostly tickPrice and tickSize). I have tried creating a new class by copy pasting the source code and making modifications to it, and then instantiating a new wrapper object from that new class. This works well for the most part, except when the checkMsg() calls marketDataType() which then calls map_int2enum(), which cannot be found. It appears to only be visible within the rib namespace, which my new copy pasted version of the class can’t see.

I tried modifying the IBWrapSimple class this way as the public methods in the objects instantiated by IBWrapSimple were blocked. Is there a way to unblock them?

More generally, what would be the preferred approach to modifying callback methods without affecting the behaviour of the rib package?

Thank you,

AS

In general you can only use functions that a package explicitly exports, i.e. those listed in NAMESPACE.
However, you can still access unexported functions by using the ::: notation.

In this case, map_int2enum() is not currently exported, but you can use it in your own code like this:

rib:::map_int2enum(...)

So, if you cut-and-paste code from within the package, you need to prepend rib::: to unexported functions.

That is a good suggestion. Thank you for the quick reply.

AS