fix plug to the store
This commit is contained in:
@@ -123,7 +123,34 @@ public class TradingBotBase : ITradingBot
|
||||
{
|
||||
var grainKey = CandleHelpers.GetCandleStoreGrainKey(Account.Exchange, Config.Ticker, Config.Timeframe);
|
||||
var grain = grainFactory.GetGrain<ICandleStoreGrain>(grainKey);
|
||||
LastCandle = await grain.GetLastCandle();
|
||||
|
||||
try
|
||||
{
|
||||
// Add a small delay to ensure grain is fully activated
|
||||
await Task.Delay(100);
|
||||
LastCandle = await grain.GetLastCandle();
|
||||
}
|
||||
catch (InvalidOperationException ex) when (ex.Message.Contains("invalid activation"))
|
||||
{
|
||||
Logger.LogWarning("Grain activation failed for {GrainKey}, retrying in 1 second...", grainKey);
|
||||
|
||||
// Wait a bit longer and retry once
|
||||
await Task.Delay(1000);
|
||||
try
|
||||
{
|
||||
LastCandle = await grain.GetLastCandle();
|
||||
}
|
||||
catch (Exception retryEx)
|
||||
{
|
||||
Logger.LogError(retryEx, "Failed to load last candle for {GrainKey} after retry", grainKey);
|
||||
LastCandle = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "Error loading last candle for {GrainKey}", grainKey);
|
||||
LastCandle = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user