Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- 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:
  • Loading branch information
Lakshmik committed Dec 27, 2024
1 parent f4cd00c commit d3be21b
Show file tree
Hide file tree
Showing 7 changed files with 724 additions and 3 deletions.
58 changes: 58 additions & 0 deletions ReleaseNotes/04_28_2024.txt
Original file line number Diff line number Diff line change
@@ -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:
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -95,18 +96,50 @@

public class HoldingsContainer
{
private boolean _dirty = false;
private double _cashValue = Double.NaN;
private double _marketValue = Double.NaN;

private Map<String, Double> _assetWeightMap = new CaseInsensitiveHashMap<Double>();

private Map<String, Double> _assetMarketValueMap = new CaseInsensitiveHashMap<Double>();

private boolean unDirty()
{
if (!_dirty || _assetMarketValueMap.isEmpty()) {
return false;
}

_dirty = false;
_marketValue = 0.;

_assetWeightMap.clear();

for (Map.Entry<String, Double> assetMarketValueMapEntry : _assetMarketValueMap.entrySet()) {
_marketValue += assetMarketValueMapEntry.getValue();
}

if (0. == _marketValue) {
return true;
}

for (Map.Entry<String, Double> assetMarketValueMapEntry : _assetMarketValueMap.entrySet()) {
_assetWeightMap.put (
assetMarketValueMapEntry.getKey(),
assetMarketValueMapEntry.getValue() / _marketValue
);
}

return true;
}

/**
* Empty <i>HoldingsContainer</i> Constructor
*/

public HoldingsContainer()
{
_cashValue = 0.;
_marketValue = 0.;

_assetWeightMap = new CaseInsensitiveHashMap<Double>();
Expand All @@ -133,6 +166,8 @@ public Map<String, Double> assetMarketValueMap()

public Map<String, Double> assetWeightMap()
{
unDirty();

return _assetWeightMap;
}

Expand All @@ -144,19 +179,32 @@ public Map<String, Double> 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)
{
Expand All @@ -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<String> 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;
}
}
104 changes: 104 additions & 0 deletions src/main/java/org/drip/portfolioconstruction/lean/Optimizer.java
Original file line number Diff line number Diff line change
@@ -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.
*/

/**
* <i>Optimizer</i> exposes Functionality for optimizing the given Portfolio
*
* <br><br>
* <ul>
* <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/PortfolioCore.md">Portfolio Core Module</a></li>
* <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/AssetAllocationAnalyticsLibrary.md">Asset Allocation Analytics</a></li>
* <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/portfolioconstruction/README.md">Portfolio Construction under Allocation Constraints</a></li>
* <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/portfolioconstruction/lean/README.md">"Lean" Portfolio Construction Utilities Suite</a></li>
* </ul>
*
* @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
);
}
Loading

0 comments on commit d3be21b

Please sign in to comment.