Skip to content
All library documents

How to Calculate Returns, Sharpe Ratio, Volatility, and Drawdown

Article FMZ digest · Author: 发明者量化-小小梦

Summary

This article walks through a backtest performance-analysis routine that takes starting assets, timestamped cumulative profits, the evaluation period, and a trading-year convention. It describes how the routine derives cumulative and annualized returns, tracks peak assets and maximum drawdown, estimates a winning rate from increases between recorded profit observations, and groups profit changes into daily periods for volatility and Sharpe calculations.

The Sharpe calculation subtracts a fixed risk-free rate from annualized returns and divides by the standard deviation of annualized period returns. The article also explains variance and standard deviation in plain language. Its main evidence is the presented algorithm and a description of its outputs, rather than a comparison against independent calculations. The implementation forces the period to one day and uses simple annualization, so users should check assumptions about sampling, return definitions, annualization, and winning-rate interpretation before applying the reported metrics to other backtests.

Key ideas

  • The routine accepts timestamped cumulative profits and derives several common backtest metrics.
  • Maximum drawdown is calculated as the decline from the running peak in total assets.
  • The Sharpe ratio uses annualized returns, a fixed risk-free rate, and the standard deviation of daily annualized returns.
  • The winning rate counts profit observations that exceed the preceding observation, rather than necessarily counting completed trades.
  • The code fixes its sampling interval to a day, so its assumptions may not fit every evaluation setup.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.