Make current price work with date offsets

This commit is contained in:
2026-03-11 21:49:04 -07:00
parent d5df9d1014
commit 8df645aac5
4 changed files with 19 additions and 10 deletions
+2 -2
View File
@@ -72,7 +72,7 @@ namespace Controllers.ProjectTest {
foreach(PurchasedStock cur in StockHistory) {
if (cur.Sold == false) {
// Get sell price
float sellPrice = cur.Quantity * _aiModule.GetCurrentPrice( cur.Symbol );
float sellPrice = cur.Quantity * _aiModule.GetCurrentPrice( cur.Symbol, i );
// Add up the total sale
totalSale += sellPrice;
// Mark as sold
@@ -85,7 +85,7 @@ namespace Controllers.ProjectTest {
if (i != 0) {
// Buy predicted stock
float stockPrice = _aiModule.GetCurrentPrice( HighestRanking.Symbol );
float stockPrice = _aiModule.GetCurrentPrice( HighestRanking.Symbol, i );
// Get max stocks user can purchase [ int cast truncates the decimal ]
int MaxQty = (int)( Money / stockPrice );
+2 -2
View File
@@ -39,8 +39,8 @@ namespace Controllers.PythonInterop {
}
}
public float GetCurrentPrice(string StockSymbol) {
(bool, string) Success = PyProcess.RunPythonProcess(_PyPath, _ExecPath + "/currentprice.py", returns: true, PyArgs: StockSymbol);
public float GetCurrentPrice(string StockSymbol, int DataEndDaysAgo = 0) {
(bool, string) Success = PyProcess.RunPythonProcess(_PyPath, _ExecPath + "/currentprice.py", returns: true, PyArgs: $"{StockSymbol} {DataEndDaysAgo}");
if (!Success.Item1) {
return 0;
} else {