StrategyServiceInterface

StrategyServiceInterface#

class sigtech.framework.services.strategy_service.common.StrategyServiceInterface

Baseclasses: ABC

Subclasses: StrategyServiceProxy, StrategyServiceNoop

Abstract class for Strategy Service

abstract cache_strategy(strategies: Union[Strategy, StrategyInstrument, Sequence[Union[Strategy, StrategyInstrument]]]) Union[str, None, Sequence[Optional[str]]]

Persist strategies into cache. :param strategies: single or a list of Strategy object(s) to be persisted. :return: single or a list of CacheKey generated and used for caching.

abstract get_keys_by_prefix(prefix: str) Sequence[str]

Return a list of keys which starts with the provided prefix :param prefix: prefix to search for :return: list of keys

abstract get_strategy_by_key(keys: Union[str, Sequence[str]]) Union[Strategy, StrategyInstrument, UnknownSerialisedValue, None, Sequence[Optional[Union[Strategy, StrategyInstrument, UnknownSerialisedValue]]]]

Returns a single cached object or list of objects of the given key(s) Some lite validation is performed, to compare the current environment dates and the environment dates stored in the metadata. Warnings are logged to stdout. :param keys: Key(s) to retrieve. :return: Strategy object(s) (value or a list), object is set to None if not found, or UnknownSerialisedValue

abstract get_strategy_by_name(strategy_names: Union[str, Sequence[str]]) Union[Strategy, StrategyInstrument, UnknownSerialisedValue, None, Sequence[Optional[Union[Strategy, StrategyInstrument, UnknownSerialisedValue]]]]

Return cached strategy(ies), given strategy name(s). Keys are first constructed from the name, together with the current environment, the cache is then queried for the cached object(s) :param strategy_names: multiple or single Strategy names. :return: (single or a list of) cached Strategy object; object is None if not found, or UnknownSerialisedValue

abstract list_keys(filter_by_environment: bool = True) Sequence[str]

Return a list of all keys :param filter_by_environment: filter keys to those generated in the same environment :return: list of keys

abstract list_strategies(filter_by_environment: bool = True) Sequence[str]

Return a list of all strategy names :param filter_by_environment: filter keys to those generated in the same environment :return: list of strategy names

abstract remove_strategy_by_key(keys: Union[str, Sequence[str]]) Union[Strategy, StrategyInstrument, UnknownSerialisedValue, None, Sequence[Optional[Union[Strategy, StrategyInstrument, UnknownSerialisedValue]]]]

Removes strategy from the persistence of the given key(s)

Parameters:

keys – Key(s) to remove.

Returns:

None

abstract remove_strategy_by_name(strategy_names: Union[str, Sequence[str]]) None

Removes strategy from the persistence of the given names(s)

Parameters:

strategy_names – multiple or single Strategy names.

Returns:

None