FinanceRoutines.jl

Financial data routines for Julia
Log | Files | Refs | README | LICENSE

commit 68bf2cdc78a73a6d641d3b42940d8df190e3b401
parent df019bc8c49fe441548c351144b6569ad97709bf
Author: Erik Loualiche <eloualic@umn.edu>
Date:   Sun, 15 Feb 2026 19:32:36 -0600

Fix documentation: broken examples, outdated content, copy-paste errors

- README: fix import_FF3(:daily) → import_FF3(frequency=:daily)
- index.md: update installation (package is registered in loulouJL),
  add links to yield curve guide and SIZ-to-CIZ demo
- wrds_advanced.md: fix undefined variable postgre_query_msenames_columns
- beta.md: replace emptymissing (unimported BazerData) with plain mean/median
- crsp_siz_to_ciz.md: fix get_postgres_table → _get_postgres_table,
  remove duplicate DataPipes import, clean up developer note
- make.jl: remove duplicate deploydocs call
- yield_curve_gsw.md: remove empty API stub header
- betas.jl: fix docstring argument order (y,x) → (X,y)
- ImportCRSP.jl: fix build_MSF! docstring (said "compustat" / "funda")
- Add CLAUDE.md with release workflow and testing instructions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Diffstat:
ACLAUDE.md | 28++++++++++++++++++++++++++++
MREADME.md | 2+-
Mdocs/make.jl | 5-----
Mdocs/src/demo/beta.md | 6+++---
Mdocs/src/demo/crsp_siz_to_ciz.md | 9++++-----
Mdocs/src/demo/wrds_advanced.md | 2+-
Mdocs/src/index.md | 15+++++++++++++--
Mdocs/src/man/yield_curve_gsw.md | 1-
Msrc/ImportCRSP.jl | 4++--
Msrc/betas.jl | 2+-
10 files changed, 53 insertions(+), 21 deletions(-)

