Skip to content

Commit

Permalink
Features:
Browse files Browse the repository at this point in the history
	- Random Upper Alpha-numeric (1, 2, 3)
	- R^d Random Sequence - CUSIP #1 (66, 67)
	- R^d Random Sequence - CUSIP #2 (68, 69, 70)
	- R^d Random Sequence - CUSIP #3 (71, 72, 73)


Bug Fixes/Re-organization:

Samples:

	- Buy Only Allocator - Scaled Market Value (4, 5)
	- Buy Only Allocator - Random Holdings #1 (6, 7)
	- Buy Only Allocator - Random Holdings #2 (8, 9, 10)
	- Post Processor Settings - Buy Only #1 (11, 12)
	- Post Processor Settings - Buy Only #2 (13, 14, 15)
	- Post Processor Settings - Buy Only #3 (16, 17)
	- Post Processor Settings - Sell Only #1 (18, 19)
	- Post Processor Settings - Sell Only #2 (20, 21)
	- Post Processor Settings - Sell Only #3 (22, 23, 24)
	- Buy Only Allocation - Random CUSIP #1 (25, 26, 27)
	- Buy Only Allocation - Random CUSIP #2 (28, 29)
	- Random Discrete Digits Generator #1 (30, 31)
	- Random Discrete Digits Generator #2 (32, 33)
	- Random Discrete Digits Generator - Digit #1 (34, 35)
	- Random Discrete Digits Generator - Digit #2 (36, 37)
	- Random Discrete Digits Generator - Upper Alpha (38, 39)
	- Random Discrete Digits Generator - Alpha-numeric #1 (40, 41)
	- Random Discrete Digits Generator - Alpha-numeric #2 (42, 43, 44)
	- Random Discrete Digits Generator - Alpha-numeric #3 (45, 46)
	- Random Discrete Digits Generator - Alpha-numeric #4 (47, 48)
	- Random Discrete Digits Generator - Alpha-numeric #5 (49, 50)
	- Random Discrete Digits Generator - Alpha-numeric #6 (51, 52)
	- Random Discrete Digits Generator - Alpha-numeric #7 (53, 54, 55)
	- Random Discrete Digits Generator - Alpha-numeric #8 (56, 57, 58)
	- Random Discrete Digits Generator - Alpha-numeric #9 (59, 60)
	- Random Discrete Digits Generator - Alpha-numeric #10 (61, 62)
	- Random Discrete Digits Generator - Alpha-numeric #11 (63, 64, 65)
	- Random Discrete Digits Generator - CUSIP #1 (74, 75)
	- Random Discrete Digits Generator - CUSIP #2 (76, 77, 78)
	- Random Discrete Digits Generator - CUSIP #3 (79, 80, 81)
	- Random Discrete Digits Generator - CUSIP #4 (82, 83, 84)
	- Random Discrete Digits Generator - CUSIP #5 (85, 86, 87)
	- Buy Only Allocation - Full Sequence Allocator (88, 89)
	- Full Sequence Allocator - Diagnostics On #1 (90, 91, 92)
	- Full Sequence Allocator - Diagnostics On #2 (93, 94)
	- Full Sequence Allocator - Diagnostics On #3 (95, 96)
	- Full Sequence Allocation - Starting Holdings #1 (97, 98, 99)
	- Full Sequence Allocation - Starting Holdings #2 (100, 101, 102)
	- Full Sequence Allocation - Starting Holdings #3 (103, 104)
	- Full Sequence Allocation - Ending Holdings #1 (105, 106)
	- Full Sequence Allocation - Ending Holdings #2 (107, 108, 109)
	- Full Sequence Allocation - Ending Holdings #3 (110, 111, 112)
	- Full Sequence Allocation Diagnostics Constructor (113)
	- Full Sequence Allocation - Allocate #1 (115, 116)
	- Full Sequence Allocation - Allocate #2 (117, 118, 119)
	- Buy Only Allocation Run (120)


IdeaDRIP:
  • Loading branch information
Lakshmik committed Jan 1, 2025
1 parent daf7b65 commit 6628e94
Show file tree
Hide file tree
Showing 8 changed files with 384 additions and 73 deletions.
62 changes: 62 additions & 0 deletions ReleaseNotes/05_01_2024.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

