Skip to content

Commit

Permalink
chore: Merge from base (#1181)
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Skender <[email protected]>
  • Loading branch information
DaveSkender authored Mar 24, 2024
1 parent 7c10580 commit cfac956
Show file tree
Hide file tree
Showing 52 changed files with 130 additions and 211 deletions.
20 changes: 19 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ dotnet_style_object_initializer = true:suggestion
dotnet_style_prefer_collection_expression = true:suggestion

[*.cs]
# ref: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/csharp-formatting-options

csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:warning
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_static_local_function = true:suggestion
csharp_prefer_braces = true:suggestion

csharp_style_namespace_declarations = file_scoped:suggestion
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
Expand All @@ -117,6 +119,22 @@ csharp_style_prefer_not_pattern = true:suggestion
csharp_style_prefer_extended_property_pattern = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion

# braces
csharp_prefer_braces = true:suggestion

csharp_new_line_before_open_brace = methods, properties, control_blocks, types
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_members_in_anonymous_types = false
csharp_new_line_between_query_expression_clauses = false

# braces overrides
csharp_type_declaration_braces = next_line
csharp_empty_block_style = together_same_line

# diagnostic analyzers
dotnet_diagnostic.CA1303.severity = none
dotnet_diagnostic.CS1591.severity = silent
dotnet_diagnostic.IDE0058.severity = none
2 changes: 1 addition & 1 deletion .github/workflows/test-performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on: [workflow_dispatch]

jobs:
analyze:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:

Expand Down
16 changes: 7 additions & 9 deletions docs/GemFile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GEM
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.2.0)
bigdecimal (3.1.6)
bigdecimal (3.1.7)
coffee-script (2.4.1)
coffee-script-source
execjs
Expand All @@ -31,10 +31,9 @@ GEM
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
cssminify2 (2.0.1)
dnsruby (1.70.0)
dnsruby (1.71.0)
simpleidn (~> 0.2.1)
drb (2.2.0)
ruby2_keywords
drb (2.2.1)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
Expand Down Expand Up @@ -107,7 +106,7 @@ GEM
nokogiri (>= 1.4)
htmlcompressor (0.4.0)
http_parser.rb (0.8.0)
i18n (1.14.1)
i18n (1.14.4)
concurrent-ruby (~> 1.0)
jekyll (3.9.5)
addressable (~> 2.4)
Expand Down Expand Up @@ -242,13 +241,13 @@ GEM
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.22.2)
minitest (5.22.3)
mutex_m (0.2.0)
net-http (0.4.1)
uri
nokogiri (1.16.2-x64-mingw-ucrt)
nokogiri (1.16.3-x64-mingw-ucrt)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-linux)
nokogiri (1.16.3-x86_64-linux)
racc (~> 1.4)
octokit (4.25.1)
faraday (>= 1, < 3)
Expand All @@ -263,7 +262,6 @@ GEM
ffi (~> 1.0)
rexml (3.2.6)
rouge (3.30.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
safe_yaml (1.0.5)
sass (3.7.4)
Expand Down
6 changes: 2 additions & 4 deletions src/_common/Candles/Candles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ public static IEnumerable<CandleResult> Condense(

public static CandleProperties ToCandle<TQuote>(
this TQuote quote)
where TQuote : IQuote => new()
{
where TQuote : IQuote => new() {
Timestamp = quote.Timestamp,
Open = quote.Open,
High = quote.High,
Expand Down Expand Up @@ -45,8 +44,7 @@ internal static List<CandleResult> ToCandleResults<TQuote>(
.. quotes
.Select(x => new CandleResult(
x.Timestamp,
Match.None)
{
Match.None) {
Candle = x.ToCandle()
})
.OrderBy(x => x.Timestamp)
Expand Down
3 changes: 1 addition & 2 deletions src/_common/Math/Numerix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ internal static DateTime RoundDown(this DateTime dateTime, TimeSpan interval)

// PERIOD-SIZE to TIMESPAN CONVERSION
internal static TimeSpan ToTimeSpan(this PeriodSize periodSize)
=> periodSize switch
{
=> periodSize switch {
PeriodSize.OneMinute => TimeSpan.FromMinutes(1),
PeriodSize.TwoMinutes => TimeSpan.FromMinutes(2),
PeriodSize.ThreeMinutes => TimeSpan.FromMinutes(3),
Expand Down
6 changes: 2 additions & 4 deletions src/_common/Quotes/Quote.Aggregates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public static IEnumerable<Quote> Aggregate<TQuote>(
return quotes
.OrderBy(x => x.Timestamp)
.GroupBy(x => new DateTime(x.Timestamp.Year, x.Timestamp.Month, 1))
.Select(x => new Quote
{
.Select(x => new Quote {
Timestamp = x.Key,
Open = x.First().Open,
High = x.Max(t => t.High),
Expand Down Expand Up @@ -55,8 +54,7 @@ public static IEnumerable<Quote> Aggregate<TQuote>(
return quotes
.OrderBy(x => x.Timestamp)
.GroupBy(x => x.Timestamp.RoundDown(timeSpan))
.Select(x => new Quote
{
.Select(x => new Quote {
Timestamp = x.Key,
Open = x.First().Open,
High = x.Max(t => t.High),
Expand Down
15 changes: 5 additions & 10 deletions src/_common/Quotes/Quote.Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public static partial class QuoteUtility
// convert to quotes in double precision
internal static QuoteD ToQuoteD<TQuote>(
this TQuote quote)
where TQuote : IQuote => new()
{
where TQuote : IQuote => new() {
Timestamp = quote.Timestamp,
Open = (double)quote.Open,
High = (double)quote.High,
Expand All @@ -57,8 +56,7 @@ internal static QuoteD ToQuoteD<TQuote>(
internal static List<QuoteD> ToQuoteD<TQuote>(
this IEnumerable<TQuote> quotes)
where TQuote : IQuote => [.. quotes
.Select(x => new QuoteD
{
.Select(x => new QuoteD {
Timestamp = x.Timestamp,
Open = (double)x.Open,
High = (double)x.High,
Expand All @@ -82,8 +80,7 @@ internal static List<QuoteD> ToQuoteD<TQuote>(
internal static (DateTime date, double value) ToTuple<TQuote>(
this TQuote q,
CandlePart candlePart)
where TQuote : IQuote => candlePart switch
{
where TQuote : IQuote => candlePart switch {
CandlePart.Open => (q.Timestamp, (double)q.Open),
CandlePart.High => (q.Timestamp, (double)q.High),
CandlePart.Low => (q.Timestamp, (double)q.Low),
Expand All @@ -101,8 +98,7 @@ internal static (DateTime date, double value) ToTuple<TQuote>(
internal static BasicResult ToBasicData<TQuote>(
this TQuote q,
CandlePart candlePart)
where TQuote : IQuote => candlePart switch
{
where TQuote : IQuote => candlePart switch {
CandlePart.Open => new BasicResult { Timestamp = q.Timestamp, Value = (double)q.Open },
CandlePart.High => new BasicResult { Timestamp = q.Timestamp, Value = (double)q.High },
CandlePart.Low => new BasicResult { Timestamp = q.Timestamp, Value = (double)q.Low },
Expand All @@ -119,8 +115,7 @@ internal static BasicResult ToBasicData<TQuote>(
// convert quoteD element to basic tuple
internal static (DateTime, double) ToTuple(
this QuoteD q,
CandlePart candlePart) => candlePart switch
{
CandlePart candlePart) => candlePart switch {
CandlePart.Open => (q.Timestamp, q.Open),
CandlePart.High => (q.Timestamp, q.High),
CandlePart.Low => (q.Timestamp, q.Low),
Expand Down
3 changes: 1 addition & 2 deletions src/a-d/Adl/Adl.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public static AdlResult Increment(
double mfv = mfm * volume;
double adl = mfv + prevAdl;

return new AdlResult
{
return new AdlResult {
Timestamp = DateTime.MinValue,
MoneyFlowMultiplier = mfm,
MoneyFlowVolume = mfv,
Expand Down
2 changes: 1 addition & 1 deletion src/a-d/Adl/Adl.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ internal static List<AdlResult> CalcAdl(

return results;
}
}
}
2 changes: 1 addition & 1 deletion src/a-d/Adx/Adx.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,4 @@ internal static List<AdxResult> CalcAdx(

return results;
}
}
}
3 changes: 1 addition & 2 deletions src/a-d/Alligator/Alligator.Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ public override void OnNext((Act act, DateTime date, double price) value)
}

// candidate result
AlligatorResult r = new()
{
AlligatorResult r = new() {
Timestamp = value.date,
Jaw = jaw.NaN2Null(),
Lips = lips.NaN2Null(),
Expand Down
3 changes: 1 addition & 2 deletions src/a-d/Beta/Beta.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ internal static List<BetaResult> CalcBeta(
{
(DateTime date, double _) = tpListEval[i];

BetaResult r = new()
{
BetaResult r = new() {
Timestamp = date,
ReturnsEval = evalReturns[i],
ReturnsMrkt = mrktReturns[i]
Expand Down
3 changes: 1 addition & 2 deletions src/a-d/ChaikinOsc/ChaikinOsc.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ internal static List<ChaikinOscResult> CalcChaikinOsc(

// money flow
List<ChaikinOscResult> results = qdList.CalcAdl()
.Select(r => new ChaikinOscResult
{
.Select(r => new ChaikinOscResult {
Timestamp = r.Timestamp,
MoneyFlowMultiplier = r.MoneyFlowMultiplier,
MoneyFlowVolume = r.MoneyFlowVolume,
Expand Down
3 changes: 1 addition & 2 deletions src/a-d/Cmf/Cmf.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ internal static List<CmfResult> CalcCmf(
{
AdlResult adl = adlResults[i];

CmfResult r = new()
{
CmfResult r = new() {
Timestamp = adl.Timestamp,
MoneyFlowMultiplier = adl.MoneyFlowMultiplier,
MoneyFlowVolume = adl.MoneyFlowVolume
Expand Down
3 changes: 1 addition & 2 deletions src/a-d/ConnorsRsi/ConnorsRsi.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ private static List<ConnorsRsiResult> CalcStreak(
{
(DateTime date, double price) = tpList[i];

ConnorsRsiResult r = new()
{
ConnorsRsiResult r = new() {
Timestamp = date,
Rsi = rsiResults[i].Rsi
};
Expand Down
3 changes: 1 addition & 2 deletions src/e-k/ElderRay/ElderRay.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ internal static List<ElderRayResult> CalcElderRay(
List<ElderRayResult> results = qdList
.ToTuple(CandlePart.Close)
.CalcEma(lookbackPeriods)
.Select(x => new ElderRayResult
{
.Select(x => new ElderRayResult {
Timestamp = x.Timestamp,
Ema = x.Ema
})
Expand Down
3 changes: 1 addition & 2 deletions src/e-k/Ema/Ema.Stream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ public override void OnNext((Act act, DateTime date, double price) value)
}

// candidate result
EmaResult r = new()
{
EmaResult r = new() {
Timestamp = value.date,
Ema = ema.NaN2Null()
};
Expand Down
3 changes: 1 addition & 2 deletions src/e-k/Epma/Epma.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ internal static List<EpmaResult> CalcEpma(
{
SlopeResult s = slopeResults[i];

EpmaResult r = new()
{
EpmaResult r = new() {
Timestamp = s.Timestamp,
Epma = ((s.Slope * (i + 1)) + s.Intercept).NaN2Null()
};
Expand Down
3 changes: 1 addition & 2 deletions src/e-k/Gator/Gator.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ internal static List<GatorResult> CalcGator(
this List<AlligatorResult> alligator)
{
List<GatorResult> results = alligator
.Select(x => new GatorResult
{
.Select(x => new GatorResult {
Timestamp = x.Timestamp,
Upper = NullMath.Abs(x.Jaw - x.Teeth),
Lower = -NullMath.Abs(x.Teeth - x.Lips)
Expand Down
3 changes: 1 addition & 2 deletions src/e-k/HeikinAshi/HeikinAshi.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ internal static List<HeikinAshiResult> CalcHeikinAshi<TQuote>(
decimal[] arrL = [q.Low, open, close];
decimal low = arrL.Min();

HeikinAshiResult r = new()
{
HeikinAshiResult r = new() {
Timestamp = q.Timestamp,
Open = open,
High = high,
Expand Down
3 changes: 1 addition & 2 deletions src/e-k/HeikinAshi/HeikinAshi.Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ public static partial class Indicator
public static IEnumerable<Quote> ToQuotes(
this IEnumerable<HeikinAshiResult> results)
=> results
.Select(x => new Quote
{
.Select(x => new Quote {
Timestamp = x.Timestamp,
Open = x.Open,
High = x.High,
Expand Down
3 changes: 1 addition & 2 deletions src/e-k/Hma/Hma.Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ internal static List<HmaResult> CalcHma(

// calculate final HMA = WMA with period SQRT(n)
List<HmaResult> hmaResults = synthHistory.CalcWma(sqN)
.Select(x => new HmaResult
{
.Select(x => new HmaResult {
Timestamp = x.Timestamp,
Hma = x.Wma
})
Expand Down
Loading

0 comments on commit cfac956

Please sign in to comment.