Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Naming standardization #1273

Merged
merged 30 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bd696c0
refactor: use `IndexOf` instead of `GetIndex`
DaveSkender Nov 11, 2024
53f869d
rename test file
DaveSkender Nov 12, 2024
6deee05
Merge branch 'v3' into v3-refactor-naming
DaveSkender Nov 16, 2024
18dccd0
drop unneeded signing
DaveSkender Nov 16, 2024
26af67b
add static indicator aliases
DaveSkender Nov 18, 2024
443cacb
fix: Private init AdxList prop
DaveSkender Nov 21, 2024
440fc5b
refactor: reorg simulation project
DaveSkender Nov 25, 2024
97b4345
Merge branch 'v3-refactor-naming' of https://github.com/DaveSkender/S…
DaveSkender Nov 25, 2024
bcc2e11
Merge branch 'v3' into v3-refactor-naming
DaveSkender Nov 27, 2024
5ae4793
Delete tests/external/application/_testdata directory
DaveSkender Nov 28, 2024
b947280
fix misc v2.x references
DaveSkender Nov 28, 2024
2a515a6
Merge branch 'v3-refactor-naming' of https://github.com/DaveSkender/S…
DaveSkender Nov 28, 2024
3dd0189
initial batch of all time-series indicators
DaveSkender Nov 28, 2024
b609e49
Add `[Obsolete]` attribute to `Quote` class's `Date` property
DaveSkender Nov 29, 2024
bd901fa
update Date obsolete note
DaveSkender Nov 29, 2024
61f692e
Merge branch 'v3-refactor-naming' of https://github.com/DaveSkender/S…
DaveSkender Nov 29, 2024
454825f
remove superfluous obsoletion tests
DaveSkender Nov 29, 2024
bd8b001
Merge branch 'v3' into v3-refactor-naming
DaveSkender Nov 29, 2024
0882f61
code cleanup
DaveSkender Nov 29, 2024
2d74f1f
simplify sim proj data file refs
DaveSkender Nov 29, 2024
a40d178
move obsolete indicator items together
DaveSkender Nov 29, 2024
3d2a78c
Merge branch 'v3' into v3-refactor-naming
DaveSkender Nov 29, 2024
5de8276
add tuples-based indicators to runner app
DaveSkender Nov 30, 2024
972898f
Merge branch 'v3-refactor-naming' of https://github.com/DaveSkender/S…
DaveSkender Nov 30, 2024
73c6c90
add utility migration scenarios
DaveSkender Dec 1, 2024
bcb070d
add missing cases to test application
DaveSkender Dec 1, 2024
e4a7064
add [obsolete] attributes to tuple-based indicators
DaveSkender Dec 1, 2024
453f3f3
add obolete utility migrations
DaveSkender Dec 1, 2024
d2679ba
Update v3 migration guide in `ObsoleteV3.md`
DaveSkender Dec 1, 2024
4bfda9a
tweaks to migration guide
DaveSkender Dec 1, 2024
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
12 changes: 6 additions & 6 deletions src/_common/Observables/StreamHub.Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal static bool TryFindIndex<T>(
out int index)
where T : ISeries
{
index = cache.GetIndex(timestamp, false);
index = cache.IndexOf(timestamp, false);
return index != -1;
}