Features:

- Random Upper Alpha-numeric (1, 2, 3)
- R^d Random Sequence - CUSIP #1 (66, 67)
- R^d Random Sequence - CUSIP #2 (68, 69, 70)
- R^d Random Sequence - CUSIP #3 (71, 72, 73)


Bug Fixes/Re-organization:

Samples:

- Buy Only Allocator - Scaled Market Value (4, 5)
- Buy Only Allocator - Random Holdings #1 (6, 7)
- Buy Only Allocator - Random Holdings #2 (8, 9, 10)
- Post Processor Settings - Buy Only #1 (11, 12)
- Post Processor Settings - Buy Only #2 (13, 14, 15)
- Post Processor Settings - Buy Only #3 (16, 17)
- Post Processor Settings - Sell Only #1 (18, 19)
- Post Processor Settings - Sell Only #2 (20, 21)
- Post Processor Settings - Sell Only #3 (22, 23, 24)
- Buy Only Allocation - Random CUSIP #1 (25, 26, 27)
- Buy Only Allocation - Random CUSIP #2 (28, 29)
- Random Discrete Digits Generator #1 (30, 31)
- Random Discrete Digits Generator #2 (32, 33)
- Random Discrete Digits Generator - Digit #1 (34, 35)
- Random Discrete Digits Generator - Digit #2 (36, 37)
- Random Discrete Digits Generator - Upper Alpha (38, 39)
- Random Discrete Digits Generator - Alpha-numeric #1 (40, 41)
- Random Discrete Digits Generator - Alpha-numeric #2 (42, 43, 44)
- Random Discrete Digits Generator - Alpha-numeric #3 (45, 46)
- Random Discrete Digits Generator - Alpha-numeric #4 (47, 48)
- Random Discrete Digits Generator - Alpha-numeric #5 (49, 50)
- Random Discrete Digits Generator - Alpha-numeric #6 (51, 52)
- Random Discrete Digits Generator - Alpha-numeric #7 (53, 54, 55)
- Random Discrete Digits Generator - Alpha-numeric #8 (56, 57, 58)
- Random Discrete Digits Generator - Alpha-numeric #9 (59, 60)
- Random Discrete Digits Generator - Alpha-numeric #10 (61, 62)
- Random Discrete Digits Generator - Alpha-numeric #11 (63, 64, 65)
- Random Discrete Digits Generator - CUSIP #1 (74, 75)
- Random Discrete Digits Generator - CUSIP #2 (76, 77, 78)
- Random Discrete Digits Generator - CUSIP #3 (79, 80, 81)
- Random Discrete Digits Generator - CUSIP #4 (82, 83, 84)
- Random Discrete Digits Generator - CUSIP #5 (85, 86, 87)
- Buy Only Allocation - Full Sequence Allocator (88, 89)
- Full Sequence Allocator - Diagnostics On #1 (90, 91, 92)
- Full Sequence Allocator - Diagnostics On #2 (93, 94)
- Full Sequence Allocator - Diagnostics On #3 (95, 96)
- Full Sequence Allocation - Starting Holdings #1 (97, 98, 99)
- Full Sequence Allocation - Starting Holdings #2 (100, 101, 102)
- Full Sequence Allocation - Starting Holdings #3 (103, 104)
- Full Sequence Allocation - Ending Holdings #1 (105, 106)
- Full Sequence Allocation - Ending Holdings #2 (107, 108, 109)
- Full Sequence Allocation - Ending Holdings #3 (110, 111, 112)
- Full Sequence Allocation Diagnostics Constructor (113)
- Full Sequence Allocation - Allocate #1 (115, 116)
- Full Sequence Allocation - Allocate #2 (117, 118, 119)
- Buy Only Allocation Run (120)


IdeaDRIP:
35 changes: 27 additions & 8 deletions src/main/java/org/drip/measure/crng/RdRandomSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,44 @@ public static final int RandomDigit()
}

/**
* Generate a Random Alphabet
* Generate a Random Upper-case Alphabet
*
* @return Random Alphabet
* @return Random Upper-case Alphabet
*/

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

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

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

return (char) (ascii + (10 > ascii ? (int) '0' : (int) 'A' - 10));
}

