Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- Buy Only Allocation - Random Holdings #1 (1, 2)
	- Buy Only Allocation - Random Holdings #2 (3, 4)
	- Holdings Container - Marker Cash Value (5)
	- Buy Only Allocator - Run #1 (6)
	- Buy Only Allocator - Run #2 (7, 8, 9)
	- Buy Only Allocator - Run #3 (10, 11, 12)
	- Buy Only Allocator - Run #4 (13, 14, 15)
	- Buy Only Allocator - Run #5 (16, 17, 18)
	- Buy Only Allocator - Run #6 (19, 20, 21)
	- Buy Only Allocator - Run #7 (22, 23, 24)
	- Buy Only Allocator - Run #8 (25)
	- Holdings Container - Cash Weight #1 (26, 27)
	- Holdings Container - Cash Weight #2 (28, 29, 30)
	- Holdings Container - Cash Weight #3 (31, 32)
	- Buy Only Allocator - Run #9 (33, 34)
	- Buy Only Allocator - Run #10 (35, 36)
	- Buy Only Allocator - Run #11 (37, 38, 39)
	- Buy Only Allocator - Run #12 (40, 41, 42)
	- Buy Only Allocator - Run #13 (43, 44, 45)
	- Buy Only Allocator - Run #14 (46, 47, 48)
	- Buy Only Allocator - Run #15 (49, 50, 51)
	- Buy Only Allocator - Run #16 (52, 53, 54)
	- Buy Only Allocator - Run #17 (55, 56, 57)
	- Buy Only Allocator - Run #18 (58, 59, 60)
	- Buy Only Allocator - Run #19 (61, 62, 63)
	- Buy Only Allocator - Run #20 (64, 65, 66)
	- Buy Only Allocator - Run #21 (67, 68, 69)
	- Buy Only Allocator - Run #22 (70, 71, 72)
	- Buy Only Allocator - Run #23 (73, 74, 75)
	- Buy Only Allocator - Run #24 (76, 77, 78)
	- Buy Only Allocator - Run #25 (79, 80, 81)
	- Buy Only Allocator - Run #26 (82, 83, 84)
	- Buy Only Allocator - Run #27 (85, 86, 87)
	- Service Env Invocation Manager 2025 (88)
	- Lean Portfolio Construction - Full Sequence Allocation (89, 90, 91)
	- Full Sequence Allocation - Starting Holdings #1 (92, 93)
	- Full Sequence Allocation - Starting Holdings #2 (94, 95, 96)
	- Full Sequence Allocation - Ending Holdings #1 (97, 98, 99)
	- Full Sequence Allocation - Ending Holdings #2 (100, 101)
	- Full Sequence Allocation - Constructor #1 (102, 103)
	- Full Sequence Allocation - Constructor #2 (104, 105)
	- Full Sequence Allocation - Constructor #3 (106, 107, 108)
	- Lean Portfolio Construction - Full Sequence Allocator (109, 110, 111)
	- Full Sequence Allocator - Post-processor Settings #1 (112, 113, 114)
	- Full Sequence Allocator - Post-processor Settings #2 (115, 116)
	- Full Sequence Allocator - Constructor #1 (117, 118)
	- Full Sequence Allocator - Constructor #2 (119, 120)


Bug Fixes/Re-organization:

Samples:

IdeaDRIP:
  • Loading branch information
Lakshmik committed Dec 29, 2024
1 parent d3be21b commit 53ce590
Show file tree
Hide file tree
Showing 7 changed files with 491 additions and 45 deletions.
57 changes: 57 additions & 0 deletions ReleaseNotes/04_29_2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

Features:

