turnover_series

Defined in fynance.metrics

turnover_series(W)[source]

One-way turnover per bar, \(\sum_i |w_{t,i} - w_{t-1,i}|\).

The first bar charges the initial position from flat (\(|w_{0,i}|\)), same convention as fynance.portfolio.sizing.transaction_cost — in fact turnover_series(W) * fee == transaction_cost(W, fee) exactly, turnover_series is just the fee-free churn underneath it.

Parameters:
Warray_like

Weights held at each step, shape (T,) or (T, N). A 1-D input is reshaped to (T, 1).

Returns:
numpy.ndarray

Turnover per bar, shape (T,).

See also

annual_turnover

same churn, annualized to a single rate.

fynance.portfolio.sizing.transaction_cost

the fee-weighted counterpart.

Examples

>>> import numpy as np
>>> W = np.array([[1.0, 0.0], [0.5, -0.5], [-1.0, -1.0], [0.0, 0.0]])
>>> turnover_series(W)
array([1., 1., 2., 2.])