utils¶
- hokohoko.utils.generate_tests(descriptions)¶
A decorator class that allows tests to be prescribed locally.
- Parameters
descriptions (str) – Test cases to generate. Should be one test case per line.
- Returns
The decorated function.
- Return type
function
- hokohoko.utils.get_fq_class(fq_class)¶
Creates a reference to a class from a fully qualified class name. This reference can then be used to instantiate the class.
- Parameters
fq_class (str) – The fully-qualified name of the class. E.g. ‘hokohoko.predictors.DoNothing’.
- Returns
The class which may then be instantiated.
- Return type
callable
- hokohoko.utils.convert_symbol_to_id(symbol)¶
Converts a symbol/currency pair name into an integer representation.
- Parameters
symbol (str) – The symbol/currency pair name to convert.
- Returns
An integer value for the symbol/currency pair name.
- Return type
numpy.int64
- hokohoko.utils.convert_id_to_symbol(symbol_id)¶
Converts an integer to a symbol/currency pair name.
- Parameters
symbol_id (numpy.int64) – The integer value to convert.
- Returns
The symbol/currency pair name from the integer.
- Return type
str
- hokohoko.utils.generate_currency_map(symbol_ids, base='USD')¶
Calculates the chain for each base currency to USD. Each item in the dictionary is a tuple which, if followed in order, will calculate the currencies conversion to USD. If the Tuple is None, it cannot be used by Hokohoko, and will be ignored if requested.
Note
This assumes there is a single direct currency pair available. It makes no attempt to build chains.
- Parameters
symbol_ids (numpy.ndarray<numpy.int64>) – The set of IDs available from the data source.
base (str) – The currency to use as a base.
- Returns
A dictionary mapping symbol_ids to their index, and the currency pair required to convert Account currency to the symbol’s currency pair, or None if not available.
- Return type
dict<numpy.int64: tuple<int, Union[numpy.int64, None]>
- hokohoko.utils.split_class_options(class_options)¶
Splits a class name from its options.
- Parameters
class_options (str) – The class name and options as a single string.
- Returns
The class and options, joint.
- Return type
Tuple[str, Union[None, str]]