Class EqualWeightOptimizer
- Namespace
- Balsam.Optimization
- Assembly
- Balsam.Backtester.dll
Static methods for combining equal-weight return streams to maximize Sharpe Ratio.
public static class EqualWeightOptimizer
- Inheritance
-
EqualWeightOptimizer
- Inherited Members
Methods
CalculateSharpe(TimeSeriesCollection, params int[])
Calculates the Sharpe Ratio using the specified indexes in the TimeSeriesCollection.
public static double CalculateSharpe(TimeSeriesCollection tsc, params int[] indexes)
Parameters
tsc
TimeSeriesCollectionindexes
int[]
Returns
CalculateSharpe(TimeSeriesCollection, int[], double[])
Calculates the Sharpe Ratio using the specified indexes and weights.
public static double CalculateSharpe(TimeSeriesCollection tsc, int[] indexes, double[] weights)
Parameters
tsc
TimeSeriesCollectionindexes
int[]weights
double[]
Returns
Exceptions
CalculateSharpe(TradeStatsCollection, params int[])
Calculates the Sharpe Ratio using the specified indexes in the TradeStatsCollection.
public static double CalculateSharpe(TradeStatsCollection tsc, params int[] indexes)
Parameters
tsc
TradeStatsCollectionindexes
int[]
Returns
CalculateSharpe(TradeStatsCollection, int[], double[])
Calculates the Sharpe Ratio using the specified indexes and weights.
public static double CalculateSharpe(TradeStatsCollection tsc, int[] indexes, double[] weights)
Parameters
tsc
TradeStatsCollectionindexes
int[]weights
double[]
Returns
MARRatio(Vector<double>)
Returns the MAR Ratio for the specified vector of returns.
public static double MARRatio(Vector<double> vector)
Parameters
vector
Vector<double>
Returns
RunBottomUp(TimeSeriesCollection, StrategyConstraints)
Returns the indexes from the specified TimeSeriesCollection that returns the highest equal-weight Sharpe subject to the specified strategy constraints.
public static int[] RunBottomUp(TimeSeriesCollection tsc, EqualWeightOptimizer.StrategyConstraints constraints)
Parameters
tsc
TimeSeriesCollectionconstraints
EqualWeightOptimizer.StrategyConstraints
Returns
- int[]
Exceptions
RunBottomUp(TimeSeriesCollection, StrategyConstraints, Func<Vector<double>, double>, int?)
Returns the indexes from the specified TimeSeriesCollection that returns the highest objective function subject to constraints, if any.
public static int[] RunBottomUp(TimeSeriesCollection tsc, EqualWeightOptimizer.StrategyConstraints constraints, Func<Vector<double>, double> objectiveFunction, int? startingIndex = null)
Parameters
tsc
TimeSeriesCollectionconstraints
EqualWeightOptimizer.StrategyConstraintsobjectiveFunction
Func<Vector<double>, double>startingIndex
int?
Returns
- int[]
Exceptions
RunBottomUp(TimeSeriesCollection, int, int)
Returns the indexes from the specified TimeSeriesCollection that returns the highest equal-weight Sharpe.
public static int[] RunBottomUp(TimeSeriesCollection tsc, int minHoldings = 1, int maxHoldings = 2147483647)
Parameters
tsc
TimeSeriesCollectionminHoldings
intmaxHoldings
int
Returns
- int[]
Index of selected holdings
RunBottomUp(TradeStatsCollection, StrategyConstraints)
Returns the indexes from the specified TradeStatsCollection that forms the highest equal-weight Sharpe portolio subject to the specified constraints
public static int[] RunBottomUp(TradeStatsCollection tsc, EqualWeightOptimizer.StrategyConstraints constraints)
Parameters
tsc
TradeStatsCollectionconstraints
EqualWeightOptimizer.StrategyConstraints
Returns
- int[]
Exceptions
RunBottomUp(TradeStatsCollection, StrategyConstraints, Func<Vector<double>, double>, int?)
Returns the indexes from the specified TradeStatsCollection that returns the highest objective function subject to constraints, if any.
public static int[] RunBottomUp(TradeStatsCollection tsc, EqualWeightOptimizer.StrategyConstraints constraints, Func<Vector<double>, double> objectiveFunction, int? startingIndex = null)
Parameters
tsc
TradeStatsCollectionconstraints
EqualWeightOptimizer.StrategyConstraintsobjectiveFunction
Func<Vector<double>, double>startingIndex
int?
Returns
- int[]
Exceptions
RunBottomUp(TradeStatsCollection, int, int)
Returns the indexes from the specified TradeStatsCollection that returns the highest equal-weight Sharpe subject to optional max holdings constraint.
public static int[] RunBottomUp(TradeStatsCollection tsc, int minHoldings = 1, int maxHoldings = 2147483647)
Parameters
tsc
TradeStatsCollectionminHoldings
intmaxHoldings
int
Returns
- int[]
RunCombinations(TimeSeriesCollection, int, int)
Runs random portfolio iterations to find the max Sharpe.
public static (int[], double[]) RunCombinations(TimeSeriesCollection tsc, int holdings, int iterations)
Parameters
tsc
TimeSeriesCollectionholdings
intiterations
int
Returns
RunCombinations(TradeStatsCollection, int, int)
Runs random portfolio iterations to find the max Sharpe.
public static (int[], double[]) RunCombinations(TradeStatsCollection tsc, int holdings, int iterations)
Parameters
tsc
TradeStatsCollectionholdings
intiterations
int
Returns
RunTopDown(TimeSeriesCollection, int, int)
Returns the indexes from the specified TimeSeriesCollection that returns the highest equal-weight Sharpe subject to optional min holdings constraint.
public static int[] RunTopDown(TimeSeriesCollection tsc, int minHoldings = 1, int maxHoldings = 2147483647)
Parameters
tsc
TimeSeriesCollectionminHoldings
intmaxHoldings
int
Returns
- int[]
RunTopDown(TradeStatsCollection, int, int)
Returns the indexes from the specified TradeStatsCollection that returns the highest equal-weight Sharpe subject to optional min holdings constraint.
public static int[] RunTopDown(TradeStatsCollection tsc, int minHoldings = 1, int maxHoldings = 2147483647)
Parameters
tsc
TradeStatsCollectionminHoldings
intmaxHoldings
int
Returns
- int[]
SharpeRatio(Vector<double>)
Returns the arithmetic Sharpe Ratio for the specified vector of returns.
public static double SharpeRatio(Vector<double> vector)
Parameters
vector
Vector<double>
Returns
UlcerPerformanceIndex(Vector<double>)
Returns the Ulcer Performance Index for the specified vector of returns.
public static double UlcerPerformanceIndex(Vector<double> vector)
Parameters
vector
Vector<double>