Skip to content

Commit c729208

Browse files
author
Ariel Silahian
committed
TriggerEngine: Refactor metric key granularity and clean up usings
Updated metric key to include exchange and symbol for finer granularity in TriggerEngineService. Adjusted metric processing logic to handle four-part keys. Removed unnecessary using statements from TimeWindow.cs, TriggerRule.cs, and TriggerEngineService.cs for improved clarity.
1 parent 164377d commit c729208

3 files changed

Lines changed: 5 additions & 25 deletions

File tree

TriggerEngine/TimeWindow.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace VisualHFT.TriggerEngine
1+
namespace VisualHFT.TriggerEngine
82
{
93
/// <summary>
104
/// Optional time-based window for smoothing or sustained condition detection.

TriggerEngine/TriggerEngineService.cs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
using Newtonsoft.Json;
2-
using Newtonsoft.Json.Linq;
32
using System;
43
using System.Collections.Concurrent;
54
using System.Collections.Generic;
65
using System.IO;
76
using System.Linq;
8-
using System.Reactive;
9-
using System.Text;
107
using System.Threading;
118
using System.Threading.Channels;
129
using System.Threading.Tasks;
13-
using System.Windows.Media;
14-
using System.Xml.Linq;
1510
using VisualHFT.Commons.Helpers;
16-
using VisualHFT.Helpers;
17-
using VisualHFT.ViewModel;
18-
using VisualHFT.ViewModels;
19-
using Windows.Storage;
2011

2112
namespace VisualHFT.TriggerEngine
2213
{
@@ -163,7 +154,7 @@ public static async Task StartBackgroundWorkerAsync(CancellationToken token)
163154

164155
private static void ProcessMetric(MetricEvent e)
165156
{
166-
string metricKey = $"{e.Plugin}.{e.Metric}";
157+
string metricKey = $"{e.Plugin}.{e.Metric}.{e.Exchange}.{e.Symbol}";
167158
var previous = LastMetricValues.ContainsKey(metricKey) ? LastMetricValues[metricKey] : double.NaN;
168159
LastMetricValues[metricKey] = e.Value;
169160

@@ -303,13 +294,13 @@ private static void EvaluateAllRulesAgainstLatestMetrics()
303294
foreach (var kvp in latestMetrics)
304295
{
305296
var parts = kvp.Key.Split('.');
306-
if (parts.Length != 2)
297+
if (parts.Length != 4)
307298
continue;
308299

309300
var plugin = parts[0];
310301
var metric = parts[1];
311302
var exchange = parts[2];
312-
var symbol= parts[3];
303+
var symbol = parts[3];
313304
var value = kvp.Value;
314305

315306
var metricEvent = new MetricEvent(plugin, metric, exchange,symbol, value, DateTime.UtcNow);

TriggerEngine/TriggerRule.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Linq;
5-
using System.Text;
6-
using System.Threading.Tasks;
1+
using System.Collections.Generic;
72

83
namespace VisualHFT.TriggerEngine
94
{

0 commit comments

Comments
 (0)