commit
c3cbb4908e
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Data;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -852,6 +853,8 @@ namespace Core.Main
|
||||||
|
|
||||||
#region PTMagic Interval Methods
|
#region PTMagic Interval Methods
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void PTMagicIntervalTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
public void PTMagicIntervalTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
// Check if the bot is idle
|
// Check if the bot is idle
|
||||||
|
@ -1297,6 +1300,8 @@ namespace Core.Main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void BuildGlobalMarketTrends()
|
private void BuildGlobalMarketTrends()
|
||||||
{
|
{
|
||||||
this.Log.DoLogInfo("Build global market trends...");
|
this.Log.DoLogInfo("Build global market trends...");
|
||||||
|
@ -1415,9 +1420,17 @@ namespace Core.Main
|
||||||
// New logic
|
// New logic
|
||||||
string triggerConnection = globalSetting.TriggerConnection;
|
string triggerConnection = globalSetting.TriggerConnection;
|
||||||
foreach (var triggerResult in triggerResults)
|
foreach (var triggerResult in triggerResults)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(triggerResult.Key))
|
||||||
{
|
{
|
||||||
triggerConnection = triggerConnection.Replace(triggerResult.Key, triggerResult.Value.ToString().ToLower());
|
triggerConnection = triggerConnection.Replace(triggerResult.Key, triggerResult.Value.ToString().ToLower());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Log.DoLogError($"ERROR: A required trigger Tag is missing for global setting {globalSetting.SettingName}. Program halted.");
|
||||||
|
Environment.Exit(1); // Stop the program
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1815,6 +1828,14 @@ namespace Core.Main
|
||||||
Dictionary<int, double> relevantTriggers = new Dictionary<int, double>();
|
Dictionary<int, double> relevantTriggers = new Dictionary<int, double>();
|
||||||
int triggerIndex = 0;
|
int triggerIndex = 0;
|
||||||
|
|
||||||
|
// Create a dictionary to store the tag and its corresponding result
|
||||||
|
Dictionary<string, bool> triggerTagsResults = new Dictionary<string, bool>();
|
||||||
|
// Initialize all tags with a value of false
|
||||||
|
foreach (Trigger trigger in marketSetting.Triggers)
|
||||||
|
{
|
||||||
|
triggerTagsResults[trigger.Tag] = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Loop through SMS triggers
|
// Loop through SMS triggers
|
||||||
foreach (Trigger trigger in marketSetting.Triggers)
|
foreach (Trigger trigger in marketSetting.Triggers)
|
||||||
{
|
{
|
||||||
|
@ -1850,6 +1871,7 @@ namespace Core.Main
|
||||||
matchedSingleMarketTriggers.Add(marketSetting.SettingName + ": " + triggerContent + " - 24h volume = " + mtc.Volume24h.ToString(new System.Globalization.CultureInfo("en-US")) + " " + this.LastRuntimeSummary.MainMarket);
|
matchedSingleMarketTriggers.Add(marketSetting.SettingName + ": " + triggerContent + " - 24h volume = " + mtc.Volume24h.ToString(new System.Globalization.CultureInfo("en-US")) + " " + this.LastRuntimeSummary.MainMarket);
|
||||||
|
|
||||||
triggerResults.Add(true);
|
triggerResults.Add(true);
|
||||||
|
triggerTagsResults[trigger.Tag] = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1880,6 +1902,7 @@ namespace Core.Main
|
||||||
|
|
||||||
relevantTriggers.Add(triggerIndex, marketAge);
|
relevantTriggers.Add(triggerIndex, marketAge);
|
||||||
triggerResults.Add(true);
|
triggerResults.Add(true);
|
||||||
|
triggerTagsResults[trigger.Tag] = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1961,6 +1984,7 @@ namespace Core.Main
|
||||||
matchedSingleMarketTriggers.Add(marketSetting.SettingName + ": " + triggerContent + " - TrendChange (" + trigger.MarketTrendRelation + ") = " + trendChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%");
|
matchedSingleMarketTriggers.Add(marketSetting.SettingName + ": " + triggerContent + " - TrendChange (" + trigger.MarketTrendRelation + ") = " + trendChange.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) + "%");
|
||||||
|
|
||||||
triggerResults.Add(true);
|
triggerResults.Add(true);
|
||||||
|
triggerTagsResults[trigger.Tag] = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2002,8 +2026,11 @@ namespace Core.Main
|
||||||
triggerIndex++;
|
triggerIndex++;
|
||||||
} // End loop SMS triggers
|
} // End loop SMS triggers
|
||||||
|
|
||||||
|
|
||||||
// Check if all triggers have to get triggered or just one
|
// Check if all triggers have to get triggered or just one
|
||||||
bool settingTriggered = false;
|
bool settingTriggered = false;
|
||||||
|
if (marketSetting.TriggerConnection.ToLower() == "and" || marketSetting.TriggerConnection.ToLower() == "or")
|
||||||
|
{
|
||||||
switch (marketSetting.TriggerConnection.ToLower())
|
switch (marketSetting.TriggerConnection.ToLower())
|
||||||
{
|
{
|
||||||
case "and":
|
case "and":
|
||||||
|
@ -2013,6 +2040,37 @@ namespace Core.Main
|
||||||
settingTriggered = triggerResults.FindAll(tr => tr == true).Count > 0;
|
settingTriggered = triggerResults.FindAll(tr => tr == true).Count > 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
// Parse the TriggerConnection string into a logical expression
|
||||||
|
string triggerConnection = marketSetting.TriggerConnection;
|
||||||
|
foreach (var triggerResult in triggerTagsResults)
|
||||||
|
{
|
||||||
|
// Replace the tag in the expression with its corresponding value from triggerTagsResults
|
||||||
|
if (!string.IsNullOrEmpty(triggerResult.Key))
|
||||||
|
{
|
||||||
|
triggerConnection = triggerConnection.Replace(triggerResult.Key, triggerResult.Value.ToString().ToLower());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Log.DoLogError($"ERROR: A required trigger Tag is missing for global setting {marketSetting.SettingName}. Program halted.");
|
||||||
|
Environment.Exit(1); // Stop the program
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
// Evaluate the expression using ParseLambda
|
||||||
|
settingTriggered = (bool)DynamicExpressionParser.ParseLambda(ParsingConfig.Default, new ParameterExpression[0], typeof(bool), triggerConnection).Compile().DynamicInvoke();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.Log.DoLogError($"ERROR: Trigger Connection for global setting {marketSetting.SettingName} is invalid or missing. Program halted.");
|
||||||
|
Environment.Exit(1); // Stop the program
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
bool isFreshTrigger = true;
|
bool isFreshTrigger = true;
|
||||||
|
|
|
@ -29,20 +29,14 @@
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-4 col-form-label">Trigger Connection <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Define if triggers will be connected by AND or OR"></i></label>
|
<label class="col-md-4 col-form-label">Trigger Connection <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Define if triggers will be connected by AND or OR"></i></label>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<select name="MarketAnalyzer_SingleMarketSetting_@(Model.SettingName)|TriggerConnection" class="form-control">
|
<input type="text" name="MarketAnalyzer_SingleMarketSetting_@(Model.SettingName)|TriggerConnection" class="form-control" value="@Model.SingleMarketSetting.TriggerConnection" />
|
||||||
<option selected="@(Model.SingleMarketSetting.TriggerConnection.Equals("AND", StringComparison.InvariantCultureIgnoreCase))">AND</option>
|
|
||||||
<option selected="@(Model.SingleMarketSetting.TriggerConnection.Equals("OR", StringComparison.InvariantCultureIgnoreCase))">OR</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-4 col-form-label">Off Trigger Connection <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Define if off triggers will be connected by AND or OR"></i></label>
|
<label class="col-md-4 col-form-label">Off Trigger Connection <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="Define if off triggers will be connected by AND or OR"></i></label>
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
<select name="MarketAnalyzer_SingleMarketSetting_@(Model.SettingName)|OffTriggerConnection" class="form-control">
|
<input type="text" name="MarketAnalyzer_SingleMarketSetting_@(Model.SettingName)|OffTriggerConnection" class="form-control" value="@Model.SingleMarketSetting.OffTriggerConnection" />
|
||||||
<option selected="@(Model.SingleMarketSetting.OffTriggerConnection.Equals("AND", StringComparison.InvariantCultureIgnoreCase))">AND</option>
|
|
||||||
<option selected="@(Model.SingleMarketSetting.OffTriggerConnection.Equals("OR", StringComparison.InvariantCultureIgnoreCase))">OR</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ using Core.Helper;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
|
||||||
[assembly: AssemblyVersion("2.8.2")]
|
[assembly: AssemblyVersion("2.8.3")]
|
||||||
[assembly: AssemblyProduct("PT Magic")]
|
[assembly: AssemblyProduct("PT Magic")]
|
||||||
|
|
||||||
namespace PTMagic
|
namespace PTMagic
|
||||||
|
|
Loading…
Reference in New Issue