Skip to content

Commit

Permalink
klines: handle empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimhellum committed Dec 3, 2024
1 parent 791f652 commit 783bb73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/binance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,11 @@ klines() {
fail "Failed to get valid data from API: $response"
fi

length=$(json_length "$response")
if (( length == 0 )); then
break
fi

klines=$(echo "$klines" "$response" | jq -s 'add')
# todo: add max_iterations and check start_time to avoid infinite loop
start_time_ms=$(echo "$response" | jq -r '.[-1][6]') # get last close time
Expand Down
5 changes: 5 additions & 0 deletions src/klines.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ klines() {
fail "Failed to get valid data from API: $response"
fi

length=$(json_length "$response")
if (( length == 0 )); then
break
fi

klines=$(echo "$klines" "$response" | jq -s 'add')
# todo: add max_iterations and check start_time to avoid infinite loop
start_time_ms=$(echo "$response" | jq -r '.[-1][6]') # get last close time
Expand Down

0 comments on commit 783bb73

Please sign in to comment.