Start work on tracking stocks
This commit is contained in:
@@ -30,15 +30,30 @@
|
|||||||
}else{
|
}else{
|
||||||
<div class="gridFrame">
|
<div class="gridFrame">
|
||||||
<span>UserName: @Session.UserName</span><br />
|
<span>UserName: @Session.UserName</span><br />
|
||||||
|
<div>
|
||||||
|
@foreach(PurchasedStock cur in Session.TrackedStocks){
|
||||||
|
<div>@cur.Symbol</div>
|
||||||
|
<div>@cur.Quantity</div>
|
||||||
|
<div>@cur.PurchasePrice</div>
|
||||||
|
<div>@cur.PurchaseDate.ToString("M-D-YYYY")</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- 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>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<!-- AI Frame -->
|
<!-- AI Frame -->
|
||||||
<div class="gridFrame">
|
<div class="gridFrame">
|
||||||
<div>
|
<div>
|
||||||
<button @onclick="pull">@pullButtonText</button>
|
|
||||||
<button @onclick="train">@trainButtonText</button>
|
|
||||||
<button @onclick="predict">@predictButtonText</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@foreach (stockPredictionPair cur in predictions){
|
@foreach (stockPredictionPair cur in predictions){
|
||||||
@@ -80,8 +95,10 @@
|
|||||||
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
|
||||||
if (BCrypt.Verify( passWord, passwordhash )){ // If the password is valid
|
if (BCrypt.Verify( passWord, passwordhash )){ // If the password is valid
|
||||||
|
List<PurchasedStock>? stocks = JsonConvert.DeserializeObject<List<PurchasedStock>>( dbDriver.Get( dbPrefix + "stock-data" ) );
|
||||||
Session = new loginSession(){
|
Session = new loginSession(){
|
||||||
UserName = userName.ToLower()
|
UserName = userName.ToLower(),
|
||||||
|
TrackedStocks = stocks != null ? stocks : new List<PurchasedStock>()
|
||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
loginError = "wrong password";
|
loginError = "wrong password";
|
||||||
@@ -94,7 +111,8 @@
|
|||||||
if (string.IsNullOrEmpty(passwordhash)){
|
if (string.IsNullOrEmpty(passwordhash)){
|
||||||
dbDriver.Set( dbPrefix + "password", BCrypt.HashPassword( passWord, BCrypt.GenerateSalt() ) );
|
dbDriver.Set( dbPrefix + "password", BCrypt.HashPassword( passWord, BCrypt.GenerateSalt() ) );
|
||||||
Session = new loginSession(){
|
Session = new loginSession(){
|
||||||
UserName = userName.ToLower()
|
UserName = userName.ToLower(),
|
||||||
|
TrackedStocks = new List<PurchasedStock>()
|
||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
loginError = "account is taken";
|
loginError = "account is taken";
|
||||||
@@ -172,6 +190,14 @@
|
|||||||
|
|
||||||
class loginSession {
|
class loginSession {
|
||||||
public string UserName { get; set; } = "";
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
@using WebServer
|
@using WebServer
|
||||||
@using WebServer.Components
|
@using WebServer.Components
|
||||||
@using BCrypt.Net;
|
@using BCrypt.Net;
|
||||||
|
@using Newtonsoft.Json;
|
||||||
|
|
||||||
@inject DbDriver dbDriver
|
@inject DbDriver dbDriver
|
||||||
@inject AIModule aiModule
|
@inject AIModule aiModule
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BCrypt.Net-Next" Version="4.1.0" />
|
<PackageReference Include="BCrypt.Net-Next" Version="4.1.0" />
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.3" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="10.0.3" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||||
<PackageReference Include="pythonnet" Version="3.0.5" />
|
<PackageReference Include="pythonnet" Version="3.0.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user