Add simulated stock history to UI
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user