FinanceRoutines.jl

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

commit 5be58b3328a515e879e42f21ab31fa995beb0e65
parent ba26e04f30801d5da6c2debad54a573613b40f55
Author: Erik Loualiche <[email protected]>
Date:   Fri,  6 Jun 2025 10:39:40 -0500

remove dependencies

Diffstat:
M.github/workflows/CI.yml | 1-
MProject.toml | 4++--
Msrc/FinanceRoutines.jl | 10++++------
Msrc/ImportCRSP.jl | 5+++--
Msrc/ImportYields.jl | 2+-
Mtest/runtests.jl | 5+++--
6 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml @@ -24,7 +24,6 @@ jobs: matrix: version: - "1.11" - - "1.10" os: - ubuntu-latest arch: diff --git a/Project.toml b/Project.toml @@ -4,6 +4,7 @@ authors = ["Erik Loualiche <[email protected]>"] version = "0.4.2" [deps] +BazerData = "d6d9bf1d-14ee-42c9-93f7-cccc2a9ff2c2" CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" DataPipes = "02685ad9-2d12-40c3-9f73-c6aeda6a7ff5" @@ -17,15 +18,14 @@ LibPQ = "194296ae-ab2e-5f79-8cd4-7183a0a5a0d1" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" -PanelShift = "d68e4d5e-4a60-4df1-b225-9a1636c75ae0" PeriodicalDates = "276e7ca9-e0d7-440b-97bc-a6ae82f545b1" -ShiftedArrays = "1277b4bf-5013-50f5-be3d-901d8477a67a" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" WeakRefStrings = "ea10d353-3f73-51f8-a26c-33c1cb351aa5" ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea" [compat] +BazerData = "0.7.4" CSV = "0.10" DataFrames = "1" julia = "1" diff --git a/src/FinanceRoutines.jl b/src/FinanceRoutines.jl @@ -2,15 +2,14 @@ module FinanceRoutines # -------------------------------------------------------------------------------------------------- -import Downloads -import ZipFile +import BazerData: tlag import CSV import DataFrames: AbstractDataFrame, AsTable, DataFrame, DataFrameRow, ByRow, groupby, nrow, passmissing, Not, rename!, select, select!, subset!, transform!, leftjoin, disallowmissing! import DataPipes: @p import Dates: Dates, Date, Day, Month, year import Decimals: Decimal -import Downloads: Downloads.download +import Downloads import FlexiJoins using FlexiJoins: by_key, by_pred import GLM: coef, lm @@ -20,11 +19,10 @@ import LinearAlgebra: qr import Logging: Logging, with_logger, ConsoleLogger, @logmsg, Logging.Debug, Logging.Info, Logging.Warn, Logging.Error import Missings: Missings, missing, disallowmissing import PeriodicalDates: MonthlyDate -import PanelShift: panellag!, tlag -import ShiftedArrays: lag import Tables: columntable import WeakRefStrings: String3, String7, String15 -import ZipFile: ZipFile.Reader +import ZipFile +# import ZipFile: ZipFile.Reader # -------------------------------------------------------------------------------------------------- diff --git a/src/ImportCRSP.jl b/src/ImportCRSP.jl @@ -189,8 +189,9 @@ function build_MSF!( # df_msf_mktcap_lag = @select(df_msf, # :datem = :datem + Month(1), :permno, :l1m_mktcap2 = :mktcap) # df_msf = leftjoin(df_msf, df_msf_mktcap_lag, on = [:permno, :datem]) - panellag!(df, :permno, :datem, - :mktcap, :l1m_mktcap, Month(1)) + # panellag!(df, :permno, :datem, :mktcap, :l1m_mktcap, Month(1)) + transform!(groupby(df, :permno), + [:mktcap, :datem] => ( (v, t) -> tlag(v, t, n=Month(1)) ) => :l1m_mktcap) # Adjusted returns (see tidy finance following Bali, Engle, and Murray) transform!(df, diff --git a/src/ImportYields.jl b/src/ImportYields.jl @@ -1131,7 +1131,7 @@ function add_returns!(df::DataFrame, maturity::Real; for col in param_cols lag_col = Symbol("lag_$col") transform!(df, [:date, col] => - ((dates, values) -> tlag(dates, values, time_step)) => + ((dates, values) -> tlag(values, dates; n=time_step)) => lag_col) end diff --git a/test/runtests.jl b/test/runtests.jl @@ -13,7 +13,8 @@ import DataPipes: @p # -------------------------------------------------------------------------------------------------- const testsuite = [ "KenFrench", - "WRDS", "betas", + "WRDS", + "betas", "Yields", ] # -------------------------------------------------------------------------------------------------- @@ -21,7 +22,7 @@ const testsuite = [ # -------------------------------------------------------------------------------------------------- # To run file locally (where environment variables are not defined by CI) -env_file = "../.env.gpg" +env_file = "/Users/loulou/Documents/data/.env/.env.gpg" if isfile(env_file) io = IOBuffer(); run(pipeline(`which gpg`; stdout=io)); gpg_cmd = strip(String(take!(io))) io = IOBuffer();