diff --git a/lib/binance.sh b/lib/binance.sh index 6b0f997..d98848d 100644 --- a/lib/binance.sh +++ b/lib/binance.sh @@ -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 diff --git a/src/klines.sh b/src/klines.sh index 3520225..2926a5a 100644 --- a/src/klines.sh +++ b/src/klines.sh @@ -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