Skip to content

eloualiche/FinanceRoutines.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FinanceRoutines

Documentation Build Status
CI Testing

FinanceRoutines.jl is a package that contains useful functions to download and process academic financial data.

So far the package provides function to import:

  • CRSP and Compustat from the WRDS Postgres server
  • Fama-French three factors series from Ken French's website
  • GSW Yield curves from the NY Fed

Installation

FinanceRoutines.jl is a not yet a registered package. You can install it from github via

import Pkg
Pkg.add(url="https://github.com/eloualiche/FinanceRoutines.jl")

Examples

Import data from WRDS

First import the monthly stock file and the compustat funda file

using FinanceRoutines
using DataFrames

# Set up a wrds connection
wrds_conn = FinanceRoutines.open_wrds_pg()

# CRSP
df_msf = import_MSF(wrds_conn); # Import the monthly stock file
build_MSF!(df_msf); # Run common processing
# Compustat
df_funda = import_Funda(wrds_conn);
build_Funda!(df_funda)
# Merge both files
df_linktable = FinanceRoutines.import_ccm_link(wrds_conn)
df_msf = link_MSF(df_linktable, df_msf) # merge gvkey on monthly stock file
df_msf = innerjoin(df_msf, df_funda, on = [:gvkey, :datey], matchmissing=:notequal)

Import the Fama-French three factors

This downloads directly data from Ken French's website and formats the data

df_FF3 = import_FF3()
# there is an option to download the daily factors
df_FF3_daily = import_FF3(:daily)

Estimate treasury bond returns

The function downloads yield curves from the NY Fed GSW and estimate returns based on the curves

df_GSW = import_GSW();
estimate_yield_GSW!(df_GSW; maturity=1); # maturity is in years
select(df_GSW, :date, :yield_1y)

To Do

  • olsgmm from cochrane GMM code
  • rolling regressions

Othere references to work with financial data

The package the closest to this one is

  • WrdsMerger.jl; WrdsMerger is probably in a more stable state than this package.

Other packages or sources of code I have used to process the WRDS data

Releases

No releases published

Packages

No packages published

Languages