Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- Full Sequence Allocator - Optimizer #1 (1, 2, 3)
	- Full Sequence Allocator - Optimizer #2 (4, 5, 6)
	- Full Sequence Allocator - Optimizer #3 (7, 8)
	- Lean Portfolio Construction - Randomized Optimizer (9, 10, 11)
	- Randomized Optimizer - Asset Size Scaler #1 (12, 13)
	- Randomized Optimizer - Asset Size Scaler #3 (14, 15)
	- Randomized Optimizer - Annotated Constructor #1 (16, 17, 18)
	- Randomized Optimizer - Annotated Constructor #2 (19, 20, 21)
	- Randomized Optimizer - Random To Scale (22, 23)
	- Randomized Optimizer - Optimize #1 (24, 25)
	- Randomized Optimizer - Optimize #2 (26, 27, 28)
	- Randomized Optimizer - Optimize #3 (29, 30, 31)
	- Randomized Optimizer - Optimize #4 (32, 33, 34)
	- Randomized Optimizer - Optimize #5 (35, 36, 37)
	- Post Processor Settings - Filter Buys #1 (38, 39)
	- Post Processor Settings - Filter Buys #2 (40, 41, 42)
	- Post Processor Settings - Filter Buys #3 (43, 44)
	- Full Sequence Allocator - Allocate #1 (45)
	- Full Sequence Allocator - Allocate #2 (46, 47, 48)
	- Full Sequence Allocator - Allocate #3 (49, 50, 51)
	- Full Sequence Allocator - Allocate #4 (52, 53, 54)
	- Full Sequence Allocator - Allocate #5 (55, 56, 57)
	- Full Sequence Allocator - Allocate #6 (58, 59, 60)
	- Full Sequence Allocator - Allocate #7 (61, 62, 63)
	- Full Sequence Allocator - Allocate #8 (64, 65, 66)
	- Full Sequence Allocator - Allocate #9 (67, 68, 69)
	- Full Sequence Allocation Diagnostics Shell (70, 71, 72)
	- Full Sequence Allocation Diagnostics - Constructor #1 (73, 74, 75)
	- Full Sequence Allocation Diagnostics - Constructor #2 (76, 77, 78)
	- Holdings Container - Instance Clone #1 (79, 80, 81)
	- Holdings Container - Instance Clone #2 (82, 83)
	- Holdings Container - Instance Clone #3 (84, 85)
	- Full Sequence Allocation Diagnostics - Buy-filtered #1 (86, 87)
	- Full Sequence Allocation Diagnostics - Buy-filtered #2 (88, 89, 90)
	- Full Sequence Allocation Diagnostics - Sell-filtered #1 (91, 92, 93)
	- Full Sequence Allocation Diagnostics - Sell-filtered #2 (94, 95)
	- Full Sequence Allocation Diagnostics - Set Buy-filtered Holdings Container #1 (96, 97)
	- Full Sequence Allocation Diagnostics - Set Buy-filtered Holdings Container #2 (98, 99, 100)
	- Full Sequence Allocation Diagnostics - Set Sell-filtered Holdings Container #1 (101, 102)
	- Full Sequence Allocation Diagnostics - Set Sell-filtered Holdings Container #2 (103, 104, 105)
	- R^d Random Sequence - Digit #1 (109, 110)
	- R^d Random Sequence - Digit #2 (111, 112)
	- R^d Random Sequence - Alphabet #1 (113, 114)
	- R^d Random Sequence - Alphabet #2 (115, 116)
	- R^d Random Sequence - Alpha-numeric #1 (117, 118)
	- R^d Random Sequence - Alpha-numeric #2 (119, 120)


Bug Fixes/Re-organization:

Samples:

	- Lean Allocator Buy-Only Allocation (106, 107, 108)


IdeaDRIP:
  • Loading branch information
Lakshmik committed Dec 31, 2024
1 parent 53ce590 commit daf7b65
Show file tree
Hide file tree
Showing 9 changed files with 659 additions and 3 deletions.
59 changes: 59 additions & 0 deletions ReleaseNotes/04_30_2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

Features:

