tidy-finance / website

This repository hosts the source code for the website tidy-finance.org
https://tidy-finance.org
Other
82 stars 47 forks source link

macro_predictors_dy #98

Closed hcchuang closed 4 months ago

hcchuang commented 5 months ago

The calculation of dy is correct? or it should be dy=lambda x: np.log(x["D12"])-np.log(x["Index"].shift(1)),

macro_predictors = ( pd.read_csv(macro_predictors_link, thousands=",") .assign( month=lambda x: pd.to_datetime(x["yyyymm"], format="%Y%m"), dp=lambda x: np.log(x["D12"])-np.log(x["Index"]), dy=lambda x: np.log(x["D12"])-np.log(x["D12"].shift(1)), ep=lambda x: np.log(x["E12"])-np.log(x["Index"]), de=lambda x: np.log(x["D12"])-np.log(x["E12"]), tms=lambda x: x["lty"]-x["tbl"], dfy=lambda x: x["BAA"]-x["AAA"] ) .rename(columns={"b/m": "bm"}) .get(["month", "dp", "dy", "ep", "de", "svar", "bm", "ntis", "tbl", "lty", "ltr", "tms", "dfy", "infl"]) .query("month >= @start_date and month <= @end_date") .dropna() )

patrick-weiss commented 4 months ago

@hcchuang This is indeed a typo. Thank you for spotting it.

patrick-weiss commented 4 months ago

Changed with https://github.com/tidy-finance/website/commit/c0f5cc09e00d9ab7f6dfc9eb55f89ed2fc090a02