- Buy Only Allocation - Random Holdings #1 (1, 2)
- Buy Only Allocation - Random Holdings #2 (3, 4)
- Holdings Container - Marker Cash Value (5)
- Buy Only Allocator - Run #1 (6)
- Buy Only Allocator - Run #2 (7, 8, 9)
- Buy Only Allocator - Run #3 (10, 11, 12)
- Buy Only Allocator - Run #4 (13, 14, 15)
- Buy Only Allocator - Run #5 (16, 17, 18)
- Buy Only Allocator - Run #6 (19, 20, 21)
- Buy Only Allocator - Run #7 (22, 23, 24)
- Buy Only Allocator - Run #8 (25)
- Holdings Container - Cash Weight #1 (26, 27)
- Holdings Container - Cash Weight #2 (28, 29, 30)
- Holdings Container - Cash Weight #3 (31, 32)
- Buy Only Allocator - Run #9 (33, 34)
- Buy Only Allocator - Run #10 (35, 36)
- Buy Only Allocator - Run #11 (37, 38, 39)
- Buy Only Allocator - Run #12 (40, 41, 42)
- Buy Only Allocator - Run #13 (43, 44, 45)
- Buy Only Allocator - Run #14 (46, 47, 48)
- Buy Only Allocator - Run #15 (49, 50, 51)
- Buy Only Allocator - Run #16 (52, 53, 54)
- Buy Only Allocator - Run #17 (55, 56, 57)
- Buy Only Allocator - Run #18 (58, 59, 60)
- Buy Only Allocator - Run #19 (61, 62, 63)
- Buy Only Allocator - Run #20 (64, 65, 66)
- Buy Only Allocator - Run #21 (67, 68, 69)
- Buy Only Allocator - Run #22 (70, 71, 72)
- Buy Only Allocator - Run #23 (73, 74, 75)
- Buy Only Allocator - Run #24 (76, 77, 78)
- Buy Only Allocator - Run #25 (79, 80, 81)
- Buy Only Allocator - Run #26 (82, 83, 84)
- Buy Only Allocator - Run #27 (85, 86, 87)
- Service Env Invocation Manager 2025 (88)
- Lean Portfolio Construction - Full Sequence Allocation (89, 90, 91)
- Full Sequence Allocation - Starting Holdings #1 (92, 93)
- Full Sequence Allocation - Starting Holdings #2 (94, 95, 96)
- Full Sequence Allocation - Ending Holdings #1 (97, 98, 99)
- Full Sequence Allocation - Ending Holdings #2 (100, 101)
- Full Sequence Allocation - Constructor #1 (102, 103)
- Full Sequence Allocation - Constructor #2 (104, 105)
- Full Sequence Allocation - Constructor #3 (106, 107, 108)
- Lean Portfolio Construction - Full Sequence Allocator (109, 110, 111)
- Full Sequence Allocator - Post-processor Settings #1 (112, 113, 114)
- Full Sequence Allocator - Post-processor Settings #2 (115, 116)
- Full Sequence Allocator - Constructor #1 (117, 118)
- Full Sequence Allocator - Constructor #2 (119, 120)


Bug Fixes/Re-organization:

Samples:

