Login
Login

Is there a way to pass as DepthCaches as to have multiple “variables” sources (could be let’s say price, volume, some moving average, …) as to be able to retrieve them when implementing the interface DepthHandler method onDepthUpdate?

There are two ways you could do to let your strategy get extra information:

  • For information updated with depth, for example, moving average of price, depth volume, etc. You could simply extend the class Depth to include those information, and add your own SequentialCache<? extends Depth> to the DepthCaches which is passed to the simulator, like:

SequentialCache myDepthCache = generateMyOwnDepthCache();

DepthCaches depthCaches = new DepthCaches();

depthCaches.add(product, myDepthCache);

Simulator simulator = new SimpleSimulator.Builder(depthCaches).build();

  • For non-depth updates, you can pass the cache of the updates to the simulator directly. Let’s take SimulationTimer as an example. SimulationTimer is a SequentialCache and is passed to the simulator like:

Simulator simulator = new SimpleSimulator.Builder(depthCaches).withNonDepthUpdates(timerUpdates).build();

  • Then, we add a simple handler instance in the enum ChannelMessageHandlerFactories for the simulator (e.g., ChannelMessageHandlerFactories.TIMER) to call back your strategy upon updates. Please also see DemoTimer in algoquant-demo for a complete example.

Comment on this FAQ

Your email address will not be published. Required fields are marked *