Update running time exec
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Managing.Application.Abstractions.Grains;
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Core;
|
||||
using Managing.Domain.Bots;
|
||||
using Managing.Domain.Candles;
|
||||
@@ -30,19 +29,17 @@ public class ScenarioRunnerGrain : Grain, IScenarioRunnerGrain
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
private async Task<HashSet<Candle>> GetCandlesAsync(TradingBotConfig config, DateTime startDate)
|
||||
private async Task<HashSet<Candle>> GetCandlesAsync(TradingExchanges tradingExchange, TradingBotConfig config)
|
||||
{
|
||||
try
|
||||
{
|
||||
var newCandles = await ServiceScopeHelpers.WithScopedService<IExchangeService, HashSet<Candle>>(
|
||||
_scopeFactory, async exchangeService =>
|
||||
var newCandles = await ServiceScopeHelpers.WithScopedService<IGrainFactory, HashSet<Candle>>(
|
||||
_scopeFactory, async grainFactory =>
|
||||
{
|
||||
return await exchangeService.GetCandlesInflux(
|
||||
TradingExchanges.Evm,
|
||||
config.Ticker,
|
||||
startDate,
|
||||
config.Timeframe,
|
||||
500);
|
||||
var priceGrainKey =
|
||||
CandleHelpers.GetCandleStoreGrainKey(tradingExchange, config.Ticker, config.Timeframe);
|
||||
var grain = grainFactory.GetGrain<ICandleStoreGrain>(priceGrainKey);
|
||||
return await grain.GetCandlesAsync();
|
||||
});
|
||||
|
||||
_logger.LogInformation($"Updated {newCandles.Count} candles for {config.Ticker}");
|
||||
@@ -56,7 +53,7 @@ public class ScenarioRunnerGrain : Grain, IScenarioRunnerGrain
|
||||
}
|
||||
|
||||
public async Task<LightSignal> GetSignals(TradingBotConfig config, Dictionary<string, LightSignal> previousSignals,
|
||||
DateTime startDate, Candle candle)
|
||||
TradingExchanges tradingExchanges, Candle candle)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -64,7 +61,7 @@ public class ScenarioRunnerGrain : Grain, IScenarioRunnerGrain
|
||||
// candle, candle.Date, TradingExchanges.Evm, IndicatorType.Composite,
|
||||
// SignalType.Signal, "Generated Signal");
|
||||
|
||||
var candlesHashSet = await GetCandlesAsync(config, startDate);
|
||||
var candlesHashSet = await GetCandlesAsync(tradingExchanges, config);
|
||||
if (candlesHashSet.LastOrDefault()!.Date <= candle.Date)
|
||||
{
|
||||
return null; // No new candles, no need to generate a signal
|
||||
|
||||
Reference in New Issue
Block a user