I have a confession to make: I am a recovering CPA. Please don't tell anyone.
But you don't have to be a CPA to figure out how we calculate our daily, monthly, yearly and annualized returns in our backtester.
Let's take a simple example, a backtest for a long IBM call, the default backtest in Wheel. Run the backtest without changing any default parameters, click on the backtest name to see the report, and hit the Download button in the top right hand corner.
You will get a zip file in your Downloads folder and you want to open the zip and click on the folder called 'Strategy Outputs'. In that folder will be OptionReturns.csv, OptionStats.csv and OptionTrades.csv.
Let's start with the OptionTrades.csv. Clicking on column S will sum the individual trade profits to $2541.80. That should match the OptionStats.csv
TotStratP&L$ of ($2,541.80) which it does. Let's turn our attention to Jan 2007 return of -1.14%. How is that calculated?
To calculate monthly return, start with daily returns. Looking at the first trade, on 1/4/2007 we bought the Feb 100 calls for $1.875. The trading rule is to travel 75% of the bid ask spread to trade. In this case, the market was $1.80 x $1.90. the formula for buying is the bid + .75(ask-bid) or $1.80 + .75($1.90-$1.80)=$1.875. The daily return will be the market to market of that option the next day minus the purchase price minus commission of .01 divided by the stock price at the opening of the trade. The bid-ask for Feb 100 calls 1.50 x 1.60 or a mid-price of $1.55.
The daily return for 1/5/2007 was -0.36% =~($1.55-$1.875-$0.01)/$98.31. As in the following pic, in cell B3 the 1/5/2007 daily return from the file OptionReturns.csv matches. Do this for each day in January and sum the daily returns and you get -1.14%, matching the Jan '07 returns in the OptionStats.csv above.
The annual return for 2007 is just adding up the months starting with -1.14% for January and ending with -0.94% for December and getting 4.31%.
To get the overall annualized return for the strategy of -1.46%, get an average of all the monthly returns, here -.12% and multiply that average monthly return by 12 to annualize and get -1.46% matching the OptionStats number.
And that is how it is done. Please see the documentation for more information.