diff --git a/ReleaseNotes/04_28_2024.txt b/ReleaseNotes/04_28_2024.txt new file mode 100644 index 00000000000..8209c8df7af --- /dev/null +++ b/ReleaseNotes/04_28_2024.txt @@ -0,0 +1,58 @@ + +Features: + + - Holdings Container - unDirty #1 (1, 2, 3) + - Holdings Container - unDirty #2 (4, 5, 6) + - Holdings Container - unDirty #3 (7, 8, 9) + - Holdings Container - unDirty #4 (10, 11) + - Holdings Container - unDirty #5 (12, 13) + - Holdings Container - Asset Weight Map (14) + - Holdings Container - Asset Market Value (15) + - Holdings Container - Asset Set #1 (16, 17) + - Holdings Container - Asset Set #2 (18, 19) + - Holdings Container - Set Cash #1 (20, 21) + - Holdings Container - Set Cash #2 (22, 23, 24) + - Holdings Container - Set Cash #3 (25, 26, 27) + - Holdings Container - Set Cash #4 (28, 29, 30) + - Holdings Container - Set Cash #5 (31, 32, 33) + - Holdings Container - Set Cash #6 (34) + - Lean Portfolio Construction Trades Container (35, 36, 37) + - Trades Container - Asset Quantity Map (38, 39, 40) + - Holdings Container - Remove Asset #1 (41, 42) + - Holdings Container - Remove Asset #2 (43, 44, 45) + - Holdings Container - Remove Asset #3 (46, 47, 48) + - Holdings Container - Remove Asset #4 (49, 50) + - Trades Container - Annotated Constructor #1 (51, 52, 53) + - Trades Container - Annotated Constructor #2 (54, 55, 56) + - Trades Container - Annotated Constructor #3 (57, 58) + - Trades Container - Starting/Ending Holdings #1 (59, 60) + - Trades Container - Starting/Ending Holdings #2 (61, 62, 63) + - Trades Container - Starting/Ending Holdings #3 (64, 65, 66) + - Trades Container - Starting/Ending Holdings #4 (67, 68, 69) + - Trades Container - Starting/Ending Holdings #5 (70, 71, 72) + - Trades Container - Starting/Ending Holdings #6 (73, 74, 75) + - Trades Container - Starting/Ending Holdings #7 (76, 77, 78) + - Trades Container - Starting/Ending Holdings #8 (79, 80, 81) + - Trades Container - Starting/Ending Holdings #9 (82, 83) + - Lean Portfolio Construction Post Processor Settings (84, 85, 86) + - Post Processor Settings - Filter Sells #1 (87, 88, 89) + - Post Processor Settings - Filter Sells #2 (90, 91) + - Post Processor Settings - Constructor #1 (92, 93) + - Post Processor Settings - Constructor #2 (94, 95, 96) + - Lean Portfolio Construction Allocator Shell (97, 98, 99) + - Lean Portfolio Construction Allocator Allocate #1 (100, 101) + - Lean Portfolio Construction Allocator Allocate #2 (102, 103) + - Lean Portfolio Construction Optimizer Optimize (104, 105) + - Construction/Usage of Lean Portfolio Allocator (106, 107, 108) + - Lean Allocator Buy Only Allocation (109, 110, 111) + - Buy Only Allocation - Main #1 (112, 113, 114) + - Buy Only Allocation - Main #2 (115, 116, 117) + - Buy Only Allocation - Zero to Hundred (118, 119) + - Buy Only Allocation - Random Holdings (120) + + +Bug Fixes/Re-organization: + +Samples: + +IdeaDRIP: diff --git a/src/main/java/org/drip/portfolioconstruction/lean/HoldingsContainer.java b/src/main/java/org/drip/portfolioconstruction/lean/HoldingsContainer.java index fa54fbbbe60..2dc976b5e2d 100644 --- a/src/main/java/org/drip/portfolioconstruction/lean/HoldingsContainer.java +++ b/src/main/java/org/drip/portfolioconstruction/lean/HoldingsContainer.java @@ -2,6 +2,7 @@ package org.drip.portfolioconstruction.lean; import java.util.Map; +import java.util.Set; import org.drip.analytics.support.CaseInsensitiveHashMap; import org.drip.numerical.common.NumberUtil; @@ -95,18 +96,50 @@ public class HoldingsContainer { + private boolean _dirty = false; + private double _cashValue = Double.NaN; private double _marketValue = Double.NaN; private Map _assetWeightMap = new CaseInsensitiveHashMap(); private Map _assetMarketValueMap = new CaseInsensitiveHashMap(); + private boolean unDirty() + { + if (!_dirty || _assetMarketValueMap.isEmpty()) { + return false; + } + + _dirty = false; + _marketValue = 0.; + + _assetWeightMap.clear(); + + for (Map.Entry assetMarketValueMapEntry : _assetMarketValueMap.entrySet()) { + _marketValue += assetMarketValueMapEntry.getValue(); + } + + if (0. == _marketValue) { + return true; + } + + for (Map.Entry assetMarketValueMapEntry : _assetMarketValueMap.entrySet()) { + _assetWeightMap.put ( + assetMarketValueMapEntry.getKey(), + assetMarketValueMapEntry.getValue() / _marketValue + ); + } + + return true; + } + /** * Empty HoldingsContainer Constructor */ public HoldingsContainer() { + _cashValue = 0.; _marketValue = 0.; _assetWeightMap = new CaseInsensitiveHashMap(); @@ -133,6 +166,8 @@ public Map assetMarketValueMap() public Map assetWeightMap() { + unDirty(); + return _assetWeightMap; } @@ -144,19 +179,32 @@ public Map assetWeightMap() public double marketValue() { + unDirty(); + return _marketValue; } /** - * Add the Asset and its Market Value to the Holdings + * Retrieve the Holdings Cash Value + * + * @return Holdings Cash Value + */ + + public double cashValue() + { + return _cashValue; + } + + /** + * Set the Asset to its Market Value on the Holdings * * @param assetID Asset ID * @param assetMarketValue Asset Market Value * - * @return TRUE - Asset successfully added to the Holdings + * @return TRUE - Asset successfully set on the Holdings */ - public boolean add ( + public boolean setAsset ( final String assetID, final double assetMarketValue) { @@ -166,6 +214,59 @@ public boolean add ( _assetMarketValueMap.put (assetID, assetMarketValue); + _dirty = true; + return true; + } + + /** + * Set the Cash Value on the Holdings + * + * @param cashValue Cash Value + * + * @return TRUE - Cash Value successfully set on the Holdings + */ + + public boolean setCashValue ( + final double cashValue) + { + if (NumberUtil.IsValid (cashValue)) { + return false; + } + + _cashValue = cashValue; + _dirty = true; + return true; + } + + /** + * Retrieve the Set of Assets + * + * @return Set of Assets + */ + + public Set assetSet() + { + return _assetMarketValueMap.keySet(); + } + + /** + * Remove the Asset corresponding to the ID + * + * @param assetID Asset ID + * + * @return TRUE - Asset successfully removed + */ + + public boolean removeAsset ( + final String assetID) + { + if (null == assetID || !_assetMarketValueMap.containsKey (assetID)) { + return false; + } + + _assetMarketValueMap.remove (assetID); + + _dirty = true; return true; } } diff --git a/src/main/java/org/drip/portfolioconstruction/lean/Optimizer.java b/src/main/java/org/drip/portfolioconstruction/lean/Optimizer.java new file mode 100644 index 00000000000..6d596786763 --- /dev/null +++ b/src/main/java/org/drip/portfolioconstruction/lean/Optimizer.java @@ -0,0 +1,104 @@ + +package org.drip.portfolioconstruction.lean; + +/* + * -*- 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. + */ + +/** + * Optimizer exposes Functionality for optimizing the given Portfolio + * + *