IdeaDRIP:
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@

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>FullSequenceAllocator</i> holds the Results of Optimization from the Initial Holdings and its eventual
* Post-Processing.
*
* <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 class FullSequenceAllocation
{
private HoldingsContainer _endingHoldings = null;
private HoldingsContainer _startingHoldings = null;

/**
* <i>FullSequenceAllocation</i> Constructor
*
* @param startingHoldings Starting Holdings
* @param endingHoldings Ending Holdings
*
* @throws Exception Thrown if the Inputs are Invalid
*/

public FullSequenceAllocation (
final HoldingsContainer startingHoldings,
final HoldingsContainer endingHoldings)
throws Exception
{
if (null == (_startingHoldings = startingHoldings) || null == (_endingHoldings = endingHoldings)) {
throw new Exception ("FullSequenceAllocation Constructor => Invalid Inputs");
}
}

/**
* Retrieve the Starting Holdings
*
* @return Starting Holdings
*/

public HoldingsContainer startingHoldings()
{
return _startingHoldings;
}

/**
* Retrieve the Ending Holdings
*
* @return Starting Holdings
*/

public HoldingsContainer endingHoldings()
{
return _endingHoldings;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

package org.drip.sample.leanallocator;

import org.drip.portfolioconstruction.lean.HoldingsContainer;
import org.drip.service.env.EnvManager;
package org.drip.portfolioconstruction.lean;

/*
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
Expand Down Expand Up @@ -77,55 +74,44 @@
*/

/**
* <i>BuyOnlyAllocation</i> illustrates the Filter-Sells Post-Processing Functionality of an Allocator.
* <i>FullSequenceAllocator</i> generates an Optimal Portfolio from the Initial Holdings and performs
* Post-Processing if necessary.
*
* <br><br>
* <ul>
* <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
* <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalAnalysisLibrary.md">Numerical Analysis Library</a></li>
* <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">DROP API Construction and Usage</a></li>
* <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/leanallocator/README.md">Construction/Usage of Lean Portfolio Allocator</a></li>
* <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 class BuyOnlyAllocation
public class FullSequenceAllocator
{
private PostProcessorSettings _postProcessorSettings = null;

private static final int ZeroToHundred()
{
return (int) (Math.random() * 100.);
}
/**
* <i>FullSequenceAllocator</i> Constructor
*
* @param postProcessorSettings Post Processing Settings Instance
*/

private static final HoldingsContainer RandomHoldings (
final int size,
final double cash)
throws Exception
public FullSequenceAllocator (
final PostProcessorSettings postProcessorSettings)
{
HoldingsContainer holdingsContainer = new HoldingsContainer();

for (int i = 0; i < size; ++i) {
holdingsContainer.setAsset ("cusip_" + i, 100. * ZeroToHundred());
}

return holdingsContainer.setCashValue (cash) ? holdingsContainer : null;
_postProcessorSettings = postProcessorSettings;
}

/**
* Entry Point
* Retrieve the Post Processing Settings
*
* @param argumentArray Command Line Argument Array
*
* @throws Exception Thrown on Error/Exception Situation
* @return Post Processing Settings
*/

public static final void main (
final String[] argumentArray)
throws Exception
public PostProcessorSettings postProcessorSettings()
{
EnvManager.InitEnv ("");

EnvManager.TerminateEnv();
return _postProcessorSettings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class HoldingsContainer
{
private boolean _dirty = false;
private double _cashValue = Double.NaN;
private double _cashWeight = Double.NaN;
private double _marketValue = Double.NaN;

private Map<String, Double> _assetWeightMap = new CaseInsensitiveHashMap<Double>();
Expand All @@ -111,7 +112,8 @@ private boolean unDirty()
}

_dirty = false;
_marketValue = 0.;
_marketValue = _cashValue;
double cumulativeWeight = 0.;

_assetWeightMap.clear();

Expand All @@ -124,12 +126,14 @@ private boolean unDirty()
}

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

_assetWeightMap.put (assetMarketValueMapEntry.getKey(), assetWeight);

cumulativeWeight += assetWeight;
}

_cashWeight = 1. - cumulativeWeight;
return true;
}

Expand All @@ -140,6 +144,7 @@ private boolean unDirty()
public HoldingsContainer()
{
_cashValue = 0.;
_cashWeight = 0.;
_marketValue = 0.;

_assetWeightMap = new CaseInsensitiveHashMap<Double>();
Expand Down Expand Up @@ -208,7 +213,7 @@ public boolean setAsset (
final String assetID,
final double assetMarketValue)
{
if (null == assetID || assetID.isEmpty() || NumberUtil.IsValid (assetMarketValue)) {
if (null == assetID || assetID.isEmpty() || !NumberUtil.IsValid (assetMarketValue)) {
return false;
}

Expand All @@ -229,7 +234,7 @@ public boolean setAsset (
public boolean setCashValue (
final double cashValue)
{
if (NumberUtil.IsValid (cashValue)) {
if (!NumberUtil.IsValid (cashValue)) {
return false;
}

Expand All @@ -249,6 +254,13 @@ public Set<String> assetSet()
return _assetMarketValueMap.keySet();
}

public double cashWeight()
{
unDirty();

return _cashWeight;
}

/**
* Remove the Asset corresponding to the ID
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static final TradesContainer FromStartAndEndHoldings (
String assetID = assetMarketValueMapEntry.getKey();

if (!assetQuantityMap.containsKey (assetID)) {
assetQuantityMap.put ( assetID, -1. * assetMarketValueMapEntry.getValue());
assetQuantityMap.put (assetID, -1. * assetMarketValueMapEntry.getValue());
}
}
}
Expand Down
Loading

0 comments on commit 53ce590

Please sign in to comment.