docker files fixes from liaqat
This commit is contained in:
157
src/Managing.Bootstrap/ApiBootstrap.cs
Normal file
157
src/Managing.Bootstrap/ApiBootstrap.cs
Normal file
@@ -0,0 +1,157 @@
|
||||
using FluentValidation;
|
||||
using Managing.Application.Shared.Behaviours;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Reflection;
|
||||
using Managing.Infrastructure.Exchanges;
|
||||
using Managing.Infrastructure.Storage;
|
||||
using Managing.Infrastructure.Databases.MongoDb;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Managing.Application.Trading;
|
||||
using Managing.Infrastructure.Messengers.Discord;
|
||||
using Managing.Infrastructure.Evm;
|
||||
using Discord.WebSocket;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Discord.Commands;
|
||||
using Managing.Application.Backtesting;
|
||||
using Managing.Application.Scenarios;
|
||||
using Managing.Application.MoneyManagements;
|
||||
using Managing.Application.Accounts;
|
||||
using Managing.Application.Abstractions;
|
||||
using Managing.Application.Shared;
|
||||
using Managing.Infrastructure.Databases;
|
||||
using Managing.Infrastructure.Databases.Abstractions;
|
||||
using Managing.Infrastructure.Databases.InfluxDb.Models;
|
||||
using Managing.Infrastructure.Databases.InfluxDb;
|
||||
using Managing.Application.Abstractions.Repositories;
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Infrastructure.Databases.MongoDb.Abstractions;
|
||||
using Managing.Infrastructure.Exchanges.Abstractions;
|
||||
using Managing.Infrastructure.Exchanges.Exchanges;
|
||||
using Managing.Application.Users;
|
||||
using Managing.Infrastructure.Evm.Subgraphs;
|
||||
using Managing.Application.ManageBot.Commands;
|
||||
using Managing.Application.Trading.Commands;
|
||||
using Managing.Domain.Trades;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Managing.Application.Workers;
|
||||
using Binance.Net.Clients;
|
||||
using Binance.Net.Interfaces.Clients;
|
||||
using Managing.Infrastructure.Evm.Services;
|
||||
using Managing.Application.Workflows;
|
||||
using Managing.Application.Bots.Base;
|
||||
|
||||
namespace Managing.Bootstrap;
|
||||
|
||||
public static class ApiBootstrap
|
||||
{
|
||||
|
||||
private static readonly Assembly ApplicationAssembly = typeof(StartBotCommand).GetTypeInfo().Assembly;
|
||||
|
||||
public static IServiceCollection RegisterApiDependencies(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
return services
|
||||
.AddApplication()
|
||||
.AddInfrastructure(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.AddTransient<ICommandHandler<OpenPositionRequest, Position>, OpenPositionCommandHandler>();
|
||||
services.AddTransient<ICommandHandler<ClosePositionCommand, Position>, ClosePositionCommandHandler>();
|
||||
|
||||
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<IInfluxDbSettings>(sp =>
|
||||
sp.GetRequiredService<IOptions<InfluxDbSettings>>().Value);
|
||||
|
||||
// Evm
|
||||
services.AddGbcFeed();
|
||||
services.AddUniswapV2();
|
||||
services.AddChainlink();
|
||||
services.AddChainlinkGmx();
|
||||
services.AddSingleton<IEvmManager, EvmManager>();
|
||||
|
||||
// Repositories
|
||||
services.AddTransient<IInfluxDbRepository, InfluxDbRepository>();
|
||||
services.AddTransient<ICandleRepository, CandleRepository>();
|
||||
services.AddTransient<IAccountRepository, AccountRepository>();
|
||||
services.AddTransient<IBacktestRepository, BacktestRepository>();
|
||||
services.AddTransient<ITradingRepository, TradingRepository>();
|
||||
services.AddTransient<ISettingsRepository, SettingsRepository>();
|
||||
services.AddTransient<IUserRepository, UserRepository>();
|
||||
services.AddTransient<IStatisticRepository, StatisticRepository>();
|
||||
services.AddTransient<IWorkflowRepository, WorkflowRepository>();
|
||||
|
||||
// Cache
|
||||
services.AddDistributedMemoryCache();
|
||||
services.AddTransient<ICacheService, CacheService>();
|
||||
services.AddTransient<ITaskCache, TaskCache>();
|
||||
|
||||
// Processors
|
||||
services.AddTransient<IExchangeProcessor, EvmProcessor>();
|
||||
services.AddTransient<IExchangeProcessor, FtxProcessor>();
|
||||
services.AddTransient<IExchangeProcessor, BinanceProcessor>();
|
||||
services.AddTransient<IExchangeProcessor, KrakenProcessor>();
|
||||
|
||||
// Services
|
||||
services.AddTransient<ITradaoService, TradaoService>();
|
||||
services.AddTransient<IExchangeService, ExchangeService>();
|
||||
services.AddTransient<IExchangeStream, ExchangeStream>();
|
||||
services.AddSingleton<IMessengerService, MessengerService>();
|
||||
services.AddSingleton<IDiscordService, DiscordService>();
|
||||
|
||||
// Stream
|
||||
services.AddSingleton<IBinanceSocketClient, BinanceSocketClient>();
|
||||
services.AddSingleton<IStreamService, StreamService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
private static IServiceCollection AddMediatR(this IServiceCollection services)
|
||||
{
|
||||
return services.AddMediatR(AppDomain.CurrentDomain.GetAssemblies())
|
||||
.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehaviour<,>))
|
||||
.AddTransient(typeof(IUnhandledExceptionBehaviour<,>), typeof(UnhandledExceptionBehaviour<,>));
|
||||
}
|
||||
|
||||
private static IServiceCollection AddFluentValidation(this IServiceCollection services)
|
||||
{
|
||||
return services.AddValidatorsFromAssembly(ApplicationAssembly);
|
||||
}
|
||||
|
||||
public static IWebHostBuilder SetupDiscordBot(this IWebHostBuilder builder)
|
||||
{
|
||||
return builder.ConfigureServices(services =>
|
||||
{
|
||||
services
|
||||
.AddSingleton<DiscordSettings>()
|
||||
.AddSingleton<DiscordSocketClient>()
|
||||
.AddSingleton<CommandService>()
|
||||
.AddHostedService<DiscordService>();
|
||||
});
|
||||
}
|
||||
}
|
||||
28
src/Managing.Bootstrap/Managing.Bootstrap.csproj
Normal file
28
src/Managing.Bootstrap/Managing.Bootstrap.csproj
Normal file
@@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.6.0" />
|
||||
<PackageReference Include="MediatR" Version="11.0.0" />
|
||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Managing.Application.Workers\Managing.Application.Workers.csproj" />
|
||||
<ProjectReference Include="..\Managing.Application\Managing.Application.csproj" />
|
||||
<ProjectReference Include="..\Managing.Infrastructure.Database\Managing.Infrastructure.Databases.csproj" />
|
||||
<ProjectReference Include="..\Managing.Infrastructure.Exchanges\Managing.Infrastructure.Exchanges.csproj" />
|
||||
<ProjectReference Include="..\Managing.Infrastructure.Messengers\Managing.Infrastructure.Messengers.csproj" />
|
||||
<ProjectReference Include="..\Managing.Infrastructure.Storage\Managing.Infrastructure.Storage.csproj" />
|
||||
<ProjectReference Include="..\Managing.Infrastructure.Web3\Managing.Infrastructure.Evm.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
117
src/Managing.Bootstrap/WorkersBootstrap.cs
Normal file
117
src/Managing.Bootstrap/WorkersBootstrap.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using Binance.Net.Clients;
|
||||
using Binance.Net.Interfaces.Clients;
|
||||
using Kraken.Net.Clients;
|
||||
using Kraken.Net.Interfaces.Clients;
|
||||
using Managing.Application.Abstractions;
|
||||
using Managing.Application.Accounts;
|
||||
using Managing.Application.Workers;
|
||||
using Managing.Application.Workers.Abstractions;
|
||||
using Managing.Infrastructure.Exchanges;
|
||||
using Managing.Infrastructure.Databases;
|
||||
using Managing.Infrastructure.Databases.Abstractions;
|
||||
using Managing.Infrastructure.Databases.InfluxDb.Models;
|
||||
using Managing.Infrastructure.Databases.MongoDb;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Managing.Infrastructure.Databases.InfluxDb;
|
||||
using Managing.Application.Abstractions.Repositories;
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Infrastructure.Databases.MongoDb.Abstractions;
|
||||
using Managing.Infrastructure.Evm.Subgraphs;
|
||||
using Managing.Infrastructure.Evm;
|
||||
using Managing.Infrastructure.Storage;
|
||||
using Managing.Infrastructure.Exchanges.Abstractions;
|
||||
using Managing.Infrastructure.Exchanges.Exchanges;
|
||||
using Managing.Application.Trading;
|
||||
using Managing.Application.Backtesting;
|
||||
using Managing.Application.MoneyManagements;
|
||||
using Managing.Application.Scenarios;
|
||||
using Managing.Application.Shared;
|
||||
using Managing.Infrastructure.Messengers.Discord;
|
||||
using Managing.Application.Trading.Commands;
|
||||
using Managing.Domain.Trades;
|
||||
using Managing.Infrastructure.Evm.Services;
|
||||
using Managing.Application.Bots.Base;
|
||||
|
||||
namespace Managing.Bootstrap;
|
||||
|
||||
public static class WorkersBootstrap
|
||||
{
|
||||
public static IServiceCollection RegisterWorkersDependencies(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
return services
|
||||
.AddApplication()
|
||||
.AddInfrastructure(configuration);
|
||||
}
|
||||
|
||||
private static IServiceCollection AddApplication(this IServiceCollection services)
|
||||
{
|
||||
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.AddTransient<ICommandHandler<OpenPositionRequest, Position>, OpenPositionCommandHandler>();
|
||||
services.AddTransient<ICommandHandler<ClosePositionCommand, Position>, ClosePositionCommandHandler>();
|
||||
|
||||
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<IInfluxDbSettings>(sp =>
|
||||
sp.GetRequiredService<IOptions<InfluxDbSettings>>().Value);
|
||||
|
||||
services.AddTransient<IInfluxDbRepository, InfluxDbRepository>();
|
||||
|
||||
// Evm
|
||||
services.AddUniswapV2();
|
||||
services.AddGbcFeed();
|
||||
services.AddChainlink();
|
||||
services.AddChainlinkGmx();
|
||||
services.AddSingleton<IEvmManager, EvmManager>();
|
||||
|
||||
// Repositories
|
||||
services.AddTransient<ICandleRepository, CandleRepository>();
|
||||
services.AddTransient<IWorkerRepository, WorkerRepository>();
|
||||
services.AddTransient<IStatisticRepository, StatisticRepository>();
|
||||
services.AddTransient<ICandleRepository, CandleRepository>();
|
||||
services.AddTransient<IAccountRepository, AccountRepository>();
|
||||
services.AddTransient<ISettingsRepository, SettingsRepository>();
|
||||
services.AddTransient<ITradingRepository, TradingRepository>();
|
||||
services.AddTransient<IBacktestRepository, BacktestRepository>();
|
||||
|
||||
// Cache
|
||||
services.AddDistributedMemoryCache();
|
||||
services.AddTransient<ICacheService, CacheService>();
|
||||
services.AddTransient<ITaskCache, TaskCache>();
|
||||
|
||||
// Processors
|
||||
services.AddTransient<IExchangeProcessor, EvmProcessor>();
|
||||
|
||||
// Web Clients
|
||||
services.AddTransient<ITradaoService, TradaoService>();
|
||||
services.AddTransient<IExchangeService, ExchangeService>();
|
||||
services.AddSingleton<IBinanceSocketClient, BinanceSocketClient>();
|
||||
services.AddSingleton<IKrakenSocketClient, KrakenSocketClient>();
|
||||
|
||||
// Messengers
|
||||
services.AddSingleton<IMessengerService, MessengerService>();
|
||||
services.AddSingleton<IDiscordService, DiscordService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user