Skip to content

Commit 88634cf

Browse files
authored
iguana v1.8.0 release (#117)
* iguana v1.8.0 release
1 parent 42f7957 commit 88634cf

File tree

71 files changed

+739
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+739
-50
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
21-
python-version: [3.6, 3.7, 3.8, 3.9]
21+
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
2222

2323
steps:
2424
- uses: actions/checkout@v2

CHANGELOG.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
# Changelog
22

3+
## 1.8.0 - 2021-11-25
4+
5+
### Added
6+
- New endpoint for Crypto Loans:
7+
- `GET /sapi/v1/loan/income` to query an asset's loan history
8+
- New endpoints for Sub-Account:
9+
- `POST /sapi/v1/sub-account/subAccountApi/ipRestriction` to support master account enable and disable IP restriction for a sub-account API Key
10+
- `POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` to support master account add IP list for a sub-account API Key
11+
- `GET /sapi/v1/sub-account/subAccountApi/ipRestriction` to support master account query IP restriction for a sub-account API Key
12+
- `DELETE /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList` to support master account delete IP list for a sub-account API Key
13+
- New endpoint for Pay:
14+
- `GET /sapi/v1/pay/transactions` to support user query Pay trade history
15+
16+
### Fixed
17+
- Removed epoch time in util method `config_logging` to provide compatibility with Windows OS
18+
- Allow optional parameter for method `isolated_margin_account_limit`
19+
320
## 1.7.0 - 2021-11-4
421

522
### Updated
623
- Universal transfer types:
7-
- Added `MAIN_FUNDING`, `FUNDING_MAIN`, `FUNDING_UMFUTURE`, `UMFUTURE_FUNDING`, `MARGIN_FUNDING`, `FUNDING_MARGIN`, `FUNDING_CMFUTURE` and `CMFUTURE_FUNDING` to support transfer assets among funding account and other accounts
8-
- Deleted `MAIN_C2C`, `C2C_MAIN`, `C2C_UMFUTURE`, `C2C_MINING`, `UMFUTURE_C2C`, `MINING_C2C`, `MARGIN_C2C`, `C2C_MARGIN`, `MAIN_PAY` and `PAY_MAIN` as C2C account, Binance Payment, Binance Card and other business accounts are merged into a Funding account and they'll be discontinued on November 04, 2021 08:00 AM UTC
24+
- Added `MAIN_FUNDING`, `FUNDING_MAIN`, `FUNDING_UMFUTURE`, `UMFUTURE_FUNDING`, `MARGIN_FUNDING`, `FUNDING_MARGIN`, `FUNDING_CMFUTURE` and `CMFUTURE_FUNDING` to support transfer assets among funding account and other accounts
25+
- Deleted `MAIN_C2C`, `C2C_MAIN`, `C2C_UMFUTURE`, `C2C_MINING`, `UMFUTURE_C2C`, `MINING_C2C`, `MARGIN_C2C`, `C2C_MARGIN`, `MAIN_PAY` and `PAY_MAIN` as C2C account, Binance Payment, Binance Card and other business accounts are merged into a Funding account and they'll be discontinued on November 04, 2021 08:00 AM UTC
926
- Util method `config_logging` can now provide date time in UTC and epoch time
1027

1128
### Added

binance/__version__.py

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

binance/lib/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def convert_list_to_json_array(symbols):
6060

6161

6262
def config_logging(logging, logging_level, log_file: str = None):
63-
"""Configures logging to provide a more detailed log format, which includes date time in UTC and an epoch timestamp in msec
64-
Example: 2021-11-02 19:42:04 UTC 1635882124165 <logging_level> <log_name>: <log_message>
63+
"""Configures logging to provide a more detailed log format, which includes date time in UTC
64+
Example: 2021-11-02 19:42:04.849 UTC <logging_level> <log_name>: <log_message>
6565
6666
Args:
6767
logging: python logging
@@ -75,6 +75,6 @@ def config_logging(logging, logging_level, log_file: str = None):
7575
logging.basicConfig(
7676
level=logging_level,
7777
filename=log_file,
78-
format="%(asctime)s%(msecs)03d %(levelname)s %(name)s: %(message)s",
79-
datefmt="%Y-%m-%d %H:%M:%S UTC %s",
78+
format="%(asctime)s.%(msecs)03d UTC %(levelname)s %(name)s: %(message)s",
79+
datefmt="%Y-%m-%d %H:%M:%S",
8080
)

binance/spot/__init__.py

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

24-
# ACCOUNT(including orders and trades)
24+
# ACCOUNT (including orders and trades)
2525
from binance.spot.account import new_order_test
2626
from binance.spot.account import new_order
2727
from binance.spot.account import cancel_order
@@ -128,7 +128,7 @@ def __init__(self, key=None, secret=None, **kwargs):
128128
from binance.spot.wallet import funding_wallet
129129
from binance.spot.wallet import api_key_permissions
130130

131-
# Mining
131+
# MINING
132132
from binance.spot.mining import mining_algo_list
133133
from binance.spot.mining import mining_coin_list
134134
from binance.spot.mining import mining_worker
@@ -171,8 +171,12 @@ def __init__(self, key=None, secret=None, **kwargs):
171171
from binance.spot.sub_account import managed_sub_account_deposit
172172
from binance.spot.sub_account import managed_sub_account_assets
173173
from binance.spot.sub_account import managed_sub_account_withdraw
174+
from binance.spot.sub_account import sub_account_api_toggle_ip_restriction
175+
from binance.spot.sub_account import sub_account_api_add_ip
176+
from binance.spot.sub_account import sub_account_api_get_ip_restriction
177+
from binance.spot.sub_account import sub_account_api_delete_ip
174178

175-
# Futures
179+
# FUTURES
176180
from binance.spot.futures import futures_transfer
177181
from binance.spot.futures import futures_transfer_history
178182
from binance.spot.futures import futures_loan_borrow
@@ -213,9 +217,15 @@ def __init__(self, key=None, secret=None, **kwargs):
213217
from binance.spot.bswap import bswap_add_liquidity_preview
214218
from binance.spot.bswap import bswap_remove_liquidity_preview
215219

216-
# Fiat
220+
# FIAT
217221
from binance.spot.fiat import fiat_order_history
218222
from binance.spot.fiat import fiat_payment_history
219223

220224
# C2C
221225
from binance.spot.c2c import c2c_trade_history
226+
227+
# CRYPTO LOANS
228+
from binance.spot.loan import loan_history
229+
230+
# PAY
231+
from binance.spot.pay import pay_history

binance/spot/loan.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from binance.lib.utils import check_required_parameter
2+
3+
4+
def loan_history(self, asset: str, **kwargs):
5+
"""Get Crypto Loans Income History (USER_DATA)
6+
7+
GET /sapi/v1/loan/income
8+
9+
https://binance-docs.github.io/apidocs/spot/en/#get-crypto-loans-income-history-user_data
10+
11+
Args:
12+
asset (str)
13+
Keyword Args:
14+
type (str, optional): All types will be returned by default.
15+
borrowIn, collateralSpent, repayAmount, collateralReturn (collateral return after repayment),
16+
addCollateral, removeCollateral, collateralReturnAfterLiquidation
17+
startTime (int, optional)
18+
endTime (int, optional)
19+
limit (int, optional): default 20, max 100
20+
recvWindow (int, optional): The value cannot be greater than 60000
21+
"""
22+
23+
check_required_parameter(asset, "asset")
24+
25+
payload = {"asset": asset, **kwargs}
26+
return self.sign_request("GET", "/sapi/v1/loan/income", payload)

binance/spot/margin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ def cancel_isolated_margin_account(self, symbol: str, **kwargs):
827827

828828
def enable_isolated_margin_account(self, symbol: str, **kwargs):
829829
"""Enable Isolated Margin Account (TRADE)
830-
Enable isolated margin account for a specific symbol.
830+
Enable isolated margin account for a specific symbol (Only supports activation of previously disabled accounts).
831831
832832
POST /sapi/v1/margin/isolated/account
833833
@@ -854,4 +854,4 @@ def isolated_margin_account_limit(self, **kwargs):
854854
Keyword Args:
855855
recvWindow (int, optional): The value cannot be greater than 60000
856856
"""
857-
return self.sign_request("GET", "/sapi/v1/margin/isolated/accountLimit", **kwargs)
857+
return self.sign_request("GET", "/sapi/v1/margin/isolated/accountLimit", kwargs)

binance/spot/mining.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ def mining_worker_list(self, algo: str, userName: str, **kwargs):
5959
userName (str): Mining account
6060
Keyword Args:
6161
pageIndex (int, optional): Page number,default is first page,start form 1
62-
sort (int, optional): sort sequence(default=0)0 positive sequence,1 negative sequence
63-
sortColumn (int, optional): Sort by( default 1):
62+
sort (int, optional): sort sequence (default=0)0 positive sequence,1 negative sequence
63+
sortColumn (int, optional): Sort by (default 1):
6464
1: miner name, 2: real-time computing power, 3: daily average computing power,
6565
4: real-time rejection rate, 5: last submission time
6666
workerStatus (int, optional): miners status (default = 0) 0 all, 1 valid, 2 invalid, 3 failure

binance/spot/pay.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def pay_history(self, **kwargs):
2+
"""Get Pay Trade History (USER_DATA)
3+
4+
GET /sapi/v1/pay/transactions
5+
6+
https://binance-docs.github.io/apidocs/spot/en/#get-pay-trade-history-user_data
7+
8+
Keyword Args:
9+
startTimestamp (int, optional)
10+
endTimestamp (int, optional)
11+
limit (int, optional): default 100, max 100
12+
recvWindow (int, optional): The value cannot be greater than 60000
13+
"""
14+
15+
return self.sign_request("GET", "/sapi/v1/pay/transactions", kwargs)

binance/spot/sub_account.py

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,3 +666,142 @@ def managed_sub_account_withdraw(
666666
return self.limited_encoded_sign_request(
667667
"POST", "/sapi/v1/managed-subaccount/withdraw", payload
668668
)
669+
670+
671+
def sub_account_api_toggle_ip_restriction(
672+
self, email: str, subAccountApiKey: str, ipRestrict: bool, **kwargs
673+
):
674+
"""Enable or Disable IP Restriction for a Sub-account API Key (For Master Account)
675+
676+
POST /sapi/v1/sub-account/subAccountApi/ipRestriction
677+
678+
https://binance-docs.github.io/apidocs/spot/en/#enable-or-disable-ip-restriction-for-a-sub-account-api-key-for-master-account
679+
680+
Args:
681+
email (str): Sub-account email
682+
subAccountApiKey (str)
683+
ipRestrict (bool): True or False
684+
Keyword Args:
685+
recvWindow (int, optional)
686+
"""
687+
688+
check_required_parameters(
689+
[
690+
[email, "email"],
691+
[subAccountApiKey, "subAccountApiKey"],
692+
[ipRestrict, "ipRestrict"],
693+
]
694+
)
695+
payload = {
696+
"email": email,
697+
"subAccountApiKey": subAccountApiKey,
698+
"ipRestrict": ipRestrict,
699+
**kwargs,
700+
}
701+
702+
return self.limited_encoded_sign_request(
703+
"POST", "/sapi/v1/sub-account/subAccountApi/ipRestriction", payload
704+
)
705+
706+
707+
def sub_account_api_add_ip(
708+
self, email: str, subAccountApiKey: str, ipAddress: str, **kwargs
709+
):
710+
"""Add IP List for a Sub-account API Key (For Master Account)
711+
712+
Before the usage of this endpoint, please ensure POST /sapi/v1/sub-account/subAccountApi/ipRestriction was used to enable the IP restriction.
713+
714+
POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList
715+
716+
https://binance-docs.github.io/apidocs/spot/en/#add-ip-list-for-a-sub-account-api-key-for-master-account
717+
718+
Args:
719+
email (str): Sub-account email
720+
subAccountApiKey (str)
721+
ipAddress (str): Can be added in batches, separated by commas
722+
Keyword Args:
723+
recvWindow (int, optional)
724+
"""
725+
726+
check_required_parameters(
727+
[
728+
[email, "email"],
729+
[subAccountApiKey, "subAccountApiKey"],
730+
[ipAddress, "ipAddress"],
731+
]
732+
)
733+
payload = {
734+
"email": email,
735+
"subAccountApiKey": subAccountApiKey,
736+
"ipAddress": ipAddress,
737+
**kwargs,
738+
}
739+
740+
return self.limited_encoded_sign_request(
741+
"POST", "/sapi/v1/sub-account/subAccountApi/ipRestriction/ipList", payload
742+
)
743+
744+
745+
def sub_account_api_get_ip_restriction(
746+
self, email: str, subAccountApiKey: str, **kwargs
747+
):
748+
"""Get IP Restriction for a Sub-account API Key (For Master Account)
749+
750+
GET /sapi/v1/sub-account/subAccountApi/ipRestriction
751+
752+
https://binance-docs.github.io/apidocs/spot/en/#get-ip-restriction-for-a-sub-account-api-key-for-master-account
753+
754+
Args:
755+
email (str): Sub-account email
756+
subAccountApiKey (str)
757+
Keyword Args:
758+
recvWindow (int, optional)
759+
"""
760+
761+
check_required_parameters(
762+
[
763+
[email, "email"],
764+
[subAccountApiKey, "subAccountApiKey"],
765+
]
766+
)
767+
payload = {"email": email, "subAccountApiKey": subAccountApiKey, **kwargs}
768+
769+
return self.limited_encoded_sign_request(
770+
"GET", "/sapi/v1/sub-account/subAccountApi/ipRestriction", payload
771+
)
772+
773+
774+
def sub_account_api_delete_ip(
775+
self, email: str, subAccountApiKey: str, ipAddress: str, **kwargs
776+
):
777+
"""Delete IP List for a Sub-account API Key (For Master Account)
778+
779+
DELETE /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList
780+
781+
https://binance-docs.github.io/apidocs/spot/en/#delete-ip-list-for-a-sub-account-api-key-for-master-account
782+
783+
Args:
784+
email (str): Sub-account email
785+
subAccountApiKey (str)
786+
ipAddress (str): Can be added in batches, separated by commas
787+
Keyword Args:
788+
recvWindow (int, optional)
789+
"""
790+
791+
check_required_parameters(
792+
[
793+
[email, "email"],
794+
[subAccountApiKey, "subAccountApiKey"],
795+
[ipAddress, "ipAddress"],
796+
]
797+
)
798+
payload = {
799+
"email": email,
800+
"subAccountApiKey": subAccountApiKey,
801+
"ipAddress": ipAddress,
802+
**kwargs,
803+
}
804+
805+
return self.limited_encoded_sign_request(
806+
"DELETE", "/sapi/v1/sub-account/subAccountApi/ipRestriction/ipList", payload
807+
)

binance/spot/wallet.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ def enable_fast_withdraw(self, **kwargs):
8888

8989

9090
def withdraw(self, coin: str, amount: float, address: str, **kwargs):
91-
"""Withdraw
91+
"""Withdraw (USER_DATA)
9292
Submit a withdraw request.
9393
9494
POST /sapi/v1/capital/withdraw/apply
9595
96-
https://binance-docs.github.io/apidocs/spot/en/#withdraw-sapi
96+
https://binance-docs.github.io/apidocs/spot/en/#withdraw-user_data
9797
9898
Args:
9999
coin (str)
@@ -105,6 +105,7 @@ def withdraw(self, coin: str, amount: float, address: str, **kwargs):
105105
addressTag (str, optional): Secondary address identifier for coins like XRP,XMR etc.
106106
transactionFeeFlag (bool, optional): When making internal transfer, true for returning the fee to the destination account; false for returning the fee back to the departure account. Default false.
107107
name (str, optional): Description of the address. Space in name should be encoded into %20.
108+
walletType (int, optional): The wallet type for withdraw,0-spot wallet,1-funding wallet. Default is spot wallet
108109
recvWindow (int, optional): The value cannot be greater than 60000
109110
"""
110111

docs/source/CHANGELOG.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@ Changelog
33
=========
44

55

6+
1.8.0 - 2021-11-25
7+
------------------
8+
9+
Added
10+
^^^^^
11+
* New endpoint for Crypto Loans:
12+
* ``GET /sapi/v1/loan/income`` to query an asset's loan history
13+
* New endpoints for Sub-Account:
14+
* ``POST /sapi/v1/sub-account/subAccountApi/ipRestriction`` to support master account enable and disable IP restriction for a sub-account API Key
15+
* ``POST /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList`` to support master account add IP list for a sub-account API Key
16+
* ``GET /sapi/v1/sub-account/subAccountApi/ipRestriction`` to support master account query IP restriction for a sub-account API Key
17+
* ``DELETE /sapi/v1/sub-account/subAccountApi/ipRestriction/ipList`` to support master account delete IP list for a sub-account API Key
18+
* New endpoint for Pay:
19+
* ``GET /sapi/v1/pay/transactions`` to support user query Pay trade history
20+
21+
Fixed
22+
^^^^^
23+
* Removed epoch time from util method ``config_logging`` to provide compatibility with Windows OS
24+
* Allow optional parameter for method ``isolated_margin_account_limit``
25+
626
1.7.0 - 2021-11-04
727
------------------
828

docs/source/binance.spot.loan.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Crypto Loans Endpoints
2+
======================
3+
4+
Get Crypto Loans Income History (USER_DATA)
5+
-------------------------------------------
6+
.. autofunction:: binance.loan.loan_history

docs/source/binance.spot.pay.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Pay Endpoints
2+
=============
3+
4+
Get Pay Trade History (USER_DATA)
5+
---------------------------------
6+
.. autofunction:: binance.spot.pay.pay_history

0 commit comments

Comments
 (0)