1. Additional analytics
There is one last important feature to cover in this course,
2. Generate profit & loss (P&L) series
which is to generate the actual profit and loss time series, along with returns for your strategy to analyze with PerformanceAnalytics.
Essentially, the blotter environment contains much of the information involved in your strategy, and you can actually access it. In this lecture, you will access the profit and loss time series of your strategy with the syntax displayed here.
3. Sharpe ratio
Getting this data allows you to take a sharpe ratio of your profit and loss. The sharpe ratio is the ratio of how much money you made compared to how volatile, or risky the process was. Simply, it is a ratio of reward to risk. Syntactically, the argument geometric has to be set to FALSE since this is not returns-based data, and in quantstrat, account equity does not compound continuously with every trade. To put it in simpler terms, in quantstrat, while you may make a profit on a trade, quantstrat does not update this at every new trade. Instead, a better way to think about a quantstrat simulation is that profits are withdrawn from the system. This means that the second trade does not depend on the outcome of the first trade, and when computing results for the strategy, you should constantly keep that in mind.
4. Getting returns
Additionally, you can obtain all the instrument returns for your strategy. Returns in a quantstrat simulation are defined as the ratio between the profit or loss on a given trade, divided by the initial equity defined at the beginning of the simulation. The PortfReturns command will create an output that contains the returns for all the individual instruments (in this example, LQD, and in the exercises, it will be SPY) over the course of the simulation. As you only ran the simulation on one instrument, you will only get one vector in return.
5. Getting Sharpe ratio for returns
Once you have your returns, you can use many of the functions from the PerformanceAnalytics package to do more analysis. In this case, you can obtain the Sharpe ratio from returns. If you do this, set geometric to FALSE since returns in quantstrat are based off of profit and loss divided by your initial account equity.
6. Let's practice!
In the following exercises, you will compute the Sharpe ratios for your strategy.
Good luck!