Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
509 changes: 403 additions & 106 deletions docs/pages/performance.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/a-d/Adl/Adl.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static IReadOnlyList<AdlResult> ToAdl(this IReadOnlyList<IQuote> source)

// initialize
int length = source.Count;
List<AdlResult> results = new(length);
AdlResult[] results = new AdlResult[length];

// roll through source values
for (int i = 0; i < length; i++)
Expand All @@ -30,9 +30,9 @@ public static IReadOnlyList<AdlResult> ToAdl(this IReadOnlyList<IQuote> source)
source[i].Volume,
i > 0 ? results[i - 1].Adl : 0);

results.Add(r);
results[i] = r;
}

return results;
return new List<AdlResult>(results);
}
}
12 changes: 6 additions & 6 deletions src/a-d/Adx/Adx.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static List<AdxResult> CalcAdx(

// initialize
int length = quotes.Count;
List<AdxResult> results = new(length);
AdxResult[] results = new AdxResult[length];

double prevHigh = 0;
double prevLow = 0;
Expand All @@ -60,7 +60,7 @@ private static List<AdxResult> CalcAdx(
prevLow = q.Low;
prevClose = q.Close;

results.Add(new(Timestamp: q.Timestamp));
results[i] = new(Timestamp: q.Timestamp);
continue;
}

Expand Down Expand Up @@ -89,7 +89,7 @@ private static List<AdxResult> CalcAdx(
// skip DM initialization period
if (i < lookbackPeriods)
{
results.Add(new(Timestamp: q.Timestamp));
results[i] = new(Timestamp: q.Timestamp);
continue;
}

Expand Down Expand Up @@ -118,7 +118,7 @@ private static List<AdxResult> CalcAdx(

if (trs == 0)
{
results.Add(new(Timestamp: q.Timestamp));
results[i] = new(Timestamp: q.Timestamp);
continue;
}

Expand Down Expand Up @@ -177,9 +177,9 @@ private static List<AdxResult> CalcAdx(
Adx: adx.NaN2Null(),
Adxr: adxr.NaN2Null());

results.Add(r);
results[i] = r;
}

return results;
return new List<AdxResult>(results);
}
}
8 changes: 4 additions & 4 deletions src/a-d/Alligator/Alligator.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ IReadOnlyList<IReusable> values

// initialize
int length = values.Count;
List<AlligatorResult> results = new(length);
AlligatorResult[] results = new AlligatorResult[length];

// roll through source values
for (int i = 0; i < length; i++)
Expand Down Expand Up @@ -125,13 +125,13 @@ IReadOnlyList<IReusable> values
}

// result
results.Add(new AlligatorResult(
results[i] = new AlligatorResult(
values[i].Timestamp,
jaw.NaN2Null(),
teeth.NaN2Null(),
lips.NaN2Null()));
lips.NaN2Null());
}

return results;
return new List<AlligatorResult>(results);
}
}
10 changes: 5 additions & 5 deletions src/a-d/Alma/Alma.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static IReadOnlyList<AlmaResult> ToAlma(

// initialize
int length = source.Count;
List<AlmaResult> results = new(length);
AlmaResult[] results = new AlmaResult[length];

// determine price weight constants
double m = offset * (lookbackPeriods - 1);
Expand Down Expand Up @@ -62,11 +62,11 @@ public static IReadOnlyList<AlmaResult> ToAlma(
alma = weightedSum / norm;
}

results.Add(
new(Timestamp: source[i].Timestamp,
Alma: alma.NaN2Null()));
results[i] = new(
Timestamp: source[i].Timestamp,
Alma: alma.NaN2Null());
}

return results;
return new List<AlmaResult>(results);
}
}
6 changes: 3 additions & 3 deletions src/a-d/Aroon/Aroon.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static List<AroonResult> CalcAroon(

// initialize
int length = quotes.Count;
List<AroonResult> results = new(length);
AroonResult[] results = new AroonResult[length];

// roll through source values
for (int i = 0; i < length; i++)
Expand Down Expand Up @@ -77,10 +77,10 @@ private static List<AroonResult> CalcAroon(
AroonDown: aroonDown,
Oscillator: aroonUp - aroonDown);

results.Add(r);
results[i] = r;

}

