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