Source code

  • S&P 500 (SPY) vs Intermediate-term US Treasuries (IEF)
  • Gold (GLD) vs Long-term US Treasuries (TLT)
  • US Real Estate (VNQ) vs Intermediate-term US Treasuries (IEF)

strategy_params

More info

IEF - 7-10 years bonds

TLT - 20+ bonds

All assets used: {'SPY', 'VNQ', 'GLD', 'IEF', 'TLT'}

Stoken's ACA Strategy¶

Load assets history¶

We will use yahoo finance client to load dividends and prices history for our ASSETS.

property Close Dividends
asset GLD IEF SPY TLT VNQ GLD IEF SPY TLT VNQ
Date
2004-11-18 44.380001 85.769997 118.739998 88.970001 54.180000 0.0 0.0 0.0 0.0 0.0
2004-11-19 44.779999 85.300003 117.419998 88.260002 53.619999 0.0 0.0 0.0 0.0 0.0
2004-11-22 44.950001 85.360001 117.980003 88.720001 53.990002 0.0 0.0 0.0 0.0 0.0
2004-11-23 44.750000 85.279999 118.160004 88.830002 54.220001 0.0 0.0 0.0 0.0 0.0
2004-11-24 45.049999 85.400002 118.440002 88.830002 55.160000 0.0 0.0 0.0 0.0 0.0

Stategy evaluaton¶

Create upper and lower channels for risk-on assets defined in the CONFIG.

Portfolio states¶

