Skip to content

root_accessors module

Root pandas accessors.

An accessor adds additional “namespace” to pandas objects.

The vectorbt.root_accessors registers a custom vbt accessor on top of each pd.Series and pd.DataFrame object. It is the main entry point for all other accessors:

vbt.base.accessors.BaseSR/DFAccessor           -> pd.Series/DataFrame.vbt.*
vbt.generic.accessors.GenericSR/DFAccessor     -> pd.Series/DataFrame.vbt.*
vbt.signals.accessors.SignalsSR/DFAccessor     -> pd.Series/DataFrame.vbt.signals.*
vbt.returns.accessors.ReturnsSR/DFAccessor     -> pd.Series/DataFrame.vbt.returns.*
vbt.ohlcv.accessors.OHLCVDFAccessor            -> pd.DataFrame.vbt.ohlc.* and pd.DataFrame.vbt.ohlcv.*
vbt.px_accessors.PXAccessor                    -> pd.DataFrame.vbt.px.*

Additionally, some accessors subclass other accessors building the following inheritance hiearchy:

vbt.base.accessors.BaseSR/DFAccessor
    -> vbt.generic.accessors.GenericSR/DFAccessor
        -> vbt.cat_accessors.CatSR/DFAccessor
        -> vbt.signals.accessors.SignalsSR/DFAccessor
        -> vbt.returns.accessors.ReturnsSR/DFAccessor
        -> vbt.ohlcv_accessors.OHLCVDFAccessor
    -> vbt.px_accessors.PXSR/DFAccessor

So, for example, the method pd.Series.vbt.to_2d_array is also available as pd.Series.vbt.returns.to_2d_array.

Note

Accessors in vectorbt are not cached, so querying df.vbt twice will also call Vbt_DFAccessor twice.


register_accessor function

register_accessor(
    name,
    cls
)

Register a custom accessor.

cls should subclass pandas.core.accessor.DirNamesMixin.


register_dataframe_accessor function

register_dataframe_accessor(
    name
)

Decorator to register a custom pd.DataFrame accessor on top of the pd.DataFrame.


register_dataframe_vbt_accessor function

register_dataframe_vbt_accessor(
    name,
    parent=vectorbt.root_accessors.Vbt_DFAccessor
)

Decorator to register a pd.DataFrame accessor on top of a parent accessor.


register_series_accessor function

register_series_accessor(
    name
)

Decorator to register a custom pd.Series accessor on top of the pd.Series.


register_series_vbt_accessor function

register_series_vbt_accessor(
    name,
    parent=vectorbt.root_accessors.Vbt_SRAccessor
)

Decorator to register a pd.Series accessor on top of a parent accessor.


Accessor class

Accessor(
    name,
    accessor
)

Custom property-like object.

Note

In contrast to other pandas accessors, this accessor is not cached!

This prevents from using old data if the object has been changed in-place.


Vbt_DFAccessor class

Vbt_DFAccessor(
    obj,
    **kwargs
)

The main vectorbt accessor for pd.DataFrame.

Superclasses

Inherited members


ohlc class variable

Accessor on top of OHLCV data. For DataFrames only.

Accessible through pd.DataFrame.vbt.ohlcv.


ohlcv class variable

Accessor on top of OHLCV data. For DataFrames only.

Accessible through pd.DataFrame.vbt.ohlcv.


px class variable

Accessor for running Plotly Express functions. For DataFrames only.

Accessible through pd.DataFrame.vbt.px.


returns class variable

Accessor on top of return series. For DataFrames only.

Accessible through pd.DataFrame.vbt.returns.


signals class variable

Accessor on top of signal series. For DataFrames only.

Accessible through pd.DataFrame.vbt.signals.


Vbt_SRAccessor class

Vbt_SRAccessor(
    obj,
    **kwargs
)

The main vectorbt accessor for pd.Series.

Superclasses

Inherited members


px class variable

Accessor for running Plotly Express functions. For Series only.

Accessible through pd.Series.vbt.px.


returns class variable

Accessor on top of return series. For Series only.

Accessible through pd.Series.vbt.returns.


signals class variable

Accessor on top of signal series. For Series only.

Accessible through pd.Series.vbt.signals.