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:
@@ -21,15 +21,13 @@ using Managing.Application.Trading.Commands;
|
||||
using Managing.Application.Users;
|
||||
using Managing.Application.Workers;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Managing.Application.Workflows;
|
||||
using Managing.Domain.Trades;
|
||||
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;
|
||||
@@ -58,60 +56,57 @@ public static class ApiBootstrap
|
||||
services.Configure<Web3ProxySettings>(configuration.GetSection("Web3Proxy"));
|
||||
|
||||
return services
|
||||
.AddWorkers(configuration)
|
||||
.AddApplication()
|
||||
.AddInfrastructure(configuration)
|
||||
.AddWorkers(configuration)
|
||||
.AddFluentValidation()
|
||||
.AddMediatR();
|
||||
}
|
||||
|
||||
private static IServiceCollection AddApplication(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<ITradingService, TradingService>();
|
||||
services.AddSingleton<IBotFactory, BotFactory>();
|
||||
services.AddSingleton<IBacktester, Backtester>();
|
||||
services.AddSingleton<IScenarioService, ScenarioService>();
|
||||
services.AddSingleton<IMoneyManagementService, MoneyManagementService>();
|
||||
services.AddSingleton<IAccountService, AccountService>();
|
||||
services.AddSingleton<IStatisticService, StatisticService>();
|
||||
services.AddSingleton<ISettingsService, SettingsService>();
|
||||
services.AddSingleton<IUserService, UserService>();
|
||||
services.AddSingleton<IWorkflowService, WorkflowService>();
|
||||
services.AddSingleton<IFlowFactory, FlowFactory>();
|
||||
services.AddSingleton<IGeneticService, GeneticService>();
|
||||
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.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<IExchangeProcessor, FtxProcessor>();
|
||||
services.AddTransient<IExchangeProcessor, BinanceProcessor>();
|
||||
services.AddTransient<IExchangeProcessor, KrakenProcessor>();
|
||||
|
||||
services.AddTransient<ITradaoService, TradaoService>();
|
||||
services.AddTransient<IExchangeService, ExchangeService>();
|
||||
services.AddTransient<IExchangeStream, ExchangeStream>();
|
||||
services.AddSingleton<IMessengerService, MessengerService>();
|
||||
services.AddSingleton<IDiscordService, DiscordService>();
|
||||
services.AddSingleton<IBotService, BotService>();
|
||||
services.AddSingleton<IWorkerService, WorkerService>();
|
||||
|
||||
|
||||
services.AddTransient<IPrivyService, PrivyService>();
|
||||
services.AddTransient<IWeb3ProxyService, Web3ProxyService>();
|
||||
services.AddTransient<IWebhookService, WebhookService>();
|
||||
services.AddTransient<ISynthPredictionService, SynthPredictionService>();
|
||||
services.AddTransient<ISynthApiClient, SynthApiClient>();
|
||||
services.AddTransient<IKaigenService, KaigenService>();
|
||||
|
||||
services.AddSingleton<IBotFactory, BotFactory>();
|
||||
services.AddSingleton<IMessengerService, MessengerService>();
|
||||
services.AddSingleton<IDiscordService, DiscordService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -128,30 +123,29 @@ public static class ApiBootstrap
|
||||
services.AddChainlinkGmx();
|
||||
services.AddSingleton<IEvmManager, EvmManager>();
|
||||
|
||||
// Repositories
|
||||
// PostgreSql Repositories
|
||||
|
||||
services.AddTransient<IAccountRepository, PostgreSqlAccountRepository>();
|
||||
services.AddTransient<IBacktestRepository, PostgreSqlBacktestRepository>();
|
||||
services.AddTransient<IGeneticRepository, PostgreSqlGeneticRepository>();
|
||||
services.AddTransient<ITradingRepository, PostgreSqlTradingRepository>();
|
||||
services.AddTransient<ISettingsRepository, PostgreSqlSettingsRepository>();
|
||||
services.AddTransient<IUserRepository, PostgreSqlUserRepository>();
|
||||
services.AddTransient<IStatisticRepository, PostgreSqlStatisticRepository>();
|
||||
services.AddTransient<IBotRepository, PostgreSqlBotRepository>();
|
||||
services.AddTransient<IWorkerRepository, PostgreSqlWorkerRepository>();
|
||||
services.AddTransient<ISynthRepository, PostgreSqlSynthRepository>();
|
||||
|
||||
// InfluxDb Repositories
|
||||
services.AddTransient<IInfluxDbRepository, InfluxDbRepository>();
|
||||
services.AddTransient<ICandleRepository, CandleRepository>();
|
||||
services.AddTransient<IAccountRepository, AccountRepository>();
|
||||
services.AddTransient<IBacktestRepository, BacktestRepository>();
|
||||
services.AddTransient<IGeneticRepository, GeneticRepository>();
|
||||
services.AddTransient<ITradingRepository, TradingRepository>();
|
||||
services.AddTransient<ISettingsRepository, SettingsRepository>();
|
||||
services.AddTransient<IUserRepository, UserRepository>();
|
||||
services.AddTransient<IStatisticRepository, StatisticRepository>();
|
||||
services.AddTransient<IWorkflowRepository, WorkflowRepository>();
|
||||
services.AddTransient<IBotRepository, BotRepository>();
|
||||
services.AddTransient<IWorkerRepository, WorkerRepository>();
|
||||
services.AddTransient<IAgentBalanceRepository, AgentBalanceRepository>();
|
||||
services.AddTransient<ISynthRepository, SynthRepository>();
|
||||
|
||||
// Cache
|
||||
services.AddDistributedMemoryCache();
|
||||
services.AddTransient<ICacheService, CacheService>();
|
||||
services.AddSingleton<ITaskCache, TaskCache>();
|
||||
|
||||
// Index Service
|
||||
services.AddSingleton<IndexService>();
|
||||
|
||||
// Services
|
||||
services.AddTransient<ICacheService, CacheService>();
|
||||
services.AddSingleton<ITaskCache, TaskCache>();
|
||||
|
||||
Reference in New Issue
Block a user