Clean a bit
This commit is contained in:
@@ -13,6 +13,5 @@ public interface IPriceFetcherGrain : IGrainWithStringKey
|
|||||||
/// Fetches price data for all supported exchange/ticker combinations
|
/// Fetches price data for all supported exchange/ticker combinations
|
||||||
/// and publishes new candles to their respective streams.
|
/// and publishes new candles to their respective streams.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>True if the operation completed successfully, false otherwise</returns>
|
Task FetchAndPublishPricesAsync();
|
||||||
Task<bool> FetchAndPublishPricesAsync();
|
}
|
||||||
}
|
|
||||||
5
src/Managing.Application/Bots/BotReminderInitializer.cs
Normal file
5
src/Managing.Application/Bots/BotReminderInitializer.cs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
namespace Managing.Application.Bots;
|
||||||
|
|
||||||
|
public class BotReminderInitializer
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -52,7 +52,8 @@ public class GeneticBacktestGrain : Grain, IGeneticBacktestGrain
|
|||||||
request.Status = GeneticRequestStatus.Running;
|
request.Status = GeneticRequestStatus.Running;
|
||||||
await geneticService.UpdateGeneticRequestAsync(request);
|
await geneticService.UpdateGeneticRequestAsync(request);
|
||||||
|
|
||||||
request.User.Accounts = await ServiceScopeHelpers.WithScopedService<IAccountService, List<Account>>(_scopeFactory,
|
request.User.Accounts = await ServiceScopeHelpers.WithScopedService<IAccountService, List<Account>>(
|
||||||
|
_scopeFactory,
|
||||||
async accountService => (await accountService.GetAccountsByUserAsync(request.User)).ToList());
|
async accountService => (await accountService.GetAccountsByUserAsync(request.User)).ToList());
|
||||||
|
|
||||||
// Run GA
|
// Run GA
|
||||||
@@ -70,7 +71,8 @@ public class GeneticBacktestGrain : Grain, IGeneticBacktestGrain
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "[GeneticBacktestGrain] Error processing request {RequestId}", requestId);
|
SentrySdk.CaptureException(ex);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var scope = _scopeFactory.CreateScope();
|
using var scope = _scopeFactory.CreateScope();
|
||||||
|
|||||||
@@ -81,12 +81,10 @@ public class PriceFetcherGrain : Grain, IPriceFetcherGrain, IRemindable
|
|||||||
await base.OnDeactivateAsync(reason, cancellationToken);
|
await base.OnDeactivateAsync(reason, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> FetchAndPublishPricesAsync()
|
public async Task FetchAndPublishPricesAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Starting {timeframe} price fetch cycle", TargetTimeframe);
|
|
||||||
|
|
||||||
var fetchTasks = new List<Task>();
|
var fetchTasks = new List<Task>();
|
||||||
|
|
||||||
// Create fetch tasks for all exchange/ticker combinations for the target timeframe
|
// Create fetch tasks for all exchange/ticker combinations for the target timeframe
|
||||||
@@ -100,16 +98,11 @@ public class PriceFetcherGrain : Grain, IPriceFetcherGrain, IRemindable
|
|||||||
|
|
||||||
// Execute all fetch operations in parallel
|
// Execute all fetch operations in parallel
|
||||||
await Task.WhenAll(fetchTasks);
|
await Task.WhenAll(fetchTasks);
|
||||||
|
|
||||||
_logger.LogInformation("{0} - Completed {1} price fetch cycle for {2} combinations",
|
|
||||||
nameof(PriceFetcherGrain), TargetTimeframe, fetchTasks.Count);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error during price fetch cycle for timeframe {Timeframe}", TargetTimeframe);
|
_logger.LogError(ex, "Error during price fetch cycle for timeframe {Timeframe}", TargetTimeframe);
|
||||||
return false;
|
SentrySdk.CaptureException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,6 +178,7 @@ public class PriceFetcherGrain : Grain, IPriceFetcherGrain, IRemindable
|
|||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error fetching prices for {Exchange}-{Ticker}-{Timeframe}",
|
_logger.LogError(ex, "Error fetching prices for {Exchange}-{Ticker}-{Timeframe}",
|
||||||
exchange, ticker, timeframe);
|
exchange, ticker, timeframe);
|
||||||
|
SentrySdk.CaptureException(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user