Skip to content

Instantly share code, notes, and snippets.

View iangow's full-sized avatar
🏠
Working from home

Ian Gow iangow

🏠
Working from home
View GitHub Profile
@iangow
iangow / db2pq.md
Last active March 31, 2026 21:29
Instructions for `db2pq`.

Steps to Creating a Parquet Data Repository from WRDS

This guide will help you download WRDS data and store it locally as Parquet files using the db2pq Python package. No administrator privileges are required for these steps. As a side-effect, after running the following, you will have a working installation of Python on your system.


Notes

@iangow
iangow / get_crsp.md
Created March 21, 2026 11:16
Code adapted from Tidy Microstructure
library(db2pq)
library(dplyr, warn.conflicts = FALSE)
library(farr, warn.conflicts = FALSE)

wrds_update_pq("stksecurityinfohist", "crsp", force = TRUE)
#> Forcing update based on user request.
#> Beginning file download at 2026-03-21 11:15:00 UTC.
#> Completed file download at 2026-03-21 11:15:10 UTC.
wrds_update_pq("dsf_v2", "crsp")
@iangow
iangow / uv_setup.md
Last active March 7, 2026 13:16
Document describing how to use `uv` to set up a project.

Setting Up a Python Environment for Quarto + Jupyter Using uv and .venv

This guide explains how to:

  1. Install uv
  2. Create a project with pyproject.toml
  3. Use a project-local .venv
  4. Add dependencies to the project
  5. Sync the environment
  6. Register the environment as a Jupyter kernel
@iangow
iangow / wrds_call_issues.md
Last active February 1, 2026 16:46
Code showing that WRDS Call Report data has same issue
library(dplyr, warn.conflicts = FALSE)
library(tidyr)
library(wrds)
#> ── Checking WRDS credentials ───────────────────────────────────── wrds 0.0.1 ──
#> βœ” Credentials found for user iangow
library(farr, warn.conflicts = FALSE)

db <- wrds_connect()
@iangow
iangow / download_occupation_profiles.md
Last active February 28, 2025 20:27
Code to download spreadsheet from Jobs and Skills.
library(readxl)
library(httr2)
library(tidyverse)

# Define file URL and destination path
url <- "https://www.jobsandskills.gov.au/sites/default/files/2024-12/occupation_profiles_data_-_november_2024.xlsx"
destfile <- "occupation_profiles_data.xlsx"

# Create request with headers
@iangow
iangow / sql_server_odbc.md
Last active April 1, 2025 13:50
Setting up the ODBC driver on MacOS.

Setting up the ODBC driver on MacOS

The following instructions improve on those here by avoiding the need to:

a. Compile the Homebrew binary itself
b. Set the path for the Homebrew binary

Steps

  1. Install HomeBrew using the .pkg file available here.
@iangow
iangow / rets_all_tables.sas
Created January 17, 2025 15:54
SAS code for making `rets_all` without views.
libname home '.';
PROC SQL;
CREATE TABLE crsp_dates AS
SELECT date, intnx('MONTH', date, 0, 'BEGINNING') AS month format=yymmdd10.
FROM crsp.msi
ORDER BY date;
QUIT;
DATA crsp_dates;
@iangow
iangow / rets_all_views.sas
Last active January 17, 2025 15:41
SAS code for making `rets_all` using views
libname home '.';
PROC SQL;
CREATE TABLE crsp_dates AS
SELECT date, intnx('MONTH', date, 0, 'BEGINNING') AS month format=yymmdd10.
FROM crsp.msi
ORDER BY date;
QUIT;
DATA crsp_dates;
@iangow
iangow / walker_stats.R
Created September 19, 2024 07:41
Code to produce AUC stats from Walker's data
library(farr)
library(tidyverse)
original <- read_csv("~/Downloads/WalkerDataCodeMar2021/original.csv")
original |>
group_by(fyear) |>
summarize(auc = auc(prob, aaer), .groups = "drop") |>
mutate(avg_auc = mean(auc))
@iangow
iangow / other_packages.R
Created September 19, 2024 04:59
Other packages
install.packages(c("formatR", "markdown", "tinytex", "downlit", "xml2"))