Table of Contents

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 TimeSeriesCollection
indexes int[]

Returns

double

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 TimeSeriesCollection
indexes int[]
weights double[]

Returns

double

Exceptions

InvalidOperationException

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 TradeStatsCollection
indexes int[]

Returns

double

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 TradeStatsCollection
indexes int[]
weights double[]

Returns

double

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

double

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 TimeSeriesCollection
constraints EqualWeightOptimizer.StrategyConstraints

Returns

int[]

Exceptions

ArgumentNullException
InvalidOperationException

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 TimeSeriesCollection
constraints EqualWeightOptimizer.StrategyConstraints
objectiveFunction Func<Vector<double>, double>
startingIndex int?

Returns

int[]

Exceptions

ArgumentNullException
InvalidOperationException

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 TimeSeriesCollection
minHoldings int
maxHoldings 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 TradeStatsCollection
constraints EqualWeightOptimizer.StrategyConstraints

Returns

int[]

Exceptions

ArgumentNullException

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 TradeStatsCollection
constraints EqualWeightOptimizer.StrategyConstraints
objectiveFunction Func<Vector<double>, double>
startingIndex int?

Returns

int[]

Exceptions

ArgumentNullException

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 TradeStatsCollection
minHoldings int
maxHoldings 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 TimeSeriesCollection
holdings int
iterations int

Returns

(int[], double[])

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 TradeStatsCollection
holdings int
iterations int

Returns

(int[], double[])

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 TimeSeriesCollection
minHoldings int
maxHoldings 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 TradeStatsCollection
minHoldings int
maxHoldings 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

double

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>

Returns

double