diff --git a/WebServer/Components/Pages/Home.razor b/WebServer/Components/Pages/Home.razor index 1a73f7eb..156699c0 100644 --- a/WebServer/Components/Pages/Home.razor +++ b/WebServer/Components/Pages/Home.razor @@ -66,50 +66,49 @@ } -
-
-

Current Signal

-
- @foreach (stockPredictionPair cur in predictions){ -
-
-

@cur.Symbol

-
-
- -> -
- @if (cur.Movement == -1){ -

Sell

- } else if (cur.Movement == 1){ -

Buy

- } else{ -

Hold

- } - + @if (Session != null){ +
+
+

Current Signal

- } -
+ @foreach (PurchasedStock cur in Session.TrackedStocks){ +
+
+

@cur.Symbol

+
+
+ -> +
+ @if (cur.PredictedMovement == -1){ +

Sell

+ } else if (cur.PredictedMovement == 1){ +

Buy

+ } else{ +

Hold

+ } + +
+ } +
+ }
- @code { - // User Stuff + ///////////////////////////////////////////////////////////////////////////////////////////// + /// Code Region + ///////////////////////////////////////////////////////////////////////////////////////////// + loginSession? Session = null; - // Login Stuff - string userName = ""; - string passWord = ""; - string loginError = ""; - List predictions = new List(){ - new stockPredictionPair(){ Symbol = "AAPL" }, - new stockPredictionPair(){ Symbol = "AAPL" }, - new stockPredictionPair(){ Symbol = "TTD" }, - new stockPredictionPair(){ Symbol = "FUN" } - }; + + + + + // On Page Load string PaymentKey = ""; protected override async Task OnInitializedAsync(){ (bool, string) result = PaymentProcessor.CreatePayment(); @@ -119,6 +118,16 @@ PaymentKey = result.Item2; } + + + + + + + // Login Stuff + string userName = ""; + string passWord = ""; + string loginError = ""; async Task LoginSession(){ string dbPrefix = $"[{userName.ToLower()}]:"; // Set the DB prefix for the get and set string passwordhash = dbDriver.Get( dbPrefix + "password" ); // Pull the password hash @@ -147,6 +156,12 @@ } } + + + + + + // AI Stuff string pullButtonText = "Pull Data"; @@ -195,20 +210,20 @@ async Task predict(){ resultError = ""; - if (Debounce){ + if (Debounce && Session != null){ Debounce = false; predictButtonText = "Do not refresh the page. The AI is predicting"; await Task.Delay(1); List threadpool = new List(); - foreach(stockPredictionPair cur in predictions){ + foreach(PurchasedStock cur in Session.TrackedStocks){ Task thread = new Task(() => { (string, int)Result = aiModule.PredictAI(cur.Symbol); if (string.IsNullOrEmpty(Result.Item1)){ - cur.Movement = Result.Item2; + cur.PredictedMovement = Result.Item2; }else{ resultError = Result.Item1; } - Console.WriteLine("Received Signal [" + cur.Symbol + "] : " + cur.Movement); + Console.WriteLine("Received Signal [" + cur.Symbol + "] : " + cur.PredictedMovement); }); thread.Start(); threadpool.Add(thread); @@ -221,6 +236,12 @@ } } + + + + + + // Stock Manipulation string buyStockSymbol = ""; @@ -259,27 +280,6 @@ return; } PaymentKey = result.Item2; - } } - - // Data Types - - class stockPredictionPair { - public string Symbol { get; set; } = ""; - public int Movement { get; set; } = 0; - } - - class loginSession { - public string UserName { get; set; } = ""; - public List TrackedStocks { get; set; } = new List(); - } - - class PurchasedStock { - public string Symbol { get; set; } = ""; - public float PurchasePrice { get; set; } = 0; - public float Quantity { get; set; } = 0; - public DateTime PurchaseDate { get; set; } = DateTime.Now; - } - } \ No newline at end of file diff --git a/WebServer/Components/_Imports.razor b/WebServer/Components/_Imports.razor index 4f8bc09b..08f4f2c3 100644 --- a/WebServer/Components/_Imports.razor +++ b/WebServer/Components/_Imports.razor @@ -13,6 +13,7 @@ @using WebServer.Components @using BCrypt.Net; @using Newtonsoft.Json; +@using Entities @inject DbDriver dbDriver @inject AIModule aiModule diff --git a/WebServer/Entities/LoginSession.cs b/WebServer/Entities/LoginSession.cs new file mode 100644 index 00000000..c35c06ee --- /dev/null +++ b/WebServer/Entities/LoginSession.cs @@ -0,0 +1,8 @@ +namespace Entities { + + class loginSession { + public string UserName { get; set; } = ""; + public List TrackedStocks { get; set; } = new List(); + } + +} \ No newline at end of file diff --git a/WebServer/Entities/PurchasedStock.cs b/WebServer/Entities/PurchasedStock.cs new file mode 100644 index 00000000..7936aa19 --- /dev/null +++ b/WebServer/Entities/PurchasedStock.cs @@ -0,0 +1,11 @@ +namespace Entities { + + class PurchasedStock { + public string Symbol { get; set; } = ""; + public float PurchasePrice { get; set; } = 0; + public float Quantity { get; set; } = 0; + public DateTime PurchaseDate { get; set; } = DateTime.Now; + public int PredictedMovement { get; set; } = 0; + } + +} \ No newline at end of file