November 2019
Beginner
394 pages
10h 31m
English
We need to measure how much the PnLs can vary from day to day or even week to week. This is an important measure of risk because if a trading strategy has large swings in PnLs, the account value is very volatile and it is hard to run a trading strategy with such a profile. Often, we compute the Standard Deviation of returns over different days or weeks or whatever timeframe we choose to use as our investment time horizon. Most optimization methods try to find optimal trading performance as a balance between PnLs and the Standard Deviation of returns.
Computing the standard deviation of returns is easy. Let's compute the standard deviation of weekly returns, as shown in the following code:
last_week = 0weekly_pnls = []for ...