/**
* Generate a Random CUSIP
*
* @return The CUSIP
*/

public static final String RandomCUSIP()
{
String cusip = "XS0" + RdRandomSequence.RandomDigit();

for (int i = 0; i < 6; ++i) {
cusip += RdRandomSequence.RandomUpperAlphaNumeric();
}

return cusip;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,49 @@ public class FullSequenceAllocation
private HoldingsContainer _startingHoldings = null;

/**
* <i>FullSequenceAllocation</i> Constructor
* Empty <i>FullSequenceAllocation</i> Constructor
*/

public FullSequenceAllocation()
{
}

/**
* Set the Starting Holdings
*
* @param startingHoldings Starting Holdings
*
* @return TRUE - The Starting Holdings successfully set
*/

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

_startingHoldings = startingHoldings;
return true;
}

/**
* Set the Ending Holdings
*
* @param endingHoldings Ending Holdings
*
* @throws Exception Thrown if the Inputs are Invalid
* @return TRUE - The Ending Holdings successfully set
*/

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

_endingHoldings = endingHoldings;
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,81 +91,43 @@

public class FullSequenceAllocationDiagnostics extends FullSequenceAllocation
{
public HoldingsContainer _buyFilteredHoldings = null;
public HoldingsContainer _sellFilteredHoldings = null;
public HoldingsContainer _preFilteredHoldings = 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
* Empty <i>FullSequenceAllocationDiagnostics</i> Constructor
*/

public HoldingsContainer sellFilteredHoldings()
public FullSequenceAllocationDiagnostics()
{
return _sellFilteredHoldings;
super();
}

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

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

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

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

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

return null != (_sellFilteredHoldings = holdingsContainer.clone());
return null != (_preFilteredHoldings = holdingsContainer.clone());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
public class FullSequenceAllocator
{
private Optimizer _optimizer = null;
private boolean _diagnosticsOn = false;
private PostProcessorSettings _postProcessorSettings = null;

/**
Expand Down Expand Up @@ -136,6 +137,17 @@ public PostProcessorSettings postProcessorSettings()
return _postProcessorSettings;
}

/**
* Indicate if the Diagnostics is turned on
*
* @return TRUE - Diagnostics is turned on
*/

public boolean diagnosticsOn()
{
return _diagnosticsOn;
}

/**
* Allocate an Instance of Post-processed Target Holdings from the Initial Portfolio
*
Expand All @@ -147,12 +159,24 @@ public PostProcessorSettings postProcessorSettings()
public FullSequenceAllocation allocate (
final HoldingsContainer startingHoldings)
{
FullSequenceAllocation fullSequenceAllocation = _diagnosticsOn ?
new FullSequenceAllocationDiagnostics() :
new FullSequenceAllocation();

if (!fullSequenceAllocation.startingHoldings (startingHoldings)) {
return null;
}

HoldingsContainer endingHoldings = _optimizer.optimize (startingHoldings);

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

if (_diagnosticsOn) {
((FullSequenceAllocationDiagnostics) fullSequenceAllocation).setPreFiltered (endingHoldings);
}

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

Expand Down Expand Up @@ -183,12 +207,6 @@ public FullSequenceAllocation allocate (
}
}

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

return null;
return fullSequenceAllocation.endingHoldings (endingHoldings) ? fullSequenceAllocation : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,40 @@ public class PostProcessorSettings
private boolean _filterBuys = false;
private boolean _filterSells = false;

/**
* Construct a Buy-only Version of <i>PostProcessorSettings</i>
*
* @return Buy-only Version of <i>PostProcessorSettings</i>
*/

public static final PostProcessorSettings BuyOnly()
{
try {
return new PostProcessorSettings (true, false);
} catch (Exception e) {
e.printStackTrace();
}

return null;
}

/**
* Construct a Sell-only Version of <i>PostProcessorSettings</i>
*
* @return Sell-only Version of <i>PostProcessorSettings</i>
*/

public static final PostProcessorSettings SellOnly()
{
try {
return new PostProcessorSettings (false, true);
} catch (Exception e) {
e.printStackTrace();
}

return null;
}

/**
* <i>PostProcessorSettings</i> Constructor
*
Expand Down
Loading

0 comments on commit 6628e94

Please sign in to comment.