Date: January 17, 2024

Topic:

Recall

The daily portfolio value is important for calculating other statistics like:

Notes

Daily portfolio value

Given the following:

start_val = 1000000
start_date = 2009-1-1
end_date = 2011-12-31
symbols = ['SPY', 'XOM', 'GOOG', 'GLD']
allocs = [0.4, 0.4, 0.1, 0.1]

Untitled

  1. Work on the prices and get the normalized values - normed = prices/prices[0]
  2. Multiply the normed prices by the allocations - alloced = normed * allocs
  3. Multiply the start value with alloced to get position values - pos_vals = alloced * start_val
  4. Finally, get the daily portfolio value - port_val = pos_vals.sum(axis=1)

Daily return stats

<aside> 💡 Ignore the first value for daily_rets as it will be 0 (daily_rets = daily_rets[1:])

</aside>

# 4 different statistics
cum_ret = (port_val[-1]/port_val[0]) - 1
avg_daily_ret = daily_rets.mean()
std_daily_ret = daily_rets.std()
sharpe_ratio # See below

<aside> 📌 SUMMARY:

</aside>


Date: January 18, 2024

Topic: Sharpe Ratio

Recall

Sharpe Ratio is used to calculate the risk adjusted return. A higher Sharpe Ratio might indicate a better stock

Notes

Sharpe Ratio

For:

<aside> 💡 Sharpe Ratio: $\frac{R_p - R_f}{\sigma_p}$, $S=\frac{E[R_p-R_f]}{std[R_p-R_f]}$

</aside>

S = mean(daily_rets - daily_rf)/std(daily_rets - daily_rf)

Risk free rate ($R_f)$

Traditional shortcut (e.g., if risk free was 10% and we have 252 trading days): $\sqrt[252]{1+0.1} - 1$

Final equation

S = mean(daily_rets - daily_rf)/std(daily_rets)

Based on how frequently we sample for the daily returns, we need to adjust the SR accordingly

Adjusting Sharpe Ratio

With daily data

SR = sqrt(252) * (mean(daily_rets - daily_rf)/std(daily_rets))

<aside> 📌 SUMMARY: Portfolio evaluations depend on: cumulative return, average daily return, risk (std. dev of daily returns) and Sharpe Ratio.

</aside>