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:
@@ -1,8 +1,4 @@
|
||||
using Binance.Net.Clients;
|
||||
using Binance.Net.Interfaces.Clients;
|
||||
using Kraken.Net.Clients;
|
||||
using Kraken.Net.Interfaces.Clients;
|
||||
using Managing.Application;
|
||||
using Managing.Application;
|
||||
using Managing.Application.Abstractions;
|
||||
using Managing.Application.Abstractions.Repositories;
|
||||
using Managing.Application.Abstractions.Services;
|
||||
@@ -24,9 +20,8 @@ using Managing.Infrastructure.Databases;
|
||||
using Managing.Infrastructure.Databases.InfluxDb;
|
||||
using Managing.Infrastructure.Databases.InfluxDb.Abstractions;
|
||||
using Managing.Infrastructure.Databases.InfluxDb.Models;
|
||||
using Managing.Infrastructure.Databases.MongoDb;
|
||||
using Managing.Infrastructure.Databases.MongoDb.Abstractions;
|
||||
using Managing.Infrastructure.Databases.MongoDb.Configurations;
|
||||
using Managing.Infrastructure.Databases.PostgreSql;
|
||||
using Managing.Infrastructure.Databases.PostgreSql.Configurations;
|
||||
using Managing.Infrastructure.Evm;
|
||||
using Managing.Infrastructure.Evm.Abstractions;
|
||||
using Managing.Infrastructure.Evm.Models.Privy;
|
||||
@@ -50,31 +45,46 @@ public static class WorkersBootstrap
|
||||
{
|
||||
return services
|
||||
.AddApplication()
|
||||
.AddWorkers(configuration)
|
||||
.AddInfrastructure(configuration);
|
||||
.AddInfrastructure(configuration)
|
||||
.AddWorkers(configuration);
|
||||
}
|
||||
|
||||
private static IServiceCollection AddApplication(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<IUserService, UserService>();
|
||||
services.AddSingleton<ITradingService, TradingService>();
|
||||
services.AddSingleton<IBotFactory, BotFactory>();
|
||||
services.AddSingleton<IScenarioService, ScenarioService>();
|
||||
services.AddSingleton<IMoneyManagementService, MoneyManagementService>();
|
||||
services.AddSingleton<IPricesService, PricesService>();
|
||||
services.AddSingleton<IWorkerService, WorkerService>();
|
||||
services.AddSingleton<IAccountService, AccountService>();
|
||||
services.AddSingleton<IStatisticService, StatisticService>();
|
||||
services.AddSingleton<ITradingService, TradingService>();
|
||||
services.AddSingleton<ISettingsService, SettingsService>();
|
||||
services.AddSingleton<IBacktester, Backtester>();
|
||||
services.AddScoped<ITradingService, TradingService>();
|
||||
services.AddScoped<IScenarioService, ScenarioService>();
|
||||
services.AddScoped<IMoneyManagementService, MoneyManagementService>();
|
||||
services.AddScoped<IAccountService, AccountService>();
|
||||
services.AddScoped<IStatisticService, StatisticService>();
|
||||
services.AddScoped<ISettingsService, SettingsService>();
|
||||
services.AddScoped<IUserService, UserService>();
|
||||
services.AddScoped<IGeneticService, GeneticService>();
|
||||
services.AddScoped<IBackupBotService, BackupBotService>();
|
||||
services.AddSingleton<IBotService, BotService>();
|
||||
services.AddSingleton<ISynthPredictionService, SynthPredictionService>();
|
||||
services.AddSingleton<IGeneticService, GeneticService>();
|
||||
services.AddSingleton<IKaigenService, KaigenService>();
|
||||
services.AddScoped<IWorkerService, WorkerService>();
|
||||
services.AddScoped<ISynthPredictionService, SynthPredictionService>();
|
||||
services.AddScoped<ISynthApiClient, SynthApiClient>();
|
||||
services.AddTransient<ICommandHandler<OpenPositionRequest, Position>, OpenPositionCommandHandler>();
|
||||
services.AddTransient<ICommandHandler<ClosePositionCommand, Position>, ClosePositionCommandHandler>();
|
||||
|
||||
// Processors
|
||||
services.AddTransient<IBacktester, Backtester>();
|
||||
services.AddTransient<IExchangeProcessor, EvmProcessor>();
|
||||
|
||||
services.AddTransient<ITradaoService, TradaoService>();
|
||||
services.AddTransient<IExchangeService, ExchangeService>();
|
||||
services.AddTransient<IExchangeStream, ExchangeStream>();
|
||||
|
||||
|
||||
services.AddTransient<IPrivyService, PrivyService>();
|
||||
services.AddTransient<IWeb3ProxyService, Web3ProxyService>();
|
||||
services.AddTransient<IWebhookService, WebhookService>();
|
||||
services.AddTransient<IKaigenService, KaigenService>();
|
||||
|
||||
services.AddSingleton<IBotFactory, BotFactory>();
|
||||
services.AddSingleton<IMessengerService, MessengerService>();
|
||||
services.AddSingleton<IDiscordService, DiscordService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -106,12 +116,6 @@ public static class WorkersBootstrap
|
||||
services.AddHostedService<PricesFiveMinutesWorker>();
|
||||
}
|
||||
|
||||
// Other Workers
|
||||
if (configuration.GetValue<bool>("WorkerFee", false))
|
||||
{
|
||||
services.AddHostedService<FeeWorker>();
|
||||
}
|
||||
|
||||
if (configuration.GetValue<bool>("WorkerSpotlight", false))
|
||||
{
|
||||
services.AddHostedService<SpotlightWorker>();
|
||||
@@ -148,9 +152,8 @@ public static class WorkersBootstrap
|
||||
private static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
// Database
|
||||
services.AddSingleton<IManagingDatabaseSettings>(sp =>
|
||||
sp.GetRequiredService<IOptions<ManagingDatabaseSettings>>().Value);
|
||||
services.AddTransient(typeof(IMongoRepository<>), typeof(MongoRepository<>));
|
||||
services.AddSingleton<IPostgreSqlSettings>(sp =>
|
||||
sp.GetRequiredService<IOptions<PostgreSqlSettings>>().Value);
|
||||
|
||||
services.AddSingleton<IInfluxDbSettings>(sp =>
|
||||
sp.GetRequiredService<IOptions<InfluxDbSettings>>().Value);
|
||||
@@ -170,25 +173,23 @@ public static class WorkersBootstrap
|
||||
// Repositories
|
||||
services.AddTransient<ICandleRepository, CandleRepository>();
|
||||
services.AddTransient<IAgentBalanceRepository, AgentBalanceRepository>();
|
||||
services.AddTransient<IWorkerRepository, WorkerRepository>();
|
||||
services.AddTransient<IStatisticRepository, StatisticRepository>();
|
||||
services.AddTransient<IWorkerRepository, PostgreSqlWorkerRepository>();
|
||||
services.AddTransient<IStatisticRepository, PostgreSqlStatisticRepository>();
|
||||
services.AddTransient<ICandleRepository, CandleRepository>();
|
||||
services.AddTransient<IAccountRepository, AccountRepository>();
|
||||
services.AddTransient<ISettingsRepository, SettingsRepository>();
|
||||
services.AddTransient<ITradingRepository, TradingRepository>();
|
||||
services.AddTransient<IBacktestRepository, BacktestRepository>();
|
||||
services.AddTransient<IBotRepository, BotRepository>();
|
||||
services.AddTransient<IUserRepository, UserRepository>();
|
||||
services.AddTransient<ISynthRepository, SynthRepository>();
|
||||
services.AddTransient<IGeneticRepository, GeneticRepository>();
|
||||
services.AddTransient<IAccountRepository, PostgreSqlAccountRepository>();
|
||||
services.AddTransient<ISettingsRepository, PostgreSqlSettingsRepository>();
|
||||
services.AddTransient<ITradingRepository, PostgreSqlTradingRepository>();
|
||||
services.AddTransient<IBacktestRepository, PostgreSqlBacktestRepository>();
|
||||
services.AddTransient<IBotRepository, PostgreSqlBotRepository>();
|
||||
services.AddTransient<IUserRepository, PostgreSqlUserRepository>();
|
||||
services.AddTransient<ISynthRepository, PostgreSqlSynthRepository>();
|
||||
services.AddTransient<IGeneticRepository, PostgreSqlGeneticRepository>();
|
||||
|
||||
// Cache
|
||||
services.AddDistributedMemoryCache();
|
||||
services.AddTransient<ICacheService, CacheService>();
|
||||
services.AddTransient<ITaskCache, TaskCache>();
|
||||
|
||||
// Index Service
|
||||
services.AddSingleton<IndexService>();
|
||||
|
||||
// Processors
|
||||
services.AddTransient<IExchangeProcessor, EvmProcessor>();
|
||||
@@ -196,8 +197,6 @@ public static class WorkersBootstrap
|
||||
// Web Clients
|
||||
services.AddTransient<ITradaoService, TradaoService>();
|
||||
services.AddTransient<IExchangeService, ExchangeService>();
|
||||
services.AddSingleton<IBinanceSocketClient, BinanceSocketClient>();
|
||||
services.AddSingleton<IKrakenSocketClient, KrakenSocketClient>();
|
||||
services.AddSingleton<IPrivyService, PrivyService>();
|
||||
services.AddSingleton<ISynthApiClient, SynthApiClient>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user