Clean a bit
This commit is contained in:
@@ -52,7 +52,8 @@ public class GeneticBacktestGrain : Grain, IGeneticBacktestGrain
|
||||
request.Status = GeneticRequestStatus.Running;
|
||||
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());
|
||||
|
||||
// Run GA
|
||||
@@ -70,7 +71,8 @@ public class GeneticBacktestGrain : Grain, IGeneticBacktestGrain
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "[GeneticBacktestGrain] Error processing request {RequestId}", requestId);
|
||||
SentrySdk.CaptureException(ex);
|
||||
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
|
||||
@@ -81,12 +81,10 @@ public class PriceFetcherGrain : Grain, IPriceFetcherGrain, IRemindable
|
||||
await base.OnDeactivateAsync(reason, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<bool> FetchAndPublishPricesAsync()
|
||||
public async Task FetchAndPublishPricesAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Starting {timeframe} price fetch cycle", TargetTimeframe);
|
||||
|
||||
var fetchTasks = new List<Task>();
|
||||
|
||||
// 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
|
||||
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)
|
||||
{
|
||||
_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}",
|
||||
exchange, ticker, timeframe);
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user