Expand All @@ -32,7 +32,7 @@ internal static bool TryFindIndex<T>(
/// <param name="throwOnFail">Throw exception when item is not found.</param>
/// <returns>Index position.</returns>
/// <exception cref="ArgumentException">When item is not found (should never happen).</exception>
internal static int GetIndex<T>(
internal static int IndexOf<T>(
this IReadOnlyList<T> cache,
T cachedItem,
bool throwOnFail)
Expand Down Expand Up @@ -105,15 +105,15 @@ internal static int GetIndex<T>(
/// <remarks>
/// Only use this when you are looking for a point in time
/// without a matching item for context. In most cases
/// <see cref="GetIndex{T}(IReadOnlyList{T},T,bool)"/> is more appropriate.
/// <see cref="IndexOf{T}(IReadOnlyList{T},T,bool)"/> is more appropriate.
/// </remarks>
/// <typeparam name="T">Type of the items in the cache, must implement ISeries.</typeparam>
/// <param name="cache">The cache to search.</param>
/// <param name="timestamp">Timestamp of cached item.</param>
/// <param name="throwOnFail">Throw exception when timestamp is not found.</param>
/// <returns>Index position.</returns>
/// <exception cref="ArgumentException">When timestamp is not found (should never happen).</exception>
internal static int GetIndex<T>(
internal static int IndexOf<T>(
this IReadOnlyList<T> cache,
DateTime timestamp,
bool throwOnFail)
Expand Down Expand Up @@ -154,13 +154,13 @@ internal static int GetIndex<T>(
/// <remarks>
/// Only use this when you are looking for a point in time
/// without a matching item for context. In most cases
/// <see cref="GetIndex{T}(IReadOnlyList{T},T,bool)"/> is more appropriate.
/// <see cref="IndexOf{T}(IReadOnlyList{T},T,bool)"/> is more appropriate.
/// </remarks>
/// <typeparam name="T">Type of the items in the cache, must implement ISeries.</typeparam>
/// <param name="cache">The cache to search.</param>
/// <param name="timestamp">Timestamp of cached item.</param>
/// <returns>First index position or -1 if not found.</returns>
internal static int GetIndexGte<T>(
internal static int IndexGte<T>(
this IReadOnlyList<T> cache,
DateTime timestamp)
where T : ISeries
Expand Down
2 changes: 1 addition & 1 deletion src/_common/Observables/StreamHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ public void Rebuild(DateTime fromTimestamp)
RemoveRange(fromTimestamp, notify: false);

// get provider position
int provIndex = ProviderCache.GetIndexGte(fromTimestamp);
int provIndex = ProviderCache.IndexGte(fromTimestamp);

// rebuild
if (provIndex >= 0)
Expand Down
2 changes: 1 addition & 1 deletion src/_common/Quotes/Quote.StreamHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected override (TQuote result, int index)
ToIndicator(TQuote item, int? indexHint)
{
int index = indexHint
?? Cache.GetIndexGte(item.Timestamp);
?? Cache.IndexGte(item.Timestamp);

return (item, index == -1 ? Cache.Count : index);
}
Expand Down
2 changes: 1 addition & 1 deletion src/a-d/Adl/Adl.StreamHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal AdlHub(IQuoteProvider<TIn> provider)
protected override (AdlResult result, int index)
ToIndicator(TIn item, int? indexHint)
{
int i = indexHint ?? ProviderCache.GetIndex(item, true);
int i = indexHint ?? ProviderCache.IndexOf(item, true);

// candidate result
AdlResult r = Adl.Increment(
Expand Down
2 changes: 1 addition & 1 deletion src/a-d/Alligator/Alligator.StreamHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected override (AlligatorResult result, int index)
double lips = double.NaN;
double teeth = double.NaN;

int i = indexHint ?? ProviderCache.GetIndex(item, true);
int i = indexHint ?? ProviderCache.IndexOf(item, true);

// calculate alligator's jaw, when in range
if (i >= JawPeriods + JawOffset - 1)
Expand Down
2 changes: 1 addition & 1 deletion src/a-d/Atr/Atr.StreamHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ internal AtrHub(IQuoteProvider<TIn> provider,
protected override (AtrResult result, int index)
ToIndicator(TIn item, int? indexHint)
{
int i = indexHint ?? ProviderCache.GetIndex(item, true);
int i = indexHint ?? ProviderCache.IndexOf(item, true);

// skip incalculable periods
if (i == 0)
Expand Down
4 changes: 2 additions & 2 deletions src/a-d/AtrStop/AtrStop.StreamHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected override (AtrStopResult result, int index)
{
// reminder: should only process "new" instructions

int i = indexHint ?? ProviderCache.GetIndex(item, true);
int i = indexHint ?? ProviderCache.IndexOf(item, true);

// handle warmup periods
if (i < LookbackPeriods)
Expand Down Expand Up @@ -232,7 +232,7 @@ protected override (AtrStopResult result, int index)
/// <inheritdoc/>
protected override void RollbackState(DateTime timestamp)
{
int i = ProviderCache.GetIndexGte(timestamp);
int i = ProviderCache.IndexGte(timestamp);

// restore prior stop point
if (i > LookbackPeriods)
Expand Down
2 changes: 1 addition & 1 deletion src/e-k/Ema/Ema.StreamHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal EmaHub(
protected override (EmaResult result, int index)
ToIndicator(TIn item, int? indexHint)
{
int i = indexHint ?? ProviderCache.GetIndex(item, true);
int i = indexHint ?? ProviderCache.IndexOf(item, true);

double ema = i >= LookbackPeriods - 1
? Cache[i - 1].Ema is not null
Expand Down
2 changes: 1 addition & 1 deletion src/m-r/Renko/Renko.StreamHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ int newBrickQty
decimal sumV = 0; // cumulative

// by aggregating provider cache range
int lastBrickIndex = ProviderCache.GetIndex(lastBrick.Timestamp, true);
int lastBrickIndex = ProviderCache.IndexOf(lastBrick.Timestamp, true);

for (int w = lastBrickIndex + 1; w <= providerIndex; w++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/s-z/Sma/Sma.StreamHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal SmaHub(
protected override (SmaResult result, int index)
ToIndicator(TIn item, int? indexHint)
{
int i = indexHint ?? ProviderCache.GetIndex(item, true);
int i = indexHint ?? ProviderCache.IndexOf(item, true);

// candidate result
SmaResult r = new(
Expand Down
2 changes: 1 addition & 1 deletion src/s-z/Tr/Tr.StreamHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ internal TrHub(IQuoteProvider<TIn> provider)
protected override (TrResult result, int index)
ToIndicator(TIn item, int? indexHint)
{
int i = indexHint ?? ProviderCache.GetIndex(item, true);
int i = indexHint ?? ProviderCache.IndexOf(item, true);

// skip first period
if (i == 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public void GetIndex()
// find position of quote
Quote q = quotesList[4];

int itemIndexEx = provider.Cache.GetIndex(q, true);
int timeIndexEx = provider.Cache.GetIndex(q.Timestamp, true);
int itemIndexEx = provider.Cache.IndexOf(q, true);
int timeIndexEx = provider.Cache.IndexOf(q.Timestamp, true);

// assert: same index
itemIndexEx.Should().Be(4);
Expand All @@ -121,22 +121,22 @@ public void GetIndex()
Quote o = Quotes[10];

Assert.ThrowsException<ArgumentException>(() => {
provider.Cache.GetIndex(o, true);
provider.Cache.IndexOf(o, true);
});

Assert.ThrowsException<ArgumentException>(() => {
provider.Cache.GetIndex(o.Timestamp, true);
provider.Cache.IndexOf(o.Timestamp, true);
});

// out of range (no exceptions)
int itemIndexNo = provider.Cache.GetIndex(o, false);
int timeIndexNo = provider.Cache.GetIndex(o.Timestamp, false);
int itemIndexNo = provider.Cache.IndexOf(o, false);
int timeIndexNo = provider.Cache.IndexOf(o.Timestamp, false);

itemIndexNo.Should().Be(-1);
timeIndexNo.Should().Be(-1);

int timeInsertOut = provider.Cache.GetIndexGte(o.Timestamp);
int timeInsertIn = provider.Cache.GetIndexGte(quotesList[2].Timestamp);
int timeInsertOut = provider.Cache.IndexGte(o.Timestamp);
int timeInsertIn = provider.Cache.IndexGte(quotesList[2].Timestamp);

timeInsertOut.Should().Be(-1);
timeInsertIn.Should().Be(2);
Expand Down