Skip to content

Commit

Permalink
Fix bug with updating existing field and strategies with no params
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomatoschaves committed Feb 12, 2024
1 parent ff155e7 commit 87ffb34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions data/sources/binance/load/_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ def save_new_entry_db(model_class, fields, count_updates=True):

fields_subset = {key: value for key, value in fields.items() if key in unique_fields}

rows = model_class.objects.filter(**fields_subset).update(**fields)
model_class.objects.filter(**fields_subset).delete()
with transaction.atomic():
new_entry = model_class.objects.create(**fields)

if rows != 0 and count_updates:
new_entry = True
if not count_updates:
new_entry = False

return new_entry
5 changes: 4 additions & 1 deletion shared/utils/helpers/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ def get_pipeline_max_window(pipeline_id):

max_value_params = 0
for strategy in strategies:
max_value = max([value for param, value in strategy["params"].items()])
try:
max_value = max([value for param, value in strategy["params"].items()])
except ValueError:
continue

if max_value > max_value_params:
max_value_params = max_value
Expand Down

0 comments on commit 87ffb34

Please sign in to comment.