forked from CyberPunkMetalHead/Cryptocurrency-Sentiment-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
59 lines (44 loc) · 2.83 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using Inverse_CC_bot.DataAccess.Repositories;
using Inverse_CC_bot.Interfaces;
using Inverse_CC_bot.Services;
using Inverse_CC_bot.Types;
using Inverse_CC_bot.Workers;
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.SetBasePath(AppContext.BaseDirectory);
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
})
.ConfigureServices((hostContext, services) =>
{
services.AddScoped<IRedditScrapingService, RedditScrapingService>();
// Retrieve the connection string and register the db
string connectionString = hostContext.Configuration.GetConnectionString("Database");
string apiKey = hostContext.Configuration.GetSection("ApiConfig:ApiKey").Value;
string apiSecret = hostContext.Configuration.GetSection("ApiConfig:ApiSecret").Value;
//Store the general Configuration Settings that determine the behaviour of the application
var appConfig = hostContext.Configuration.GetSection("AppConfig").Get<AppConfig>();
if (appConfig == null) { return; }
services.AddScoped(_ => new DatabaseService(connectionString));
services.AddScoped<IExchangeService>(_ => new ExchangeService(Inverse_CC_bot.Enums.ExchangeNameEnum.Binance, apiKey, apiSecret));
services.AddScoped<IRedditDAL, RedditDAL>();
services.AddScoped<ICoinsDAL, CoinsDAL>();
services.AddScoped<ICoinSentimentsDAL, CoinSentimentsDAL>();
services.AddScoped<ISentimentAnalysisService, SentimentAnalysisService>();
services.AddScoped<ISentimentAggregatorService, SentimentAggregatorService>();
services.AddScoped<IOrdersDAL, OrdersDAL>();
services.AddScoped<IPortfolioDAL, PortfolioDAL>();
services.AddHostedService<RedditPostsWorker>();
services.AddHostedService<SentimentLabellerWorker>();
services.AddHostedService<SentimentAggregatorWorker>();
//services.AddHostedService<ExchangeBuyWorker>();
services.AddHostedService(provider =>
{
var logger = provider.GetRequiredService<ILogger<ExchangeBuyWorker>>();
var serviceProvider = provider.GetRequiredService<IServiceProvider>();
return new ExchangeBuyWorker(logger, serviceProvider, appConfig);
});
// TO DO - Create a Portfolio Manager Worker that calculates PNL and Sells coins.
})
.Build();
host.Run();