Skip to content

Commit e741fe1

Browse files
committed
Removed redundant properties
1 parent 27cf67d commit e741fe1

6 files changed

Lines changed: 8 additions & 46 deletions

File tree

Common/Optimizer/BacktestSummary.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*
1515
*/
1616

17+
using Newtonsoft.Json;
1718
using System.Collections.Generic;
1819

1920
namespace QuantConnect.Optimizer
@@ -24,8 +25,9 @@ namespace QuantConnect.Optimizer
2425
public class BacktestSummary
2526
{
2627
/// <summary>
27-
/// The backtest id.
28+
/// The backtest id; kept for programmatic access but not serialized into the analysis JSON.
2829
/// </summary>
30+
[JsonIgnore]
2931
public string BacktestId { get; set; }
3032

3133
/// <summary>

Common/Optimizer/Cluster.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ namespace QuantConnect.Optimizer
2323
/// </summary>
2424
public class Cluster
2525
{
26-
/// <summary>
27-
/// Cluster index; 0 is the highest mean Sharpe.
28-
/// </summary>
29-
public int Index { get; set; }
30-
3126
/// <summary>
3227
/// Cluster centroid in original parameter units.
3328
/// </summary>

Common/Optimizer/ParameterReport.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ public class ParameterReport
4545
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
4646
public decimal? Step { get; set; }
4747

48-
/// <summary>
49-
/// Number of distinct values this parameter took across completed backtests.
50-
/// </summary>
51-
public int DistinctValueCount { get; set; }
52-
5348
/// <summary>
5449
/// Mean Sharpe range (max - min) across every 1-D slice.
5550
/// </summary>

Common/Optimizer/SliceFit.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,7 @@ public class SliceFit
2929
public IReadOnlyDictionary<string, decimal> FixedParameters { get; set; }
3030

3131
/// <summary>
32-
/// Grid values of the slicing parameter, sorted ascending.
33-
/// </summary>
34-
public IReadOnlyList<decimal> ParameterValues { get; set; }
35-
36-
/// <summary>
37-
/// Sharpe ratio at each entry in <see cref="ParameterValues"/>.
38-
/// </summary>
39-
public IReadOnlyList<decimal> SharpeValues { get; set; }
40-
41-
/// <summary>
42-
/// max(<see cref="SharpeValues"/>) - min(<see cref="SharpeValues"/>) across this slice.
32+
/// Max Sharpe minus min Sharpe across this slice.
4333
/// </summary>
4434
public decimal SharpeRange { get; set; }
4535

@@ -48,11 +38,6 @@ public class SliceFit
4838
/// </summary>
4939
public decimal MaxAbsDerivative { get; set; }
5040

51-
/// <summary>
52-
/// True for the slice whose fixed parameters match the values at the best backtest.
53-
/// </summary>
54-
public bool IsPrimary { get; set; }
55-
5641
/// <summary>
5742
/// Piecewise linear pieces of the fit; one per adjacent pair of grid points.
5843
/// </summary>

Optimizer/Analysis/OptimizationClustering.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public static IReadOnlyList<Cluster> Build(
8888

8989
output.Add(new Cluster
9090
{
91-
Index = c,
9291
Centroid = centroidDict,
9392
MemberCount = memberIndices.Count,
9493
SharpeMean = sharpes.Average(),
@@ -98,13 +97,8 @@ public static IReadOnlyList<Cluster> Build(
9897
});
9998
}
10099

101-
// Re-index so Cluster 0 is the best-performing region.
102-
var ordered = output.OrderByDescending(x => x.SharpeMean).ToList();
103-
for (var i = 0; i < ordered.Count; i++)
104-
{
105-
ordered[i].Index = i;
106-
}
107-
return ordered;
100+
// Order by mean Sharpe descending so the best-performing region is first.
101+
return output.OrderByDescending(x => x.SharpeMean).ToList();
108102
}
109103

110104
private static int SelectKByElbow(Dictionary<int, KMeansResult> results)

Optimizer/Analysis/OptimizationSlicing.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,13 @@ public static ParameterReport AnalyzeParameter(
4949
.Cast<IGrouping<string, OptimizationBacktestMetrics>>()
5050
: owning.GroupBy(b => SliceKey(b, otherParamNames));
5151

52-
var primaryKey = otherParamNames.Count == 0 ? "" : SliceKey(best, otherParamNames);
53-
5452
var slices = new List<SliceFit>();
5553
foreach (var group in grouped)
5654
{
57-
var isPrimary = group.Key == primaryKey;
58-
var slice = BuildSlice(group.ToList(), name, otherParamNames, isPrimary);
55+
var slice = BuildSlice(group.ToList(), name, otherParamNames);
5956
if (slice != null) slices.Add(slice);
6057
}
6158

62-
var distinctValueCount = owning.Select(b => b.Parameters[name]).Distinct().Count();
6359
var hasBest = best.Parameters.TryGetValue(name, out var bestValue);
6460
var (searchedMin, searchedMax, step) = ExtractGridSpec(parameter, owning, name);
6561
var bestAtEdge = hasBest && IsAtSearchedEdge(bestValue, searchedMin, searchedMax, step);
@@ -76,7 +72,6 @@ public static ParameterReport AnalyzeParameter(
7672
SearchedMin = searchedMin,
7773
SearchedMax = searchedMax,
7874
Step = step,
79-
DistinctValueCount = distinctValueCount,
8075
MeanWithinSliceSharpeRange = meanRange,
8176
MaxWithinSliceSharpeRange = maxRange,
8277
MaxAbsDerivativePerStep = maxDerivPerStep,
@@ -89,8 +84,7 @@ public static ParameterReport AnalyzeParameter(
8984
private static SliceFit BuildSlice(
9085
List<OptimizationBacktestMetrics> backtests,
9186
string varyingParamName,
92-
IReadOnlyList<string> otherParamNames,
93-
bool isPrimary)
87+
IReadOnlyList<string> otherParamNames)
9488
{
9589
// Defensively collapse duplicate parameter values by averaging Sharpes.
9690
var points = backtests
@@ -136,11 +130,8 @@ private static SliceFit BuildSlice(
136130
return new SliceFit
137131
{
138132
FixedParameters = fixedParams,
139-
ParameterValues = xs,
140-
SharpeValues = ys,
141133
SharpeRange = sharpeRange,
142134
MaxAbsDerivative = maxAbsDerivative,
143-
IsPrimary = isPrimary,
144135
Segments = segments
145136
};
146137
}

0 commit comments

Comments
 (0)