# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python [conda env:retropy]
#     language: python
#     name: conda-env-retropy-py
# ---

# %run retropy.ipynb
import framework.etfs_high_yield as hy

# https://www.bdcinvestor.com/bdc-etfs  
# http://etfdb.com/compare/dividend-yield/

# # SRET
# - "global" (but actually mostly US) REIT, with highest yield and lowest volatility
# - ~6% net yield
# - fairly well performing compared to SPY and better than VNQ
# - only $100M is AUM
# - thoughts: good. looks good, but short has short history, and low AUM
#
# # DRW
# - international real-estate related companies
# - did better than i_reit, but almost same NTR as VNQI
# - has a 5+ rolling net-yield (passes the bar), but that is offset with higher price churn, giving same NTR and VNQI
# - yield is sporadic, sec-yield is 3+% while rolling 12m-yield is ~7-10% gross
# - It's (and VNQI) is also in general very similar to VXUS, but gave more yield
# - small AUM, 100MM
# - thoughts: TBD. generally ok, but sporadic yield is a negative
#
# # KBWY
# - small cap REITs, weighted by yield
# - NTR similar to VNQ, but fluctuates
# - 12m and sec yield is 7+% gross, 5.5% net
# - yield is stable and has grown from 5% to 7+% since 2015
# - being comprable to VNQ, indicates a very nasty 70-80% draw-down during 2008
# - thoughts: good. nice stable yield, comprable NTR to VNQ
#
# # PSK
# - prefered securities
# - similar to the actively managed FPE, almost the same NTR, with more history, slightly less draw-down risk
# - moderatly comprable to JNK, which indicates a major crash in 2008
# - has 700MM AUM vs 4B in FPE, but has lower ER 0.45% than FPE 0.85%
# - ~4.2% net yield
# - thoughts: good. generaly similar to FPE (which is favorable)
#
# # PGF
# - prefered securities in financials sector
# - vastly outperformed XLF (financials ETF), in NTR and in portfolio flow
# - yield is stable but has gradually declined to 5+% gross (4.0% net) currently
# - thoughts: no. yield isn't big enough and sector tilt are both turndowns
#
# # PGX
# - similar to PGF, but without the sector tilt
# - performed better than FPE
# - thoughts: TBD
#
# # PSP
# - publicly listed private equity
# - global, ~40% US, has a similar PR to VXUS in recent times, but crashed much harder than i_ac in 2008
# - expensive at ~2% fee (reflecting the underlying holdings)
# - 12m rolling yield is all over the place, ranging from 3-4% to 10-12% gross (currently at 10% gross)
# - compared to SPY, it tends to crash much more during bad times, and doesn't recover more to compensate
# - thoughts: no. the spordic yield, and excess crashes are a deterant
#
# # PCEF
# - closed end funds
# - yield is mostly steady at 5.5-6% net
# - price is in a declining trend, and so is the net income, which declined from 600 to 400 in 7 years
# - thoughts: no. declining income isn't great
#
# # YYY
# - high yield closed end funds
# - yield is high at 6+% net
# - canibalizing on price return, and way underperforming vs SPY
# - thoughts: no, returns are too low to justify such a yield
#
# # ALTY
# - a crazy mix of assets
# - 5.5-6% net yield, general ok pearformance
# - only $15M in AUM !!
# - thoughts: TBD. interesting, but AUM is too low.
#
# # MDIV
# - a mix of assets
# - ~5% net yield
# - price is somewhat declining, with big drawdowns of 20%+
# - good AUM at 700MM
# - toughs: TBD. price decline and dd are serious
#
#
# # HYEM
# - high-yield emerging-markets bonds
# - ~4.5% net yield (even 5.5% net sec-yield)
# - price is declining, but that seems inline with EMB and VWO decline
# - comprable flow to EMB, less risk than with VWO
# - thoughts: yes. consider overall EM exposure.
#
# # YLD
# - ..
#
# # PGHY / SHYG
# - ..
#
# # LMBS
# - ..
# # RIGS
# - ..

# +
# show_comp(DRW, VNQI, extra=i_ac)
# show_comp(PSK, FPE, extra=JNK)
# show_comp(PSP, SPY)
# show_comp(PSP, VXUS, i_ac)
# show_comp(KBWY, VNQ)
# show_comp(HYEM, EMB, VWO)

# +
#bdcs_fit = 'ARCC@Y:43.7|PSEC@Y:31.2|AINV@Y:22.2|OHAI@Y:2.9 = BDCS - fit'
#_all = hy.all
_all = hy.select
port = "|".join(_all)

all = get(_all, trim=True, start=2014, mode="NTR")
# -

# ## Analyze mix of ETFs

x = get(port, start=2010)
#show(get_income(x, per_month=True, smooth=4), ta=False, log=False)
show_rr_yield(x, SPY, cjb)

res = [get(port, start=year) for year in range(2000, 2018)]

show(res, trim=False, legend=False)

# ## Analyze assets

analyze_assets(*all, start=2015)



StarcoderdataJupyterScriptsDedupFiltered