- Full Sequence Allocator - Optimizer #1 (1, 2, 3)
- Full Sequence Allocator - Optimizer #2 (4, 5, 6)
- Full Sequence Allocator - Optimizer #3 (7, 8)
- Lean Portfolio Construction - Randomized Optimizer (9, 10, 11)
- Randomized Optimizer - Asset Size Scaler #1 (12, 13)
- Randomized Optimizer - Asset Size Scaler #3 (14, 15)
- Randomized Optimizer - Annotated Constructor #1 (16, 17, 18)
- Randomized Optimizer - Annotated Constructor #2 (19, 20, 21)
- Randomized Optimizer - Random To Scale (22, 23)
- Randomized Optimizer - Optimize #1 (24, 25)
- Randomized Optimizer - Optimize #2 (26, 27, 28)
- Randomized Optimizer - Optimize #3 (29, 30, 31)
- Randomized Optimizer - Optimize #4 (32, 33, 34)
- Randomized Optimizer - Optimize #5 (35, 36, 37)
- Post Processor Settings - Filter Buys #1 (38, 39)
- Post Processor Settings - Filter Buys #2 (40, 41, 42)
- Post Processor Settings - Filter Buys #3 (43, 44)
- Full Sequence Allocator - Allocate #1 (45)
- Full Sequence Allocator - Allocate #2 (46, 47, 48)
- Full Sequence Allocator - Allocate #3 (49, 50, 51)
- Full Sequence Allocator - Allocate #4 (52, 53, 54)
- Full Sequence Allocator - Allocate #5 (55, 56, 57)
- Full Sequence Allocator - Allocate #6 (58, 59, 60)
- Full Sequence Allocator - Allocate #7 (61, 62, 63)
- Full Sequence Allocator - Allocate #8 (64, 65, 66)
- Full Sequence Allocator - Allocate #9 (67, 68, 69)
- Full Sequence Allocation Diagnostics Shell (70, 71, 72)
- Full Sequence Allocation Diagnostics - Constructor #1 (73, 74, 75)
- Full Sequence Allocation Diagnostics - Constructor #2 (76, 77, 78)
- Holdings Container - Instance Clone #1 (79, 80, 81)
- Holdings Container - Instance Clone #2 (82, 83)
- Holdings Container - Instance Clone #3 (84, 85)
- Full Sequence Allocation Diagnostics - Buy-filtered #1 (86, 87)
- Full Sequence Allocation Diagnostics - Buy-filtered #2 (88, 89, 90)
- Full Sequence Allocation Diagnostics - Sell-filtered #1 (91, 92, 93)
- Full Sequence Allocation Diagnostics - Sell-filtered #2 (94, 95)
- Full Sequence Allocation Diagnostics - Set Buy-filtered Holdings Container #1 (96, 97)
- Full Sequence Allocation Diagnostics - Set Buy-filtered Holdings Container #2 (98, 99, 100)
- Full Sequence Allocation Diagnostics - Set Sell-filtered Holdings Container #1 (101, 102)
- Full Sequence Allocation Diagnostics - Set Sell-filtered Holdings Container #2 (103, 104, 105)
- R^d Random Sequence - Digit #1 (109, 110)
- R^d Random Sequence - Digit #2 (111, 112)
- R^d Random Sequence - Alphabet #1 (113, 114)
- R^d Random Sequence - Alphabet #2 (115, 116)
- R^d Random Sequence - Alpha-numeric #1 (117, 118)
- R^d Random Sequence - Alpha-numeric #2 (119, 120)


Bug Fixes/Re-organization:

Samples:

- Lean Allocator Buy-Only Allocation (106, 107, 108)


