Bollinger

class hokohoko.predictors.Bollinger(lock, parameters=None, debug=False)

Bases: Predictor

This is an example Predictor. It makes a single random prediction per Bar. It demonstrates:

  1. How to inherit Predictor and override the appropriate methods.

  2. How to use self.random() to access fully-deterministic RNG.

  3. How to access self.Account. This particular example clears all Positions at the end of each bar, as simulate mode doesn’t normally do that.

Initialises the Predictor, saving the given parameters for use in on_start. It provides the following instance objects for use:

Parameters
  • lock (multiprocessing.Lock) – An lock which is shared between all concurrent Predictor processes. Intended use is for shared access to external resource, etc. Stored in self.lock, provided for custom Predictors which might need access to shared external resources.

  • parameters (str, optional) – User-customisable parameters, which get stored in self.parameters.

Note that it is not strictly necessary to override, this is just to show how to add your own data structures in.

on_start(bars)

Has to be overridden, the base class raises a NotImplementedError otherwise.

Parameters

bars (A list containing one or more hokohoko.entities.Bar[s].) – The list of Bars containing the opening values for each currency pair. If set, only the requested subset is provided.

on_bar(bars)

This implementation picks a random direction for each symbol. Predictors provide access to a deterministic RNG source (themselves), so all random calls should be self.random(), self.randint(), etc.

Parameters

bars (A list containing one or more hokohoko.entities.Bar[s].) – The latest bar in the data. This is an array of the selected currencies.