Class InstrumentDataRequestRedirector
java.lang.Object
velox.api.layer1.providers.helper.InstrumentDataRequestRedirector
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 Summary
Modifier and TypeMethodDescriptionkeepProvider(boolean keepProvider) trueif your instruments should report the provider of the real instrument they are based on (e.g.overwriteSupportedFeaturesForAlias(BiFunction<String, Layer1ApiProviderSupportedFeatures, Layer1ApiProviderSupportedFeatures> overwriter) Adjusts the supported features reported for instruments created by your strategy.overwriteSupportedFeaturesForProviderType(BiFunction<velox.api.layer1.data.ProviderType, Layer1ApiProviderSupportedFeatures, Layer1ApiProviderSupportedFeatures> overwriter) Adjusts the features reported for a whole provider type.Call this from yoursendUserMessageoverride and return its result.
-
Method Details
-
keepProvider
trueif 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),falseto report an unknown provider. Default isfalse. -
overwriteSupportedFeaturesForAlias
public InstrumentDataRequestRedirector overwriteSupportedFeaturesForAlias(BiFunction<String, Layer1ApiProviderSupportedFeatures, Layer1ApiProviderSupportedFeatures> overwriter) 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 returnedtradingflag as authoritative for your instrument:falsedisables trading even if the real instrument is tradable,truestill 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
Call this from yoursendUserMessageoverride and return its result.
-