return results;
return new List<AroonResult>(results);
}
}
10 changes: 4 additions & 6 deletions src/a-d/Atr/Atr.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal static List<AtrResult> CalcAtr(

// initialize
int length = quotes.Count;
List<AtrResult> results = new(length);
AtrResult[] results = new AtrResult[length];
double prevAtr = double.NaN;
double prevClose = double.NaN;
double sumTr = 0;
Expand All @@ -43,7 +43,7 @@ internal static List<AtrResult> CalcAtr(
if (length > 0)
{
QuoteD q = quotes[0];
results.Add(new(Timestamp: q.Timestamp));
results[0] = new AtrResult(Timestamp: q.Timestamp);
prevClose = q.Close;
}

Expand Down Expand Up @@ -87,17 +87,15 @@ internal static List<AtrResult> CalcAtr(
atrp = null;
}

AtrResult r = new(
results[i] = new AtrResult(
Timestamp: q.Timestamp,
Tr: tr.NaN2Null(),
Atr: atr.NaN2Null(),
Atrp: atrp);

results.Add(r);

prevClose = q.Close;
}

return results;
return new List<AtrResult>(results);
}
}
8 changes: 4 additions & 4 deletions src/a-d/AtrStop/AtrStop.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static List<AtrStopResult> CalcAtrStop(

// initialize
int length = quotes.Count;
List<AtrStopResult> results = new(length);
AtrStopResult[] results = new AtrStopResult[length];
List<AtrResult> atrResults = quotes.CalcAtr(lookbackPeriods);

// prevailing direction and bands
Expand All @@ -47,7 +47,7 @@ private static List<AtrStopResult> CalcAtrStop(
// handle warmup periods
if (i < lookbackPeriods)
{
results.Add(new(Timestamp: quotes[i].Timestamp));
results[i] = new(Timestamp: quotes[i].Timestamp);
continue;
}

Expand Down Expand Up @@ -123,9 +123,9 @@ private static List<AtrStopResult> CalcAtrStop(
Atr: atr);
}

results.Add(r);
results[i] = r;
}

return results;
return new List<AtrStopResult>(results);
}
}
8 changes: 3 additions & 5 deletions src/a-d/Awesome/Awesome.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ IReadOnlyList<IReusable> values

// initialize
int length = values.Count;
List<AwesomeResult> results = new(length);
AwesomeResult[] results = new AwesomeResult[length];
double[] pr = new double[length];

// roll through source values
Expand Down Expand Up @@ -57,14 +57,12 @@ IReadOnlyList<IReusable> values
normalized = pr[i] != 0 ? 100 * oscillator / pr[i] : null;
}

AwesomeResult r = new(
results[i] = new AwesomeResult(
Timestamp: s.Timestamp,
Oscillator: oscillator,
Normalized: normalized);

results.Add(r);
}

return results;
return new List<AwesomeResult>(results);
}
}
14 changes: 7 additions & 7 deletions src/a-d/Beta/Beta.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static IReadOnlyList<BetaResult> ToBeta(

// initialize
int length = sourceEval.Count;
List<BetaResult> results = new(length);
BetaResult[] results = new BetaResult[length];

bool calcSd = type is BetaType.All or BetaType.Standard;
bool calcUp = type is BetaType.All or BetaType.Up;
Expand Down Expand Up @@ -68,10 +68,10 @@ public static IReadOnlyList<BetaResult> ToBeta(
// skip warmup periods
if (i < lookbackPeriods)
{
results.Add(new(
results[i] = new(
Timestamp: eval.Timestamp,
ReturnsEval: evalReturns[i],
ReturnsMrkt: mrktReturns[i]));
ReturnsMrkt: mrktReturns[i]);

continue;
}
Expand Down Expand Up @@ -108,18 +108,18 @@ public static IReadOnlyList<BetaResult> ToBeta(
convexity = (betaUp - betaDown) * (betaUp - betaDown);
}

results.Add(
new(Timestamp: eval.Timestamp,
results[i] = new(
Timestamp: eval.Timestamp,
Beta: beta,
BetaUp: betaUp,
BetaDown: betaDown,
Ratio: ratio,
Convexity: convexity,
ReturnsEval: evalReturns[i],
ReturnsMrkt: mrktReturns[i]));
ReturnsMrkt: mrktReturns[i]);
}

return results;
return new List<BetaResult>(results);
}

