Link in the Automation component
This commit is contained in:
+21
-11
@@ -2,28 +2,38 @@ using WebServer.Components;
|
||||
using Controllers.PythonInterop;
|
||||
using Controllers.DataBase;
|
||||
using Controllers.Payment;
|
||||
using System.Runtime.InteropServices;
|
||||
using Controllers.Automation;
|
||||
|
||||
// Load the module in globally and use correct path for local or docker runners
|
||||
AIModule interopModule = new AIModule();
|
||||
AIModule _aiModule;
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) {
|
||||
_aiModule = new AIModule("/opt/homebrew/bin//python3.11");
|
||||
} else {
|
||||
_aiModule = new AIModule();
|
||||
}
|
||||
|
||||
// Load the Payment Processor
|
||||
IPayment _paymentProcessor = new PaymentTestor();
|
||||
|
||||
if (args.Contains("Retrain-AI")) {
|
||||
// This runs once per month on the first -> set by the crontab.txt
|
||||
interopModule.PullAI();
|
||||
interopModule.TrainAI();
|
||||
DbDriver _dbDriver = new DbDriver();
|
||||
AutomationController auto = new AutomationController(_aiModule, _dbDriver, _paymentProcessor);
|
||||
auto.GlobalTrainAI();
|
||||
} else if (args.Contains("Perform-AI")) {
|
||||
// This runs every hour that the stock market is open -> set by the crontab.txt
|
||||
|
||||
// Get all current holdings for Stocks
|
||||
// Perform the AI Signal per stock
|
||||
// Perform action in background for each stock
|
||||
DbDriver _dbDriver = new DbDriver();
|
||||
AutomationController auto = new AutomationController(_aiModule, _dbDriver, _paymentProcessor);
|
||||
auto.GlobalPredictAI();
|
||||
} else {
|
||||
// This runs when the server is started normally
|
||||
|
||||
// Make sure the data is ready before first run
|
||||
string firstPullRan = (new DbDriver()).Get("FirstPull");
|
||||
if (firstPullRan != "1") {
|
||||
interopModule.PullAI();
|
||||
interopModule.TrainAI();
|
||||
_aiModule.PullAI();
|
||||
_aiModule.TrainAI();
|
||||
(new DbDriver()).Set("FirstPull", "1");
|
||||
}
|
||||
|
||||
@@ -38,11 +48,11 @@ if (args.Contains("Retrain-AI")) {
|
||||
|
||||
// Insert the payment Processor
|
||||
builder.Services.AddSingleton<IPayment>(
|
||||
new PaymentTestor() // Of type Payment Testor -> Change this with stripe or square in the future
|
||||
_paymentProcessor
|
||||
);
|
||||
|
||||
// Insert the python modlue for Dependency Injection
|
||||
builder.Services.AddSingleton(interopModule);
|
||||
builder.Services.AddSingleton(_aiModule);
|
||||
|
||||
// Build the app
|
||||
var app = builder.Build();
|
||||
|
||||
Reference in New Issue
Block a user