Static

class hokohoko.predictors.Static(lock, parameters=None)

Bases: Predictor

This allows the testing of purely static settings, e.g. TAKE_PROFIT set to 0.01 (100 pips).

Parameters
  • lock (multiprocessing.Lock) – A single lock shared by all Predictors in each Period for this invocation. Stored in self.lock.

  • parameters (str) – The parameters passed in from hokohoko.entities.Config. Stored in self.parameters.

Other Attributes:

symbol_ids      [numpy.ndarray] The list of symbols
                available in the data source.

account         [hokohoko.entities.Account] The internal
                account keeping track of state.

Deterministic RNG:

In order that successive runs of Hokohoko with identical settings and data generate the exact same results, the Predictor class inherits from random.Random to provide a fully deterministic RNG. For any specific minute within the dataset, the generated random number sequence should be identical.

The RNG should typically be accessed via self.random() or self.randint().

See random for additional methods.

on_start(bars)

This is called when the predictor is first loaded. The order of the symbols within the list doesn’t change for the duration of the test.

Parameters

bars (list[hokohoko.entities.Bar]) – A bar containing the closing values of the bar prior to the Period the Predictor is running.

Important

This must be overridden.

on_bar(bars)

This is called at the end of every bar, and is where the majority of a Predictor’s work takes place. During this method, Orders and Positions can be requested closed, and Orders can be placed, but none are actioned until after this routine exits. Upon exit, close_order requests are handled first, then place_order[s].

on_bar is considered to happen between the end of one bar, and the start of the next.

Parameters

bars (list[hokohoko.entities.Bar]) – The latest bar in the data.

Important

This must be overridden.