+ * + * + * @author Lakshmi Krishnamurthy + */ + +public interface Optimizer +{ + + /** + * Optimize from the Starting Holdings + * + * @param startingHoldingsContainer Starting Holdings + * + * @return The Allocated Holdings + */ + + public abstract HoldingsContainer optimize ( + final HoldingsContainer startingHoldingsContainer + ); +} diff --git a/src/main/java/org/drip/portfolioconstruction/lean/PostProcessorSettings.java b/src/main/java/org/drip/portfolioconstruction/lean/PostProcessorSettings.java new file mode 100644 index 00000000000..0bda60bec95 --- /dev/null +++ b/src/main/java/org/drip/portfolioconstruction/lean/PostProcessorSettings.java @@ -0,0 +1,119 @@ + +package org.drip.portfolioconstruction.lean; + +/* + * -*- 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. + */ + +/** + * PostProcessorSettings holds the Control Settings guiding the Allocation Post-process. + * + *

+ * + * + * @author Lakshmi Krishnamurthy + */ + +public class PostProcessorSettings +{ + private boolean _filterSells = false; + + /** + * PostProcessorSettings Constructor + * + * @param filterSells TRUE - Sells are to be removed + * + * @throws Exception Thrown if the Inputs are Invalid + */ + + public PostProcessorSettings ( + final boolean filterSells) + throws Exception + { + _filterSells = filterSells; + } + + /** + * Indicate if Sells are to be removed + * + * @return TRUE - Sells are to be removed + */ + + public boolean filterSells() + { + return _filterSells; + } +} diff --git a/src/main/java/org/drip/portfolioconstruction/lean/TradesContainer.java b/src/main/java/org/drip/portfolioconstruction/lean/TradesContainer.java new file mode 100644 index 00000000000..c78e0f47b4c --- /dev/null +++ b/src/main/java/org/drip/portfolioconstruction/lean/TradesContainer.java @@ -0,0 +1,200 @@ + +package org.drip.portfolioconstruction.lean; + +import java.util.Map; + +import org.drip.analytics.support.CaseInsensitiveHashMap; + +/* + * -*- 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. + */ + +/** + * TradesContainer implements the container that maintains the Map of Trades. + * + *

+ * + * + * @author Lakshmi Krishnamurthy + */ + +public class TradesContainer +{ + private Map _assetQuantityMap = null; + + /** + * Construct a TradesContainer Instance from the Starting and the Ending Holdings + * + * @param startingHoldingsContainer Starting HoldingsContainer + * @param endingHoldingsContainer Ending HoldingsContainer + * + * @return TradesContainer Instance + */ + + public static final TradesContainer FromStartAndEndHoldings ( + final HoldingsContainer startingHoldingsContainer, + final HoldingsContainer endingHoldingsContainer) + { + if (null == startingHoldingsContainer && null == endingHoldingsContainer) { + return null; + } + + Map assetQuantityMap = new CaseInsensitiveHashMap(); + + if (null == startingHoldingsContainer) { + for (Map.Entry assetMarketValueMapEntry : + endingHoldingsContainer.assetMarketValueMap().entrySet()) + { + assetQuantityMap.put ( + assetMarketValueMapEntry.getKey(), + assetMarketValueMapEntry.getValue() + ); + } + } else if (null == endingHoldingsContainer) { + for (Map.Entry assetMarketValueMapEntry : + startingHoldingsContainer.assetMarketValueMap().entrySet()) + { + assetQuantityMap.put ( + assetMarketValueMapEntry.getKey(), + -1. * assetMarketValueMapEntry.getValue() + ); + } + } else { + Map startingAssetMarketValueMap = + startingHoldingsContainer.assetMarketValueMap(); + + for (Map.Entry assetMarketValueMapEntry : + endingHoldingsContainer.assetMarketValueMap().entrySet()) + { + String assetID = assetMarketValueMapEntry.getKey(); + + assetQuantityMap.put ( + assetID, + assetMarketValueMapEntry.getValue() - ( + startingAssetMarketValueMap.containsKey (assetID) ? + startingAssetMarketValueMap.get (assetID) : 0. + ) + ); + } + + for (Map.Entry assetMarketValueMapEntry : + startingHoldingsContainer.assetMarketValueMap().entrySet()) + { + String assetID = assetMarketValueMapEntry.getKey(); + + if (!assetQuantityMap.containsKey (assetID)) { + assetQuantityMap.put ( assetID, -1. * assetMarketValueMapEntry.getValue()); + } + } + } + + try { + return new TradesContainer (assetQuantityMap); + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } + + /** + * TradesContainer Constructor + * + * @param assetQuantityMap Asset Quantity Map + * + * @throws Exception Thrown if the Inputs are Invalid + */ + + public TradesContainer ( + final Map assetQuantityMap) + throws Exception + { + if (null == (_assetQuantityMap = assetQuantityMap) || 0 == _assetQuantityMap.size()) { + throw new Exception ("TradesContainer Constructor => Invalid Asset Quantity Map"); + } + } + + /** + * Retrieve the Asset Quantity Map + * + * @return Asset Quantity Map + */ + + public Map assetQuantityMap() + { + return _assetQuantityMap; + } +} diff --git a/src/main/java/org/drip/sample/leanallocator/BuyOnlyAllocation.java b/src/main/java/org/drip/sample/leanallocator/BuyOnlyAllocation.java new file mode 100644 index 00000000000..ff36ef8fbc8 --- /dev/null +++ b/src/main/java/org/drip/sample/leanallocator/BuyOnlyAllocation.java @@ -0,0 +1,131 @@ + +package org.drip.sample.leanallocator; + +import org.drip.portfolioconstruction.lean.HoldingsContainer; +import org.drip.service.env.EnvManager; + +/* + * -*- 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. + */ + +/** + * BuyOnlyAllocation illustrates the Filter-Sells Post-Processing Functionality of an Allocator. + * + *

+ * + * + * @author Lakshmi Krishnamurthy + */ + +public class BuyOnlyAllocation +{ + + private static final int ZeroToHundred() + { + return (int) (Math.random() * 100.); + } + + private static final HoldingsContainer RandomHoldings ( + final int size, + final double cash) + throws Exception + { + HoldingsContainer holdingsContainer = new HoldingsContainer(); + + for (int i = 0; i < size; ++i) { + holdingsContainer.setAsset ("cusip_" + i, 100. * ZeroToHundred()); + } + + return holdingsContainer.setCashValue (cash) ? holdingsContainer : null; + } + + /** + * Entry Point + * + * @param argumentArray Command Line Argument Array + * + * @throws Exception Thrown on Error/Exception Situation + */ + + public static final void main ( + final String[] argumentArray) + throws Exception + { + EnvManager.InitEnv (""); + + EnvManager.TerminateEnv(); + } +} diff --git a/src/main/java/org/drip/sample/leanallocator/package-info.java b/src/main/java/org/drip/sample/leanallocator/package-info.java new file mode 100644 index 00000000000..965ac8cab9e --- /dev/null +++ b/src/main/java/org/drip/sample/leanallocator/package-info.java @@ -0,0 +1,8 @@ + +/** + * Construction/Usage of Lean Portfolio Allocator + * + * @author Lakshmi Krishnamurthy + */ + +package org.drip.sample.leanallocator;