Add simulated stock history to UI

This commit is contained in:
derek.holloway
2026-03-13 10:35:20 -07:00
parent b6798e84f5
commit b54f4a29b7
3 changed files with 17 additions and 8 deletions
+5 -2
View File
@@ -16,7 +16,7 @@ namespace Controllers.ProjectTest {
_aiModule = aiModule;
}
public async Task<float> Simulate(List<Stock> TrackedStocks) {
public async Task<(float, List<PurchasedStock>)> Simulate(List<Stock> TrackedStocks) {
float StartingMoney = Money;
// Run once for each day 30 days straight
for (int i=30; i>=0; i--) {
@@ -68,6 +68,8 @@ namespace Controllers.ProjectTest {
Money = Money + sellPrice;
// Mark as sold
cur.Sold = true;
// Set Sell Date
cur.SellDate = DateTime.Now.AddDays(-i);
}
}
@@ -85,6 +87,7 @@ namespace Controllers.ProjectTest {
Symbol = HighestRanking.Symbol.ToUpper(),
PurchasePrice = stockPrice,
Quantity = MaxQty,
BuyDate = DateTime.Now.AddDays(-i)
} );
Money = Money - ( stockPrice * MaxQty );
}
@@ -103,7 +106,7 @@ namespace Controllers.ProjectTest {
float earned = StartingMoney / SPYbegin * SPYend;
// Return the difference between the AI and the SPY -> if value returned is 10. The AI did better than the SPY by $10
return Money - earned;
return (Money - earned, StockHistory);
}