From 38a8914a41d35f1f71a8499132f272d22aae637a Mon Sep 17 00:00:00 2001 From: Lakshmi Krishnamurthy Date: Tue, 27 Feb 2024 07:01:40 -0500 Subject: [PATCH] Features: - Investing Factors Portfolio Financing Scheme (35, 36) - Investing Factors Portfolio Financing Scheme - Zero Investment (37) - Investing Factors Portfolio Financing Scheme - Zero Cost/Self (38, 39) - Investing Factors Factor Portfolio Shell (40, 41) - Portfolio Construction Core Block Hashcode (42, 43, 44) - Portfolio Construction Core Asset Hashcode (45, 46) - Factor Investing Component Loading Map (47, 48) - Investing Factors Factor Portfolio Country (49, 50) - Investing Factors Factor Portfolio Is Global (51, 52) - Investing Factors Factor Portfolio Financing Scheme (53, 54) - Investing Factors Factor Portfolio Country - Constructor (55, 56, 57) - Investing Factor Portfolio Builder Shell (58, 59) Bug Fixes/Re-organization: - Special Function Incomplete Gamma Lower S Fixed Series - Weierstrass Limit (1, 2) - Special Function Incomplete Gamma Lower S Fixed Series - NIST 2019 Limit (3, 4, 5) - Special Function Incomplete Gamma Lower S Fixed (6, 7, 8) - Special Function Incomplete Gamma Lower S Fixed - Series (9) - Special Function Incomplete Gamma Lower S Fixed - Constructor (10, 11) - Special Function Incomplete Gamma Lower S Fixed - Weierstrass Limit #1 (12) - Special Function Incomplete Gamma Lower S Fixed - Non-dimensional (13) - Special Function Incomplete Gamma Lower S Fixed - Evaluate (14, 15) - Special Function Incomplete Gamma Lower S Fixed - Weierstrass Limit #2 (16, 17) - Special Function Incomplete Gamma Lower S Fixed - NIST 2019 (18, 19, 20) - Special Function Incomplete Gamma Lower Regularized (21, 22, 23) - Special Function Incomplete Gamma Lower Regularized - Constructor (24) - Special Function Incomplete Gamma Lower Regularized - p (25) - Special Function Incomplete Gamma Lower Regularized - Gauss Continued Fraction (26, 27) - Special Function Incomplete Gamma Lower Regularized - Euler Integral (28, 29) - Special Function Incomplete Gamma Lower Regularized - Weierstrass Limit (30, 31) - Special Function Incomplete Gamma Lower Regularized - NIST 2019 (32, 33) - Risk Factor Premium Migration Re-factoring (34) - Factor Portfolio Builder To Ranker (60) Samples: IdeaDRIP: --- IdeaDRIP/FactorInvesting/FI_v0.01 | 39 ++++ ReleaseNotes/08_03_2023.txt | 43 ++++ ScheduleSheet.xlsx | Bin 54815 -> 54931 bytes .../factors/FactorComponentLoading.java | 6 +- .../investing/factors/FactorPortfolio.java | 193 ++++++++++++++++++ .../factors/FactorPortfolioRanker.java | 117 +++++++++++ .../factors/PortfolioFinancingScheme.java | 134 ++++++++++++ .../RiskPremiumCategory.java | 4 +- .../portfolioconstruction/core/Asset.java | 7 + .../portfolioconstruction/core/Block.java | 11 + .../incompletegamma/LowerRegularized.java | 92 +++++---- .../incompletegamma/LowerSFixed.java | 118 ++++++----- .../incompletegamma/LowerSFixedSeries.java | 25 +-- 13 files changed, 661 insertions(+), 128 deletions(-) create mode 100644 IdeaDRIP/FactorInvesting/FI_v0.01 create mode 100644 ReleaseNotes/08_03_2023.txt create mode 100644 src/main/java/org/drip/investing/factors/FactorPortfolio.java create mode 100644 src/main/java/org/drip/investing/factors/FactorPortfolioRanker.java create mode 100644 src/main/java/org/drip/investing/factors/PortfolioFinancingScheme.java rename src/main/java/org/drip/investing/{investible => factors}/RiskPremiumCategory.java (96%) diff --git a/IdeaDRIP/FactorInvesting/FI_v0.01 b/IdeaDRIP/FactorInvesting/FI_v0.01 new file mode 100644 index 000000000000..3502da7bcb13 --- /dev/null +++ b/IdeaDRIP/FactorInvesting/FI_v0.01 @@ -0,0 +1,39 @@ + + Factor Investing + ---------------- + 1) Security Characteristics - aka Factors: Size, Low-volatility, Value, Momentum, Asset growth, Profitability, Leverage, Liquidity, Term, Carry - DONE + 2) Beta Tilt Direction - Towards (+ve), Away (-ve) - DONE + 3) Risk Premia Category - Corporates, Govvies, Equity, Commodities - DONE + 4) Value Factor - Difference between Intrinsic/Fundamental Value and Market Value + 5) Value Factor Metrics - P/E Ratio, P/B Ratio, P/S Ratio, Dividend Yield + 6) Low-volatility Factor - Portfolio acquires only low-volatility assets + 7) Momentum Factor - High returns over past 3-12 months minus Low returns over past 3-12 months, Returns Horizon, Momentum Lag + 8) Momentum Factor caused by seasonality (e.g., January effect) + + Fama-French Three-Factor Model + ------------------------------ + 1) Three Factors - Market Excess Return, Outperformance of Small versus Big Cap, Outperformance of High/low book-to-market (value) + 2) Market Factor - PRESENT/ABSENT + 3) Accounting Manipulation Proxy Factor - Replacement for the Value Factor + 4) CAPM - Single Factor, i.e., Market Factor + 5) Factor Component Loading - Weight, Returns, Category - DONE + 6) Portfolio Type - Zero Investment or Zero Cost (Self Financing) - DONE + 7) Factor Portfolio - Asset Map of Factor Component Loading, Country, Is Global, Portfolio Type - DONE + 8) Factor Portfolio Builder - Factor Component Loading vs Score Ordered Map, Component Ranking Scheme, Re-ranked Components, Top List, Bottom List, Weight Sign + 9) Factor - Code, Description, Factor Portfolio +10) Factor Model - Model Code, Model Description, Collection of Factors +11) Asset Factor Loading - Factor Returns, Factor, Asset Factor Beta +12) Factor Regressor - Asset Specification - DONE +13) Risk Free Setting - Instrument (Treasury/LIBOR/OIS/SOFR), Tenor (e.g., 3M), Rate +14) Factor Regressor Output - Collection of Asset Factor Loading, Factor Risk Free Premia, Alpha, Asset Returns, Asset Risk Premia +15) Factor Regressor Function - Apply Risk Free Setting to Factor Regressor to generate Factor Regressor Output +16) CAPM One-Factor Model - Market Factor +17) Fama-French Three-Factor Model - Market Factor, Size Factor, Value Factor +18) Mramor-Pahor Three-Factor Model - Market Factor, Size Factor, Accounting Manipulation Proxy Factor +19) Fama-French Five-Factor Model - Market Factor, Size Factor, Value Factor, Profitability Factor, Investing Factor + + Carhart Four-Factor Model + ------------------------------ + 1) Four Factors - Market Excess Return, Outperformance of Small versus Big Cap, Outperformance of High/low book-to-market (value), Momentum Factor + 2) Market Portfolio Name - CRSP + 3) MOM Portfolio Name - UMD 12M winners minus 12M losers diff --git a/ReleaseNotes/08_03_2023.txt b/ReleaseNotes/08_03_2023.txt new file mode 100644 index 000000000000..d11932270057 --- /dev/null +++ b/ReleaseNotes/08_03_2023.txt @@ -0,0 +1,43 @@ + +Features: + + - Investing Factors Portfolio Financing Scheme (35, 36) + - Investing Factors Portfolio Financing Scheme - Zero Investment (37) + - Investing Factors Portfolio Financing Scheme - Zero Cost/Self (38, 39) + - Investing Factors Factor Portfolio Shell (40, 41) + - Portfolio Construction Core Block Hashcode (42, 43, 44) + - Portfolio Construction Core Asset Hashcode (45, 46) + - Factor Investing Component Loading Map (47, 48) + - Investing Factors Factor Portfolio Country (49, 50) + - Investing Factors Factor Portfolio Is Global (51, 52) + - Investing Factors Factor Portfolio Financing Scheme (53, 54) + - Investing Factors Factor Portfolio Country - Constructor (55, 56, 57) + - Investing Factor Portfolio Builder Shell (58, 59) + + +Bug Fixes/Re-organization: + + - Special Function Incomplete Gamma Lower S Fixed Series - Weierstrass Limit (1, 2) + - Special Function Incomplete Gamma Lower S Fixed Series - NIST 2019 Limit (3, 4, 5) + - Special Function Incomplete Gamma Lower S Fixed (6, 7, 8) + - Special Function Incomplete Gamma Lower S Fixed - Series (9) + - Special Function Incomplete Gamma Lower S Fixed - Constructor (10, 11) + - Special Function Incomplete Gamma Lower S Fixed - Weierstrass Limit #1 (12) + - Special Function Incomplete Gamma Lower S Fixed - Non-dimensional (13) + - Special Function Incomplete Gamma Lower S Fixed - Evaluate (14, 15) + - Special Function Incomplete Gamma Lower S Fixed - Weierstrass Limit #2 (16, 17) + - Special Function Incomplete Gamma Lower S Fixed - NIST 2019 (18, 19, 20) + - Special Function Incomplete Gamma Lower Regularized (21, 22, 23) + - Special Function Incomplete Gamma Lower Regularized - Constructor (24) + - Special Function Incomplete Gamma Lower Regularized - p (25) + - Special Function Incomplete Gamma Lower Regularized - Gauss Continued Fraction (26, 27) + - Special Function Incomplete Gamma Lower Regularized - Euler Integral (28, 29) + - Special Function Incomplete Gamma Lower Regularized - Weierstrass Limit (30, 31) + - Special Function Incomplete Gamma Lower Regularized - NIST 2019 (32, 33) + - Risk Factor Premium Migration Re-factoring (34) + - Factor Portfolio Builder To Ranker (60) + + +Samples: + +IdeaDRIP: diff --git a/ScheduleSheet.xlsx b/ScheduleSheet.xlsx index a230763cbf2288d3afbe0d5cfbe9fda52d961cb3..c6626cdaa0a8ab47f860460c0a66717cb4c07011 100644 GIT binary patch delta 5951 zcmZvgWmHt(*T;wM5(H^Pm;ot8LO@cK4iONL?jFD)27wER2qHQ3P$Ho;4kaOogtXE_ zcf-&yEx ztB5bu%f%WBbrJS+b1gA&gCeCFu7dI}N!onL!3y}!(sbr9f$En@%QY5Y1L0I_qI)PU zM9~D$+}W=&WS9Qc{h4*A+`G;Jsa2_!i^Y1k50F+OyXj$NhZv{0GE3fVj=~inYAQW7 zJg!c_6Zk1DDxMvAPu@J>bTy#;bU&mr9}kq7nqHk4XgitvSuLuac~gxf`TZWFhS9#t z%fpO0z2UH5HI-(aWLu0w{Zm}Z7Yvk!231`A0^!LpFM?LJH@v@@#JAh2ONF#UT<%*? zHyKpakVKG7=weG0wLS^u_H@R0Ui?-VcUfX}p$29_LBB$NOlJ}neEMW!;sG||9RN+t z#L2zql#)<_>Q%_~|8P>x>g%F65T8OV{E#swdR;PilTr%!5UyZiB0$H3$#lHRLb{k| zyr{Ze%eu}|hmoH*G$^_sO-zxNq@UpB9AnjGxYS3?d4^VCt*E#04bwcg7FlI=Pt0q5 zdsYq4whcs_;4SN`eYczp1)GrXT!yzi z>E=m1-`KfPHm0Sk9UhU3JeeMZU13)?Lpb&-Pl3nrb-Gp)w5#DgE7!6233xfS^?mPr z!@Cw468Lq&bV2AH?3^+w(G;fq=}+K`UD9cw*)}LbDJ<@0hm}3tU9LvSAyhE26P~WU zKRz&pp{1nB4V_mUoxCBi_GMjBHdb@YuL;EkVR6K&FSetD1jVoKZMn`Gv}}krbJD5YfY~R$s~^_Eje! zgUB!y{B8LyeJ8n!r}am*gJ*bI7Pd4^qgt{@n!i+D;EzZl;ArerxO&Y$@587U!L`;m{*fY;Y} zC>-&-8a(r>`i6-210W+G-TNX*U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wp3JadG5 zgUH2Q^IKM7b&vq&TFdo;e15#3z+!21?o+Bi{JAvR?ruzLI{leOaksb3&9|#P3Qx60 zEh)c7-zD<@Vioe#VNls7SS{eKD!xK>wp8nawBk%y=AAoOC@r7J@ioy?VP*eHQeS4s zg>a~8)v85za)24D)C(+t5=T+5p?U(ZD1t{gAr6`|>ikIc_@OC!_#*P^IR&!Kpi$25h&bD6V7FoaAcq-%YbofwDsOG;VCQ_VAHTLA z8nvZ2L2~IN)h-g*%+6K3bZNaY^xNZCoA@DWWYnj#sQmLqqrslpW?Oui^>Wk?`ELO* z{q60tf?Q0XHTAZiqR-h-d-c%ImZL@bPgk$)?nbt-H!B>g9Y z#v<&{!TM9j1Ko-6V@f1<(U2Ia%+bUMa_^fE5%3wp5Vx#*P7TK0&ax}6SJ{XCg?@Gf+YysF)YrBCm1Nvk&eGpXOK`Ecaj zIe^i-)%=jrR%_rk`bX<(5r*nkGYKt6hSAM|V25o^$h8-&(zkHF`R`8px4YesH{z`2 z1Kih+y*2|=o{i+JK&W;Ljbr@U7NPToT)eCL`~CKpb7ra8TfzJw##RO$^BsnL}~o1L*=$&v-ztnGmY1Y;fIg$33k@h6W* z43x>sBv|^lA~lV3oKn&h+t`_p+v?(II+zHxbJ>SrMz_Gzgg@nw$R>APWfs zMg(#~oOq`Ou{r^}>CyD>EIA-B%+m?sH_3=lon$5c)Q+&7R3iS-h4Ag>N8FmCK}=7w z60IQKOtK@Wrlg72dJuV2dSN8t^a;R;4 diff --git a/src/main/java/org/drip/investing/factors/FactorComponentLoading.java b/src/main/java/org/drip/investing/factors/FactorComponentLoading.java index f833edbab846..d9995d2f7ba4 100644 --- a/src/main/java/org/drip/investing/factors/FactorComponentLoading.java +++ b/src/main/java/org/drip/investing/factors/FactorComponentLoading.java @@ -128,7 +128,7 @@ public class FactorComponentLoading * @param weight Factor Weight * @param returns Factor Returns * - * @throws Exception Thriwn if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public FactorComponentLoading ( @@ -138,9 +138,7 @@ public FactorComponentLoading ( final double returns) throws Exception { - if (!NumberUtil.IsValid (_weight = weight) || - !NumberUtil.IsValid (_returns = returns)) - { + if (!NumberUtil.IsValid (_weight = weight) || !NumberUtil.IsValid (_returns = returns)) { throw new Exception ("FactorComponentLoading Constructor => Invalid Inputs"); } diff --git a/src/main/java/org/drip/investing/factors/FactorPortfolio.java b/src/main/java/org/drip/investing/factors/FactorPortfolio.java new file mode 100644 index 000000000000..daac3d724415 --- /dev/null +++ b/src/main/java/org/drip/investing/factors/FactorPortfolio.java @@ -0,0 +1,193 @@ + +package org.drip.investing.factors; + +import java.util.Map; + +/* + * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ + +/*! + * Copyright (C) 2024 Lakshmi Krishnamurthy + * + * This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics, + * asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment + * analytics, and portfolio construction analytics within and across fixed income, credit, commodity, + * equity, FX, and structured products. It also includes auxiliary libraries for algorithm support, + * numerical analysis, numerical optimization, spline builder, model validation, statistical learning, + * graph builder/navigator, and computational support. + * + * https://lakshmidrip.github.io/DROP/ + * + * DROP is composed of three modules: + * + * - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/ + * - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/ + * - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/ + * + * DROP Product Core implements libraries for the following: + * - Fixed Income Analytics + * - Loan Analytics + * - Transaction Cost Analytics + * + * DROP Portfolio Core implements libraries for the following: + * - Asset Allocation Analytics + * - Asset Liability Management Analytics + * - Capital Estimation Analytics + * - Exposure Analytics + * - Margin Analytics + * - XVA Analytics + * + * DROP Computational Core implements libraries for the following: + * - Algorithm Support + * - Computation Support + * - Function Analysis + * - Graph Algorithm + * - Model Validation + * - Numerical Analysis + * - Numerical Optimizer + * - Spline Builder + * - Statistical Learning + * + * Documentation for DROP is Spread Over: + * + * - Main => https://lakshmidrip.github.io/DROP/ + * - Wiki => https://github.com/lakshmiDRIP/DROP/wiki + * - GitHub => https://github.com/lakshmiDRIP/DROP + * - Repo Layout Taxonomy => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md + * - Javadoc => https://lakshmidrip.github.io/DROP/Javadoc/index.html + * - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal + * - Release Versions => https://lakshmidrip.github.io/DROP/version.html + * - Community Credits => https://lakshmidrip.github.io/DROP/credits.html + * - Issues Catalog => https://github.com/lakshmiDRIP/DROP/issues + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * FactorPortfolio has the Portfolio Details that constitute a Factor. The References are: + * + *

