Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/accessing-and-managing-financial-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
var hash = window.location.hash.startsWith('#') ? window.location.hash.slice(1) : window.location.hash;
var redirect = redirects[hash] || redirects[""] || "/";
window.document.title = 'Redirect to ' + redirect;
if (!redirects[hash]) {
redirect = redirect + window.location.hash;
}
redirect = redirect + window.location.search;
window.location.replace(redirect);
</script>
</head>
Expand Down
771 changes: 509 additions & 262 deletions docs/python/accessing-and-managing-financial-data.html

Large diffs are not rendered by default.

305 changes: 157 additions & 148 deletions docs/r/accessing-and-managing-financial-data.html

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions docs/search.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
</url>
<url>
<loc>https://www.tidy-finance.org/python/accessing-and-managing-financial-data.html</loc>
<lastmod>2025-09-04T10:41:27.789Z</lastmod>
<lastmod>2025-12-07T22:27:22.252Z</lastmod>
</url>
<url>
<loc>https://www.tidy-finance.org/python/changelog.html</loc>
Expand Down Expand Up @@ -274,7 +274,7 @@
</url>
<url>
<loc>https://www.tidy-finance.org/r/accessing-and-managing-financial-data.html</loc>
<lastmod>2025-09-04T08:29:23.489Z</lastmod>
<lastmod>2025-12-07T22:27:49.384Z</lastmod>
</url>
<url>
<loc>https://www.tidy-finance.org/r/changelog.html</loc>
Expand Down
235 changes: 154 additions & 81 deletions python/accessing-and-managing-financial-data.qmd

Large diffs are not rendered by default.

26 changes: 12 additions & 14 deletions r/accessing-and-managing-financial-data.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -241,30 +241,28 @@ We can then use the `httr2` [@httr2] package to request the CSV, extract the dat
#| message: false
library(httr2)

cpi_daily <- request(cpi_url) |>
req_perform() |>
resp_body_string() |>
resp <- request(cpi_url) |>
req_perform()
resp_csv <- resp |>
resp_body_string()

cpi_monthly <- resp_csv |>
read_csv() |>
mutate(
date = as.Date(observation_date),
value = as.numeric(.data[[series]]),
series = series,
.keep = "none"
)
```

We convert the daily CPI data to monthly because we use the latter in later chapters.

```{r}
cpi_monthly <- cpi_daily |>
) |>
filter(date >= start_date & date <= end_date) |>
mutate(
date = floor_date(date, "month"),
cpi = value / value[date == max(date)],
.keep = "none"
cpi = value / value[date == max(date)]
)
```

The `tidyfinance` package can, of course, also fetch the same daily data and many more data series:
The last line sets the current (latest) price level as the reference price level.

The `tidyfinance` package can, of course, also fetch the same index data and many more data series:

```{r}
#| message: false
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ statsmodels==0.14.4
tabulate==0.9.0
terminado==0.17.1
threadpoolctl==3.2.0
tidyfinance==0.1.2
tidyfinance==0.2.4
tinycss2==1.2.1
tomli==2.0.1
tornado==6.3.3
Expand Down