- Polars backend returns WRDS date columns as
Date(#66): Withset_backend("polars"), the calendar-date columns of the WRDS downloads (trd_exctn_dtfromtrace_enhanced,datadatefrom Compustat,linkdt/linkenddtfrom CCM links,calculation_datefrom monthly CRSP, and the FISD date columns) are now cast topolars.Dateinstead of surfacing aspolars.Datetime, matching the R package and the existing normalization of thedatecolumn. This fixesSchemaErrors when joining or vertically stacking TRACE output againstDate-typed frames. True time-of-day columns (e.g.trd_exctn_tm) and timezone-aware datetimes are unaffected. - Added FRED-MD and FRED-QD macroeconomic databases:
download_data("FRED", "FRED-MD")anddownload_data("FRED", "FRED-QD")download the McCracken and Ng (2016, 2021) curated monthly / quarterly macro panels as wide tables (one column per series).transform=Trueapplies each series' stationarity transform code (tcode).vintageselects the current release (default), a specific"YYYY-MM"release, or"all"— the full real-time panel across every archived vintage (recent vintages are hosted individually; older ones are read from the St. Louis Fed vintage archive zips), enabling leak-free point-in-time analysis. - Added Global Factor Data, Pastor-Stambaugh, and Stambaugh-Yuan
downloads:
download_data("Global Factor Data")downloads characteristic-managed portfolio returns, the underlying long-short portfolios, industry returns, or reference cutoff files from Global Factor Data (Jensen, Kelly, and Pedersen, 2023); the requested selection is validated against the library's live availability manifest, andlist_supported_jkp_factors()lists the available regions and factors.download_data("Pastor-Stambaugh")downloads the liquidity factors of Pastor and Stambaugh (2003).download_data("Stambaugh-Yuan")downloads the mispricing factors of Stambaugh and Yuan (2017), with adatasetargument selecting"monthly"(default) or"daily"data. - OSAP download aligned with beginning-of-month and scaled returns:
download_data("Open Source Asset Pricing")now aligns thedatecolumn to the beginning of the month (the dataset previously returned end-of-month dates), matching the convention used by the other download functions. All predictor columns are monthly long-short returns expressed in percent and are now divided by 100 to return plain numeric (decimal) returns. sorting_variableis now optional forfactor_library: Callingdownload_data("Tidy Finance", "factor_library")without asorting_variablenow returns the default portfolio construction for all sorting variables instead of raising an error. Other defaults (e.g.rebalancing,weighting_scheme) still apply; passfill_all=Trueto leave every column unrestricted. PassingNonefor any filter column now removes that filter entirely and returns all values for that column (e.g.min_size_quantile=Noneincludes all size groups), matching the R package'sNULLbehavior.- Added
detailparameter toestimate_fama_macbeth: matching the R package, passingdetail=Truereturns a dict withcoefficients(the usual risk premium estimates) andsummary_statistics(a one-row data frame with the mean cross-sectionalr_squared,adj_r_squared, andn_obsacross all per-period regressions). The default (detail=False) behavior — returning only the coefficients data frame — is unchanged. - Dependencies (replaced pyfixest with formulaic): The
pyfixestdependency was dropped in favor offormulaicplus a small internal numpy OLS helper (_fit_ols).pyfixestwas used only for plain OLS with classical (IID) standard errors inestimate_modeland the cross-sectional / IID-variance steps ofestimate_fama_macbeth, but it pulled ingreat-tables→multimark, acffiC-extension that ships no Python 3.14 wheels and therefore required a C/C++ toolchain (e.g. MSVC Build Tools on Windows) to install on unsupported interpreters._fit_olsbuilds the design matrix viaformulaicand reproducesfeolscoefficients, standard errors, t-statistics, and residuals to ~1e-9 for models without fixed effects, so results are unchanged. Note thatestimate_modelandestimate_fama_macbethnow perform classical OLS only (the fixed-effects / clustered-SE features ofpyfixestwere never used and are no longer available).
- Development version
- Initial PyPI release.
- Added new FRED url for data download
- added
curl_cffipackage to handle HTTP 429 Too Many Requests client error on Yahoo finance
- removed
pandas_datareaderpackage requirements, replaced withrequestsfromcurl_cffipackage - bug fix fred download
- added "_" to internal data download function names
- removed internal
__download_data_factorsfunction
- added
get_available_famafrench_datasetsas a public function
- fix date for monthly data in
_download_data_factors_ff
- Added support for Hugging Face datasets via
domain="tidyfinance", includinghigh_frequency_sp500andfactor_library
- Dependencies (removed statsmodels): The
statsmodelsdependency was dropped; the regression-based functions now usepyfixestinstead.estimate_modeland the cross-sectional / IID-variance steps ofestimate_fama_macbethcallpyfixest.feols, andestimate_betaswas rewritten to estimate rolling betas via closed-form OLS on cumulative cross-product sums (the design Gram matrixX'Xand moment vectorX'yare accumulated and rolled by cumulative-sum differencing, then solved once per window). This follows the fast beta estimation approach, generalized to multiple regressors, and returns coefficients identical to ordinary least squares while avoiding a full refit per window (#49). - Docs (Great Docs): Added a Great Docs documentation site configured via
great-docs.yml, including LLM-friendly artifacts (llms.txt,llms-full.txt). The API reference is generated from the numpydoc docstrings; build locally withgreat-docs build(on Windows setPYTHONUTF8=1to avoid a cp1252 decode error during post-processing). The generatedgreat-docs/build directory is gitignored. (#29) - Breaking (Python version): The minimum supported Python is now 3.11 (was 3.10), as required by the Great Docs toolchain.
- Docs (R parity): Fixed docstring discrepancies surfaced by the rendered reference, aligning the Python docs with r-tidyfinance:
breakpoint_options(removed a duplicatedbreakpoints_exchangesentry and documented the previously undocumentedbreakpoints_min_size_threshold),create_summary_statistics(enumerated the reported statistics and detail quantiles),compute_portfolio_returns/implement_portfolio_sort(min_portfolio_sizeunivariate/bivariate semantics and the "set to 0 to deactivate" behavior),estimate_betas(lookbackannotated asintto match its use as an observation-count window), andwinsorize(corrected thextype tonp.ndarrayand documented the[0, 0.5]range forcut). - Polars support: the public API can now work with polars data frames via a global backend. Call
tidyfinance.set_backend("polars")(default"pandas";get_backend()reports the current setting). When set to"polars", the data-bearing functions (download_data, theestimate_*/compute_*family,add_lagged_columns,assign_portfolio's frame inputs,list_supported_datasets, etc.) return polars data frames, and all of them also accept polars input regardless of the active backend (converted to pandas internally). DataFrame outputs convert; Series/dict/ndarray returns (e.g.assign_portfolio) are left as-is, and date indices are preserved as columns. Internals remain pandas-based for now. Requires the optionalpolarsdependency (pip install tidyfinance[polars]) (#42). - Breaking (WRDS credentials): WRDS credentials are now read exclusively from environment variables (e.g. via a
.envfile). Support forconfig.yamlhas been removed:set_wrds_credentials()now writes a.envfile (withWRDS_USERandWRDS_PASSWORD), andget_wrds_connection()no longer accepts aconfig_pathargument. Thepyyamldependency was dropped. Migrate any existingconfig.yamlcredentials into a.envfile or environment variables. - Breaking (CRSP): the monthly CRSP price column returned by
download_data(domain="wrds", dataset="crsp_monthly")is now namedprc(wasaltprc), aligning with r-tidyfinance and both book editions. The value is unchanged — it ismthprcfrom the CRSP v2 monthly stock file;altprcwas the legacy (v1) column name and was semantically stale for v2 downloads. Update any downstream code that referencedaltprc(including the dependentmktcapcomputation). - Fix (Fama-MacBeth Newey-West):
estimate_fama_macbethnow matches R'ssandwich::NeweyWestdefaults, so the Python and R editions agree on Newey-West t-statistics. The previous implementation used statsmodels HAC with a fixedmaxlags=6and no prewhitening (textbook Newey-West 1987); the new numpy implementation uses VAR(1) prewhitening plus the automatic Newey & West (1994) bandwidth, Bartlett kernel, recoloring, and no finite-sample adjustment (verified againstsandwich3.1.1 to ~1e-13).vcov_optionsnow mirrors R's interface (lag,prewhite,adjust) and defaults toNone; the legacymaxlagskey is accepted as a deprecated alias forlag(preserving the old no-prewhitening behavior) and emits aDeprecationWarning(#35). - Fix (CRSP column order):
download_data(domain="wrds", dataset="crsp_monthly")now orderslisting_agebeforemktcapto match r-tidyfinance'sdownload_data_wrds_crsp()(..., siccd, listing_age, mktcap, mktcap_lag, ...). Values are unchanged; only the column order differed (#36). - Fix (TRACE regime cutoff):
process_trace_datanow uses the correct Dick-Nielsen (2014) enhanced-TRACE regime cutoff of2012-02-06(was the transposed2012-06-02). Samples spanning Feb 6 – Jun 2, 2012 were previously cleaned under the wrong cancellation/correction/reversal regime, producing incorrect output; samples entirely after June 2012 were unaffected. This aligns the Python edition with r-tidyfinance'sdownload_data_wrds_trace_enhanced()(#34). download_data()now uses the human-readable domain names returned bylist_supported_datasets()(e.g.,"Fama-French","Global Q","WRDS","Tidy Finance"). The"pseudo"and"tidyfinance"domains were renamed to"Pseudo Data"and"Tidy Finance". The previous machine-readable domain names (e.g.,"famafrench","wrds","pseudo","tidyfinance") are soft-deprecated but still accepted.- Breaking (package API): the dataset-specific
_download_data_*helpers (e.g._download_data_wrds,_download_data_macro_predictors,_download_data_constituents,_download_data_factors_ff,_download_data_factors_q,_download_data_osap,_download_data_risk_free,_download_data_stock_prices) are no longer re-exported from the package root. Public access continues via the dispatcherdownload_data(domain, dataset, ...). If you need a helper directly, import it from its defining module (e.g.from tidyfinance.data_download import _download_data_wrds).