@foreach (stockPredictionPair cur in predictions){
Symbol: @cur.Symbol
@if (cur.Movement == -1){
Sell
} else if (cur.Movement == 1){
Buy
} else{
Hold
}
}
@code {
string button1Text = "Train AI";
string button2Text = "Predict AI";
List predictions = new List(){
new stockPredictionPair(){ Symbol = "AAPL" },
new stockPredictionPair(){ Symbol = "AAPL" },
new stockPredictionPair(){ Symbol = "TTD" },
new stockPredictionPair(){ Symbol = "FUN" }
};
async Task pullandtrain(){
button1Text = "Do not refresh the page. The data is refreshing.";
await Task.Delay(1);
aiModule.TrainAI();
button1Text = "Refresh Completed";
}
async Task predict(){
button2Text = "Do not refresh the page. The data is refreshing.";
await Task.Delay(1);
List threadpool = new List();
foreach(stockPredictionPair cur in predictions){
Task thread = new Task(() => {
cur.Movement = aiModule.PredictAI(cur.Symbol);
Console.WriteLine("Received Signal [" + cur.Symbol + "] : " + cur.Movement);
});
thread.Start();
threadpool.Add(thread);
}
await Task.WhenAll(threadpool);
button2Text = "Refresh Completed";
StateHasChanged();
await Task.Delay(1);
}
class stockPredictionPair{
public string Symbol = "";
public int Movement = 0;
}
}