Add debounce and stylize
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
<!-- User Frame -->
|
||||
}else{
|
||||
<div class="gridFrame">
|
||||
<div><h2>Account</h2></div>
|
||||
<span>UserName: @Session.UserName</span><br />
|
||||
<div>
|
||||
@foreach(PurchasedStock cur in Session.TrackedStocks){
|
||||
@@ -42,10 +43,16 @@
|
||||
<!-- Tool Frame -->
|
||||
<div class="gridFrame">
|
||||
<div>
|
||||
<span>Actions</span>
|
||||
<button @onclick="pull">@pullButtonText</button>
|
||||
<button @onclick="train">@trainButtonText</button>
|
||||
<button @onclick="predict">@predictButtonText</button>
|
||||
<div><h2>Actions</h2></div>
|
||||
@if (Debounce){
|
||||
<button @onclick="pull">@pullButtonText</button>
|
||||
<button @onclick="train">@trainButtonText</button>
|
||||
<button @onclick="predict">@predictButtonText</button>
|
||||
}else{
|
||||
<button disabled>@pullButtonText</button>
|
||||
<button disabled>@trainButtonText</button>
|
||||
<button disabled>@predictButtonText</button>
|
||||
}
|
||||
<span>@PredictError</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -54,22 +61,26 @@
|
||||
<!-- AI Frame -->
|
||||
<div class="gridFrame">
|
||||
<div>
|
||||
|
||||
<h2>Current Signal</h2>
|
||||
</div>
|
||||
<div>
|
||||
@foreach (stockPredictionPair cur in predictions){
|
||||
@foreach (stockPredictionPair cur in predictions){
|
||||
<div class="signalBlock">
|
||||
<div>
|
||||
<h1>Symbol: @cur.Symbol</h1><br />
|
||||
@if (cur.Movement == -1){
|
||||
<p>Sell</p>
|
||||
} else if (cur.Movement == 1){
|
||||
<p>Buy</p>
|
||||
} else{
|
||||
<p>Hold</p>
|
||||
}
|
||||
<p>@cur.Symbol</p>
|
||||
</div>
|
||||
}
|
||||
</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>
|
||||
}
|
||||
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -127,11 +138,11 @@
|
||||
string predictButtonText = "Predict AI";
|
||||
string PredictError = "";
|
||||
|
||||
bool pullDebounce = true;
|
||||
bool Debounce = true;
|
||||
async Task pull(){
|
||||
PredictError = "";
|
||||
if (pullDebounce){
|
||||
pullDebounce = false;
|
||||
if (Debounce){
|
||||
Debounce = false;
|
||||
pullButtonText = "Do not refresh the page. The data is pulling.";
|
||||
await Task.Delay(1);
|
||||
Task thread = new Task(async () => {
|
||||
@@ -141,17 +152,16 @@
|
||||
await Task.Delay(2000);
|
||||
pullButtonText = "Pull Data";
|
||||
await InvokeAsync(StateHasChanged);
|
||||
pullDebounce = true;
|
||||
Debounce = true;
|
||||
});
|
||||
thread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
bool trainDebounce = true;
|
||||
async Task train(){
|
||||
PredictError = "";
|
||||
if (trainDebounce){
|
||||
trainDebounce = false;
|
||||
if (Debounce){
|
||||
Debounce = false;
|
||||
trainButtonText = "Do not refresh the page. The AI is training.";
|
||||
await Task.Delay(1);
|
||||
Task thread = new Task(async () => {
|
||||
@@ -161,7 +171,7 @@
|
||||
await Task.Delay(2000);
|
||||
trainButtonText = "Train AI";
|
||||
StateHasChanged();
|
||||
trainDebounce = true;
|
||||
Debounce = true;
|
||||
});
|
||||
thread.Start();
|
||||
}
|
||||
@@ -169,26 +179,30 @@
|
||||
|
||||
async Task predict(){
|
||||
PredictError = "";
|
||||
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){
|
||||
Task thread = new Task(() => {
|
||||
(string, int)Result = aiModule.PredictAI(cur.Symbol);
|
||||
if (string.IsNullOrEmpty(Result.Item1)){
|
||||
cur.Movement = Result.Item2;
|
||||
}else{
|
||||
PredictError = Result.Item1;
|
||||
}
|
||||
Console.WriteLine("Received Signal [" + cur.Symbol + "] : " + cur.Movement);
|
||||
});
|
||||
thread.Start();
|
||||
threadpool.Add(thread);
|
||||
if (Debounce){
|
||||
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){
|
||||
Task thread = new Task(() => {
|
||||
(string, int)Result = aiModule.PredictAI(cur.Symbol);
|
||||
if (string.IsNullOrEmpty(Result.Item1)){
|
||||
cur.Movement = Result.Item2;
|
||||
}else{
|
||||
PredictError = Result.Item1;
|
||||
}
|
||||
Console.WriteLine("Received Signal [" + cur.Symbol + "] : " + cur.Movement);
|
||||
});
|
||||
thread.Start();
|
||||
threadpool.Add(thread);
|
||||
}
|
||||
await Task.WhenAll(threadpool);
|
||||
predictButtonText = "Predictions loaded";
|
||||
await Task.Delay(2000);
|
||||
predictButtonText = "Predict AI";
|
||||
Debounce = true;
|
||||
}
|
||||
await Task.WhenAll(threadpool);
|
||||
predictButtonText = "Predictions loaded";
|
||||
await Task.Delay(2000);
|
||||
predictButtonText = "Predict AI";
|
||||
}
|
||||
|
||||
// Data Types
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
grid-auto-columns: auto;
|
||||
grid-auto-flow: column;
|
||||
grid-template-columns: max-content;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
.gridFrame {
|
||||
@@ -59,4 +58,30 @@
|
||||
|
||||
.loginRow button:last-of-type{
|
||||
float: right;
|
||||
}
|
||||
|
||||
.signalBlock {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.signalBlock > :nth-child(1) {
|
||||
border: solid #040 1px;
|
||||
border-radius: 15px;
|
||||
width: 40px;
|
||||
padding: 0px 20px;
|
||||
background-color: greenyellow;
|
||||
}
|
||||
|
||||
.signalBlock > :nth-child(2) {
|
||||
padding: 0 30px;
|
||||
font-size: 30px;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.signalBlock > :nth-child(3) {
|
||||
color: white;
|
||||
padding: 0 30px;
|
||||
width: 40px;
|
||||
border: solid #000 1px;
|
||||
border-radius: 15px;
|
||||
}
|
||||
Reference in New Issue
Block a user