Class AbstractStrategy
java.lang.Object
com.wualabs.qtsurfer.engine.core.AbstractNameable
com.wualabs.qtsurfer.engine.strategy.AbstractStrategy
- Direct Known Subclasses:
AbstractSubscriptionStrategy
Base strategy class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprotected Assetprotected Assetprotected final StrategyStats -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final booleanacceptCurrency(@NonNull Asset asset) voidapplyProperty(@NonNull String key, @NonNull Object value) Applies a runtime property value, routingreflectedproperties through their typed setter so the strategy's underlying field actually changes — not just the property map (asStrategy.setProperty(String, Object)does).protected voidclearNotice(@NonNull Object key) Drops a recorded notice, for conditions that genuinely clear (a resubscribe undoing a dead source).voidconfigure(TypeSafeConfig config) voidemitSignal(@NonNull StrategySignal signal) voidemitYield(@NonNull StrategyYield yield) boolean@NonNull StrategyCurrencyFilterprotected final StringThe engine version this strategy is running on (e.g.protected final intprotected final intHow the execution layer runs this strategy: backtest simulation settings, risk guards and entry sizing.getExecutionMode(Instrument instrument) getId()doubleprotected BigDecimalThis strategy's own diagnostics, in the order the conditions were first raised.double<T> TgetProperty(@NonNull String key) getPropertyInfo(@NonNull String propertyInfoId) io.reactivex.rxjava3.core.Observable<StrategySignal> getStats()io.reactivex.rxjava3.core.Observable<StrategyYield> inthashCode()booleanhasProperty(@NonNull String key) voidinit(@NonNull com.wualabs.qtsurfer.engine.exchange.ExchangeSupport exchangeSupport) booleanprotected voidraiseNotice(@NonNull Notice notice) Records a diagnostic about this strategy, keeping the first occurrence of eachNotice.key(): a condition seen again is the same problem, not a new one, and the first sighting is the informative one.protected PropertyInforegisterPropertyInfo(@NonNull PropertyInfo propertyInfo) protected PropertyInforegisterPropertyInfo(String name, String description, Class type) protected PropertyInforegisterPropertyInfo(String name, String description, Class type, String beanProperty) protected PropertyInforegisterPropertyInfo(String name, String description, Class type, String beanProperty, boolean reflected) voidreset(@NonNull Instrument instrument) voidsetBlacklistedCurrencies(List<String> currencyCodes) Reflection bridge for the property system.voidsetCurrencyFilter(@NonNull StrategyCurrencyFilter currencyFilter) voidsetEnabled(boolean enabled) voidsetExecutionCallback(ExecutionCallback executionCallback) voidsetExecutionMode(@NonNull ExecutionMode executionMode) voidsetMinGain(double minGain) voidsetMultiEntryEnabled(boolean multiEntryEnabled) Backward-compatible setter: maps the legacymultiEntryEnabledconfig property toExecutionMode.LONG_MULTIorExecutionMode.LONG.voidsetPercentGain(double percent) Sets the minimum percent gain threshold and precomputes the multiplier used to evaluate whether a trade meets the gain requirement.voidsetProperty(@NonNull String key, @NonNull Object value) voidsetWhitelistedCurrencies(List<String> currencyCodes) Reflection bridge for the property system.toString()protected voidtoString(com.google.common.base.MoreObjects.ToStringHelper ts) Methods inherited from class AbstractNameable
getName, setNameMethods inherited from interface Strategy
getProperty, getStateStore, hasProperty, isCurrencyLess, setProperty
-
Field Details
-
CONFIG_INPUT_CURRENCY
- See Also:
-
CONFIG_OUTPUT_CURRENCY
- See Also:
-
inputCurrency
-
outputCurrency
-
stats
-
-
Constructor Details
-
AbstractStrategy
public AbstractStrategy()
-
-
Method Details
-
configure
-
init
-
reset
-
getYields
-
getSignals
- Specified by:
getSignalsin interfaceStrategy
-
getExecutionMode
- Specified by:
getExecutionModein interfaceStrategy
-
getExecutionCallback
- Specified by:
getExecutionCallbackin interfaceStrategy
-
setEnabled
public void setEnabled(boolean enabled) - Specified by:
setEnabledin interfaceStrategy
-
getNotices
This strategy's own diagnostics, in the order the conditions were first raised. Subclasses that own further sources of notices override this and union them in —AbstractSubscriptionStrategyadds its per-instrument indicator groups.Synchronized on the map because
synchronizedMapdoes not cover iteration, and copying the values is an iteration — seestrategyNotices.- Specified by:
getNoticesin interfaceStrategy- Returns:
- the notices raised so far, empty if none (the default for strategies without indicators)
-
raiseNotice
Records a diagnostic about this strategy, keeping the first occurrence of eachNotice.key(): a condition seen again is the same problem, not a new one, and the first sighting is the informative one. What "the same" means is the notice's own business — a strategy-wide one keys on its code, a property one on (code, property).- Parameters:
notice- the notice to record
-
clearNotice
Drops a recorded notice, for conditions that genuinely clear (a resubscribe undoing a dead source). Do not use it to hide a condition that merely stopped repeating.- Parameters:
key- theNotice.key()to clear — the code itself for strategy-wide notices
-
setProperty
- Specified by:
setPropertyin interfaceStrategy
-
applyProperty
Description copied from interface:StrategyApplies a runtime property value, routingreflectedproperties through their typed setter so the strategy's underlying field actually changes — not just the property map (asStrategy.setProperty(String, Object)does). This is the injection seam the batch/sweep runner uses to apply a parameter vector before a run. The default falls back toStrategy.setProperty(String, Object)(map-only) for implementations without a reflected-property registry.- Specified by:
applyPropertyin interfaceStrategy- Parameters:
key- the registered propertyname()(NOT the field name)value- the value to inject; converted to the property's declared type when reflecting
-
hasProperty
- Specified by:
hasPropertyin interfaceStrategy
-
getProperty
- Specified by:
getPropertyin interfaceStrategy
-
getPropertyInfo
- Specified by:
getPropertyInfoin interfaceStrategy
-
getPropertyInfos
- Specified by:
getPropertyInfosin interfaceStrategy
-
setExecutionMode
-
setMultiEntryEnabled
public void setMultiEntryEnabled(boolean multiEntryEnabled) Backward-compatible setter: maps the legacymultiEntryEnabledconfig property toExecutionMode.LONG_MULTIorExecutionMode.LONG. -
setExecutionCallback
-
setCurrencyFilter
-
setPercentGain
public void setPercentGain(double percent) Sets the minimum percent gain threshold and precomputes the multiplier used to evaluate whether a trade meets the gain requirement.- Parameters:
percent- the minimum gain percentage (0-100)
-
getPercentGain
public double getPercentGain() -
setMinGain
public void setMinGain(double minGain) -
getMinGain
public double getMinGain() -
setWhitelistedCurrencies
-
setBlacklistedCurrencies
-
equals
-
hashCode
-
toString
-
getEngineVersion
The engine version this strategy is running on (e.g."0.99.55"), or"unknown"if it cannot be determined — sugar forEngineVersion.get(), so a strategy can log or emit it without an import.Worth recording from a strategy that is stored and re-run later: engine APIs change between versions, and a stored strategy that stops compiling is only diagnosable if the engine it was written against is known.
- Returns:
- the running engine version
-
getEngineVersionMajor
protected final int getEngineVersionMajor()- Returns:
- the major component, or
EngineVersion.UNKNOWN_COMPONENT(-1) if the version cannot be parsed — negative so a gate such asgetEngineVersionMajor() >= 1fails closed rather than matching by accident
-
getEngineVersionMinor
protected final int getEngineVersionMinor()- Returns:
- the minor component, or
EngineVersion.UNKNOWN_COMPONENT(-1) if the version cannot be parsed
-
getMinPercentGainMultiplier
-
acceptCurrency
-
emitYield
-
emitSignal
-
registerPropertyInfo
-
registerPropertyInfo
protected PropertyInfo registerPropertyInfo(String name, String description, Class type, String beanProperty) -
registerPropertyInfo
protected PropertyInfo registerPropertyInfo(String name, String description, Class type, String beanProperty, boolean reflected) -
registerPropertyInfo
-
toString
protected void toString(com.google.common.base.MoreObjects.ToStringHelper ts) -
getInputCurrency
- Specified by:
getInputCurrencyin interfaceStrategy
-
getOutputCurrency
- Specified by:
getOutputCurrencyin interfaceStrategy
-
getStats
-
getInstruments
- Specified by:
getInstrumentsin interfaceStrategy
-
getId
-
getExchangeName
-
isEnabled
-
getCurrencyFilter
-
getExecutionConfig
Description copied from interface:StrategyHow the execution layer runs this strategy: backtest simulation settings, risk guards and entry sizing. Set by whoever drives the run — the backtest runner, or a deployment's configuration — and read by the execution pipelines.A strategy implementation has no reason to consult this: it decides when to trade, and this decides what the execution layer does with the resulting signals. It is here so that the configuration and sweep channels can reach it by the property names they already use.
- Specified by:
getExecutionConfigin interfaceStrategy- Returns:
- this strategy's execution configuration, never null
-