Class InstrumentDataRequestRedirector

java.lang.Object
velox.api.layer1.providers.helper.InstrumentDataRequestRedirector

public final class InstrumentDataRequestRedirector extends Object
Answers Bookmap's questions about instruments created by your strategy.

When a strategy announces its own instruments (via onInstrumentAdded), Bookmap asks about them exactly as it asks about real ones: which provider they belong to, which features they support, whether they can be traded. Those questions arrive in your sendUserMessage override. A InstrumentDataRequestRedirector forwards them to the real instrument your synthetic one is based on and lets you adjust the answers.

Typical use:

 private final InstrumentDataRequestRedirector redirector = InstrumentDataRequestRedirectHelper
         .redirector(super::sendUserMessage, this::sourceAliasFor)
         .keepProvider(true)
         .overwriteSupportedFeaturesForAlias((alias, inherited) ->
                 inherited.toBuilder().setTrading(false).build());

 @Override
 public Object sendUserMessage(Object data) {
     return redirector.redirect(data);
 }
 
The alias mapper receives an alias and returns the alias of the real instrument it is based on, or null if the alias was not created by your strategy.
  • Method Details

    • keepProvider

      public InstrumentDataRequestRedirector keepProvider(boolean keepProvider)
      true if your instruments should report the provider of the real instrument they are based on (e.g. a copy of a Rithmic instrument still belongs to Rithmic), false to report an unknown provider. Default is false.
    • overwriteSupportedFeaturesForAlias

      Adjusts the supported features reported for instruments created by your strategy. The function receives your instrument's alias and the features inherited from the real instrument, and returns the features to report instead. Bookmap treats the returned trading flag as authoritative for your instrument: false disables trading even if the real instrument is tradable, true still requires the real instrument to be tradable.
    • overwriteSupportedFeaturesForProviderType

      public InstrumentDataRequestRedirector overwriteSupportedFeaturesForProviderType(BiFunction<velox.api.layer1.data.ProviderType,Layer1ApiProviderSupportedFeatures,Layer1ApiProviderSupportedFeatures> overwriter)
      Adjusts the features reported for a whole provider type. Only relevant if your strategy registers its own provider type; leave unset otherwise.
    • redirect

      public Object redirect(Object data)
      Call this from your sendUserMessage override and return its result.