Baselight
Loading...Loading chart...
1WITH monthly_t10y2y AS (
2  SELECT 
3    DATE_TRUNC('month', observation_date) as month,
4    AVG(t10y2y) as avg_t10y2y,
5    MIN(t10y2y) as min_t10y2y,
6    MAX(t10y2y) as max_t10y2y
7  FROM "@michal.fred_data.t10y2y_csv"
8  WHERE t10y2y IS NOT NULL
9  GROUP BY DATE_TRUNC('month', observation_date)
10),
11monthly_baa10y AS (
12  SELECT 
13    DATE_TRUNC('month', observation_date) as month,
14    AVG(baa10y) as avg_baa10y,
15    MIN(baa10y) as min_baa10y,
16    MAX(baa10y) as max_baa10y
17  FROM "@michal.fred_data.baa10y_csv"
18  WHERE baa10y IS NOT NULL
19  GROUP BY DATE_TRUNC('month', observation_date)
20),
21monthly_ic4wsa AS (
22  SELECT 
23    DATE_TRUNC('month', observation_date) as month,
24    AVG(ic4wsa) as avg_ic4wsa,
25    MIN(ic4wsa) as min_ic4wsa,
26    MAX(ic4wsa) as max_ic4wsa
27  FROM "@michal.fred_data.ic4wsa_csv"
28  WHERE ic4wsa IS NOT NULL
29  GROUP BY DATE_TRUNC('month', observation_date)
30),
31monthly_vixcls AS (
32  SELECT 
33    DATE_TRUNC('month', observation_date) as month,
34    AVG(vixcls) as avg_vixcls,
35    MIN(vixcls) as min_vixcls,
36    MAX(vixcls) as max_vixcls
37  FROM "@michal.fred_data.vixcls_csv"
38  WHERE vixcls IS NOT NULL
39  GROUP BY DATE_TRUNC('month', observation_date)
40),
41monthly_umcsent AS (
42  SELECT 
43    DATE_TRUNC('month', observation_date) as month,
44    AVG(umcsent) as avg_umcsent
45  FROM "@michal.fred_data.umcsent_csv"
46  WHERE umcsent IS NOT NULL
47  GROUP BY DATE_TRUNC('month', observation_date)
48),
49monthly_usslind AS (
50  SELECT 
51    DATE_TRUNC('month', observation_date) as month,
52    AVG(usslind) as avg_usslind
53  FROM "@michal.fred_data.usslind_csv"
54  WHERE usslind IS NOT NULL
55  GROUP BY DATE_TRUNC('month', observation_date)
56),
57monthly_unrate AS (
58  SELECT 
59    DATE_TRUNC('month', observation_date) as month,
60    AVG(unrate) as avg_unrate
61  FROM "@michal.fred_data.unrate_csv"
62  WHERE unrate IS NOT NULL
63  GROUP BY DATE_TRUNC('month', observation_date)
64),
65all_months AS (
66  SELECT DISTINCT month FROM monthly_t10y2y
67  UNION
68  SELECT DISTINCT month FROM monthly_baa10y
69  UNION
70  SELECT DISTINCT month FROM monthly_ic4wsa
71  UNION
72  SELECT DISTINCT month FROM monthly_vixcls
73  UNION
74  SELECT DISTINCT month FROM monthly_umcsent
75  UNION
76  SELECT DISTINCT month FROM monthly_usslind
77  UNION
78  SELECT DISTINCT month FROM monthly_unrate
79)
80
81SELECT 
82  am.month,
83  ROUND(t.avg_t10y2y, 2) as yield_spread_10y2y,
84  ROUND(b.avg_baa10y, 2) as corp_bond_spread,
85  ROUND(i.avg_ic4wsa, 0) as initial_claims_4wk,
86  ROUND(v.avg_vixcls, 2) as vix_volatility,
87  ROUND(u.avg_umcsent, 1) as consumer_sentiment,
88  ROUND(l.avg_usslind, 2) as leading_index,
89  ROUND(un.avg_unrate, 1) as unemployment_rate
90FROM all_months am
91LEFT JOIN monthly_t10y2y t ON am.month = t.month
92LEFT JOIN monthly_baa10y b ON am.month = b.month
93LEFT JOIN monthly_ic4wsa i ON am.month = i.month
94LEFT JOIN monthly_vixcls v ON am.month = v.month
95LEFT JOIN monthly_umcsent u ON am.month = u.month
96LEFT JOIN monthly_usslind l ON am.month = l.month
97LEFT JOIN monthly_unrate un ON am.month = un.month
98WHERE am.month >= '2022-01-01'
99ORDER BY am.month asc
100
101
monthyield_spread_10y2ycorp_bond_spreadinitial_claims_4wkvix_volatilityconsumer_sentimentleading_indexunemployment_rate
2022-01-010.781.8223215023.1867.2null4
2022-02-010.52.0322593825.7562.8null3.8
2022-03-010.222.1721737526.9759.4null3.7
2022-04-010.211.9121255024.3765.2null3.7
2022-05-010.282.2221243829.3158.4null3.6
2022-06-010.152.1221150028.2350null3.6
2022-07-01-0.142.322151502551.5null3.5
2022-08-01-0.352.2522025022.1758.2null3.6
2022-09-01-0.342.1720487527.3458.6null3.5
2022-10-01-0.392.2820035030.0159.9null3.6
2022-11-01-0.612.1720637523.356.7null3.6
2022-12-01-0.671.9821020021.7859.8null3.5
2023-01-01-0.681.9720500020.1764.9null3.5
2023-02-01-0.791.8521056320.1266.9null3.6
2023-03-01-0.642.0522225021.6462null3.5
2023-04-01-0.562.0722155017.8263.7null3.4
2023-05-01-0.562.1922100017.6459null3.6
2023-06-01-0.892.012444381464.2null3.6
2023-07-01-0.931.8423890013.9371.5null3.5
2023-08-01-0.731.8524337515.8569.4null3.7
2023-09-01-0.641.7822610015.1767.8null3.8
2023-10-01-0.271.8321081318.8963.8null3.9
2023-11-01-0.381.7921687514.0261.3null3.7
2023-12-01-0.441.6221110012.7269.7null3.8
2024-01-01-0.261.6220431313.3979null3.7
2024-02-01-0.341.5621412513.9876.9null3.9
2024-03-01-0.381.5521250013.7979.4null3.9
2024-04-01-0.331.4621362516.1477.2null3.9
2024-05-01-0.371.4721818813.0669.1null4
2024-06-01-0.431.5123060012.6768.2null4.1
2024-07-01-0.251.5923406314.3766.4null4.2
2024-08-01-0.091.7323460019.3167.9null4.2
2024-09-010.11.6922718817.6670.3null4.1
2024-10-010.121.5423593819.9670.5null4.1
2024-11-010.11.4222075016.0271.8null4.2
2024-12-010.171.4122450015.8774null4.1
2025-01-010.361.4521325016.7671.7null4
2025-02-010.241.4721968816.9764.7null4.1
2025-03-010.311.6522620021.8457null4.2
2025-04-010.51.922268831.9752.2null4.2
2025-05-010.51.8623085020.4652.2null4.2
2025-06-010.491.7624325018.460.7null4.1
2025-07-010.511.7122775016.3861.7null4.2
2025-08-010.561.7322560015.7558.2null4.3
2025-09-010.551.7123950015.79nullnullnull
2025-10-010.561.67null17.2nullnullnull

Share link

Anyone who has the link will be able to view this.