Add error handling for the predictor
This commit is contained in:
@@ -35,13 +35,18 @@ namespace PythonInterop {
|
||||
}
|
||||
}
|
||||
|
||||
public int PredictAI(string StockSymbol) {
|
||||
using (Py.GIL()) {
|
||||
dynamic predictor = Py.Import("ai-predictor");
|
||||
using (dynamic x = predictor.Predict(StockSymbol)) {
|
||||
int result = (int)x;
|
||||
return result;
|
||||
// Return ( Error, Signal )
|
||||
public (string, int) PredictAI(string StockSymbol) {
|
||||
try {
|
||||
using (Py.GIL()) {
|
||||
dynamic predictor = Py.Import("ai-predictor");
|
||||
using (dynamic x = predictor.Predict(StockSymbol)) {
|
||||
int result = (int)x;
|
||||
return ("", result);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
return (ex.ToString(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user