capital cash portfolio
Date
2006-02-28 9991.900000 154.830234 [{'asset': 'IEF', 'amount': 108.0}, {'asset': ...
2006-03-01 10041.550162 154.830234 [{'asset': 'IEF', 'amount': 108.0}, {'asset': ...
2006-03-02 10074.980395 154.830234 [{'asset': 'IEF', 'amount': 108.0}, {'asset': ...
2006-03-03 10014.480040 154.830234 [{'asset': 'IEF', 'amount': 108.0}, {'asset': ...
2006-03-06 9997.960192 154.830234 [{'asset': 'IEF', 'amount': 108.0}, {'asset': ...
capital cash portfolio
Date
2023-01-09 32452.033037 266.30385 [{'asset': 'IEF', 'amount': 108.0}, {'asset': ...
2023-01-10 32137.864091 266.30385 [{'asset': 'IEF', 'amount': 108.0}, {'asset': ...
2023-01-11 32448.013749 266.30385 [{'asset': 'IEF', 'amount': 108.0}, {'asset': ...
2023-01-12 32852.333345 266.30385 [{'asset': 'IEF', 'amount': 108.0}, {'asset': ...
2023-01-13 32633.823388 266.30385 [{'asset': 'IEF', 'amount': 108.0}, {'asset': ...

Overall performance¶

Volume traded 5731 stocks
Fees paid 114.62$
Dividends 7738.56$

Free cash¶

<AxesSubplot: xlabel='Date'>

Equity¶

Initial investment at 2006-02-28: 10000
Last value at 2023-01-13: 32660.28
Annualized return 7.27%
Annualized volatility 10.76%
Sharpe ratio 0.68 
Annualized downside volatility 8.04%
Sortino ratio 0.90
(on the basis of 0.00% risk free rate)

Returns by month/by year¶

change total
month 1 2 3 4 5 6 7 8 9 10 11 12
year
2006 NaN 0.00% 3.25% 3.25% -2.25% -0.15% 2.50% 1.32% -0.13% 3.45% 4.48% -0.97% 15.50%
2007 4.25% -0.72% -0.75% 2.09% 0.22% -4.08% -1.24% 1.52% 4.69% 3.18% -0.53% 2.00% 10.75%
2008 2.98% 2.56% -1.26% -3.01% -0.90% 2.22% -0.06% -1.49% 0.35% -1.23% 9.71% 7.87% 18.32%
2009 -6.89% -1.01% 3.42% -4.01% -2.54% -1.25% 2.81% 5.60% 3.42% -0.92% 8.44% 0.32% 6.57%
2010 -3.46% 3.94% 5.16% 4.83% -3.41% -2.60% 3.38% 0.06% 5.69% 4.01% 0.08% 4.25% 23.46%
2011 -0.32% 4.66% -0.10% 5.77% -0.50% -2.54% 2.65% -3.69% -5.34% -0.23% 0.93% -2.47% -1.77%
2012 3.75% -0.34% 2.32% 0.67% -4.26% 2.41% 2.29% 0.35% -0.67% -1.07% 0.48% 0.56% 6.43%
2013 1.86% 1.22% 2.01% 4.35% -3.39% -2.20% 1.43% -3.78% 2.38% 3.54% -1.36% 0.39% 6.22%
2014 2.21% 3.31% 0.61% 2.02% 2.51% 0.87% -0.19% 3.81% -3.25% 4.92% 2.49% 1.51% 22.61%
2015 4.52% -1.63% 0.35% -2.77% -0.45% -3.58% 4.04% -4.32% 0.68% 4.43% -0.37% -0.21% 0.19%
2016 -2.05% -0.19% 0.22% 0.80% -1.37% 5.22% 3.22% -2.33% -0.43% -3.41% -1.40% 1.96% -0.11%
2017 0.79% 2.97% -1.04% 0.91% 0.85% 1.10% 0.86% 1.10% -0.20% 0.46% 2.11% 0.83% 11.23%
2018 -1.26% -2.21% -0.32% -0.60% 0.71% -0.39% 0.50% 2.34% -1.69% -4.28% 2.71% -3.91% -8.32%
2019 0.56% -0.89% 4.04% -0.65% 0.21% 4.40% 1.03% 3.34% -0.05% 1.94% -0.39% 2.34% 16.88%
2020 1.91% -5.11% -3.52% 2.49% 1.07% 0.95% 4.27% 0.45% -2.54% -1.47% 1.95% 2.97% 3.02%
2021 -1.28% 0.38% 1.41% 5.23% 0.50% 2.93% 3.47% 1.63% -4.47% 5.54% -0.22% 4.22% 20.61%
2022 -5.68% -2.64% 3.52% -4.96% -4.72% -1.10% 1.41% -4.09% -5.87% -2.90% 4.62% -1.87% -22.29%
2023 4.57% NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 4.57%

Drawdown analysis¶

Longest/max drawdowns¶

Longest drawdowns
days months years from_date to_date max_depth max_dd_date days_d months_d years_d
0 620 20.37 1.70 2011-07-25 2013-04-05 -12.87 2011-10-20 87 2.86 0.24
1 568 18.66 1.56 2017-12-19 2019-07-10 -10.09 2018-12-26 372 12.22 1.02
2 549 18.04 1.50 2015-01-27 2016-07-29 -10.46 2015-08-25 210 6.90 0.57
3 414 13.60 1.13 2020-02-24 2021-04-13 -16.78 2020-03-19 24 0.79 0.07
4 375 12.32 1.03 2022-01-03 2023-01-13 -25.96 2022-10-24 294 9.66 0.80
5 315 10.35 0.86 2016-08-02 2017-06-13 -8.38 2016-12-01 121 3.98 0.33
6 281 9.23 0.77 2013-05-22 2014-02-27 -10.34 2013-08-19 89 2.92 0.24
7 265 8.71 0.73 2008-12-31 2009-09-22 -15.45 2009-06-10 161 5.29 0.44
8 247 8.11 0.68 2008-03-18 2008-11-20 -8.54 2008-06-13 87 2.86 0.24
9 238 7.82 0.65 2007-02-22 2007-10-18 -7.96 2007-08-16 175 5.75 0.48
Deepest drawdowns
days months years from_date to_date max_depth max_dd_date days_d months_d years_d
0 375 12.32 1.03 2022-01-03 2023-01-13 -25.96 2022-10-24 294 9.66 0.80
1 414 13.60 1.13 2020-02-24 2021-04-13 -16.78 2020-03-19 24 0.79 0.07
2 265 8.71 0.73 2008-12-31 2009-09-22 -15.45 2009-06-10 161 5.29 0.44
3 620 20.37 1.70 2011-07-25 2013-04-05 -12.87 2011-10-20 87 2.86 0.24
4 161 5.29 0.44 2006-05-11 2006-10-19 -10.90 2006-06-14 34 1.12 0.09
5 130 4.27 0.36 2010-05-13 2010-09-20 -10.74 2010-07-06 54 1.77 0.15
6 549 18.04 1.50 2015-01-27 2016-07-29 -10.46 2015-08-25 210 6.90 0.57
7 281 9.23 0.77 2013-05-22 2014-02-27 -10.34 2013-08-19 89 2.92 0.24
8 568 18.66 1.56 2017-12-19 2019-07-10 -10.09 2018-12-26 372 12.22 1.02
9 247 8.11 0.68 2008-03-18 2008-11-20 -8.54 2008-06-13 87 2.86 0.24

Drawdown quantiles¶

Quantiles:
50.0% of time expected drawdown is no more than 3.59% theoretically or 4.63% actually
75.0% of time expected drawdown is no more than 7.19% theoretically or 7.19% actually
95.0% of time expected drawdown is no more than 15.53% theoretically or 13.64% actually
99.0% of time expected drawdown is no more than 23.87% theoretically or 21.80% actually
Max DD was 25.96%
Last DD (2023-01-13) was 18.74%

Current portfolio state¶

Structure¶

IEF: 0.33%
IEF: 0.33%
TLT: 0.34%

Channels¶

  Defensive asset Lower Current price Upper Risk asset
0 IEF 356.559998 398.500000 429.700012 SPY
1 IEF 76.139999 88.180000 102.129997 VNQ
2 TLT 151.229996 178.759995 191.509995 GLD