Skip to content

Commit

Permalink
Merge pull request #21 from Ma007ks/fix/api-limits
Browse files Browse the repository at this point in the history
fix(api): fix limits validations in a few api methods
  • Loading branch information
Th0rgal authored Jun 11, 2021
2 parents 6129f18 + bdaab0c commit 6205688
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions binance/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ async def fetch_recent_trades_list(self, symbol, limit=500):
self.assert_symbol(symbol)
if limit == 500:
params = {"symbol": symbol}
elif limit > 0 and limit < 1000:
elif limit > 0 and limit <= 1000:
params = {"symbol": symbol, "limit": limit}
else:
raise ValueError(
f"{limit} is not a valid limit. A valid limit should be > 0 and < to 1000."
f"{limit} is not a valid limit. A valid limit should be > 0 and <= to 1000."
)
return await self.http.send_api_call(
"/api/v3/trades", params=params, signed=False
Expand All @@ -182,11 +182,11 @@ async def fetch_old_trades_list(self, symbol, from_id=None, limit=500):
self.assert_symbol(symbol)
if limit == 500:
params = {"symbol": symbol}
elif limit > 0 and limit < 1000:
elif limit > 0 and limit <= 1000:
params = {"symbol": symbol, "limit": limit}
else:
raise ValueError(
f"{limit} is not a valid limit. A valid limit should be > 0 and < to 1000."
f"{limit} is not a valid limit. A valid limit should be > 0 and <= to 1000."
)
if from_id:
params["fromId"] = from_id
Expand All @@ -201,11 +201,11 @@ async def fetch_aggregate_trades_list(
self.assert_symbol(symbol)
if limit == 500:
params = {"symbol": symbol}
elif limit > 0 and limit < 1000:
elif limit > 0 and limit <= 1000:
params = {"symbol": symbol, "limit": limit}
else:
raise ValueError(
f"{limit} is not a valid limit. A valid limit should be > 0 and < to 1000."
f"{limit} is not a valid limit. A valid limit should be > 0 and <= to 1000."
)
if from_id:
params["fromId"] = from_id
Expand All @@ -227,11 +227,11 @@ async def fetch_klines(
raise ValueError("This query requires an interval.")
if limit == 500:
params = {"symbol": symbol, "interval": interval}
elif limit > 0 and limit < 1000:
elif limit > 0 and limit <= 1000:
params = {"symbol": symbol, "interval": interval, "limit": limit}
else:
raise ValueError(
f"{limit} is not a valid limit. A valid limit should be > 0 and < to 1000."
f"{limit} is not a valid limit. A valid limit should be > 0 and <= to 1000."
)
if start_time:
params["startTime"] = start_time
Expand Down Expand Up @@ -451,11 +451,11 @@ async def fetch_all_orders(
self.assert_symbol(symbol)
if limit == 500:
params = {"symbol": symbol}
elif limit > 0 and limit < 1000:
elif limit > 0 and limit <= 1000:
params = {"symbol": symbol, "limit": limit}
else:
raise ValueError(
f"{limit} is not a valid limit. A valid limit should be > 0 and < to 1000."
f"{limit} is not a valid limit. A valid limit should be > 0 and <= to 1000."
)

if order_id:
Expand Down Expand Up @@ -642,8 +642,12 @@ async def fetch_account_trade_list(
self.assert_symbol(symbol)
if limit == 500:
params = {"symbol": symbol}
elif limit > 0 and limit < 1000:
elif limit > 0 and limit <= 1000:
params = {"symbol": symbol, "limit": limit}
else:
raise ValueError(
f"{limit} is not a valid limit. A valid limit should be > 0 and <= to 1000."
)

if start_time:
params["startTime"] = start_time
Expand Down

0 comments on commit 6205688

Please sign in to comment.