/// <summary>
Expand Down
10 changes: 5 additions & 5 deletions src/a-d/BollingerBands/BollingerBands.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static IReadOnlyList<BollingerBandsResult> ToBollingerBands(

// initialize
int length = source.Count;
List<BollingerBandsResult> results = new(length);
BollingerBandsResult[] results = new BollingerBandsResult[length];

// roll through source values
for (int i = 0; i < length; i++)
Expand All @@ -51,7 +51,7 @@ public static IReadOnlyList<BollingerBandsResult> ToBollingerBands(
double? upperBand = sma + (standardDeviations * stdDev);
double? lowerBand = sma - (standardDeviations * stdDev);

results.Add(new BollingerBandsResult(
results[i] = new BollingerBandsResult(

Timestamp: s.Timestamp,

Expand All @@ -64,16 +64,16 @@ public static IReadOnlyList<BollingerBandsResult> ToBollingerBands(

ZScore: stdDev == 0 ? null : (s.Value - sma) / stdDev,
Width: sma == 0 ? null : (upperBand - lowerBand) / sma
));
);
}

// initization period
else
{
results.Add(new(s.Timestamp));
results[i] = new(s.Timestamp);
}
}

return results;
return new List<BollingerBandsResult>(results);
}
}
8 changes: 4 additions & 4 deletions src/a-d/Bop/Bop.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static List<BopResult> CalcBop(

// initialize
int length = quotes.Count;
List<BopResult> results = new(length);
BopResult[] results = new BopResult[length];

double[] raw = quotes
.Select(static x => x.High - x.Low != 0 ?
Expand All @@ -56,11 +56,11 @@ private static List<BopResult> CalcBop(
bop = sum / smoothPeriods;
}

results.Add(new(
results[i] = new BopResult(
Timestamp: quotes[i].Timestamp,
Bop: bop.NaN2Null()));
Bop: bop.NaN2Null());
}

return results;
return new List<BopResult>(results);
}
}
8 changes: 4 additions & 4 deletions src/a-d/Cci/Cci.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static List<CciResult> CalcCci(

// initialize
int length = quotes.Count;
List<CciResult> results = new(length);
CciResult[] results = new CciResult[length];
double[] tp = new double[length];

// roll through source values
Expand Down Expand Up @@ -68,11 +68,11 @@ private static List<CciResult> CalcCci(
: ((tp[i] - avgTp) / (0.015 * avgDv)).NaN2Null();
}

results.Add(new(
results[i] = new(
Timestamp: q.Timestamp,
Cci: cci));
Cci: cci);
}

return results;
return new List<CciResult>(results);
}
}
8 changes: 4 additions & 4 deletions src/a-d/ChaikinOsc/ChaikinOsc.StaticSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static IReadOnlyList<ChaikinOscResult> ToChaikinOsc(

// initialize
int length = quotes.Count;
List<ChaikinOscResult> results = new(length);
ChaikinOscResult[] results = new ChaikinOscResult[length];

// money flow
IReadOnlyList<AdlResult> adlResults = quotes.ToAdl();
Expand All @@ -39,17 +39,17 @@ public static IReadOnlyList<ChaikinOscResult> ToChaikinOsc(
EmaResult f = adlEmaFast[i];
EmaResult s = adlEmaSlow[i];

results.Add(new(
results[i] = new(
Timestamp: a.Timestamp,
MoneyFlowMultiplier: a.MoneyFlowMultiplier,
MoneyFlowVolume: a.MoneyFlowVolume,
Adl: a.Adl,
Oscillator: f.Ema - s.Ema,
FastEma: f.Ema,
SlowEma: s.Ema
));
);
}

return results;
return new List<ChaikinOscResult>(results);
}
}
Loading
Loading