Skip to main content

default_splitter_kwargs

default_splitter_kwargs(
    splitter: str,
    **kwargs,
) ‑> Dict[str, Any]
Generate default keyword arguments for the specified splitter type. Parameters:
NameTypeDefaultDescription
splitterstr--The type of splitter.
kwargstp.Kwargs--Arbitrary keyword arguments, will be filtered based on the splitter type.
Raises:
TypeDescription
ValueErrorIf the splitter type is unsupported.
Returns:
TypeDescription
tp.KwargsA dictionary containing the necessary keyword arguments for the splitter.

CustomSplitter

CustomSplitter(
    wrapper: vectorbtpro.base.wrapping.ArrayWrapper,
    index: pandas.core.indexes.base.Index,
    splits_arr: numpy.ndarray,
    **kwargs,
)
Custom splitter.

Ancestors

  • vectorbtpro.generic.splitting.base.Splitter
  • vectorbtpro.generic.analyzable.Analyzable
  • vectorbtpro.base.wrapping.Wrapping
  • vectorbtpro.utils.config.Configured
  • vectorbtpro.utils.config.HasSettings
  • vectorbtpro.utils.caching.Cacheable
  • vectorbtpro.utils.checks.Comparable
  • vectorbtpro.utils.pickling.Pickleable
  • vectorbtpro.utils.formatting.Prettified
  • vectorbtpro.utils.chaining.Chainable
  • vectorbtpro.base.wrapping.HasWrapper
  • vectorbtpro.base.indexing.ExtPandasIndexer
  • vectorbtpro.base.indexing.PandasIndexer
  • vectorbtpro.base.indexing.IndexingBase
  • vectorbtpro.utils.params.ItemParamable
  • vectorbtpro.utils.params.Itemable
  • vectorbtpro.utils.params.Paramable
  • vectorbtpro.base.indexes.IndexApplier
  • vectorbtpro.utils.attr_.AttrResolverMixin
  • vectorbtpro.generic.stats_builder.StatsBuilderMixin
  • vectorbtpro.generic.plots_builder.PlotsBuilderMixin
  • vectorbtpro.utils.base.Base

Static methods

from_custom_rolling

from_custom_rolling(
    index: pandas.core.indexes.base.Index,
    length: int,
    offset: int = 0,
    offset_anchor: str = 'prev_end',
    offset_anchor_set: int = 0,
    offset_space: str = 'prev',
    backwards: bool | str = False,
    split: int = None,
    split_range_kwargs: Dict[str, Any] = None,
    range_bounds_kwargs: Dict[str, Any] = None,
    template_context: Dict[str, Any] = None,
    freq: str = None,
    **kwargs,
) ‑> ~SplitterT
Create a custom Splitter instance from a rolling range of fixed length. Superset Splitter.from_rolling by adding the first (if backwards is sorted) or last remaining split. Creates a rolling sequence of slices based on the provided index. The first slice uses a length defined by length, and each subsequent slice begins after an offset from the previous slice’s right boundary. Uses Splitter.from_splits to generate an array of splits and corresponding labels, and then construct the Splitter instance. See Splitter.from_rolling for further informations. Parameters:
NameTypeDefaultDescription
indextp.IndexLike--The index to use for the splits. Must be a datetime-like index.
lengthint--The length of each rolling slice. Can be an int, Float, or timedelta.
offsetint0The offset to apply to the start of each slice after the first one. Can be an integer, float, or timedelta.
offset_anchorstrprev_endThe anchor point for the offset. Can be prev_end or start.
offset_anchor_setint0The index of the anchor point to use for the offset. If None, uses the last anchor point.
offset_spacestrprevThe space in which the offset is applied. Can be prev or all.
backwardsboolFalseIf True, the rolling slices are created in reverse order. If ‘sorted’, the first slice is sorted in reverse order. If False, the rolling slices are created in forward order.
splittp.SplitLikeNoneIf provided, the rolling slices will be split further according to this parameter. Can be a single split or a list of splits.
split_range_kwargstp.KwargsLikeNoneAdditional keyword arguments to pass to the split_range method.
range_bounds_kwargstp.KwargsLikeNoneAdditional keyword arguments to pass to the get_range_bounds method.
template_contexttp.KwargsLikeNoneContext for template rendering, if applicable.
freqtp.FrequencyLikeNoneFrequency of the index. If None, it will be inferred from the index.
kwargstp.Kwargs--Additional keyword arguments to pass to the Splitter.from_splits method.
Raises:
TypeDescription
ValueErrorIf backwards is a string that is not sorted.
ValueErrorIf the length is negative when backwards is True.
Returns:
TypeDescription
SplitterTAn instance of Splitter containing the rolling slices and their labels.

from_custom_expanding

from_custom_expanding(
    index: pandas.core.indexes.base.Index,
    min_length: int,
    offset: int,
    split: int = None,
    split_range_kwargs: Dict[str, Any] = None,
    range_bounds_kwargs: Dict[str, Any] = None,
    template_context: Dict[str, Any] = None,
    freq: str = None,
    **kwargs,
) ‑> ~SplitterT
Create a Splitter instance from an expanding range. Creates an expanding sequence of slices based on the provided index. The first slice uses a minimum length defined by min_length, and each subsequent slice begins after an offset from the previous slice’s right boundary. Uses Splitter.from_expanding by adding the last remaining split. See Splitter.from_expanding for further informations. Parameters:
NameTypeDefaultDescription
indextp.IndexLike--The index to use for the splits. Must be a datetime-like index.
min_lengthint--The minimum length of each expanding slice. Can be an int, float, or timedelta.
offsetint--The offset to apply to the start of each slice after the first one. Can be an int, Float, or timedelta.
splittp.SplitLikeNoneIf provided, the expanding slices will be split further according to this parameter. Can be a single split or a list of splits.
split_range_kwargstp.KwargsLikeNoneAdditional keyword arguments to pass to the split_range method.
range_bounds_kwargstp.KwargsLikeNoneAdditional keyword arguments to pass to the get_range_bounds method.
template_contexttp.KwargsLikeNoneContext for template rendering, if applicable.
freqtp.FrequencyLikeNoneFrequency of the index. If None, it will be inferred from the index.
kwargstp.Kwargs--Additional keyword arguments to pass to the Splitter.from_splits method.
Raises:
TypeDescription
ValueErrorIf the min_length is negative.
ValueErrorIf the offset is negative.
ValueErrorIf the split is not a valid split type.
Returns:
TypeDescription
SplitterTAn instance of Splitter containing the expanding slices and their labels.