Skip to content

Commit 736d879

Browse files
authored
Release v1.13.0 (#143)
Co-authored-by: Alexander Tanti <tantialex@users.noreply.github.com>
1 parent ee48af0 commit 736d879

37 files changed

+876
-28
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ jobs:
4040
- name: Test with pytest
4141
run: |
4242
pytest
43+
- name: Test document build
44+
run: |
45+
python -m pip install sphinx sphinx-rtd-theme
46+
cd docs && sphinx-build -W source build

CHANGELOG.md

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

3+
## 1.13.0 - 2022-05-23
4+
5+
### Added
6+
- New endpoint for Gift Card:
7+
- `GET /sapi/v1/giftcard/cryptography/rsa-public-key` to fetch RSA public key.
8+
9+
- New endpoints for Staking:
10+
- `GET /sapi/v1/staking/productList` to get Staking product list
11+
- `POST /sapi/v1/staking/purchase` to stake product
12+
- `POST /sapi/v1/staking/redeem` to redeem product
13+
- `GET /sapi/v1/staking/position` to get Staking product holding position
14+
- `GET /sapi/v1/staking/stakingRecord` to inquiry Staking history records
15+
- `POST /sapi/v1/staking/setAutoStaking` to set Auto Staking function
16+
- `GET /sapi/v1/staking/personalLeftQuota` to inquiry Staking left quota
17+
18+
### Changed
19+
- Update endpoints for Market:
20+
- `GET /api/v3/ticker/24hr`, `GET /api/v3/ticker/price` and `GET /api/v3/ticker/bookTicker` new optional parameter symbols.
21+
22+
- Update endpoint for Gift Card:
23+
- `POST /sapi/v1/giftcard/redeemCode`: new optional parameter externalUid. Each external unique ID represents a unique user on the partner platform. The function helps you to identify the redemption behavior of different users.
24+
325
## 1.12.0 - 2022-05-03
426

527
### Added

binance/__version__.py

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

binance/spot/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ def __init__(self, key=None, secret=None, **kwargs):
110110
from binance.spot.savings import savings_interest_history
111111
from binance.spot.savings import savings_change_position
112112

113+
# Staking
114+
from binance.spot.staking import staking_product_list
115+
from binance.spot.staking import staking_purchase_product
116+
from binance.spot.staking import staking_redeem_product
117+
from binance.spot.staking import staking_product_position
118+
from binance.spot.staking import staking_history
119+
from binance.spot.staking import staking_set_auto_staking
120+
from binance.spot.staking import staking_product_quota
121+
113122
# WALLET
114123
from binance.spot.wallet import system_status
115124
from binance.spot.wallet import coin_info
@@ -256,6 +265,7 @@ def __init__(self, key=None, secret=None, **kwargs):
256265
from binance.spot.gift_card import gift_card_create_code
257266
from binance.spot.gift_card import gift_card_redeem_code
258267
from binance.spot.gift_card import gift_card_verify_code
268+
from binance.spot.gift_card import gift_card_rsa_public_key
259269

260270
# Portfolio Margin
261271
from binance.spot.portfolio_margin import portfolio_margin_account

binance/spot/gift_card.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def gift_card_redeem_code(self, code: str, **kwargs):
4141
Args:
4242
code (str): Binance Code
4343
Keyword Args:
44-
recvWindow (int, optional): The value cannot be greater than 60000
44+
externalUid (str, optional): Each external unique ID represents a unique user on the partner platform. The function helps you to identify the redemption behavior of different users, such as redemption frequency and amount. It also helps risk and limit control of a single account, such as daily limit on redemption volume, frequency, and incorrect number of entries. This will also prevent a single user account reach the partner's daily redemption limits. We strongly recommend you to use this feature and transfer us the User ID of your users if you have different users redeeming Binance codes on your platform. To protect user data privacy, you may choose to transfer the user id in any desired format (max. 400 characters).
45+
recvWindow (int, optional): The value cannot be greater than 60000
4546
"""
4647
check_required_parameter(code, "code")
4748

@@ -71,3 +72,24 @@ def gift_card_verify_code(self, referenceNo: str, **kwargs):
7172
payload = {"referenceNo": referenceNo, **kwargs}
7273

7374
return self.sign_request("GET", "/sapi/v1/giftcard/verify", payload)
75+
76+
77+
def gift_card_rsa_public_key(self, **kwargs):
78+
"""Fetch RSA Public Key (USER_DATA)
79+
80+
This API is for fetching the RSA Public Key.
81+
This RSA Public key will be used to encrypt the card code.
82+
Please note that the RSA Public key fetched is valid only for the current day.
83+
84+
Weight(IP): 1
85+
86+
GET /sapi/v1/giftcard/cryptography/rsa-public-key
87+
88+
https://binance-docs.github.io/apidocs/spot/en/#fetch-rsa-public-key-user_data
89+
90+
Keyword Args:
91+
recvWindow (int, optional): The value cannot be greater than 60000
92+
"""
93+
94+
url_path = "/sapi/v1/giftcard/cryptography/rsa-public-key"
95+
return self.sign_request("GET", url_path, {**kwargs})

binance/spot/market.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def avg_price(self, symbol: str):
171171
return self.query("/api/v3/avgPrice", params)
172172

173173

174-
def ticker_24hr(self, symbol: str = None):
174+
def ticker_24hr(self, symbol: str = None, symbols: list = None):
175175
"""24hr Ticker Price Change Statistics
176176
177177
GET /api/v3/ticker/24hr
@@ -180,15 +180,17 @@ def ticker_24hr(self, symbol: str = None):
180180
181181
Args:
182182
symbol (str, optional): the trading pair
183+
symbols (list, optional): list of trading pairs
183184
"""
184185

185-
params = {
186-
"symbol": symbol,
187-
}
186+
if symbol and symbols:
187+
raise ParameterArgumentError("symbol and symbols cannot be sent together.")
188+
check_type_parameter(symbols, "symbols", list)
189+
params = {"symbol": symbol, "symbols": convert_list_to_json_array(symbols)}
188190
return self.query("/api/v3/ticker/24hr", params)
189191

190192

191-
def ticker_price(self, symbol: str = None):
193+
def ticker_price(self, symbol: str = None, symbols: list = None):
192194
"""Symbol Price Ticker
193195
194196
GET /api/v3/ticker/price
@@ -197,15 +199,17 @@ def ticker_price(self, symbol: str = None):
197199
198200
Args:
199201
symbol (str, optional): the trading pair
202+
symbols (list, optional): list of trading pairs
200203
"""
201204

202-
params = {
203-
"symbol": symbol,
204-
}
205+
if symbol and symbols:
206+
raise ParameterArgumentError("symbol and symbols cannot be sent together.")
207+
check_type_parameter(symbols, "symbols", list)
208+
params = {"symbol": symbol, "symbols": convert_list_to_json_array(symbols)}
205209
return self.query("/api/v3/ticker/price", params)
206210

207211

208-
def book_ticker(self, symbol: str = None):
212+
def book_ticker(self, symbol: str = None, symbols: list = None):
209213
"""Symbol Order Book Ticker
210214
211215
GET /api/v3/ticker/bookTicker
@@ -214,9 +218,11 @@ def book_ticker(self, symbol: str = None):
214218
215219
Args:
216220
symbol (str, optional): the trading pair
221+
symbols (list, optional): list of trading pairs
217222
"""
218223

219-
params = {
220-
"symbol": symbol,
221-
}
224+
if symbol and symbols:
225+
raise ParameterArgumentError("symbol and symbols cannot be sent together.")
226+
check_type_parameter(symbols, "symbols", list)
227+
params = {"symbol": symbol, "symbols": convert_list_to_json_array(symbols)}
222228
return self.query("/api/v3/ticker/bookTicker", params)

binance/spot/staking.py

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
from binance.lib.utils import (
2+
check_required_parameter,
3+
)
4+
from binance.lib.utils import check_required_parameters
5+
6+
7+
def staking_product_list(self, product: str, **kwargs):
8+
"""Get Staking Product List (USER_DATA)
9+
10+
Get available Staking product list.
11+
12+
Weight(IP): 1
13+
14+
GET /sapi/v1/staking/productList
15+
16+
https://binance-docs.github.io/apidocs/spot/en/#get-staking-product-list-user_data
17+
18+
Args:
19+
product (str)
20+
Keyword Args:
21+
asset (str, optional)
22+
current (int, optional): Currently querying page. Start from 1. Default:1
23+
size (int, optional): Default:10, Max:100
24+
recvWindow (int, optional): The value cannot be greater than 60000
25+
"""
26+
check_required_parameter(product, "product")
27+
28+
params = {"product": product, **kwargs}
29+
url_path = "/sapi/v1/staking/productList"
30+
return self.sign_request("GET", url_path, params)
31+
32+
33+
def staking_purchase_product(
34+
self, product: str, productId: str, amount: float, **kwargs
35+
):
36+
"""Purchase Staking Product (USER_DATA)
37+
38+
Weight(IP): 1
39+
40+
POST /sapi/v1/staking/purchase
41+
42+
https://binance-docs.github.io/apidocs/spot/en/#purchase-staking-product-user_data
43+
44+
Args:
45+
product (str)
46+
productId (str)
47+
amount (float)
48+
Keyword Args:
49+
renewable (str, optional): true or false, default false. Active if product is `STAKING` or `L_DEFI`
50+
recvWindow (int, optional): The value cannot be greater than 60000
51+
"""
52+
check_required_parameters(
53+
[[product, "product"], [productId, "productId"], [amount, "amount"]]
54+
)
55+
56+
params = {"product": product, "productId": productId, "amount": amount, **kwargs}
57+
url_path = "/sapi/v1/staking/purchase"
58+
return self.sign_request("POST", url_path, params)
59+
60+
61+
def staking_redeem_product(self, product: str, productId: str, **kwargs):
62+
"""Redeem Staking Product (USER_DATA)
63+
64+
Redeem Staking product. Locked staking and Locked DeFI staking belong to early redemption, redeeming in advance will result in loss of interest that you have earned.
65+
66+
Weight(IP): 1
67+
68+
POST /sapi/v1/staking/redeem
69+
70+
https://binance-docs.github.io/apidocs/spot/en/#redeem-staking-product-user_data
71+
72+
Args:
73+
product (str)
74+
productId (str)
75+
Keyword Args:
76+
positionId (str, optional): Mandatory if product is `STAKING` or `L_DEFI`
77+
amount (float, optional): Mandatory if product is `F_DEFI`
78+
recvWindow (int, optional): The value cannot be greater than 60000
79+
"""
80+
check_required_parameters([[product, "product"], [productId, "productId"]])
81+
82+
params = {"product": product, "productId": productId, **kwargs}
83+
url_path = "/sapi/v1/staking/redeem"
84+
return self.sign_request("POST", url_path, params)
85+
86+
87+
def staking_product_position(self, product: str, **kwargs):
88+
"""Get Staking Product Position (USER_DATA)
89+
90+
Weight(IP): 1
91+
92+
GET /sapi/v1/staking/position
93+
94+
https://binance-docs.github.io/apidocs/spot/en/#get-staking-product-position-user_data
95+
96+
Args:
97+
product (str)
98+
Keyword Args:
99+
productId (str, optional)
100+
asset (str, optional)
101+
current (int, optional): Currently querying the page. Start from 1. Default:1
102+
size (int, optional): Default:10, Max:100
103+
recvWindow (int, optional): The value cannot be greater than 60000
104+
"""
105+
check_required_parameter(product, "product")
106+
107+
params = {"product": product, **kwargs}
108+
url_path = "/sapi/v1/staking/position"
109+
return self.sign_request("GET", url_path, params)
110+
111+
112+
def staking_history(self, product: str, txnType: str, **kwargs):
113+
"""Get Staking History (USER_DATA)
114+
115+
Weight(IP): 1
116+
117+
GET /sapi/v1/staking/stakingRecord
118+
119+
https://binance-docs.github.io/apidocs/spot/en/#get-staking-history-user_data
120+
121+
Args:
122+
product (str)
123+
txnType (str)
124+
Keyword Args:
125+
asset (str, optional)
126+
startTime (int, optional)
127+
endTime (int, optional)
128+
current (int, optional): Currently querying the page. Start from 1. Default:1
129+
size (int, optional): Default:10, Max:100
130+
recvWindow (int, optional): The value cannot be greater than 60000
131+
"""
132+
check_required_parameters([[product, "product"], [txnType, "txnType"]])
133+
134+
params = {"product": product, "txnType": txnType, **kwargs}
135+
url_path = "/sapi/v1/staking/stakingRecord"
136+
return self.sign_request("GET", url_path, params)
137+
138+
139+
def staking_set_auto_staking(
140+
self, product: str, positionId: str, renewable: str, **kwargs
141+
):
142+
"""Set Auto Staking (USER_DATA)
143+
144+
Set auto staking on Locked Staking or Locked DeFi Staking
145+
146+
Weight(IP): 1
147+
148+
POST /sapi/v1/staking/setAutoStaking
149+
150+
https://binance-docs.github.io/apidocs/spot/en/#set-auto-staking-user_data
151+
152+
Args:
153+
product (str)
154+
positionId (str)
155+
renewable (str)
156+
Keyword Args:
157+
recvWindow (int, optional): The value cannot be greater than 60000
158+
"""
159+
check_required_parameters(
160+
[[product, "product"], [positionId, "positionId"], [renewable, "renewable"]]
161+
)
162+
163+
params = {
164+
"product": product,
165+
"positionId": positionId,
166+
"renewable": renewable,
167+
**kwargs,
168+
}
169+
url_path = "/sapi/v1/staking/setAutoStaking"
170+
return self.sign_request("POST", url_path, params)
171+
172+
173+
def staking_product_quota(self, product: str, productId: str, **kwargs):
174+
"""Get Personal Left Quota of Staking Product (USER_DATA)
175+
176+
Weight(IP): 1
177+
178+
GET /sapi/v1/staking/personalLeftQuota
179+
180+
https://binance-docs.github.io/apidocs/spot/en/#get-personal-left-quota-of-staking-product-user_data
181+
182+
Args:
183+
product (str)
184+
productId (str)
185+
Keyword Args:
186+
recvWindow (int, optional): The value cannot be greater than 60000
187+
"""
188+
check_required_parameters([[product, "product"], [productId, "productId"]])
189+
190+
params = {"product": product, "productId": productId, **kwargs}
191+
url_path = "/sapi/v1/staking/personalLeftQuota"
192+
return self.sign_request("GET", url_path, params)

docs/source/binance.spot.bswap.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Remove Liquidity Preview (USER_DATA)
4747

4848
Get Unclaimed Rewards Record (USER_DATA)
4949
----------------------------------------
50-
.. autofunction:: binance.spot.bswap_unclaimed_rewards
50+
.. autofunction:: binance.spot.bswap.bswap_unclaimed_rewards
5151

5252
Claim rewards (TRADE)
5353
---------------------

docs/source/binance.spot.gift_card.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ Redeem a Binance Code (USER_DATA)
1212
Verify a Binance Code (USER_DATA)
1313
---------------------------------
1414
.. autofunction:: binance.spot.gift_card.gift_card_verify_code
15+
16+
Gift Card RSA Public Key (USER_DATA)
17+
------------------------------------
18+
.. autofunction:: binance.spot.gift_card.gift_card_rsa_public_key

docs/source/binance.spot.loan.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Crypto Loans Endpoints
33

44
Get Crypto Loans Income History (USER_DATA)
55
-------------------------------------------
6-
.. autofunction:: binance.loan.loan_history
6+
.. autofunction:: binance.spot.loan.loan_history

docs/source/binance.spot.portfolio_margin.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Account / Trade Endpoints
2-
=========================
1+
Portfolio Margin Endpoints
2+
==========================
33

44

55
Get Portfolio Margin Account Info (USER_DATA)

docs/source/binance.spot.rebate.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Rebate Endpoints
2-
=============
2+
================
33

44
Get Spot Rebate History Records (USER_DATA)
55
-------------------------------------------

0 commit comments

Comments
 (0)