Skip to content

Commit

Permalink
Add frequency checking option for trader quote alerts (#512)
Browse files Browse the repository at this point in the history
Hide sell trade quotes since they don't populate
Closes #509
Closes #508
  • Loading branch information
AlexMacocian authored Dec 15, 2023
1 parent c27a0db commit 8ffbb91
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
11 changes: 10 additions & 1 deletion Daybreak/Configuration/Options/TradeAlertingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@

namespace Daybreak.Configuration.Options;

[OptionsIgnore]
[OptionsName(Name = "Trade Alerts")]
internal sealed class TradeAlertingOptions
{
[OptionIgnore]
public TimeSpan MaxLookbackPeriod { get; set; } = TimeSpan.FromDays(31);

[OptionIgnore]
public DateTime LastCheckTime { get; set; } = DateTime.MinValue;

[OptionIgnore]
public List<ITradeAlert> Alerts { get; set; } = [];

[OptionName(Name = "Quote Alerts Interval", Description = "The amount of seconds in between checking for alerts based on trade quotes")]
[OptionRange<double>(MinValue = 30d, MaxValue = 1440d)]
public double QuoteAlertsInterval { get; set; } = 30;
}
2 changes: 1 addition & 1 deletion Daybreak/Configuration/Options/TraderQuotesOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ internal sealed class TraderQuotesOptions

[OptionIgnore]
public DateTime LastCheckTime { get; set;} = DateTime.MinValue;
[OptionName(Name = "Cache Update Interval", Description = "The amount of minutes in between cache updates")]

[OptionName(Name = "Cache Update Interval", Description = "The amount of minutes in between cache updates")]
[OptionRange<double>(MinValue = 30d, MaxValue = 1440d)]
public double CacheUpdateInterval { get; set; } = 60;
}
2 changes: 1 addition & 1 deletion Daybreak/Daybreak.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<LangVersion>preview</LangVersion>
<ApplicationIcon>Daybreak.ico</ApplicationIcon>
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
<Version>0.9.8.160</Version>
<Version>0.9.8.161</Version>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<UserSecretsId>cfb2a489-db80-448d-a969-80270f314c46</UserSecretsId>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
Expand Down
6 changes: 3 additions & 3 deletions Daybreak/Services/TradeChat/TradeAlertingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal sealed class TradeAlertingService : ITradeAlertingService, IApplication
private readonly ITradeHistoryDatabase tradeHistoryDatabase;
private readonly ITradeChatService<KamadanTradeChatOptions> kamadanTradeChatService;
private readonly ITradeChatService<AscalonTradeChatOptions> ascalonTradeChatService;
private readonly IUpdateableOptions<TradeAlertingOptions> options;
private readonly ILiveUpdateableOptions<TradeAlertingOptions> options;
private readonly ILogger<TradeAlertingService> logger;
private readonly CancellationTokenSource cancellationTokenSource = new();

Expand All @@ -39,7 +39,7 @@ public TradeAlertingService(
ITradeHistoryDatabase tradeHistoryDatabase,
ITradeChatService<KamadanTradeChatOptions> kamadanTradeChatService,
ITradeChatService<AscalonTradeChatOptions> ascalonTradeChatService,
IUpdateableOptions<TradeAlertingOptions> options,
ILiveUpdateableOptions<TradeAlertingOptions> options,
ILogger<TradeAlertingService> logger)
{
this.traderQuoteService = traderQuoteService.ThrowIfNull();
Expand Down Expand Up @@ -187,7 +187,7 @@ private async Task CheckTraderQuotes(CancellationToken cancellationToken)
}
}

await Task.Delay(QuoteCheckDelay, cancellationToken);
await Task.Delay(TimeSpan.FromSeconds(this.options.Value.QuoteAlertsInterval), cancellationToken);
}
}

Expand Down
3 changes: 2 additions & 1 deletion Daybreak/Views/Trade/QuoteAlertSetupView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@
Cursor="Hand"/>
</Grid>
<Grid Grid.Row="2"
Height="35">
Height="35"
Visibility="Collapsed">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
Expand Down
1 change: 1 addition & 0 deletions Daybreak/Views/Trade/TradeAlertsChoiceView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
Clicked="AddBuyQuoteAlertButton_Clicked" />
<buttons:HighlightButton
Title="Sell Quote Alert"
Visibility="Collapsed"
Foreground="{StaticResource MahApps.Brushes.ThemeForeground}"
Background="{StaticResource MahApps.Brushes.ThemeBackground}"
HighlightColor="{StaticResource MahApps.Brushes.Accent}"
Expand Down

0 comments on commit 8ffbb91

Please sign in to comment.