Skip to content

Commit 5c2afe3

Browse files
authored
Release v1.15.0 (#160)
Co-authored-by: Alexander Tanti <tantialex@users.noreply.github.com>
1 parent 179ba81 commit 5c2afe3

File tree

11 files changed

+166
-3
lines changed

11 files changed

+166
-3
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# Changelog
22

3-
## 1.14.0 - TBA
3+
## 1.15.0 - 2022-07-19
4+
5+
### Added
6+
- New endpoint for Margin:
7+
- `POST /sapi/v3/asset/getUserAsset` to get user assets.
8+
9+
- New endpoint for Wallet:
10+
- `GET /sapi/v1/margin/dribblet` to query the historical information of user's margin account small-value asset conversion BNB.
11+
12+
## 1.14.0 - 2022-07-04
413

514
### Added
615

binance/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.14.0"
1+
__version__ = "1.15.0"

binance/spot/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def __init__(self, key=None, secret=None, **kwargs):
9595
from binance.spot.margin import isolated_margin_fee
9696
from binance.spot.margin import isolated_margin_tier
9797
from binance.spot.margin import margin_order_usage
98+
from binance.spot.margin import margin_dust_log
9899

99100
# SAVINGS
100101
from binance.spot.savings import savings_flexible_products
@@ -141,6 +142,7 @@ def __init__(self, key=None, secret=None, **kwargs):
141142
from binance.spot.wallet import asset_detail
142143
from binance.spot.wallet import trade_fee
143144
from binance.spot.wallet import funding_wallet
145+
from binance.spot.wallet import user_asset
144146
from binance.spot.wallet import api_key_permissions
145147
from binance.spot.wallet import bnb_convertible_assets
146148

binance/spot/margin.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,3 +922,24 @@ def margin_order_usage(self, **kwargs):
922922
"""
923923

924924
return self.sign_request("GET", "/sapi/v1/margin/rateLimit/order", kwargs)
925+
926+
927+
def margin_dust_log(self, **kwargs):
928+
"""Margin Dust Log (USER_DATA)
929+
930+
Query the historical information of user's margin account small-value asset conversion BNB.
931+
932+
Weight(IP): 1
933+
934+
GET /sapi/v1/margin/dribblet
935+
936+
https://binance-docs.github.io/apidocs/spot/en/#margin-dustlog-user_data
937+
938+
Keyword Args:
939+
startTime (int, optional): UTC timestamp in ms
940+
endTime (int, optional): UTC timestamp in ms
941+
recvWindow (int, optional): The value cannot be greater than 60000
942+
"""
943+
944+
url_path = "/sapi/v1/margin/dribblet"
945+
return self.sign_request("GET", url_path, {**kwargs})

binance/spot/wallet.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,27 @@ def funding_wallet(self, **kwargs):
356356
return self.sign_request("POST", "/sapi/v1/asset/get-funding-asset", kwargs)
357357

358358

359+
def user_asset(self, **kwargs):
360+
"""User Asset (USER_DATA)
361+
362+
Get user assets, just for positive data.
363+
364+
Weight(IP): 5
365+
366+
POST /sapi/v3/asset/getUserAsset
367+
368+
https://binance-docs.github.io/apidocs/spot/en/#user-asset-user_data
369+
370+
Keyword Args:
371+
asset (str, optional): If asset is blank, then query all positive assets user have.
372+
needBtcValuation (str, optional)
373+
recvWindow (int, optional): The value cannot be greater than 60000
374+
"""
375+
376+
url_path = "/sapi/v3/asset/getUserAsset"
377+
return self.sign_request("POST", url_path, {**kwargs})
378+
379+
359380
def api_key_permissions(self, **kwargs):
360381
"""Get API Key Permission (USER_DATA)
361382

docs/source/binance.spot.margin.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,8 @@ Query Isolated Margin Tier Data (USER_DATA)
171171

172172
Query Current Margin Order Count Usage (TRADE)
173173
----------------------------------------------
174-
.. autofunction:: binance.spot.margin.margin_order_usage
174+
.. autofunction:: binance.spot.margin.margin_order_usage
175+
176+
Margin Dust Log (USER_DATA)
177+
---------------------------
178+
.. autofunction:: binance.spot.margin.margin_dust_log

docs/source/binance.spot.wallet.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ Funding Wallet (USER_DATA)
7777
--------------------------
7878
.. autofunction:: binance.spot.wallet.funding_wallet
7979

80+
User Asset (USER_DATA)
81+
----------------------
82+
.. autofunction:: binance.spot.wallet.user_asset
83+
8084
API Key Permission (USER_DATA)
8185
------------------------------
8286
.. autofunction:: binance.spot.wallet.api_key_permissions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
3+
import logging
4+
from binance.spot import Spot as Client
5+
from binance.lib.utils import config_logging
6+
from binance.error import ClientError
7+
8+
config_logging(logging, logging.DEBUG)
9+
10+
key = ""
11+
secret = ""
12+
13+
client = Client(key, secret)
14+
15+
try:
16+
response = client.margin_dust_log(recvWindow=5000)
17+
logging.info(response)
18+
except ClientError as error:
19+
logging.error(
20+
"Found error. status: {}, error code: {}, error message: {}".format(
21+
error.status_code, error.error_code, error.error_message
22+
)
23+
)

examples/spot/wallet/user_asset.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python
2+
3+
import logging
4+
from binance.spot import Spot as Client
5+
from binance.lib.utils import config_logging
6+
from binance.error import ClientError
7+
8+
config_logging(logging, logging.DEBUG)
9+
10+
key = ""
11+
secret = ""
12+
13+
client = Client(key, secret)
14+
15+
try:
16+
response = client.user_asset(asset="BNB", recvWindow=5000)
17+
logging.info(response)
18+
except ClientError as error:
19+
logging.error(
20+
"Found error. status: {}, error code: {}, error message: {}".format(
21+
error.status_code, error.error_code, error.error_message
22+
)
23+
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import responses
2+
3+
from binance.spot import Spot as Client
4+
from tests.util import random_str
5+
from urllib.parse import urlencode
6+
from tests.util import mock_http_response
7+
8+
mock_item = {"key_1": "value_1", "key_2": "value_2"}
9+
mock_exception = {"code": -1, "msg": "error message"}
10+
11+
key = random_str()
12+
secret = random_str()
13+
14+
params = {"recvWindow": 5000}
15+
16+
17+
@mock_http_response(
18+
responses.GET,
19+
"/sapi/v1/margin/dribblet\\?" + urlencode(params),
20+
mock_item,
21+
200,
22+
)
23+
def test_margin_dust_log():
24+
"""Tests the API endpoint to margin dustlog"""
25+
26+
client = Client(key, secret)
27+
response = client.margin_dust_log(**params)
28+
response.should.equal(mock_item)

tests/spot/wallet/test_user_asset.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import responses
2+
3+
from binance.spot import Spot as Client
4+
from tests.util import random_str
5+
from urllib.parse import urlencode
6+
from tests.util import mock_http_response
7+
8+
mock_item = {"key_1": "value_1", "key_2": "value_2"}
9+
mock_exception = {"code": -1, "msg": "error message"}
10+
11+
key = random_str()
12+
secret = random_str()
13+
14+
params = {"asset": "BNB", "recvWindow": 5000}
15+
16+
17+
@mock_http_response(
18+
responses.POST,
19+
"/sapi/v3/asset/getUserAsset\\?" + urlencode(params),
20+
mock_item,
21+
200,
22+
)
23+
def test_user_asset():
24+
"""Tests the API endpoint to user asset"""
25+
26+
client = Client(key, secret)
27+
response = client.user_asset(**params)
28+
response.should.equal(mock_item)

0 commit comments

Comments
 (0)