Define functions
As follows are are functions that have been used throughout this book. You can find the full versions on the GitHub. Functions will generally be preceded with their chapter of appearance. The screening will feature both absolute and relative series, so we need the relative function. This will be followed by the classic regime definition functions:
# CHAPTER 5: Regime Definition
### RELATIVE
def relative(df,_o,_h,_l,_c, bm_df, bm_col, ccy_df, ccy_col, dgt, start, end,rebase=True):
#### removed for brevity: check GitHub repo for full code ####
### RELATIVE ###
def lower_upper_OHLC(df,relative = False):
if relative==True:
rel = 'r'
else:
rel= ''
if 'Open' in df.columns:
ohlc = [rel+'Open',rel+'High',rel+'Low',rel+'Close']
elif 'open' in df.columns:
ohlc = [rel+'open',rel+'high',rel+'low&apos...