Skip to content

Commit ee48af0

Browse files
authored
release v1.12.0 (#136)
1 parent afcb5f3 commit ee48af0

20 files changed

+304
-37
lines changed

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Release Distributables
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
build-n-upload:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
with:
15+
python-version: "3.10"
16+
- run: pip install wheel
17+
- name: Build new distributables
18+
run: python setup.py sdist bdist_wheel
19+
- name: Upload distributables to PyPI
20+
uses: pypa/gh-action-pypi-publish@release/v1
21+
with:
22+
user: __token__
23+
password: ${{ secrets.PYPI_API_TOKEN }}
24+
- name: Post release cleaning
25+
run: |
26+
python setup.py clean --all
27+
rm dist/*

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 1.12.0 - 2022-05-03
4+
5+
### Added
6+
- New endpoint `GET /sapi/v1/managed-subaccount/accountSnapshot` to support investor master account query asset snapshot of managed sub-account.
7+
- New endpoint `GET /sapi/v1/portfolio/account` to support query portfolio margin account info
8+
- New endpoint `GET /sapi/v1/margin/rateLimit/order`, which will display the user's current margin order count usage for all intervals.
9+
310
## 1.11.0 - 2022-02-23
411

512
### Added

binance/__version__.py

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

binance/spot/__init__.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ def __init__(self, key=None, secret=None, **kwargs):
2222
from binance.spot.market import book_ticker
2323

2424
# ACCOUNT (including orders and trades)
25-
from binance.spot.account import new_order_test
26-
from binance.spot.account import new_order
27-
from binance.spot.account import cancel_order
28-
from binance.spot.account import cancel_open_orders
29-
from binance.spot.account import get_order
30-
from binance.spot.account import get_open_orders
31-
from binance.spot.account import get_orders
32-
from binance.spot.account import new_oco_order
33-
from binance.spot.account import cancel_oco_order
34-
from binance.spot.account import get_oco_order
35-
from binance.spot.account import get_oco_orders
36-
from binance.spot.account import get_oco_open_orders
37-
from binance.spot.account import account
38-
from binance.spot.account import my_trades
39-
from binance.spot.account import get_order_rate_limit
25+
from binance.spot.trade import new_order_test
26+
from binance.spot.trade import new_order
27+
from binance.spot.trade import cancel_order
28+
from binance.spot.trade import cancel_open_orders
29+
from binance.spot.trade import get_order
30+
from binance.spot.trade import get_open_orders
31+
from binance.spot.trade import get_orders
32+
from binance.spot.trade import new_oco_order
33+
from binance.spot.trade import cancel_oco_order
34+
from binance.spot.trade import get_oco_order
35+
from binance.spot.trade import get_oco_orders
36+
from binance.spot.trade import get_oco_open_orders
37+
from binance.spot.trade import account
38+
from binance.spot.trade import my_trades
39+
from binance.spot.trade import get_order_rate_limit
4040

4141
# STREAMS
4242
from binance.spot.data_stream import new_listen_key
@@ -92,6 +92,7 @@ def __init__(self, key=None, secret=None, **kwargs):
9292
from binance.spot.margin import margin_fee
9393
from binance.spot.margin import isolated_margin_fee
9494
from binance.spot.margin import isolated_margin_tier
95+
from binance.spot.margin import margin_order_usage
9596

9697
# SAVINGS
9798
from binance.spot.savings import savings_flexible_products
@@ -180,6 +181,7 @@ def __init__(self, key=None, secret=None, **kwargs):
180181
from binance.spot.sub_account import sub_account_api_add_ip
181182
from binance.spot.sub_account import sub_account_api_get_ip_restriction
182183
from binance.spot.sub_account import sub_account_api_delete_ip
184+
from binance.spot.sub_account import managed_sub_account_get_snapshot
183185

184186
# FUTURES
185187
from binance.spot.futures import futures_transfer
@@ -254,3 +256,6 @@ def __init__(self, key=None, secret=None, **kwargs):
254256
from binance.spot.gift_card import gift_card_create_code
255257
from binance.spot.gift_card import gift_card_redeem_code
256258
from binance.spot.gift_card import gift_card_verify_code
259+
260+
# Portfolio Margin
261+
from binance.spot.portfolio_margin import portfolio_margin_account

binance/spot/bswap.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def bswap_liquidity_add(self, poolId: int, asset: str, quantity: float, **kwargs
4343
asset (str)
4444
quantity (float)
4545
Keyword Args:
46+
type (str, optional): "Single" to add a single token; "Combination" to add dual tokens. Default "Single"
4647
recvWindow (int, optional): The value cannot be greater than 60000
4748
"""
4849
check_required_parameters(

binance/spot/margin.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,3 +905,20 @@ def isolated_margin_tier(self, symbol: str, **kwargs):
905905
check_required_parameter(symbol, "symbol")
906906
payload = {"symbol": symbol, **kwargs}
907907
return self.sign_request("GET", "/sapi/v1/margin/isolatedMarginTier", payload)
908+
909+
910+
def margin_order_usage(self, **kwargs):
911+
"""Query Current Margin Order Count Usage (TRADE)
912+
Displays the user's current margin order count usage for all intervals.
913+
914+
GET /sapi/v1/margin/rateLimit/order
915+
916+
https://binance-docs.github.io/apidocs/spot/en/#query-current-margin-order-count-usage-trade
917+
918+
Keyword Args:
919+
isIsolated (str, optional): for isolated margin or not, "TRUE", "FALSE", default "FALSE"
920+
symbol (str, optional): isolated symbol, mandatory for isolated margin
921+
recvWindow (int, optional): The value cannot be greater than 60000
922+
"""
923+
924+
return self.sign_request("GET", "/sapi/v1/margin/rateLimit/order", kwargs)

binance/spot/market.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def depth(self, symbol: str, **kwargs):
6666
Args:
6767
symbol (str): the trading pair
6868
Keyword Args:
69-
limit (int, optional): limit the results. Default 100; valid limits:[5, 10, 20, 50, 100, 500, 1000, 5000]
69+
limit (int, optional): limit the results. Default 100; max 5000. If limit > 5000, then the response will truncate to 5000.
7070
"""
7171

7272
check_required_parameter(symbol, "symbol")

binance/spot/portfolio_margin.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def portfolio_margin_account(self, **kwargs):
2+
"""Get Portfolio Margin Account Info (USER_DATA)
3+
4+
GET /sapi/v1/portfolio/account
5+
6+
https://binance-docs.github.io/apidocs/spot/en/#get-portfolio-margin-account-info-user_data
7+
8+
Keyword Args:
9+
recvWindow (int, optional): The value cannot be greater than 60000
10+
"""
11+
12+
return self.sign_request("GET", "/sapi/v1/portfolio/account", {**kwargs})

binance/spot/sub_account.py

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,17 +426,21 @@ def sub_account_universal_transfer(
426426
You need to enable "internal transfer" option for the api key which requests this endpoint.
427427
Transfer from master account by default if fromEmail is not sent.
428428
Transfer to master account by default if toEmail is not sent.
429-
Transfer between futures accounts is not supported.
429+
Supported transfer scenarios:
430+
- Master account SPOT transfer to sub-account SPOT, USDT_FUTURE, COIN_FUTURE, MARGIN(Cross), ISOLATED_MARGIN
431+
- Sub-account SPOT, USDT_FUTURE, COIN_FUTURE, MARGIN(Cross), ISOLATED_MARGIN transfer to master account SPOT
432+
- Transfer between two SPOT sub-accounts
430433
431434
Args:
432-
fromAccountType (str): "SPOT","USDT_FUTURE","COIN_FUTURE"
433-
toAccountType (str): "SPOT","USDT_FUTURE","COIN_FUTURE"
435+
fromAccountType (str): "SPOT", "USDT_FUTURE", "COIN_FUTURE", "MARGIN"(Cross), "ISOLATED_MARGIN"
436+
toAccountType (str): "SPOT", "USDT_FUTURE", "COIN_FUTURE", "MARGIN"(Cross), "ISOLATED_MARGIN"
434437
asset (str)
435438
amount (float)
436439
Keyword Args:
437440
fromEmail (str, optional)
438441
toEmail (str, optional)
439442
clientTranId (str, optional): Must be unique
443+
symbol (str, optional): Only supported under ISOLATED_MARGIN type
440444
recvWindow (int, optional): The value cannot be greater than 60000
441445
"""
442446
check_required_parameters(
@@ -807,3 +811,37 @@ def sub_account_api_delete_ip(
807811
return self.limited_encoded_sign_request(
808812
"DELETE", "/sapi/v1/sub-account/subAccountApi/ipRestriction/ipList", payload
809813
)
814+
815+
816+
def managed_sub_account_get_snapshot(self, email: str, type: str, **kwargs):
817+
"""Query Managed Sub-account Snapshot(For Investor Master Account)
818+
819+
GET /sapi/v1/managed-subaccount/accountSnapshot (HMAC SHA256)
820+
821+
https://binance-docs.github.io/apidocs/spot/en/#query-managed-sub-account-snapshot-for-investor-master-account
822+
823+
Args:
824+
email (str): email
825+
type (str): "SPOT", "MARGIN"(cross), "FUTURES"(UM)
826+
Keyword Args:
827+
startTime (int, optional)
828+
endTime (int, optional)
829+
limit (int, optional): min 7, max 30, default 7
830+
recvWindow (int, optional)
831+
"""
832+
833+
check_required_parameters(
834+
[
835+
[email, "email"],
836+
[type, "type"],
837+
]
838+
)
839+
payload = {
840+
"email": email,
841+
"type": type,
842+
**kwargs,
843+
}
844+
845+
return self.limited_encoded_sign_request(
846+
"GET", "/sapi/v1/managed-subaccount/accountSnapshot", payload
847+
)
File renamed without changes.

docs/source/binance.spot.margin.rst

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

168168
Query Isolated Margin Tier Data (USER_DATA)
169169
-------------------------------------------
170-
.. autofunction:: binance.spot.margin.isolated_margin_tier
170+
.. autofunction:: binance.spot.margin.isolated_margin_tier
171+
172+
Query Current Margin Order Count Usage (TRADE)
173+
----------------------------------------------
174+
.. autofunction:: binance.spot.margin.margin_order_usage
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Account / Trade Endpoints
2+
=========================
3+
4+
5+
Get Portfolio Margin Account Info (USER_DATA)
6+
---------------------------------------------
7+
.. autofunction:: binance.spot.portfolio_margin.portfolio_margin_account

docs/source/binance.spot.sub_account.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,8 @@ Get IP Restriction for a Sub-account API Key (For Master Account)
127127

128128
Delete IP List for a Sub-account API Key (For Master Account)
129129
-------------------------------------------------------------
130-
.. autofunction:: binance.spot.sub_account.sub_account_api_delete_ip
130+
.. autofunction:: binance.spot.sub_account.sub_account_api_delete_ip
131+
132+
Query Managed Sub-account Snapshot (For Investor Master Account)
133+
----------------------------------------------------------------
134+
.. autofunction:: binance.spot.sub_account.managed_sub_account_get_snapshot

docs/source/binance.spot.account.rst renamed to docs/source/binance.spot.trade.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,60 @@ Account / Trade Endpoints
44

55
Test New Order (TRADE)
66
----------------------
7-
.. autofunction:: binance.spot.account.new_order_test
7+
.. autofunction:: binance.spot.trade.new_order_test
88

99
New Order (TRADE)
1010
-----------------
11-
.. autofunction:: binance.spot.account.new_order
11+
.. autofunction:: binance.spot.trade.new_order
1212

1313
Cancel Order (TRADE)
1414
--------------------
15-
.. autofunction:: binance.spot.account.cancel_order
15+
.. autofunction:: binance.spot.trade.cancel_order
1616

1717
Cancel all Open Orders on a Symbol (TRADE)
1818
------------------------------------------
19-
.. autofunction:: binance.spot.account.cancel_open_orders
19+
.. autofunction:: binance.spot.trade.cancel_open_orders
2020

2121
Query Order (USER_DATA)
2222
-----------------------
23-
.. autofunction:: binance.spot.account.get_order
23+
.. autofunction:: binance.spot.trade.get_order
2424

2525
Current Open Orders (USER_DATA)
2626
-------------------------------
27-
.. autofunction:: binance.spot.account.get_open_orders
27+
.. autofunction:: binance.spot.trade.get_open_orders
2828

2929
All Orders (USER_DATA)
3030
----------------------
31-
.. autofunction:: binance.spot.account.get_orders
31+
.. autofunction:: binance.spot.trade.get_orders
3232

3333
New OCO (TRADE)
3434
---------------
35-
.. autofunction:: binance.spot.account.new_oco_order
35+
.. autofunction:: binance.spot.trade.new_oco_order
3636

3737
Cancel OCO (TRADE)
3838
------------------
39-
.. autofunction:: binance.spot.account.cancel_oco_order
39+
.. autofunction:: binance.spot.trade.cancel_oco_order
4040

4141
Query OCO (USER_DATA)
4242
---------------------
43-
.. autofunction:: binance.spot.account.get_oco_order
43+
.. autofunction:: binance.spot.trade.get_oco_order
4444

4545
Query all OCO (USER_DATA)
4646
-------------------------
47-
.. autofunction:: binance.spot.account.get_oco_orders
47+
.. autofunction:: binance.spot.trade.get_oco_orders
4848

4949
Query Open OCO (USER_DATA)
5050
--------------------------
51-
.. autofunction:: binance.spot.account.get_oco_open_orders
51+
.. autofunction:: binance.spot.trade.get_oco_open_orders
5252

5353
Account Information (USER_DATA)
5454
-------------------------------
55-
.. autofunction:: binance.spot.account.account
55+
.. autofunction:: binance.spot.trade.account
5656

5757
Account Trade List (USER_DATA)
5858
------------------------------
59-
.. autofunction:: binance.spot.account.my_trades
59+
.. autofunction:: binance.spot.trade.my_trades
6060

6161
Query Current Order Count Usage (TRADE)
6262
---------------------------------------
63-
.. autofunction:: binance.spot.account.get_order_rate_limit
63+
.. autofunction:: binance.spot.trade.get_order_rate_limit
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
7+
config_logging(logging, logging.DEBUG)
8+
9+
key = ""
10+
secret = ""
11+
12+
client = Client(key, secret)
13+
logging.info(client.margin_order_usage(isIsolated="TRUE", symbol="BTCUSDT"))
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+
logger = logging.getLogger(__name__)
15+
16+
try:
17+
logger.info(client.portfolio_margin_account())
18+
except ClientError as error:
19+
logger.error(
20+
"Found error. status: {}, error code: {}, error message: {}".format(
21+
error.status_code, error.error_code, error.error_message
22+
)
23+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
7+
config_logging(logging, logging.DEBUG)
8+
9+
key = ""
10+
secret = ""
11+
12+
spot_client = Client(key, secret)
13+
14+
logging.info(
15+
spot_client.managed_sub_account_get_snapshot(email="alice@test.com", type="SPOT")
16+
)

0 commit comments

Comments
 (0)