Postgres (#30)
* Add postgres * Migrate users * Migrate geneticRequest * Try to fix Concurrent call * Fix asyncawait * Fix async and concurrent * Migrate backtests * Add cache for user by address * Fix backtest migration * Fix not open connection * Fix backtest command error * Fix concurrent * Fix all concurrency * Migrate TradingRepo * Fix scenarios * Migrate statistic repo * Save botbackup * Add settings et moneymanagement * Add bot postgres * fix a bit more backups * Fix bot model * Fix loading backup * Remove cache market for read positions * Add workers to postgre * Fix workers api * Reduce get Accounts for workers * Migrate synth to postgre * Fix backtest saved * Remove mongodb * botservice decorrelation * Fix tradingbot scope call * fix tradingbot * fix concurrent * Fix scope for genetics * Fix account over requesting * Fix bundle backtest worker * fix a lot of things * fix tab backtest * Remove optimized moneymanagement * Add light signal to not use User and too much property * Make money management lighter * insert indicators to awaitable * Migrate add strategies to await * Refactor scenario and indicator retrieval to use asynchronous methods throughout the application * add more async await * Add services * Fix and clean * Fix bot a bit * Fix bot and add message for cooldown * Remove fees * Add script to deploy db * Update dfeeploy script * fix script * Add idempotent script and backup * finish script migration * Fix did user and agent name on start bot
This commit is contained in:
@@ -9,15 +9,29 @@ public interface IAccountService
|
||||
Task<Account> CreateAccount(User user, Account account);
|
||||
bool DeleteAccount(User user, string name);
|
||||
IEnumerable<Account> GetAccountsByUser(User user, bool hideSecrets = true);
|
||||
IEnumerable<Account> GetAccounts(bool hideSecrets, bool getBalance);
|
||||
Task<IEnumerable<Account>> GetAccountsByUserAsync(User user, bool hideSecrets = true);
|
||||
Task<IEnumerable<Account>> GetAccounts(bool hideSecrets, bool getBalance);
|
||||
Task<IEnumerable<Account>> GetAccountsAsync(bool hideSecrets, bool getBalance);
|
||||
Task<Account> GetAccount(string name, bool hideSecrets, bool getBalance);
|
||||
Task<Account> GetAccountByUser(User user, string name, bool hideSecrets, bool getBalance);
|
||||
Task<Account> GetAccountByKey(string key, bool hideSecrets, bool getBalance);
|
||||
public Task<Account> GetAccountByUser(User user, string name, bool hideSecrets, bool getBalance);
|
||||
public Task<Account> GetAccountByKey(string key, bool hideSecrets, bool getBalance);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an account by name directly from the repository.
|
||||
/// </summary>
|
||||
/// <param name="accountName">The name of the account to find</param>
|
||||
/// <param name="hideSecrets">Whether to hide sensitive information</param>
|
||||
/// <param name="getBalance">Whether to fetch the current balance</param>
|
||||
/// <returns>The found account or null if not found</returns>
|
||||
Task<Account> GetAccountByAccountName(string accountName, bool hideSecrets = true, bool getBalance = false);
|
||||
|
||||
IEnumerable<Account> GetAccountsBalancesByUser(User user, bool hideSecrets = true);
|
||||
Task<IEnumerable<Account>> GetAccountsBalancesByUserAsync(User user, bool hideSecrets = true);
|
||||
Task<GmxClaimableSummary> GetGmxClaimableSummaryAsync(User user, string accountName);
|
||||
|
||||
Task<SwapInfos> SwapGmxTokensAsync(User user, string accountName, Ticker fromTicker, Ticker toTicker,
|
||||
double amount, string orderType = "market", double? triggerRatio = null, double allowedSlippage = 0.5);
|
||||
|
||||
Task<SwapInfos> SendTokenAsync(User user, string accountName, string recipientAddress, Ticker ticker, decimal amount, int? chainId = null);
|
||||
Task<SwapInfos> SendTokenAsync(User user, string accountName, string recipientAddress, Ticker ticker,
|
||||
decimal amount, int? chainId = null);
|
||||
}
|
||||
@@ -50,25 +50,34 @@ namespace Managing.Application.Abstractions.Services
|
||||
object metadata = null);
|
||||
|
||||
// Additional methods for backtest management
|
||||
bool DeleteBacktest(string id);
|
||||
Task<bool> DeleteBacktestAsync(string id);
|
||||
bool DeleteBacktests();
|
||||
IEnumerable<Backtest> GetBacktestsByUser(User user);
|
||||
Task<IEnumerable<Backtest>> GetBacktestsByUserAsync(User user);
|
||||
IEnumerable<Backtest> GetBacktestsByRequestId(string requestId);
|
||||
Task<IEnumerable<Backtest>> GetBacktestsByRequestIdAsync(string requestId);
|
||||
(IEnumerable<LightBacktest> Backtests, int TotalCount) GetBacktestsByRequestIdPaginated(string requestId, int page, int pageSize, string sortBy = "score", string sortOrder = "desc");
|
||||
Backtest GetBacktestByIdForUser(User user, string id);
|
||||
bool DeleteBacktestByUser(User user, string id);
|
||||
bool DeleteBacktestsByIdsForUser(User user, IEnumerable<string> ids);
|
||||
Task<(IEnumerable<LightBacktest> Backtests, int TotalCount)> GetBacktestsByRequestIdPaginatedAsync(string requestId, int page, int pageSize, string sortBy = "score", string sortOrder = "desc");
|
||||
Task<Backtest> GetBacktestByIdForUserAsync(User user, string id);
|
||||
Task<bool> DeleteBacktestByUserAsync(User user, string id);
|
||||
Task<bool> DeleteBacktestsByIdsForUserAsync(User user, IEnumerable<string> ids);
|
||||
bool DeleteBacktestsByUser(User user);
|
||||
bool DeleteBacktestsByRequestId(string requestId);
|
||||
Task<bool> DeleteBacktestsByRequestIdAsync(string requestId);
|
||||
(IEnumerable<LightBacktest> Backtests, int TotalCount) GetBacktestsByUserPaginated(User user, int page, int pageSize, string sortBy = "score", string sortOrder = "desc");
|
||||
Task<(IEnumerable<LightBacktest> Backtests, int TotalCount)> GetBacktestsByUserPaginatedAsync(User user, int page, int pageSize, string sortBy = "score", string sortOrder = "desc");
|
||||
|
||||
// Bundle backtest methods
|
||||
void InsertBundleBacktestRequestForUser(User user, BundleBacktestRequest bundleRequest);
|
||||
IEnumerable<BundleBacktestRequest> GetBundleBacktestRequestsByUser(User user);
|
||||
Task<IEnumerable<BundleBacktestRequest>> GetBundleBacktestRequestsByUserAsync(User user);
|
||||
BundleBacktestRequest? GetBundleBacktestRequestByIdForUser(User user, string id);
|
||||
Task<BundleBacktestRequest?> GetBundleBacktestRequestByIdForUserAsync(User user, string id);
|
||||
void UpdateBundleBacktestRequest(BundleBacktestRequest bundleRequest);
|
||||
Task UpdateBundleBacktestRequestAsync(BundleBacktestRequest bundleRequest);
|
||||
void DeleteBundleBacktestRequestByIdForUser(User user, string id);
|
||||
Task DeleteBundleBacktestRequestByIdForUserAsync(User user, string id);
|
||||
IEnumerable<BundleBacktestRequest> GetBundleBacktestRequestsByStatus(BundleBacktestRequestStatus status);
|
||||
Task<IEnumerable<BundleBacktestRequest>> GetBundleBacktestRequestsByStatusAsync(BundleBacktestRequestStatus status);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public interface IExchangeService
|
||||
|
||||
Task<decimal> GetBalance(Account account, bool isForPaperTrading = false);
|
||||
Task<List<Balance>> GetBalances(Account account, bool isForPaperTrading = false);
|
||||
decimal GetPrice(Account account, Ticker ticker, DateTime date);
|
||||
Task<decimal> GetPrice(Account account, Ticker ticker, DateTime date);
|
||||
Task<Trade> GetTrade(Account account, string order, Ticker ticker);
|
||||
|
||||
Task<List<Candle>> GetCandles(Account account, Ticker ticker, DateTime startDate, Timeframe interval,
|
||||
@@ -54,7 +54,7 @@ public interface IExchangeService
|
||||
Task<List<Candle>> GetCandlesInflux(TradingExchanges exchange, Ticker ticker, DateTime startDate,
|
||||
Timeframe timeframe, DateTime endDate);
|
||||
|
||||
decimal GetBestPrice(Account account, Ticker ticker, decimal lastPrice, decimal quantity, TradeDirection direction);
|
||||
Task<decimal> GetBestPrice(Account account, Ticker ticker, decimal lastPrice, decimal quantity, TradeDirection direction);
|
||||
Orderbook GetOrderbook(Account account, Ticker ticker);
|
||||
|
||||
Trade BuildEmptyTrade(Ticker ticker, decimal price, decimal quantity, TradeDirection direction, decimal? leverage,
|
||||
|
||||
@@ -64,7 +64,7 @@ public interface IGeneticService
|
||||
/// Updates a genetic request
|
||||
/// </summary>
|
||||
/// <param name="geneticRequest">The genetic request to update</param>
|
||||
void UpdateGeneticRequest(GeneticRequest geneticRequest);
|
||||
Task UpdateGeneticRequestAsync(GeneticRequest geneticRequest);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a genetic request by ID for a user
|
||||
@@ -74,10 +74,11 @@ public interface IGeneticService
|
||||
void DeleteGeneticRequestByIdForUser(User user, string id);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all pending genetic requests across all users
|
||||
/// Gets all genetic requests by status across all users
|
||||
/// </summary>
|
||||
/// <returns>Collection of pending genetic requests</returns>
|
||||
IEnumerable<GeneticRequest> GetPendingGeneticRequests();
|
||||
/// <param name="status">The status to filter by</param>
|
||||
/// <returns>Collection of genetic requests</returns>
|
||||
Task<List<GeneticRequest>> GetGeneticRequestsAsync(GeneticRequestStatus status);
|
||||
|
||||
/// <summary>
|
||||
/// Runs the genetic algorithm for a specific request
|
||||
|
||||
@@ -13,9 +13,13 @@ public interface IStatisticService
|
||||
int pageSize = 10);
|
||||
|
||||
List<Trader> GetBadTraders();
|
||||
Task<List<Trader>> GetBadTradersAsync();
|
||||
List<Trader> GetBestTraders();
|
||||
SpotlightOverview GetLastSpotlight(DateTime dateTime);
|
||||
Task<List<Trader>> GetBestTradersAsync();
|
||||
Task<SpotlightOverview> GetLastSpotlight(DateTime dateTime);
|
||||
Task<SpotlightOverview> GetLastSpotlightAsync(DateTime dateTime);
|
||||
IList<TopVolumeTicker> GetLastTopVolumeTicker();
|
||||
Task<IList<TopVolumeTicker>> GetLastTopVolumeTickerAsync();
|
||||
Task<List<Trade>> GetLeadboardPositons();
|
||||
Task<IList<Enums.Ticker>> GetTickers();
|
||||
Task UpdateLeaderboard();
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Managing.Domain.Bots;
|
||||
using Managing.Domain.MoneyManagements;
|
||||
using Managing.Domain.Strategies;
|
||||
using Managing.Domain.Synth.Models;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
@@ -70,7 +68,7 @@ public interface ISynthPredictionService
|
||||
/// <param name="isBacktest">Whether this is a backtest</param>
|
||||
/// <param name="customThresholds">Custom probability thresholds for decision-making. If null, uses default thresholds.</param>
|
||||
/// <returns>Comprehensive signal validation result including confidence, probabilities, and risk analysis</returns>
|
||||
Task<SignalValidationResult> ValidateSignalAsync(Signal signal, decimal currentPrice,
|
||||
Task<SignalValidationResult> ValidateSignalAsync(LightSignal signal, decimal currentPrice,
|
||||
TradingBotConfig botConfig, bool isBacktest, Dictionary<string, decimal> customThresholds = null);
|
||||
|
||||
/// <summary>
|
||||
@@ -105,5 +103,5 @@ public interface ISynthPredictionService
|
||||
/// <param name="direction">Position direction</param>
|
||||
/// <param name="moneyManagement">Money management settings</param>
|
||||
/// <returns>Estimated liquidation price</returns>
|
||||
decimal EstimateLiquidationPrice(decimal currentPrice, TradeDirection direction, MoneyManagement moneyManagement);
|
||||
decimal EstimateLiquidationPrice(decimal currentPrice, TradeDirection direction, LightMoneyManagement moneyManagement);
|
||||
}
|
||||
@@ -14,36 +14,28 @@ namespace Managing.Application.Abstractions.Services;
|
||||
|
||||
public interface ITradingService
|
||||
{
|
||||
Scenario GetScenarioByName(string scenario);
|
||||
void InsertSignal(Signal signal);
|
||||
void InsertPosition(Position position);
|
||||
void UpdatePosition(Position position);
|
||||
Indicator GetStrategyByName(string strategy);
|
||||
void InsertScenario(Scenario scenario);
|
||||
void InsertStrategy(Indicator indicator);
|
||||
IEnumerable<Scenario> GetScenarios();
|
||||
IEnumerable<Indicator> GetStrategies();
|
||||
void DeleteScenario(string name);
|
||||
void DeleteStrategy(string name);
|
||||
void DeleteScenarios();
|
||||
void DeleteStrategies();
|
||||
Position GetPositionByIdentifier(string identifier);
|
||||
IEnumerable<Position> GetPositions(PositionInitiator positionInitiator);
|
||||
IEnumerable<Position> GetPositions();
|
||||
IEnumerable<Position> GetPositionsByStatus(PositionStatus positionStatus);
|
||||
Task<Scenario> GetScenarioByNameAsync(string scenario);
|
||||
Task InsertPositionAsync(Position position);
|
||||
Task UpdatePositionAsync(Position position);
|
||||
Task<Indicator> GetStrategyByNameAsync(string strategy);
|
||||
Task InsertScenarioAsync(Scenario scenario);
|
||||
Task InsertStrategyAsync(Indicator indicator);
|
||||
Task<IEnumerable<Scenario>> GetScenariosAsync();
|
||||
Task<IEnumerable<Indicator>> GetStrategiesAsync();
|
||||
Task DeleteScenarioAsync(string name);
|
||||
Task DeleteStrategyAsync(string name);
|
||||
Task<Position> GetPositionByIdentifierAsync(string identifier);
|
||||
Task<Position> ManagePosition(Account account, Position position);
|
||||
void UpdateFee(TradingExchanges evm);
|
||||
decimal GetFee(Account account, bool isForPaperTrading = false);
|
||||
|
||||
Task WatchTrader();
|
||||
IEnumerable<Trader> GetTradersWatch();
|
||||
void UpdateDeltaNeutralOpportunities();
|
||||
void UpdateScenario(Scenario scenario);
|
||||
void UpdateStrategy(Indicator indicator);
|
||||
Task<IEnumerable<Trader>> GetTradersWatch();
|
||||
Task UpdateScenarioAsync(Scenario scenario);
|
||||
Task UpdateStrategyAsync(Indicator indicator);
|
||||
Task<IEnumerable<Position>> GetBrokerPositions(Account account);
|
||||
Task<PrivyInitAddressResponse> InitPrivyWallet(string publicAddress);
|
||||
|
||||
// Synth API integration methods
|
||||
Task<SignalValidationResult> ValidateSynthSignalAsync(Signal signal, decimal currentPrice,
|
||||
Task<SignalValidationResult> ValidateSynthSignalAsync(LightSignal signal, decimal currentPrice,
|
||||
TradingBotConfig botConfig,
|
||||
bool isBacktest);
|
||||
|
||||
@@ -59,7 +51,7 @@ public interface ITradingService
|
||||
/// <param name="scenario">The scenario containing indicators.</param>
|
||||
/// <param name="candles">The candles to calculate indicators for.</param>
|
||||
/// <returns>A dictionary of indicator types to their calculated values.</returns>
|
||||
Task<Dictionary<IndicatorType, IndicatorsResultBase>> CalculateIndicatorsValuesAsync(
|
||||
Scenario scenario,
|
||||
Dictionary<IndicatorType, IndicatorsResultBase> CalculateIndicatorsValuesAsync(
|
||||
Scenario scenario,
|
||||
List<Candle> candles);
|
||||
}
|
||||
@@ -9,5 +9,5 @@ public interface IUserService
|
||||
Task<User> UpdateAgentName(User user, string agentName);
|
||||
Task<User> UpdateAvatarUrl(User user, string avatarUrl);
|
||||
Task<User> UpdateTelegramChannel(User user, string telegramChannel);
|
||||
User GetUser(string name);
|
||||
}
|
||||
Task<User> GetUser(string name);
|
||||
}
|
||||
Reference in New Issue
Block a user