Repository navigation
Expand file tree
/
Copy pathindex.qmd
More file actions
108 lines (83 loc) · 2.94 KB
/
Copy pathindex.qmd
File metadata and controls
108 lines (83 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
title: "Housing Market at a Glance"
format:
dashboard:
theme: [litera, custom.scss]
orientation: columns
logo: logo.png
---
```{python}
#| label: setup
#| include: false
import pandas as pd
import plotly.express as px
import plotly.io as pio
pio.templates.default = 'plotly_white'
data_files = ['data/weekly_mortgage_rates.csv', 'data/hoi.csv', 'data/mortgage_origination_state.csv']
data_frames = [pd.read_csv(file).sort_values(by='date') for file in data_files]
mortgages, hoi, origin = data_frames
```
```{python}
#| label: create-graphs
#| output: false
# Mortgage rates over time
fig = px.line(mortgages, x='date', y=['fixed_30', 'fixed_15'], title='Interest Rates 15- and 30-Year')
fig.update_traces(name='30-year', selector=dict(name='fixed_30'))
fig.update_traces(name='15-year', selector=dict(name='fixed_15'))
fig.update_xaxes(title_text='')
fig.update_yaxes(title_text='')
fig.update_layout(legend_title_text='')
# Housing opportunity index
hoi_fig = px.line(hoi, x='date', y='hoi', title='Housing Opportunity Index<br><sup>Percentage of homes affordable to median-income families</sup>')
hoi_fig.update_xaxes(title_text='')
hoi_fig.update_yaxes(title_text='')
# Mortgage origination
origin_fig = px.choropleth(origin, scope='usa', locations='GEOID', locationmode='USA-states', color='MORT_ADJ', color_continuous_scale='Jet', animation_frame='date', range_color=(0.009, 0.073))
origin_fig.update_traces(showscale=False)
origin_fig.update_layout(coloraxis_colorbar=dict(title=''))
# Median home prices
price_fig = px.bar(hoi, x='date', y='median_price')
price_fig.update_xaxes(title_text='')
price_fig.update_yaxes(title_text='Median Home Price (thousands $)')
```
# Stats
## Column {width="20%"}
::: {.valuebox color="white"}
`{python} mortgages['fixed_30'].iloc[-1]`%
Average annual rate for a 30-year fixed mortgage in Oct. 2023
:::
::: {.valuebox color="white"}
`{python} mortgages['fixed_15'].iloc[-1]`%
Average annual rate for a 15-year fixed mortgage in Oct. 2023
:::
::: {.valuebox color="white"}
$`{python} hoi['median_price'].iloc[-1]`k
National median home price
:::
## Column
```{python}
#| title: "Mortgage Originations per Capita"
#| height: 50%
origin_fig.show()
```
```{python}
#| title: Mortgage Originations
#| height: 50%
#| padding: 0;
from IPython.display import Markdown
Markdown(mortgages.to_markdown(index = False))
```
## Column {.tabset width="40%"}
```{python}
#| title: "Housing Economics"
fig.show()
hoi_fig.show()
```
```{python}
#| title: "Median Price"
price_fig.show()
```
# Data
The data is from the National Association Of Home Builders Of The United States (NAHB). [Access the NAHB website](https://www.nahb.org/).
* [Mortgage Interest Rates 15- and 30-Year](https://www.nahb.org/news-and-economics/housing-economics/national-statistics/weekly-mortgage-rates-15-and-30-year)
* [Housing Opportunity Index and Median Home Prices](https://www.nahb.org/news-and-economics/housing-economics/indices/housing-opportunity-index)