IdeaDRIP:
33 changes: 33 additions & 0 deletions src/main/java/org/drip/measure/crng/RdRandomSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,39 @@
public class RdRandomSequence
{

/**
* Generate a Random Digit
*
* @return Random Digit
*/

public static final int RandomDigit()
{
return (int) (10. * Math.random());
}

/**
* Generate a Random Alphabet
*
* @return Random Alphabet
*/

public static final char RandomAlphabet()
{
return (char) (26. * Math.random() + (int) 'a');
}

/**
* Generate a Random Alpha-numeric Character
*
* @return Random Alpha-numeric Character
*/

public static final char RandomAlphaNumeric()
{
return (char) (36. * Math.random() + (int) 'a');
}

/**
* Construct a 1D Array of Random Elements up to the Maximum Value
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@

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>FullSequenceAllocationDiagnostics</i> augments <i>FullSequenceAllocation</i> by holding the Results of
* the pre-processed Allocation.
*
* <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 FullSequenceAllocationDiagnostics extends FullSequenceAllocation
{
public HoldingsContainer _buyFilteredHoldings = null;
public HoldingsContainer _sellFilteredHoldings = null;

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

public FullSequenceAllocationDiagnostics (
final HoldingsContainer startingHoldings,
final HoldingsContainer endingHoldings)
throws Exception
{
super (startingHoldings, endingHoldings);
}

/**
* Retrieve the Buy-Filtered Holdings
*
* @return Buy-Filtered Holdings
*/

public HoldingsContainer buyFilteredHoldings()
{
return _buyFilteredHoldings;
}

/**
* Retrieve the Sell-Filtered Holdings
*
* @return Sell-Filtered Holdings
*/

public HoldingsContainer sellFilteredHoldings()
{
return _sellFilteredHoldings;
}

/**
* Set <i>Buy Filtered</i> Holdings Container
*
* @param holdingsContainer <i>Buy Filtered</i> Holdings Container
*
* @return <i>Buy Filtered</i> Holdings Container successfully set
*/

public boolean setBuyFiltered (
final HoldingsContainer holdingsContainer)
{
if (null == holdingsContainer) {
return false;
}

return null != (_buyFilteredHoldings = holdingsContainer.clone());
}

/**
* Set <i>Sell Filtered</i> Holdings Container
*
* @param holdingsContainer <i>Sell Filtered</i> Holdings Container
*
* @return <i>Sell Filtered</i> Holdings Container successfully set
*/

public boolean setSellFiltered (
final HoldingsContainer holdingsContainer)
{
if (null == holdingsContainer) {
return false;
}

return null != (_sellFilteredHoldings = holdingsContainer.clone());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

package org.drip.portfolioconstruction.lean;

import java.util.Map;

/*
* -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*/
Expand Down Expand Up @@ -90,20 +92,39 @@

public class FullSequenceAllocator
{
private Optimizer _optimizer = null;
private PostProcessorSettings _postProcessorSettings = null;

/**
* <i>FullSequenceAllocator</i> Constructor
*
* @param postProcessorSettings Post Processing Settings Instance
* @param optimizer Optimizer
* @param postProcessorSettings Post Processing Settings
*/

public FullSequenceAllocator (
final Optimizer optimizer,
final PostProcessorSettings postProcessorSettings)
throws Exception
{
if (null == (_optimizer = optimizer)) {
throw new Exception ("FullSequenceAllocator Constructor => Invalid Inputs");
}

_postProcessorSettings = postProcessorSettings;
}

/**
* Retrieve the Optimizer
*
* @return Optimizer
*/

public Optimizer optimizer()
{
return _optimizer;
}

/**
* Retrieve the Post Processing Settings
*
Expand All @@ -114,4 +135,60 @@ public PostProcessorSettings postProcessorSettings()
{
return _postProcessorSettings;
}

/**
* Allocate an Instance of Post-processed Target Holdings from the Initial Portfolio
*
* @param startingHoldings Starting Holdings
*
* @return Instance of Post-processed Target Holdings
*/

public FullSequenceAllocation allocate (
final HoldingsContainer startingHoldings)
{
HoldingsContainer endingHoldings = _optimizer.optimize (startingHoldings);

if (null == endingHoldings) {
return null;
}

if (null != _postProcessorSettings) {
Map<String, Double> startingAssetMarketValueMap = startingHoldings.assetMarketValueMap();

Map<String, Double> endingAssetMarketValueMap = endingHoldings.assetMarketValueMap();

if (_postProcessorSettings.filterSells()) {
for (String assetID : endingAssetMarketValueMap.keySet()) {
double startingAssetMarketValue = startingAssetMarketValueMap.containsKey (assetID) ?
startingAssetMarketValueMap.get (assetID) : 0.;

double tradeAmount = endingAssetMarketValueMap.get (assetID) - startingAssetMarketValue;

if (0. > tradeAmount) {
endingHoldings.setAsset (assetID, startingAssetMarketValue);
}
}
} else if (_postProcessorSettings.filterBuys()) {
for (String assetID : endingAssetMarketValueMap.keySet()) {
double startingAssetMarketValue = startingAssetMarketValueMap.containsKey (assetID) ?
startingAssetMarketValueMap.get (assetID) : 0.;

double tradeAmount = endingAssetMarketValueMap.get (assetID) - startingAssetMarketValue;

if (0. < tradeAmount) {
endingHoldings.setAsset (assetID, startingAssetMarketValue);
}
}
}
}

try {
return new FullSequenceAllocation (startingHoldings, endingHoldings);
} catch (Exception e) {
e.printStackTrace();
}

return null;
}
}
Loading

0 comments on commit daf7b65

Please sign in to comment.