Make predictions based on owned stocks

This commit is contained in:
2026-03-08 19:58:26 -07:00
parent 04631398ed
commit ce4f9a197d
4 changed files with 79 additions and 59 deletions
+59 -59
View File
@@ -66,50 +66,49 @@
}
<!-- AI Frame -->
<div class="gridFrame">
<div>
<h2>Current Signal</h2>
</div>
@foreach (stockPredictionPair cur in predictions){
<div class="signalBlock">
<div>
<p>@cur.Symbol</p>
</div>
<div>
<span>-></span>
</div>
@if (cur.Movement == -1){
<div style="background-color: red;"><p style=>Sell</p></div>
} else if (cur.Movement == 1){
<div style="background-color: green;"><p>Buy</p></div>
} else{
<div style="background-color: #444;"><p>Hold</p></div>
}
@if (Session != null){
<div class="gridFrame">
<div>
<h2>Current Signal</h2>
</div>
}
</div>
@foreach (PurchasedStock cur in Session.TrackedStocks){
<div class="signalBlock">
<div>
<p>@cur.Symbol</p>
</div>
<div>
<span>-></span>
</div>
@if (cur.PredictedMovement == -1){
<div style="background-color: red;"><p style=>Sell</p></div>
} else if (cur.PredictedMovement == 1){
<div style="background-color: green;"><p>Buy</p></div>
} else{
<div style="background-color: #444;"><p>Hold</p></div>
}
</div>
}
</div>
}
</div>
@code {
// User Stuff
/////////////////////////////////////////////////////////////////////////////////////////////
/// Code Region
/////////////////////////////////////////////////////////////////////////////////////////////
loginSession? Session = null;
// Login Stuff
string userName = "";
string passWord = "";
string loginError = "";
List<stockPredictionPair> predictions = new List<stockPredictionPair>(){
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<Task> threadpool = new List<Task>();
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<PurchasedStock> TrackedStocks { get; set; } = new List<PurchasedStock>();
}
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;
}
}