67 lines
3.2 KiB
C#
67 lines
3.2 KiB
C#
using Managing.Application.Bots.Models;
|
|
using Managing.Domain.Accounts;
|
|
using Managing.Domain.Bots;
|
|
using Managing.Domain.Trades;
|
|
using static Managing.Common.Enums;
|
|
|
|
namespace Managing.Application.Abstractions;
|
|
|
|
public interface IBotService
|
|
{
|
|
Task<IEnumerable<Bot>> GetBotsAsync();
|
|
Task<IEnumerable<Bot>> GetBotsByStatusAsync(BotStatus status);
|
|
Task<BotStatus> StopBot(Guid identifier);
|
|
Task<BotStatus> RestartBot(Guid identifier);
|
|
Task<bool> DeleteBot(Guid identifier);
|
|
Task<bool> UpdateBotConfiguration(Guid identifier, TradingBotConfig newConfig);
|
|
Task<IEnumerable<string>> GetActiveBotsNamesAsync();
|
|
Task<IEnumerable<Bot>> GetBotsByUser(int id);
|
|
Task<IEnumerable<Bot>> GetBotsByIdsAsync(IEnumerable<Guid> botIds);
|
|
Task<Bot> GetBotByName(string name);
|
|
Task<Bot> GetBotByIdentifier(Guid identifier);
|
|
Task<Position> OpenPositionManuallyAsync(Guid identifier, TradeDirection direction);
|
|
Task<Position> ClosePositionAsync(Guid identifier, Guid positionId);
|
|
Task<TradingBotConfig> GetBotConfig(Guid identifier);
|
|
Task<IEnumerable<TradingBotConfig>> GetBotConfigsByIdsAsync(IEnumerable<Guid> botIds);
|
|
Task<bool> UpdateBotStatisticsAsync(Guid identifier);
|
|
Task<bool> SaveBotStatisticsAsync(Bot bot);
|
|
|
|
/// <summary>
|
|
/// Computes the remaining available USDC allocation for the provided account,
|
|
/// subtracting the sum of BotTradingBalance from other bots using the same account.
|
|
/// Optionally exclude a specific bot identifier from the allocation sum (useful for restarts/updates).
|
|
/// </summary>
|
|
/// <param name="account">Target account.</param>
|
|
/// <param name="excludeIdentifier">Bot identifier to exclude from allocation sum.</param>
|
|
/// <returns>Available USDC amount that can be allocated.</returns>
|
|
Task<decimal> GetAvailableAllocationUsdAsync(Account account, Guid excludeIdentifier = default);
|
|
|
|
/// <summary>
|
|
/// Gets paginated bots with filtering and sorting
|
|
/// </summary>
|
|
/// <param name="pageNumber">Page number (1-based)</param>
|
|
/// <param name="pageSize">Number of items per page</param>
|
|
/// <param name="status">Filter by status (optional)</param>
|
|
/// <param name="name">Filter by name (partial match, case-insensitive)</param>
|
|
/// <param name="ticker">Filter by ticker (partial match, case-insensitive)</param>
|
|
/// <param name="agentName">Filter by agent name (partial match, case-insensitive)</param>
|
|
/// <param name="sortBy">Sort field</param>
|
|
/// <param name="sortDirection">Sort direction ("Asc" or "Desc")</param>
|
|
/// <returns>Tuple containing the bots for the current page and total count</returns>
|
|
Task<(IEnumerable<Bot> Bots, int TotalCount)> GetBotsPaginatedAsync(
|
|
int pageNumber,
|
|
int pageSize,
|
|
BotStatus? status = null,
|
|
string? name = null,
|
|
string? ticker = null,
|
|
string? agentName = null,
|
|
string sortBy = "CreateDate",
|
|
string sortDirection = "Desc");
|
|
|
|
/// <summary>
|
|
/// Checks USDC and ETH balances for EVM/GMX V2 accounts
|
|
/// </summary>
|
|
/// <param name="account">The account to check balances for</param>
|
|
/// <returns>Balance check result</returns>
|
|
Task<BalanceCheckResult> CheckAccountBalancesAsync(Account account);
|
|
} |