Make predictions based on owned stocks
This commit is contained in:
@@ -66,50 +66,49 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<!-- AI Frame -->
|
<!-- AI Frame -->
|
||||||
<div class="gridFrame">
|
@if (Session != null){
|
||||||
<div>
|
<div class="gridFrame">
|
||||||
<h2>Current Signal</h2>
|
<div>
|
||||||
</div>
|
<h2>Current Signal</h2>
|
||||||
@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>
|
|
||||||
}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
}
|
@foreach (PurchasedStock cur in Session.TrackedStocks){
|
||||||
</div>
|
<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>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
// User Stuff
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Code Region
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
loginSession? Session = null;
|
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 = "";
|
string PaymentKey = "";
|
||||||
protected override async Task OnInitializedAsync(){
|
protected override async Task OnInitializedAsync(){
|
||||||
(bool, string) result = PaymentProcessor.CreatePayment();
|
(bool, string) result = PaymentProcessor.CreatePayment();
|
||||||
@@ -119,6 +118,16 @@
|
|||||||
PaymentKey = result.Item2;
|
PaymentKey = result.Item2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Login Stuff
|
||||||
|
string userName = "";
|
||||||
|
string passWord = "";
|
||||||
|
string loginError = "";
|
||||||
async Task LoginSession(){
|
async Task LoginSession(){
|
||||||
string dbPrefix = $"[{userName.ToLower()}]:"; // Set the DB prefix for the get and set
|
string dbPrefix = $"[{userName.ToLower()}]:"; // Set the DB prefix for the get and set
|
||||||
string passwordhash = dbDriver.Get( dbPrefix + "password" ); // Pull the password hash
|
string passwordhash = dbDriver.Get( dbPrefix + "password" ); // Pull the password hash
|
||||||
@@ -147,6 +156,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// AI Stuff
|
// AI Stuff
|
||||||
|
|
||||||
string pullButtonText = "Pull Data";
|
string pullButtonText = "Pull Data";
|
||||||
@@ -195,20 +210,20 @@
|
|||||||
|
|
||||||
async Task predict(){
|
async Task predict(){
|
||||||
resultError = "";
|
resultError = "";
|
||||||
if (Debounce){
|
if (Debounce && Session != null){
|
||||||
Debounce = false;
|
Debounce = false;
|
||||||
predictButtonText = "Do not refresh the page. The AI is predicting";
|
predictButtonText = "Do not refresh the page. The AI is predicting";
|
||||||
await Task.Delay(1);
|
await Task.Delay(1);
|
||||||
List<Task> threadpool = new List<Task>();
|
List<Task> threadpool = new List<Task>();
|
||||||
foreach(stockPredictionPair cur in predictions){
|
foreach(PurchasedStock cur in Session.TrackedStocks){
|
||||||
Task thread = new Task(() => {
|
Task thread = new Task(() => {
|
||||||
(string, int)Result = aiModule.PredictAI(cur.Symbol);
|
(string, int)Result = aiModule.PredictAI(cur.Symbol);
|
||||||
if (string.IsNullOrEmpty(Result.Item1)){
|
if (string.IsNullOrEmpty(Result.Item1)){
|
||||||
cur.Movement = Result.Item2;
|
cur.PredictedMovement = Result.Item2;
|
||||||
}else{
|
}else{
|
||||||
resultError = Result.Item1;
|
resultError = Result.Item1;
|
||||||
}
|
}
|
||||||
Console.WriteLine("Received Signal [" + cur.Symbol + "] : " + cur.Movement);
|
Console.WriteLine("Received Signal [" + cur.Symbol + "] : " + cur.PredictedMovement);
|
||||||
});
|
});
|
||||||
thread.Start();
|
thread.Start();
|
||||||
threadpool.Add(thread);
|
threadpool.Add(thread);
|
||||||
@@ -221,6 +236,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Stock Manipulation
|
// Stock Manipulation
|
||||||
|
|
||||||
string buyStockSymbol = "";
|
string buyStockSymbol = "";
|
||||||
@@ -259,27 +280,6 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PaymentKey = result.Item2;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
@using WebServer.Components
|
@using WebServer.Components
|
||||||
@using BCrypt.Net;
|
@using BCrypt.Net;
|
||||||
@using Newtonsoft.Json;
|
@using Newtonsoft.Json;
|
||||||
|
@using Entities
|
||||||
|
|
||||||
@inject DbDriver dbDriver
|
@inject DbDriver dbDriver
|
||||||
@inject AIModule aiModule
|
@inject AIModule aiModule
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Entities {
|
||||||
|
|
||||||
|
class loginSession {
|
||||||
|
public string UserName { get; set; } = "";
|
||||||
|
public List<PurchasedStock> TrackedStocks { get; set; } = new List<PurchasedStock>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user