FinanceRoutines.jl

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

commit f7a0bb47e287116750b8f4d7f7486308b1720286
parent 95151f27d7ab321862e8e22627a9a5b9783655c3
Author: Erik Loualiche <[email protected]>
Date:   Sun, 22 Mar 2026 10:13:50 -0500

Remove broken @log_msg macro, clean up Logging dep and stale export

- Delete log_with_level() and @log_msg macro from Utilities.jl
- Replace @log_msg calls in ImportCRSP.jl with @debug
- Remove Logging from [deps] (@debug/@warn available from Base)
- Remove stale export greet_FinanceRoutines (never defined)

[skip ci]

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

Diffstat:
MProject.toml | 1-
Msrc/FinanceRoutines.jl | 2--
Msrc/ImportCRSP.jl | 8++++----
Msrc/Utilities.jl | 36------------------------------------
4 files changed, 4 insertions(+), 43 deletions(-)

diff --git a/Project.toml b/Project.toml @@ -16,7 +16,6 @@ GLM = "38e38edf-8417-5370-95a0-9cbb8c7f171a" IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" LibPQ = "194296ae-ab2e-5f79-8cd4-7183a0a5a0d1" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" -Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" PeriodicalDates = "276e7ca9-e0d7-440b-97bc-a6ae82f545b1" Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665" diff --git a/src/FinanceRoutines.jl b/src/FinanceRoutines.jl @@ -16,7 +16,6 @@ import GLM: coef, lm import IntervalSets:(..) import LibPQ: LibPQ.execute, LibPQ.Connection 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 Roots @@ -42,7 +41,6 @@ include("Merge_CRSP_Comp.jl") # -------------------------------------------------------------------------------------------------- # List of exported functions -export greet_FinanceRoutines # for debugging # Yields on Treasuries export import_gsw_parameters # basic data import function diff --git a/src/ImportCRSP.jl b/src/ImportCRSP.jl @@ -300,7 +300,7 @@ function import_MSF_v2(wrds_conn::Connection; # ---------------------------------------------------------------------------------------------- # the easy way - @log_msg "# -- GETTING MONTHLY STOCK FILE (CIZ) ... msf_v2" + @debug "Getting monthly stock file (CIZ) ... msf_v2" msf_v2_columns = _get_postgres_columns("crsp", "msf_v2"; wrds_conn=wrds_conn) |> sort col_select = ["permno", "hdrcusip", "mthcaldt", "mthprc", "mthret", "mthcap", "shrout", "mthretx", "mthprevcap", "mthprevprc", "permco"] @@ -328,7 +328,7 @@ function import_MSF_v2(wrds_conn::Connection; # ---------------------------------------------------------------------------------------------- # the hard way # ------ - log_msg("# -- GETTING MONTHLY STOCK FILE (CIZ) ... stkmthsecuritydata") + @debug "Getting monthly stock file (CIZ) ... stkmthsecuritydata" msf_columns = _get_postgres_columns("crsp", "stkmthsecuritydata"; wrds_conn=wrds_conn) # download potential columns # msf_columns = _get_postgres_columns("crsp", "msf_v2"; wrds_conn=wrds_conn) # this one is pre-merged! msf_columns = join(uppercase.(msf_columns), ", ") @@ -378,7 +378,7 @@ function import_MSF_v2(wrds_conn::Connection; # ---------------------------------------------------------------------------------------------- # ------ - @log_msg "# -- GETTING StkSecurityInfoHist (CIZ)" + @debug "Getting StkSecurityInfoHist (CIZ)" # stksecurityinfo = _get_postgres_columns("crsp", "stksecurityinfohist"; wrds_conn=wrds_conn) stksecurityinfo_cols = vcat( ["PERMNO", "SecInfoStartDt", "SecInfoEndDt", "IssuerNm", "ShareClass", @@ -397,7 +397,7 @@ function import_MSF_v2(wrds_conn::Connection; disallowmissing!(df_stksecurityinfo, [:permno, :secinfostartdt, :secinfoenddt, :issuernm, :hdrcusip]) # ------ - @log_msg "# -- MERGING STOCK PRICES, INFO FILE" + @debug "Merging stock prices, info file" # we do left-join here because we dont want to lose obs. df_msf_v2 = FlexiJoins.leftjoin( (df_msf_v2, df_stksecurityinfo), diff --git a/src/Utilities.jl b/src/Utilities.jl @@ -66,40 +66,4 @@ end # -------------------------------------------------------------------------------------------------- -# -------------------------------------------------------------------------------------------------- -function log_with_level(message::String, level::Symbol=:debug; - _module=@__MODULE__, _file=@__FILE__, _line=@__LINE__) - # Convert symbol level to proper logging level - log_level = if level == :debug - Logging.Debug - elseif level == :info - Logging.Info - elseif level == :warn - Logging.Warn - elseif level == :error - Logging.Error - else - @warn "logging level not recognized ($level); default to debug" - # Default to Debug if unknown level is provided - Logging.Debug - end - - # Log the message at the specified level, preserving caller information - with_logger(ConsoleLogger(stderr, log_level)) do - @logmsg log_level message _module=_module _file=_file _line=_line - end -end - -# I am not sure this is working! -macro log_msg(message) - quote - # Use the logging_level variable from the current scope - if @isdefined(logging_level) && logging_level ∈ [:debug, :info, :warn, :error] - log_with_level($(esc(message)), logging_level; - _module=@__MODULE__, _file=@__FILE__, _line=@__LINE__) - end - end -end -# -------------------------------------------------------------------------------------------------- -