diff --git a/CLAUDE.md b/CLAUDE.md @@ -0,0 +1,28 @@ +# CLAUDE.md + +## Project + +FinanceRoutines.jl — Julia package for financial data (WRDS/CRSP, Compustat, Fama-French, GSW yield curves, bond pricing). + +- **Registry**: https://github.com/LouLouLibs/loulouJL (manual updates, no registrator bot) +- **Julia compat**: 1.10+ + +## Release workflow + +1. Bump `version` in `Project.toml` +2. Commit, push, and tag: `git tag vX.Y.Z && git push origin vX.Y.Z` +3. Update the LouLouLibs registry (`F/FinanceRoutines/` in `LouLouLibs/loulouJL`): + - **Versions.toml**: Add entry with `git-tree-sha1` (get via `git rev-parse vX.Y.Z^{tree}`) + - **Deps.toml**: Update if deps changed (use version ranges to scope additions/removals) + - **Compat.toml**: Update if compat bounds changed + - Can update via GitHub API (`gh api ... -X PUT`) without cloning + +## Testing + +```bash +julia --project=. -e 'using Pkg; Pkg.test()' +``` + +- WRDS tests require `WRDS_USERNAME` and `WRDS_PWD` environment variables +- Local env loaded from `/Users/loulou/Documents/data/.env/.env.gpg` via gpg in `test/runtests.jl` +- Test suites: KenFrench, WRDS, betas, Yields diff --git a/README.md b/README.md @@ -80,7 +80,7 @@ This downloads directly data from Ken French's website and formats the data ```julia df_FF3 = import_FF3() # there is an option to download the daily factors -df_FF3_daily = import_FF3(:daily) +df_FF3_daily = import_FF3(frequency=:daily) ``` ### Estimate treasury bond returns diff --git a/docs/make.jl b/docs/make.jl @@ -28,11 +28,6 @@ makedocs( ] ) -deploydocs( - repo="github.com/louloulibs/FinanceRoutines.jl.git", - target = "build", -) - deploydocs(; repo="github.com/louloulibs/FinanceRoutines.jl.git", target = "build", diff --git a/docs/src/demo/beta.md b/docs/src/demo/beta.md @@ -109,9 +109,9 @@ insertcols!(df_msf, :a=>missing, :bMKT=>missing, :bSMB=>missing, :bHML=>missing) end import Statistics: median, mean -@p df_msf |> groupby(__, :datem) |> - combine(__, :bMKT .=> - [(x-> emptymissing(mean)(skipmissing(x))) (x-> emptymissing(median)(skipmissing(x)))] .=> +@p df_msf |> groupby(__, :datem) |> + combine(__, :bMKT .=> + [(x-> mean(skipmissing(x))) (x-> median(skipmissing(x)))] .=> [:bMKT_mean :bMKT_median]) ``` Go make some coffee ... this takes a little while (~ 15mn on M2max macbook pro). diff --git a/docs/src/demo/crsp_siz_to_ciz.md b/docs/src/demo/crsp_siz_to_ciz.md @@ -16,7 +16,7 @@ These tables are available from the WRDS postgres server ```julia using FinanceRoutines -using DataPipes, DataFrames, DataFramesMeta, DataPipes +using DataPipes, DataFrames, DataFramesMeta import LibPQ: LibPQ.execute, LibPQ.Connection # to connect directly to the server import Tables: columntable @@ -25,7 +25,7 @@ see(df) = show(df, allcols=true, allrows=true, truncate=0) # to view df without ``` ```julia -const get_postgres_table = FinanceRoutines.get_postgres_table +const get_postgres_table = FinanceRoutines._get_postgres_table # main table for converting columns siz_to_ciz = get_postgres_table("crsp", "metasiztociz"; wrds_conn=wrds_conn) |> DataFrame # flag information @@ -164,9 +164,8 @@ stock_info_hist_subset = @rsubset(stock_info_hist, groupby(__, [:shrcd, :sharetype, :securitytype, :securitysubtype, :usincflg, :issuertype]) |> combine(__, nrow) ``` -!!There still seems to be some discrepancy!! -If we do not want to worry, we simply use the [CRSP cross reference guide](https://www.crsp.org/wp-content/uploads/guides/CRSP_Cross_Reference_Guide_1.0_to_2.0.pdf) which leads us to this [mapping table](https://www.crsp.org/wp-content/uploads/ShareCode.html -) +There still seems to be some discrepancy in the mapping. +If we do not want to worry, we simply use the [CRSP cross reference guide](https://www.crsp.org/wp-content/uploads/guides/CRSP_Cross_Reference_Guide_1.0_to_2.0.pdf) which leads us to this [mapping table](https://www.crsp.org/wp-content/uploads/ShareCode.html). ### Exchange Filters diff --git a/docs/src/demo/wrds_advanced.md b/docs/src/demo/wrds_advanced.md @@ -29,7 +29,7 @@ postgre_query_columns= """ WHERE table_schema = 'crsp' AND table_name = 'StkSecurityInfoHist'; """ -msenames_columns = @p LibPQ.execute(wrds_conn, postgre_query_msenames_columns) |> +msenames_columns = @p LibPQ.execute(wrds_conn, postgre_query_columns) |> DataFrame |> __.column_name |> sort ``` diff --git a/docs/src/index.md b/docs/src/index.md @@ -14,10 +14,17 @@ This is still very much work in progress: file [issues](https://github.com/loulo ## Installation -`FinanceRoutines.jl` is a not yet a registered package. -You can install it from github via +`FinanceRoutines.jl` is a registered package in the [`loulouJL`](https://github.com/LouLouLibs/loulouJL) registry. +You can install it via the Julia package manager: ```julia +using Pkg +pkg"registry add https://github.com/LouLouLibs/loulouJL.git" +Pkg.add("FinanceRoutines") +``` + +Or install directly from GitHub: +```julia import Pkg Pkg.add("https://github.com/louloulibs/FinanceRoutines.jl") ``` @@ -26,6 +33,10 @@ Pkg.add("https://github.com/louloulibs/FinanceRoutines.jl") - Using WRDS (CRSP, Compustat, etc) + See the [WRDS User Guide](@ref) for an introduction to using the package to download data from WRDS + + See [Transitioning to the new CRSP file format](@ref) for a guide on converting from SIZ to CIZ + + - Treasury yield curves + + See the [Import Yield Curve Data](@ref) guide for GSW yield curve parameters and bond return calculations - Demos to how this integrates into standard estimations + See how to estimate asset pricing betas in the [Estimating Stock Betas](@ref) demo. diff --git a/docs/src/man/yield_curve_gsw.md b/docs/src/man/yield_curve_gsw.md @@ -205,7 +205,6 @@ stats = combine( ``` -## API ## Data Source GSW yield curve parameters are downloaded from the Federal Reserve Economic Data (FRED): diff --git a/src/ImportCRSP.jl b/src/ImportCRSP.jl @@ -150,10 +150,10 @@ end Clean up the CRSP Monthly Stock File (see `import_MSF`) # Arguments -- `df::DataFrame`: A standard dataframe with compustat data (minimum variables are in `import_Funda`) +- `df::DataFrame`: A standard dataframe with CRSP MSF data (minimum variables are in `import_MSF`) # Keywords -- `save::String`: Save a gzip version of the data on path `\$save/funda.csv.gz`; Default does not save the data. +- `save::String`: Save a gzip version of the data on path `\$save/msf.csv.gz`; Default does not save the data. - `trim_cols::Bool`: Only keep a subset of relevant columns in the final dataset - `clean_cols::Bool`: Clean up the columns of the dataframe to be of type Float64; Default is `false` and leaves the Decimal type intact diff --git a/src/betas.jl b/src/betas.jl @@ -10,7 +10,7 @@ # -------------------------------------------------------------------------------------------------- """ - calculate_rolling_betas(y, x; window=60) + calculate_rolling_betas(X, y; window=60, min_data=nothing, method=:linalg) Calculate rolling betas using `window` months of returns. """