A lot of stuff is fixed. The strategies need to reflect the stats in the ui.

This commit is contained in:
Rob 2024-11-20 01:38:46 -04:00
parent e1516a80cf
commit dab122d15f
3 changed files with 27 additions and 11 deletions

View File

@ -830,14 +830,28 @@ class BrighterTrades:
required_fields = ['strategy', 'start_date', 'capital', 'commission', 'user_name']
if not all(field in msg_data for field in required_fields):
return standard_reply("backtest_error", {"message": "Missing required fields."})
try:
# Delegate backtest handling to the Backtester
resp = self.backtester.handle_backtest_message(
user_id=self.get_user_info(user_name=msg_data['user_name'], info='User_id'),
msg_data=msg_data,
socket_conn_id=socket_conn_id)
socket_conn_id=socket_conn_id
)
if 'error' in resp:
# If there's an error, send a backtest_error message
return standard_reply("backtest_error", {"message": resp['error']})
else:
# If successful, send a backtest_submitted message
return standard_reply("backtest_submitted", resp)
except Exception as e:
# Catch any unexpected exceptions and send a backtest_error message
logger.error(f"Unhandled exception during backtest submission: {e}", exc_info=True)
return standard_reply("backtest_error",
{"message": "An unexpected error occurred during backtest submission."})
if msg_type == 'delete_backtest':
response = self.delete_backtest(msg_data)
return standard_reply("backtest_deleted", response)

View File

@ -100,9 +100,6 @@ class Backtesting {
}
}
handleBacktestError(data) {
console.error("Backtest error:", data.message);
@ -120,7 +117,6 @@ class Backtesting {
this.hideElement(this.resultsContainer);
}
handleBacktestResults(data) {
const test = this.tests.find(t => t.name === data.test_id);
if (test) {

View File

@ -40,7 +40,7 @@
</div>
<!-- Status message (Initially Hidden) -->
<div id="backtest-status-message" style="display: none; margin-top: 10px; color: blue;"></div>
<div id="backtest-status-message" style="margin-top: 10px; color: blue;"></div>
<!-- Progress bar (Initially Hidden) -->
<div id="backtest-progress-container">
@ -163,5 +163,11 @@
#backtest-results.show {
display: block; /* Show when backtest is complete */
}
#backtest-status-message {
display: none;
}
#backtest-status-message.show{
display: block;
}
</style>