contains_cross_under#

API documentation for tradeexecutor.utils.crossover.contains_cross_under Python function.

contains_cross_under(series1, series2, lookback_period=2, must_return_index=False)[source]#

Detect if the first series has crossed under the second. To be used in decide_trades()

Parameters:
  • series1 (Series) – A pandas.Series object.

  • series2 (Series) – A pandas.Series object.

  • must_return_index (bool) – If True, also returns the index of the crossover.

  • lookback_period (int) –

Lookback_period:

The number of periods to look back to detect a crossover.

Return type:

bool

bool. True if the series has crossed under the other series in the latest iteration, False otherwise.

If must_return_index is True, also returns the index of the crossover. Note the index is a negative index e.g. -1 is the latest index, -2 is the second latest etc.