+ *
    + *
  • + * Baltussen, G., L. Swinkels, and P. van Vliet (2021): Global Factor Premiums Journal of Financial + * Economics 142 (3) 1128-1154 + *
  • + *
  • + * Blitz, D., and P. van Vliet (2007): The Volatility Effect: Lower Risk without Lower Return Journal + * of Portfolio Management 34 (1) 102-113 + *
  • + *
  • + * Fisher, G. S., R. Shah, and S. Titman (2017): Combining Value and Momentum + * https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2472936 eSSRN + *
  • + *
  • + * Houweling, P., and J. van Zundert (2017): Factor Investing in the Corporate Bond Market Financial + * Analysts Journal 73 (2) 100-115 + *
  • + *
  • + * Wikipedia (2024): Factor Investing https://en.wikipedia.org/wiki/Factor_investing + *
  • + *
+ * + *

+ * + * + * @author Lakshmi Krishnamurthy + */ + +public class FactorPortfolio +{ + private String _country = ""; + private boolean _isGlobal = false; + private int _financingScheme = Integer.MIN_VALUE; + private Map _factorComponentLoadingMap = null; + + /** + * FactorPortfolio Constructor + * + * @param factorComponentLoadingMap Factor Component Loading Map + * @param country Country + * @param isGlobal TRUE - The Portfolio is Global + * @param financingScheme Financing Scheme + * + * @throws Exception Thrown if the Inputs are Invalid + */ + + public FactorPortfolio ( + final Map factorComponentLoadingMap, + final String country, + final boolean isGlobal, + final int financingScheme) + throws Exception + { + if (null == (_factorComponentLoadingMap = factorComponentLoadingMap) || + null == (_country = country) || _country.isEmpty()) + { + throw new Exception ("FactorPortfolio Constructor => Invalid Inputs"); + } + + _isGlobal = isGlobal; + _financingScheme = financingScheme; + } + + /** + * Retrieve the Factor Component Loading Map + * + * @return The Factor Component Loading Map + */ + + public Map factorComponentLoadingMap() + { + return _factorComponentLoadingMap; + } + + /** + * Retrieve the Country + * + * @return The Country + */ + + public String country() + { + return _country; + } + + /** + * Indicate if the Portfolio is Global + * + * @return TRUE - The Portfolio is Global + */ + + public boolean isGlobal() + { + return _isGlobal; + } + + /** + * Retrieve the Financing Scheme + * + * @return The Financing Scheme + */ + + public int financingScheme() + { + return _financingScheme; + } +} diff --git a/src/main/java/org/drip/investing/factors/FactorPortfolioRanker.java b/src/main/java/org/drip/investing/factors/FactorPortfolioRanker.java new file mode 100644 index 000000000000..ab49a40ae007 --- /dev/null +++ b/src/main/java/org/drip/investing/factors/FactorPortfolioRanker.java @@ -0,0 +1,117 @@ + +package org.drip.investing.factors; + +/* + * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ + +/*! + * Copyright (C) 2024 Lakshmi Krishnamurthy + * + * This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics, + * asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment + * analytics, and portfolio construction analytics within and across fixed income, credit, commodity, + * equity, FX, and structured products. It also includes auxiliary libraries for algorithm support, + * numerical analysis, numerical optimization, spline builder, model validation, statistical learning, + * graph builder/navigator, and computational support. + * + * https://lakshmidrip.github.io/DROP/ + * + * DROP is composed of three modules: + * + * - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/ + * - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/ + * - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/ + * + * DROP Product Core implements libraries for the following: + * - Fixed Income Analytics + * - Loan Analytics + * - Transaction Cost Analytics + * + * DROP Portfolio Core implements libraries for the following: + * - Asset Allocation Analytics + * - Asset Liability Management Analytics + * - Capital Estimation Analytics + * - Exposure Analytics + * - Margin Analytics + * - XVA Analytics + * + * DROP Computational Core implements libraries for the following: + * - Algorithm Support + * - Computation Support + * - Function Analysis + * - Graph Algorithm + * - Model Validation + * - Numerical Analysis + * - Numerical Optimizer + * - Spline Builder + * - Statistical Learning + * + * Documentation for DROP is Spread Over: + * + * - Main => https://lakshmidrip.github.io/DROP/ + * - Wiki => https://github.com/lakshmiDRIP/DROP/wiki + * - GitHub => https://github.com/lakshmiDRIP/DROP + * - Repo Layout Taxonomy => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md + * - Javadoc => https://lakshmidrip.github.io/DROP/Javadoc/index.html + * - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal + * - Release Versions => https://lakshmidrip.github.io/DROP/version.html + * - Community Credits => https://lakshmidrip.github.io/DROP/credits.html + * - Issues Catalog => https://github.com/lakshmiDRIP/DROP/issues + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * FactorPortfolioRanker contains Functionality for Ranking the Factor Portfolio Constituents. The + * References are: + * + *

+ *
    + *
  • + * Baltussen, G., L. Swinkels, and P. van Vliet (2021): Global Factor Premiums Journal of Financial + * Economics 142 (3) 1128-1154 + *
  • + *
  • + * Blitz, D., and P. van Vliet (2007): The Volatility Effect: Lower Risk without Lower Return Journal + * of Portfolio Management 34 (1) 102-113 + *
  • + *
  • + * Fisher, G. S., R. Shah, and S. Titman (2017): Combining Value and Momentum + * https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2472936 eSSRN + *
  • + *
  • + * Houweling, P., and J. van Zundert (2017): Factor Investing in the Corporate Bond Market Financial + * Analysts Journal 73 (2) 100-115 + *
  • + *
  • + * Wikipedia (2024): Factor Investing https://en.wikipedia.org/wiki/Factor_investing + *
  • + *
+ * + *

+ * + * + * @author Lakshmi Krishnamurthy + */ + +public class FactorPortfolioRanker +{ + +} diff --git a/src/main/java/org/drip/investing/factors/PortfolioFinancingScheme.java b/src/main/java/org/drip/investing/factors/PortfolioFinancingScheme.java new file mode 100644 index 000000000000..e2c65dccf0fe --- /dev/null +++ b/src/main/java/org/drip/investing/factors/PortfolioFinancingScheme.java @@ -0,0 +1,134 @@ + +package org.drip.investing.factors; + +/* + * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + */ + +/*! + * Copyright (C) 2024 Lakshmi Krishnamurthy + * + * This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics, + * asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment + * analytics, and portfolio construction analytics within and across fixed income, credit, commodity, + * equity, FX, and structured products. It also includes auxiliary libraries for algorithm support, + * numerical analysis, numerical optimization, spline builder, model validation, statistical learning, + * graph builder/navigator, and computational support. + * + * https://lakshmidrip.github.io/DROP/ + * + * DROP is composed of three modules: + * + * - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/ + * - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/ + * - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/ + * + * DROP Product Core implements libraries for the following: + * - Fixed Income Analytics + * - Loan Analytics + * - Transaction Cost Analytics + * + * DROP Portfolio Core implements libraries for the following: + * - Asset Allocation Analytics + * - Asset Liability Management Analytics + * - Capital Estimation Analytics + * - Exposure Analytics + * - Margin Analytics + * - XVA Analytics + * + * DROP Computational Core implements libraries for the following: + * - Algorithm Support + * - Computation Support + * - Function Analysis + * - Graph Algorithm + * - Model Validation + * - Numerical Analysis + * - Numerical Optimizer + * - Spline Builder + * - Statistical Learning + * + * Documentation for DROP is Spread Over: + * + * - Main => https://lakshmidrip.github.io/DROP/ + * - Wiki => https://github.com/lakshmiDRIP/DROP/wiki + * - GitHub => https://github.com/lakshmiDRIP/DROP + * - Repo Layout Taxonomy => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md + * - Javadoc => https://lakshmidrip.github.io/DROP/Javadoc/index.html + * - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal + * - Release Versions => https://lakshmidrip.github.io/DROP/version.html + * - Community Credits => https://lakshmidrip.github.io/DROP/credits.html + * - Issues Catalog => https://github.com/lakshmiDRIP/DROP/issues + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * PortfolioFinancingScheme maintains the Financing Scheme Settings used in Factor Portfolio + * Construction. The References are: + * + *

+ *
    + *
  • + * Baltussen, G., L. Swinkels, and P. van Vliet (2021): Global Factor Premiums Journal of Financial + * Economics 142 (3) 1128-1154 + *
  • + *
  • + * Blitz, D., and P. van Vliet (2007): The Volatility Effect: Lower Risk without Lower Return Journal + * of Portfolio Management 34 (1) 102-113 + *
  • + *
  • + * Fisher, G. S., R. Shah, and S. Titman (2017): Combining Value and Momentum + * https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2472936 eSSRN + *
  • + *
  • + * Houweling, P., and J. van Zundert (2017): Factor Investing in the Corporate Bond Market Financial + * Analysts Journal 73 (2) 100-115 + *
  • + *
  • + * Wikipedia (2024): Factor Investing https://en.wikipedia.org/wiki/Factor_investing + *
  • + *
+ * + *

+ * + * + * @author Lakshmi Krishnamurthy + */ + +public class PortfolioFinancingScheme +{ + + /** + * Zero Investment Portfolio Financing Scheme + */ + + public static final int ZERO_INVESTMENT = 1; + + /** + * Zero Cost Portfolio Financing Scheme + */ + + public static final int ZERO_COST = 2; + + /** + * Self Funding Portfolio Financing Scheme + */ + + public static final int SELF_FUNDING = 2; +} diff --git a/src/main/java/org/drip/investing/investible/RiskPremiumCategory.java b/src/main/java/org/drip/investing/factors/RiskPremiumCategory.java similarity index 96% rename from src/main/java/org/drip/investing/investible/RiskPremiumCategory.java rename to src/main/java/org/drip/investing/factors/RiskPremiumCategory.java index 3c2894d0943f..76a674ca7556 100644 --- a/src/main/java/org/drip/investing/investible/RiskPremiumCategory.java +++ b/src/main/java/org/drip/investing/factors/RiskPremiumCategory.java @@ -1,5 +1,5 @@ -package org.drip.investing.investible; +package org.drip.investing.factors; /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- @@ -104,7 +104,7 @@ *
  • Module = Portfolio Core Module
  • *
  • Library = Asset Allocation Analytics
  • *
  • Project = Factor/Style Based Quantitative Investing
  • - *
  • Package = Quantitative Description of Investible Assets
  • + *
  • Package = Factor Types, Characteristics, and Constitution
  • * * * @author Lakshmi Krishnamurthy diff --git a/src/main/java/org/drip/portfolioconstruction/core/Asset.java b/src/main/java/org/drip/portfolioconstruction/core/Asset.java index 7853650836cc..64e7a9f79f40 100644 --- a/src/main/java/org/drip/portfolioconstruction/core/Asset.java +++ b/src/main/java/org/drip/portfolioconstruction/core/Asset.java @@ -155,4 +155,11 @@ public java.lang.String sector() { return _sector; } + + @Override public int hashCode() + { + int hashCode = _currency.hashCode() + 31 * super.hashCode(); + + return _sector.hashCode() + 31 * hashCode; + } } diff --git a/src/main/java/org/drip/portfolioconstruction/core/Block.java b/src/main/java/org/drip/portfolioconstruction/core/Block.java index 0a4c3a8b80d8..8a22851d92f6 100644 --- a/src/main/java/org/drip/portfolioconstruction/core/Block.java +++ b/src/main/java/org/drip/portfolioconstruction/core/Block.java @@ -198,4 +198,15 @@ public java.util.Date timeStamp() { return _dateTimeStamp; } + + @Override public int hashCode() + { + int hashCode = _name.hashCode(); + + hashCode += _id.hashCode() + 31 * hashCode; + + hashCode += _description.hashCode() + 31 * hashCode; + + return _dateTimeStamp.hashCode() + 31 * hashCode; + } } diff --git a/src/main/java/org/drip/specialfunction/incompletegamma/LowerRegularized.java b/src/main/java/org/drip/specialfunction/incompletegamma/LowerRegularized.java index e9443919f95f..0830ff70ae58 100644 --- a/src/main/java/org/drip/specialfunction/incompletegamma/LowerRegularized.java +++ b/src/main/java/org/drip/specialfunction/incompletegamma/LowerRegularized.java @@ -1,11 +1,16 @@ package org.drip.specialfunction.incompletegamma; +import org.drip.specialfunction.gamma.NemesAnalytic; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -78,7 +83,7 @@ /** * LowerRegularized implements the Regularized Version of the Lower Incomplete Gamma. The References - * are: + * are: * *

    *
      @@ -105,15 +110,31 @@ * https://en.wikipedia.org/wiki/Incomplete_gamma_function * *
    + * + * It provides the following functionality: * - *

    * * + *
    + * + * + * + * + * + * + * + *
    Module Computational Core Module
    Library Function Analysis Library
    Project Special Function Implementation and Analysis
    Package Upper/Lower Incomplete Gamma Functions
    + * * @author Lakshmi Krishnamurthy */ @@ -121,7 +142,7 @@ public abstract class LowerRegularized { /** - * Construct the Gauss Continued Version of Lower Regularized Incomplete Gamma Function + * Construct the Gauss Continued Fraction Version of Lower Regularized Incomplete Gamma Function * * @param n Count of the Number of Terms * @@ -131,20 +152,15 @@ public abstract class LowerRegularized public static final LowerRegularized GaussContinuedFraction ( final int n) { - return new LowerRegularized() - { + return new LowerRegularized() { @Override public double p ( final double s, final double z) - throws java.lang.Exception + throws Exception { - double p = org.drip.specialfunction.incompletegamma.GaussContinuedFraction.Lower ( - z, - s, - n - ) / new org.drip.specialfunction.gamma.NemesAnalytic (null).evaluate (s); + double p = GaussContinuedFraction.Lower (z, s, n) / new NemesAnalytic (null).evaluate (s); - return p > 1. ? 1. : p; + return 1. < p ? 1. : p; } }; } @@ -157,19 +173,16 @@ public static final LowerRegularized GaussContinuedFraction ( public static final LowerRegularized EulerIntegral() { - return new LowerRegularized() - { + return new LowerRegularized() { @Override public double p ( final double s, final double z) - throws java.lang.Exception + throws Exception { - double p = new org.drip.specialfunction.incompletegamma.LowerEulerIntegral ( - null, - z - ).evaluate (s) / new org.drip.specialfunction.gamma.NemesAnalytic (null).evaluate (s); + double p = new LowerEulerIntegral (null, z).evaluate (s) / + new NemesAnalytic (null).evaluate (s); - return p > 1. ? 1. : p; + return 1. < p ? 1. : p; } }; } @@ -185,19 +198,16 @@ public static final LowerRegularized EulerIntegral() public static final LowerRegularized WeierstrassLimit ( final int n) { - return new LowerRegularized() - { + return new LowerRegularized() { @Override public double p ( final double s, final double z) - throws java.lang.Exception + throws Exception { - double p = org.drip.specialfunction.incompletegamma.LowerSFixed.WeierstrassLimit ( - s, - n - ).evaluate (z) / new org.drip.specialfunction.gamma.NemesAnalytic (null).evaluate (s); + double p = LowerSFixed.WeierstrassLimit (s, n).evaluate (z) / + new NemesAnalytic (null).evaluate (s); - return p > 1. ? 1. : p; + return 1. < p ? 1. : p; } }; } @@ -213,19 +223,15 @@ public static final LowerRegularized WeierstrassLimit ( public static final LowerRegularized NIST2019 ( final int n) { - return new LowerRegularized() - { + return new LowerRegularized() { @Override public double p ( final double s, final double z) - throws java.lang.Exception + throws Exception { - double p = org.drip.specialfunction.incompletegamma.LowerSFixed.NIST2019 ( - s, - n - ).evaluate (z) / new org.drip.specialfunction.gamma.NemesAnalytic (null).evaluate (s); + double p = LowerSFixed.NIST2019 (s, n).evaluate (z) / new NemesAnalytic (null).evaluate (s); - return p > 1. ? 1. : p; + return 1. < p ? 1. : p; } }; } @@ -242,11 +248,11 @@ private LowerRegularized() * * @return p(s, z) * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public abstract double p ( final double s, - final double z) - throws java.lang.Exception; + final double z + ) throws Exception; } diff --git a/src/main/java/org/drip/specialfunction/incompletegamma/LowerSFixed.java b/src/main/java/org/drip/specialfunction/incompletegamma/LowerSFixed.java index 6b329d9abc23..ccd5090fc774 100644 --- a/src/main/java/org/drip/specialfunction/incompletegamma/LowerSFixed.java +++ b/src/main/java/org/drip/specialfunction/incompletegamma/LowerSFixed.java @@ -1,11 +1,18 @@ package org.drip.specialfunction.incompletegamma; +import org.drip.numerical.differentiation.DerivativeControl; +import org.drip.numerical.estimation.R1Estimate; +import org.drip.numerical.estimation.R1ToR1Estimator; + /* * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /*! + * Copyright (C) 2025 Lakshmi Krishnamurthy + * Copyright (C) 2024 Lakshmi Krishnamurthy + * Copyright (C) 2023 Lakshmi Krishnamurthy * Copyright (C) 2022 Lakshmi Krishnamurthy * Copyright (C) 2021 Lakshmi Krishnamurthy * Copyright (C) 2020 Lakshmi Krishnamurthy @@ -78,7 +85,7 @@ /** * LowerSFixed implements the Lower Incomplete Gamma Function using Power Series for a Fixed s. The - * References are: + * References are: * *

    *
      @@ -105,21 +112,37 @@ * https://en.wikipedia.org/wiki/Incomplete_gamma_function * *
    + * + * It provides the following functionality: * - *

    * * + *
    + * + * + * + * + * + * + * + *
    Module Computational Core Module
    Library Function Analysis Library
    Project Special Function Implementation and Analysis
    Package Upper/Lower Incomplete Gamma Functions
    + * * @author Lakshmi Krishnamurthy */ -public abstract class LowerSFixed extends org.drip.numerical.estimation.R1ToR1Estimator +public abstract class LowerSFixed extends R1ToR1Estimator { - private org.drip.specialfunction.incompletegamma.LowerSFixedSeries _lowerSFixedSeries = null; + private LowerSFixedSeries _lowerSFixedSeries = null; /** * Construct the Weierstrass Lower S Fixed Series Incomplete Gamma Estimator @@ -134,26 +157,16 @@ public static final LowerSFixed WeierstrassLimit ( final double s, final int termCount) { - try - { - return new LowerSFixed ( - org.drip.specialfunction.incompletegamma.LowerSFixedSeries.WeierstrassLimit ( - s, - termCount - ), - null - ) - { + try { + return new LowerSFixed (LowerSFixedSeries.WeierstrassLimit (s, termCount), null) { @Override public double nonDimensional ( final double z) - throws java.lang.Exception + throws Exception { - return weierstrassLimit (z) * java.lang.Math.exp (-1. * z); + return weierstrassLimit (z) * Math.exp (-1. * z); } }; - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } @@ -175,24 +188,15 @@ public static final LowerSFixed NIST2019 ( { try { - return new LowerSFixed ( - org.drip.specialfunction.incompletegamma.LowerSFixedSeries.NIST2019 ( - s, - termCount - ), - null - ) - { + return new LowerSFixed (LowerSFixedSeries.NIST2019 (s, termCount), null) { @Override public double nonDimensional ( final double z) - throws java.lang.Exception + throws Exception { return weierstrassLimit (z); } }; - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); } @@ -200,36 +204,29 @@ public static final LowerSFixed NIST2019 ( } /** - * LowerSFixed Constructor + * LowerSFixed Constructor * * @param lowerSFixedSeries R1 To R1 Lower S Fixed Limit Series - * @param dc Differential Control + * @param derivativeControl Differential Control * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public LowerSFixed ( - final org.drip.specialfunction.incompletegamma.LowerSFixedSeries lowerSFixedSeries, - final org.drip.numerical.differentiation.DerivativeControl dc) - throws java.lang.Exception + final LowerSFixedSeries lowerSFixedSeries, + final DerivativeControl derivativeControl) + throws Exception { - super (dc); + super (derivativeControl); _lowerSFixedSeries = lowerSFixedSeries; } - @Override public org.drip.numerical.estimation.R1Estimate seriesEstimateNative ( + @Override public R1Estimate seriesEstimateNative ( final double x) { - return null == _lowerSFixedSeries ? seriesEstimate ( - x, - null, - null - ) : seriesEstimate ( - x, - _lowerSFixedSeries.termWeightMap(), - _lowerSFixedSeries - ); + return null == _lowerSFixedSeries ? seriesEstimate (x, null, null) : + seriesEstimate (x, _lowerSFixedSeries.termWeightMap(), _lowerSFixedSeries); } /** @@ -239,12 +236,12 @@ public LowerSFixed ( * * @return The Limiting Weierstrass Sum * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public double weierstrassLimit ( final double z) - throws java.lang.Exception + throws Exception { return _lowerSFixedSeries.evaluate (z); } @@ -256,19 +253,18 @@ public double weierstrassLimit ( * * @return The Non-dimensional Incomplete Gamma (Weierstrass Gamma Star) * - * @throws java.lang.Exception Thrown if the Inputs are Invalid + * @throws Exception Thrown if the Inputs are Invalid */ public abstract double nonDimensional ( - final double z) - throws java.lang.Exception; + final double z + ) throws Exception; @Override public double evaluate ( final double z) - throws java.lang.Exception + throws Exception { - return java.lang.Math.exp ( - _lowerSFixedSeries.s() * java.lang.Math.log (z) + _lowerSFixedSeries.logGammaS() - ) * nonDimensional (z); + return Math.exp (_lowerSFixedSeries.s() * Math.log (z) + _lowerSFixedSeries.logGammaS()) * + nonDimensional (z); } } diff --git a/src/main/java/org/drip/specialfunction/incompletegamma/LowerSFixedSeries.java b/src/main/java/org/drip/specialfunction/incompletegamma/LowerSFixedSeries.java index 7240bc9d25fc..608fe0ec43ce 100644 --- a/src/main/java/org/drip/specialfunction/incompletegamma/LowerSFixedSeries.java +++ b/src/main/java/org/drip/specialfunction/incompletegamma/LowerSFixedSeries.java @@ -193,33 +193,22 @@ public static final LowerSFixedSeries NIST2019 ( final double s, final int termCount) { - try - { - double logGammaS = new org.drip.specialfunction.loggamma.NemesAnalyticEstimator (null).evaluate (s); + try { + double logGammaS = new NemesAnalyticEstimator (null).evaluate (s); - java.util.TreeMap termWeightMap = new - java.util.TreeMap(); + TreeMap termWeightMap = new TreeMap(); - for (int termIndex = 0; termIndex <= termCount; ++termIndex) - { - termWeightMap.put ( - termIndex, - 1. - ); + for (int termIndex = 0; termIndex <= termCount; ++termIndex) { + termWeightMap.put (termIndex, 1.); } return new LowerSFixedSeries ( - org.drip.specialfunction.incompletegamma.LowerSFixedSeriesTerm.NIST2019 ( - s, - logGammaS - ), + LowerSFixedSeriesTerm.NIST2019 (s, logGammaS), termWeightMap, s, logGammaS ); - } - catch (java.lang.Exception e) - { + } catch (Exception e) { e.printStackTrace(); }