pyfolio icon indicating copy to clipboard operation
pyfolio copied to clipboard

Inconsistent Turnover Calculations

Open humdings opened this issue 11 years ago • 0 comments

We have a turnover function in pos.py, but plotting.plot_turnover() does not use it. Also, the two calculations are done differently.

# plotting.plot_turnover
df_turnover = transactions.txn_volume / positions.abs().sum(axis='columns')

# pos.turnover
turnover = transactions_df.apply(
        lambda z: z.apply(
            lambda r: abs(r))).resample(period, 'sum').sum(axis=1)
portfolio_value = backtest_data_df.portfolio_value.resample(period, 'mean')
turnoverpct = turnover / portfolio_value

These two calculations do not produce the same output

humdings avatar Aug 03 '15 20:08 humdings