plug candle store and bot
This commit is contained in:
@@ -51,7 +51,7 @@ public class TradingBotBase : ITradingBot
|
||||
Signals = new Dictionary<string, LightSignal>();
|
||||
Positions = new Dictionary<Guid, Position>();
|
||||
WalletBalances = new Dictionary<DateTime, decimal>();
|
||||
PreloadSince = CandleExtensions.GetBotPreloadSinceFromTimeframe(config.Timeframe);
|
||||
PreloadSince = CandleHelpers.GetBotPreloadSinceFromTimeframe(config.Timeframe);
|
||||
}
|
||||
|
||||
public async Task Start(BotStatus previousStatus)
|
||||
@@ -119,11 +119,11 @@ public class TradingBotBase : ITradingBot
|
||||
|
||||
public async Task LoadLastCandle()
|
||||
{
|
||||
await ServiceScopeHelpers.WithScopedService<IExchangeService>(_scopeFactory, async exchangeService =>
|
||||
await ServiceScopeHelpers.WithScopedService<IGrainFactory>(_scopeFactory, async grainFactory =>
|
||||
{
|
||||
var candles = await exchangeService.GetCandlesInflux(Account.Exchange, Config.Ticker, PreloadSince,
|
||||
Config.Timeframe, DateTime.UtcNow, 1);
|
||||
LastCandle = candles.Single();
|
||||
var grainKey = CandleHelpers.GetCandleStoreGrainKey(Account.Exchange, Config.Ticker, Config.Timeframe);
|
||||
var grain = grainFactory.GetGrain<ICandleStoreGrain>(grainKey);
|
||||
LastCandle = await grain.GetLastCandle();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1829,7 +1829,7 @@ public class TradingBotBase : ITradingBot
|
||||
}
|
||||
|
||||
// Calculate cooldown end time based on last position closing time
|
||||
var baseIntervalSeconds = CandleExtensions.GetBaseIntervalInSeconds(Config.Timeframe);
|
||||
var baseIntervalSeconds = CandleHelpers.GetBaseIntervalInSeconds(Config.Timeframe);
|
||||
var cooldownEndTime = LastPositionClosingTime.Value.AddSeconds(baseIntervalSeconds * Config.CooldownPeriod);
|
||||
var isInCooldown = LastCandle.Date < cooldownEndTime;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user