Skip to content

Commit

Permalink
Merge pull request #146 from peterwilli/fix/backtest_error_improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
cardosofede authored Jun 18, 2024
2 parents a5525e5 + 52b2e4c commit ee05848
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 2 additions & 0 deletions backend/services/backend_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ def run_backtesting(self, start_time: int, end_time: int, backtesting_resolution
}
response = requests.post(url, json=payload)
backtesting_results = response.json()
if "error" in backtesting_results:
raise Exception(backtesting_results["error"])
if "processed_data" not in backtesting_results:
data = None
else:
Expand Down
19 changes: 12 additions & 7 deletions frontend/components/backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ def backtesting_section(inputs, backend_api_client):
if run_backtesting:
start_datetime = datetime.combine(start_date, datetime.min.time())
end_datetime = datetime.combine(end_date, datetime.max.time())
backtesting_results = backend_api_client.run_backtesting(
start_time=int(start_datetime.timestamp()) * 1000,
end_time=int(end_datetime.timestamp()) * 1000,
backtesting_resolution=backtesting_resolution,
trade_cost=trade_cost / 100,
config=inputs,
)
try:
backtesting_results = backend_api_client.run_backtesting(
start_time=int(start_datetime.timestamp()) * 1000,
end_time=int(end_datetime.timestamp()) * 1000,
backtesting_resolution=backtesting_resolution,
trade_cost=trade_cost / 100,
config=inputs,
)
except Exception as e:
st.error(e)
return None

if len(backtesting_results["processed_data"]) == 0:
st.error("No trades were executed during the backtesting period.")
return None
Expand Down

0 comments on commit ee05848

Please sign in to comment.