Add bot worker
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Application.Workers;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Managing.Application.Workers;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Api.Workers.Workers;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Managing.Application.Workers;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Api.Workers.Workers;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Application.Hubs;
|
||||
using Managing.Application.Workers;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Application.Workers;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Managing.Domain.Trades;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Managing.Application.Workers;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Api.Workers.Workers;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Managing.Application.Workers;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Managing.Common;
|
||||
|
||||
namespace Managing.Api.Workers.Workers;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Application.Workers;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Text.Json.Serialization;
|
||||
using Managing.Api.Authorization;
|
||||
using Managing.Api.Exceptions;
|
||||
using Managing.Api.Filters;
|
||||
using Managing.Api.Workers;
|
||||
using Managing.Application.Hubs;
|
||||
using Managing.Bootstrap;
|
||||
using Managing.Common;
|
||||
@@ -126,6 +127,7 @@ builder.Services.AddSwaggerGen(options =>
|
||||
});
|
||||
|
||||
builder.WebHost.SetupDiscordBot();
|
||||
builder.Services.AddHostedService<BotManagerWorker>();
|
||||
|
||||
// App
|
||||
var app = builder.Build();
|
||||
|
||||
32
src/Managing.Api/Workers/BotManagerWorker.cs
Normal file
32
src/Managing.Api/Workers/BotManagerWorker.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Managing.Application.ManageBot;
|
||||
using Managing.Application.Workers;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using MediatR;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Api.Workers;
|
||||
|
||||
public class BotManagerWorker : BaseWorker<BotManagerWorker>
|
||||
{
|
||||
private readonly IMediator _mediator;
|
||||
private static readonly WorkerType _workerType = WorkerType.Fee;
|
||||
|
||||
public BotManagerWorker(
|
||||
ILogger<BotManagerWorker> logger,
|
||||
IMediator tradingService,
|
||||
IWorkerService workerService) : base(
|
||||
_workerType,
|
||||
logger,
|
||||
TimeSpan.FromMinutes(1),
|
||||
workerService
|
||||
)
|
||||
{
|
||||
_mediator = tradingService;
|
||||
}
|
||||
|
||||
protected override async Task Run(CancellationToken cancellationToken)
|
||||
{
|
||||
var loadBackupBotCommand = new LoadBackupBotCommand();
|
||||
await _mediator.Send(loadBackupBotCommand, cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Api.Workers;
|
||||
namespace Managing.Application.Workers;
|
||||
|
||||
public abstract class BaseWorker<T> : BackgroundService where T : class
|
||||
{
|
||||
@@ -9,6 +9,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
public interface IBotService
|
||||
using Managing.Application.Bots;
|
||||
using Managing.Common;
|
||||
|
||||
public interface IBotService
|
||||
{
|
||||
void SaveBotBackup(BotBackup botBackup);
|
||||
}
|
||||
void SaveBotBackup(string name, Enums.BotType botType, string data);
|
||||
}
|
||||
@@ -16,6 +16,7 @@ namespace Managing.Application.Bots.Base
|
||||
private readonly IAccountService _accountService;
|
||||
private readonly ILogger<TradingBot> _tradingBotLogger;
|
||||
private readonly ITradingService _tradingService;
|
||||
private readonly IBotService _botService;
|
||||
|
||||
public BotFactory(
|
||||
IExchangeService exchangeService,
|
||||
@@ -23,7 +24,8 @@ namespace Managing.Application.Bots.Base
|
||||
IMoneyManagementService moneyManagementService,
|
||||
IMessengerService messengerService,
|
||||
IAccountService accountService,
|
||||
ITradingService tradingService)
|
||||
ITradingService tradingService,
|
||||
IBotService botService)
|
||||
{
|
||||
_tradingBotLogger = tradingBotLogger;
|
||||
_exchangeService = exchangeService;
|
||||
@@ -31,11 +33,12 @@ namespace Managing.Application.Bots.Base
|
||||
_messengerService = messengerService;
|
||||
_accountService = accountService;
|
||||
_tradingService = tradingService;
|
||||
_botService = botService;
|
||||
}
|
||||
|
||||
IBot IBotFactory.CreateSimpleBot(string botName, Workflow workflow)
|
||||
{
|
||||
return new SimpleBot(botName, _tradingBotLogger, workflow);
|
||||
return new SimpleBot(botName, _tradingBotLogger, workflow, _botService);
|
||||
}
|
||||
|
||||
ITradingBot IBotFactory.CreateScalpingBot(string accountName, MoneyManagement moneyManagement, string name, Ticker ticker, string scenario, Timeframe interval, bool isForWatchingOnly)
|
||||
@@ -52,6 +55,7 @@ namespace Managing.Application.Bots.Base
|
||||
interval,
|
||||
_accountService,
|
||||
_messengerService,
|
||||
_botService,
|
||||
isForWatchingOnly: isForWatchingOnly);
|
||||
}
|
||||
|
||||
@@ -69,6 +73,7 @@ namespace Managing.Application.Bots.Base
|
||||
interval,
|
||||
_accountService,
|
||||
_messengerService,
|
||||
_botService,
|
||||
true,
|
||||
isForWatchingOnly);
|
||||
}
|
||||
@@ -87,6 +92,7 @@ namespace Managing.Application.Bots.Base
|
||||
interval,
|
||||
_accountService,
|
||||
_messengerService,
|
||||
_botService,
|
||||
isForWatchingOnly: isForWatchingOnly);
|
||||
}
|
||||
|
||||
@@ -104,6 +110,7 @@ namespace Managing.Application.Bots.Base
|
||||
interval,
|
||||
_accountService,
|
||||
_messengerService,
|
||||
_botService,
|
||||
true,
|
||||
isForWatchingOnly);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Managing.Application.Bots
|
||||
Timeframe timeframe,
|
||||
IAccountService accountService,
|
||||
IMessengerService messengerService,
|
||||
IBotService botService,
|
||||
bool isForBacktest = false,
|
||||
bool isForWatchingOnly = false)
|
||||
: base(accountName,
|
||||
@@ -31,6 +32,7 @@ namespace Managing.Application.Bots
|
||||
timeframe,
|
||||
accountService,
|
||||
messengerService,
|
||||
botService,
|
||||
isForBacktest,
|
||||
isForWatchingOnly,
|
||||
flipPosition: true)
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Managing.Application.Bots
|
||||
Timeframe timeframe,
|
||||
IAccountService accountService,
|
||||
IMessengerService messengerService,
|
||||
IBotService botService,
|
||||
bool isForBacktest = false,
|
||||
bool isForWatchingOnly = false)
|
||||
: base(accountName,
|
||||
@@ -31,6 +32,7 @@ namespace Managing.Application.Bots
|
||||
timeframe,
|
||||
accountService,
|
||||
messengerService,
|
||||
botService,
|
||||
isForBacktest,
|
||||
isForWatchingOnly)
|
||||
{
|
||||
|
||||
@@ -2,17 +2,20 @@
|
||||
using Managing.Domain.Workflows;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Application.Bots
|
||||
{
|
||||
public class SimpleBot : Bot
|
||||
{
|
||||
public readonly ILogger<TradingBot> Logger;
|
||||
private readonly IBotService _botService;
|
||||
private Workflow _workflow;
|
||||
|
||||
public SimpleBot(string name, ILogger<TradingBot> logger, Workflow workflow) : base(name)
|
||||
public SimpleBot(string name, ILogger<TradingBot> logger, Workflow workflow, IBotService botService) : base(name)
|
||||
{
|
||||
Logger = logger;
|
||||
_botService = botService;
|
||||
_workflow = workflow;
|
||||
Interval = 100;
|
||||
Start();
|
||||
@@ -33,13 +36,15 @@ namespace Managing.Application.Bots
|
||||
Logger.LogInformation(Identifier);
|
||||
Logger.LogInformation(DateTime.Now.ToString());
|
||||
await _workflow.Execute();
|
||||
SaveBackup();
|
||||
Logger.LogInformation("__________________________________________________");
|
||||
});
|
||||
}
|
||||
|
||||
public override string GetBackup()
|
||||
public override void SaveBackup()
|
||||
{
|
||||
return JsonConvert.SerializeObject(_workflow);
|
||||
var data = JsonConvert.SerializeObject(_workflow);
|
||||
_botService.SaveBotBackup(Name, BotType.SimpleBot, data);
|
||||
}
|
||||
|
||||
public override void LoadBackup(BotBackup backup)
|
||||
|
||||
@@ -23,6 +23,7 @@ public class TradingBot : Bot, ITradingBot
|
||||
public readonly IMessengerService MessengerService;
|
||||
public readonly IAccountService AccountService;
|
||||
private readonly ITradingService TradingService;
|
||||
private readonly IBotService BotService;
|
||||
|
||||
public Account Account { get; set; }
|
||||
public HashSet<IStrategy> Strategies { get; set; }
|
||||
@@ -55,6 +56,7 @@ public class TradingBot : Bot, ITradingBot
|
||||
Timeframe timeframe,
|
||||
IAccountService accountService,
|
||||
IMessengerService messengerService,
|
||||
IBotService botService,
|
||||
bool isForBacktest = false,
|
||||
bool isForWatchingOnly = false,
|
||||
bool flipPosition = false)
|
||||
@@ -64,7 +66,7 @@ public class TradingBot : Bot, ITradingBot
|
||||
AccountService = accountService;
|
||||
MessengerService = messengerService;
|
||||
TradingService = tradingService;
|
||||
|
||||
BotService = botService;
|
||||
|
||||
IsForWatchingOnly = isForWatchingOnly;
|
||||
FlipPosition = flipPosition;
|
||||
@@ -168,6 +170,9 @@ public class TradingBot : Bot, ITradingBot
|
||||
if (!IsForWatchingOnly)
|
||||
await ManagePositions();
|
||||
|
||||
if (!IsForBacktest)
|
||||
SaveBackup();
|
||||
|
||||
await UpdateWalletBalances();
|
||||
Logger.LogInformation($"Candles : {Candles.Count}");
|
||||
Logger.LogInformation($"Signals : {Signals.Count}");
|
||||
@@ -659,9 +664,9 @@ public class TradingBot : Bot, ITradingBot
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetBackup()
|
||||
public override void SaveBackup()
|
||||
{
|
||||
return JsonConvert.SerializeObject(new TradingBotBackup
|
||||
var data = new TradingBotBackup
|
||||
{
|
||||
Name = Name,
|
||||
BotType = BotType,
|
||||
@@ -675,7 +680,8 @@ public class TradingBot : Bot, ITradingBot
|
||||
IsForWatchingOnly = IsForWatchingOnly,
|
||||
WalletBalances = WalletBalances,
|
||||
MoneyManagement = MoneyManagement
|
||||
});
|
||||
};
|
||||
BotService.SaveBotBackup(Name, BotType, JsonConvert.SerializeObject(data));
|
||||
}
|
||||
|
||||
public override void LoadBackup(BotBackup backup)
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
using Managing.Domain.Bots;
|
||||
using MediatR;
|
||||
using static Managing.Common.Enums;
|
||||
using Managing.Application.Abstractions;
|
||||
|
||||
namespace Managing.Application.ManageBot
|
||||
{
|
||||
public class BackupBotCommandHandler : IRequestHandler<BackupBotCommand, bool>
|
||||
{
|
||||
private readonly ITaskCache _taskCache;
|
||||
private readonly IBotService _botService;
|
||||
|
||||
public BackupBotCommandHandler(ITaskCache taskCache, IBotService botService)
|
||||
{
|
||||
_taskCache = taskCache;
|
||||
_botService = botService;
|
||||
}
|
||||
|
||||
public Task<bool> Handle(BackupBotCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var botBackup = new BotBackup
|
||||
{
|
||||
Name = request.Name,
|
||||
BotType = request.BotType,
|
||||
Data = ""
|
||||
};
|
||||
|
||||
switch (request.BotType)
|
||||
{
|
||||
case BotType.SimpleBot:
|
||||
var simpleBot = _taskCache.Get<IBot>(request.Name);
|
||||
botBackup.Data = simpleBot.GetBackup();
|
||||
break;
|
||||
case BotType.ScalpingBot:
|
||||
var scalpingBot = _taskCache.Get<ITradingBot>(request.Name);
|
||||
botBackup.Data = scalpingBot.GetBackup();
|
||||
break;
|
||||
case BotType.FlippingBot:
|
||||
var flippingBot = _taskCache.Get<ITradingBot>(request.Name);
|
||||
botBackup.Data = flippingBot.GetBackup();
|
||||
break;
|
||||
default:
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
_botService.SaveBotBackup(botBackup);
|
||||
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
|
||||
public class BackupBotCommand : IRequest<bool>
|
||||
{
|
||||
public string Name { get; }
|
||||
public BotType BotType { get; }
|
||||
|
||||
public BackupBotCommand(BotType botType, string name)
|
||||
{
|
||||
BotType = botType;
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,33 @@
|
||||
using Managing.Application.Abstractions;
|
||||
using Managing.Application.Bots;
|
||||
using Managing.Common;
|
||||
|
||||
namespace Managing.Application.ManageBot
|
||||
{
|
||||
public class BotService : IBotService
|
||||
{
|
||||
private readonly IBotFactory _botFactory;
|
||||
private readonly IBotRepository _botRepository;
|
||||
|
||||
public BotService(IBotFactory botFactory, IBotRepository botRepository)
|
||||
public BotService(IBotRepository botRepository)
|
||||
{
|
||||
_botFactory = botFactory;
|
||||
_botRepository = botRepository;
|
||||
}
|
||||
|
||||
// public void CreateBot()
|
||||
// {
|
||||
// // Use the factory to create a new bot
|
||||
// return _botFactory.CreateBot();
|
||||
// }
|
||||
|
||||
// public void LoadBotBackup(BotBackup botBackup)
|
||||
// {
|
||||
// // Deserialize the JSON into a Bot object
|
||||
// var bot = JsonConvert.DeserializeObject<Bot>(json);
|
||||
|
||||
// return bot;
|
||||
// }
|
||||
|
||||
public async void SaveBotBackup(BotBackup botBackup)
|
||||
{
|
||||
await _botRepository.InsertBotAsync(botBackup);
|
||||
}
|
||||
|
||||
public void SaveBotBackup(string name, Enums.BotType botType, string data)
|
||||
{
|
||||
var botBackup = new BotBackup
|
||||
{
|
||||
Name = name,
|
||||
BotType = botType,
|
||||
Data = data
|
||||
};
|
||||
|
||||
_botRepository.InsertBotAsync(botBackup);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,9 @@ using MediatR;
|
||||
using static Managing.Common.Enums;
|
||||
using Managing.Application.Abstractions;
|
||||
using Managing.Core;
|
||||
using Managing.Domain.MoneyManagements;
|
||||
using Newtonsoft.Json;
|
||||
using Managing.Application.Bots;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Managing.Application.ManageBot
|
||||
{
|
||||
@@ -15,20 +15,18 @@ namespace Managing.Application.ManageBot
|
||||
private readonly ITaskCache _taskCache;
|
||||
private readonly IMoneyManagementService _moneyManagementService;
|
||||
private readonly IBotRepository _botRepository;
|
||||
private readonly IMediator _mediator;
|
||||
private readonly ILogger<LoadBackupBotCommandHandler> _logger;
|
||||
|
||||
public LoadBackupBotCommandHandler(
|
||||
IBotFactory botFactory,
|
||||
ITaskCache taskCache,
|
||||
IMoneyManagementService moneyManagementService,
|
||||
IBotRepository botRepository,
|
||||
IMediator mediator)
|
||||
IBotRepository botRepository)
|
||||
{
|
||||
_botFactory = botFactory;
|
||||
_taskCache = taskCache;
|
||||
_moneyManagementService = moneyManagementService;
|
||||
_botRepository = botRepository;
|
||||
_mediator = mediator;
|
||||
}
|
||||
|
||||
public Task<string> Handle(LoadBackupBotCommand request, CancellationToken cancellationToken)
|
||||
@@ -37,6 +35,8 @@ namespace Managing.Application.ManageBot
|
||||
var backupBots = _botRepository.GetBots();
|
||||
var result = new Dictionary<string, BotStatus>();
|
||||
|
||||
_logger.LogInformation($"Loading {backupBots.Count()} backup bots");
|
||||
|
||||
foreach (var backupBot in backupBots)
|
||||
{
|
||||
// Check if bot is existing in cache
|
||||
@@ -46,7 +46,8 @@ namespace Managing.Application.ManageBot
|
||||
var simpleBot = _taskCache.Get<IBot>(backupBot.Name);
|
||||
if (simpleBot == null)
|
||||
{
|
||||
StartBot(request, backupBot);
|
||||
_logger.LogInformation($"Starting backup bot {backupBot.Name}");
|
||||
StartBot(backupBot);
|
||||
simpleBot.LoadBackup(backupBot);
|
||||
result.Add(simpleBot.GetName(), BotStatus.Backup);
|
||||
}
|
||||
@@ -61,7 +62,8 @@ namespace Managing.Application.ManageBot
|
||||
var scalpingBot = _taskCache.Get<ITradingBot>(backupBot.Name);
|
||||
if (scalpingBot == null)
|
||||
{
|
||||
StartBot(request, backupBot);
|
||||
_logger.LogInformation($"Starting backup bot {backupBot.Name}");
|
||||
StartBot(backupBot);
|
||||
scalpingBot.LoadBackup(backupBot);
|
||||
result.Add(scalpingBot.GetName(), BotStatus.Backup);
|
||||
}
|
||||
@@ -80,13 +82,13 @@ namespace Managing.Application.ManageBot
|
||||
return Task.FromResult(botStatus.ToString());
|
||||
}
|
||||
|
||||
private void StartBot(LoadBackupBotCommand request, BotBackup backupBot)
|
||||
private void StartBot(BotBackup backupBot)
|
||||
{
|
||||
switch (backupBot.BotType)
|
||||
{
|
||||
case BotType.SimpleBot:
|
||||
Func<Task<IBot>> simpleBot = () => Task.FromResult(_botFactory.CreateSimpleBot(request.Name, null));
|
||||
var bot1 = _taskCache.AddOrGetExisting(request.Name, simpleBot).Result;
|
||||
Func<Task<IBot>> simpleBot = () => Task.FromResult(_botFactory.CreateSimpleBot(backupBot.Name, null));
|
||||
var bot1 = _taskCache.AddOrGetExisting(backupBot.Name, simpleBot).Result;
|
||||
bot1.LoadBackup(backupBot);
|
||||
break;
|
||||
case BotType.ScalpingBot:
|
||||
@@ -99,7 +101,7 @@ namespace Managing.Application.ManageBot
|
||||
data.Scenario,
|
||||
data.Timeframe,
|
||||
data.IsForWatchingOnly));
|
||||
var bot2 = _taskCache.AddOrGetExisting(request.Name, scalpingBot).Result;
|
||||
var bot2 = _taskCache.AddOrGetExisting(backupBot.Name, scalpingBot).Result;
|
||||
bot2.LoadBackup(backupBot);
|
||||
break;
|
||||
case BotType.FlippingBot:
|
||||
@@ -112,7 +114,7 @@ namespace Managing.Application.ManageBot
|
||||
dataFlippingBot.Scenario,
|
||||
dataFlippingBot.Timeframe,
|
||||
dataFlippingBot.IsForWatchingOnly));
|
||||
var bot3 = _taskCache.AddOrGetExisting(request.Name, flippingBot).Result;
|
||||
var bot3 = _taskCache.AddOrGetExisting(backupBot.Name, flippingBot).Result;
|
||||
bot3.LoadBackup(backupBot);
|
||||
break;
|
||||
};
|
||||
@@ -121,7 +123,5 @@ namespace Managing.Application.ManageBot
|
||||
|
||||
public class LoadBackupBotCommand : IRequest<string>
|
||||
{
|
||||
public string Name { get; internal set; }
|
||||
public string AccountName { get; internal set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ public static class ApiBootstrap
|
||||
services.AddTransient<IStatisticRepository, StatisticRepository>();
|
||||
services.AddTransient<IWorkflowRepository, WorkflowRepository>();
|
||||
services.AddTransient<IBotRepository, BotRepository>();
|
||||
services.AddTransient<IWorkerRepository, WorkerRepository>();
|
||||
|
||||
// Cache
|
||||
services.AddDistributedMemoryCache();
|
||||
@@ -126,6 +127,7 @@ public static class ApiBootstrap
|
||||
services.AddSingleton<IMessengerService, MessengerService>();
|
||||
services.AddSingleton<IDiscordService, DiscordService>();
|
||||
services.AddSingleton<IBotService, BotService>();
|
||||
services.AddSingleton<IWorkerService, WorkerService>();
|
||||
|
||||
// Stream
|
||||
services.AddSingleton<IBinanceSocketClient, BinanceSocketClient>();
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace Managing.Domain.Bots
|
||||
public int Interval { get; set; }
|
||||
public BotStatus Status { get; set; }
|
||||
private CancellationTokenSource CancellationToken { get; set; }
|
||||
public string Data { get; set; }
|
||||
|
||||
public Bot(string name)
|
||||
{
|
||||
@@ -74,7 +73,7 @@ namespace Managing.Domain.Bots
|
||||
return Name;
|
||||
}
|
||||
|
||||
public abstract string GetBackup();
|
||||
public abstract void SaveBackup();
|
||||
public abstract void LoadBackup(BotBackup backup);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
void Restart();
|
||||
string GetStatus();
|
||||
string GetName();
|
||||
string GetBackup();
|
||||
void SaveBackup();
|
||||
void LoadBackup(BotBackup backup);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user