Skip to content

Commit

Permalink
Some tests for compustat.
Browse files Browse the repository at this point in the history
  • Loading branch information
eloualiche committed Jan 8, 2025
1 parent 8750b5b commit 5112acf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ImportComp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const compd_funda = [
"ISNGC", "ISNGM", "ISOTC", "ISOTH", "ISOTM", "ISSC", "ISSM", "ISSU", "IST", "ISTC", "ISTM", "ISUT", "ITCB", "ITCC", "ITCI", "IVACO", "IVAEQ", "IVAO", "IVCH", "IVGOD",
"IVI", "IVNCF", "IVPT", "IVST", "IVSTCH", "LCABG", "LCACL", "LCACR", "LCAG", "LCAL", "LCALT", "LCAM", "LCAO", "LCAST", "LCAT", "LCO", "LCOX", "LCOXAR", "LCOXDR", "LCT",
"LCUACU", "LI", "LIF", "LIFR", "LIFRP", "LLOML", "LLOO", "LLOT", "LLRCI", "LLRCR", "LLWOCI", "LLWOCR", "LNO", "LO", "LOL2", "LOXDR", "LQPL1", "LRV", "LS", "LSE", "LST",
"LT", "LUL3", "MIB", "MIBN", "MIBT", "MII", "MRC1", "MRC2", "MRC3", "MRC4", "MRC5", "MRCT", "MRCTA", "MSA", "MSVRV", "MTL", "NAICS", "NAT", "NCO", "NFSR", "NI", "NIADJ", "NIECI",
"LT", "LUL3", "MIB", "MIBN", "MIBT", "MII", "MRC1", "MRC2", "MRC3", "MRC4", "MRC5", "MRCT", "MRCTA", "MSA", "MSVRV", "MTL", "NAT", "NCO", "NFSR", "NI", "NIADJ", "NIECI",
"NIINT", "NIINTPFC", "NIINTPFP", "NIIT", "NIM", "NIO", "NIPFC", "NIPFP", "NIT", "NITS", "NOPI", "NOPIO", "NP", "NPANL", "NPAORE", "NPARL", "NPAT", "NRTXT", "NRTXTD",
"NRTXTEPS", "OANCF", "OB", "OIADP", "OIBDP", "OPEPS", "OPILI", "OPINCAR", "OPINI", "OPIOI", "OPIRI", "OPITI", "OPREPSX", "OPTCA", "OPTDR", "OPTEX", "OPTEXD", "OPTFVGR",
"OPTGR", "OPTLIFE", "OPTOSBY", "OPTOSEY", "OPTPRCBY", "OPTPRCCA", "OPTPRCEX", "OPTPRCEY", "OPTPRCGR", "OPTPRCWA", "OPTRFR", "OPTVOL", "PALR", "PANLR", "PATR", "PCL",
Expand Down
28 changes: 22 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# ---------------------------------------------------------
# --------------------------------------------------------------------------------------------------
using FinanceRoutines
using Test

import DataFrames: DataFrame, nrow, rename!
import Dates: Date
import Dates: Date, year
import LibPQ: Connection
# ---------------------------------------------------------
# --------------------------------------------------------------------------------------------------


# ---------------------------------------------------------
# --------------------------------------------------------------------------------------------------
@testset "FinanceRoutines.jl" begin
# Write your tests here.

Expand Down Expand Up @@ -42,7 +42,7 @@ import LibPQ: Connection
wrds_conn = FinanceRoutines.open_wrds_pg(WRDS_USERNAME, WRDS_PWD)
@test typeof(wrds_conn) == Connection

@testset "MSF" begin
@testset "CRSP MSF" begin
df_msf = import_MSF(wrds_conn; date_range = (Date("2000-01-01"), Date("2002-01-01")));
build_MSF!(df_msf; clean_cols=true);

Expand All @@ -51,7 +51,23 @@ import LibPQ: Connection
@test nrow(df_msf) > 100_000
end

@testset "Compustat FUNDA" begin
df_funda = import_Funda(wrds_conn;
date_range = (Date("2000-01-01"), Date("2002-01-01")),
variables=["PPENT", "NAICSH", "NAICS"])
build_Funda!(df_funda; clean_cols=true)

# check basic properties of the DataFrame (mainly that it has downloaded)
@test minimum(skipmissing(df_funda.datey)) >= year(Date("2000-01-01"))
@test maximum(skipmissing(df_funda.datey)) <= year(Date("2002-01-01"))
@test nrow(df_funda) > 20_000

# check that the variables are downloaded and in the dataframe
@test all(map(s -> s in names(df_funda), lowercase.(["PPENT", "NAICSH"])))

end

end

end
# ---------------------------------------------------------
# --------------------------------------------------------------------------------------------------

0 comments on commit 5112acf

Please sign in to comment.