From 2ea74f760220bdd2c91e6e0aa61faa92f94d5a0a Mon Sep 17 00:00:00 2001 From: aisling-2 <112478306+aisling-2@users.noreply.github.com> Date: Thu, 29 Sep 2022 10:21:14 +0100 Subject: [PATCH 1/6] 1.18.0 release --- CHANGELOG.md | 18 ++ binance/__version__.py | 2 +- binance/spot/__init__.py | 7 + binance/spot/loan.py | 163 +++++++++++++++++- binance/spot/market.py | 17 +- binance/spot/savings.py | 2 +- binance/spot/sub_account.py | 5 +- binance/spot/wallet.py | 10 +- docs/source/CHANGELOG.rst | 41 ++++- docs/source/binance.spot.loan.rst | 28 +++ examples/spot/loan/loan_adjust_ltv.py | 18 ++ examples/spot/loan/loan_adjust_ltv_history.py | 14 ++ examples/spot/loan/loan_borrow.py | 18 ++ examples/spot/loan/loan_borrow_history.py | 14 ++ examples/spot/loan/loan_ongoing_orders.py | 14 ++ examples/spot/loan/loan_repay.py | 14 ++ examples/spot/loan/loan_repay_history.py | 14 ++ examples/spot/market/exchange_info.py | 13 +- tests/spot/loan/test_loan_adjust_ltv.py | 58 +++++++ .../spot/loan/test_loan_adjust_ltv_history.py | 24 +++ tests/spot/loan/test_loan_borrow.py | 62 +++++++ tests/spot/loan/test_loan_borrow_history.py | 24 +++ tests/spot/loan/test_loan_ongoing_orders.py | 24 +++ tests/spot/loan/test_loan_repay.py | 47 +++++ tests/spot/loan/test_loan_repay_history.py | 24 +++ tests/spot/market/test_exchange_info.py | 36 +++- 26 files changed, 688 insertions(+), 23 deletions(-) create mode 100644 examples/spot/loan/loan_adjust_ltv.py create mode 100644 examples/spot/loan/loan_adjust_ltv_history.py create mode 100644 examples/spot/loan/loan_borrow.py create mode 100644 examples/spot/loan/loan_borrow_history.py create mode 100644 examples/spot/loan/loan_ongoing_orders.py create mode 100644 examples/spot/loan/loan_repay.py create mode 100644 examples/spot/loan/loan_repay_history.py create mode 100644 tests/spot/loan/test_loan_adjust_ltv.py create mode 100644 tests/spot/loan/test_loan_adjust_ltv_history.py create mode 100644 tests/spot/loan/test_loan_borrow.py create mode 100644 tests/spot/loan/test_loan_borrow_history.py create mode 100644 tests/spot/loan/test_loan_ongoing_orders.py create mode 100644 tests/spot/loan/test_loan_repay.py create mode 100644 tests/spot/loan/test_loan_repay_history.py diff --git a/CHANGELOG.md b/CHANGELOG.md index f65cb191..d94bf146 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 1.18.0 - 2022-09-29 + +### Added +- New endpoints for Crypto Loan: + - `POST /sapi/v1/loan/borrow` - Crypto Loan Borrow + - `GET /sapi/v1/loan/borrow/history` - Get Loan Borrow History + - `GET/sapi/v1/loan/ongoing/orders` - Get Loan Ongoing Orders + - `POST/sapi/v1/loan/repay` - Crypto Loan Repay + - `GET/sapi/v1/loan/repay/history` - Get Loan Repayment History + - `POST/sapi/v1/loan/adjust/ltv` - Crypto Loan Adjust LTV + - `GET/sapi/v1/loan/ltv/adjustment/history` - Get Loan LTV Adjustment History + +### Changed +- Changes to `GET /api/v3/exchangeInfo`: + - New optional parameter `permissions` added to display all symbols with the permissions matching the parameter provided. (eg.SPOT, MARGIN, LEVERAGED) + - If not provided, the default value will be `["SPOT","MARGIN", "LEVERAGED"]` + - Cannot be combined with symbol or symbols + ## 1.17.0 - 2022-09-05 ### Added diff --git a/binance/__version__.py b/binance/__version__.py index 30244104..6cea18d8 100644 --- a/binance/__version__.py +++ b/binance/__version__.py @@ -1 +1 @@ -__version__ = "1.17.0" +__version__ = "1.18.0" diff --git a/binance/spot/__init__.py b/binance/spot/__init__.py index 42076744..f9a0c565 100644 --- a/binance/spot/__init__.py +++ b/binance/spot/__init__.py @@ -250,6 +250,13 @@ def __init__(self, key=None, secret=None, **kwargs): # CRYPTO LOANS from binance.spot.loan import loan_history + from binance.spot.loan import loan_borrow + from binance.spot.loan import loan_borrow_history + from binance.spot.loan import loan_ongoing_orders + from binance.spot.loan import loan_repay + from binance.spot.loan import loan_repay_history + from binance.spot.loan import loan_adjust_ltv + from binance.spot.loan import loan_adjust_ltv_history # PAY from binance.spot.pay import pay_history diff --git a/binance/spot/loan.py b/binance/spot/loan.py index 26fcd42b..e3eb1208 100644 --- a/binance/spot/loan.py +++ b/binance/spot/loan.py @@ -1,4 +1,4 @@ -from binance.lib.utils import check_required_parameter +from binance.lib.utils import check_required_parameters, check_required_parameter def loan_history(self, asset: str, **kwargs): @@ -24,3 +24,164 @@ def loan_history(self, asset: str, **kwargs): payload = {"asset": asset, **kwargs} return self.sign_request("GET", "/sapi/v1/loan/income", payload) + + +def loan_borrow(self, loanCoin: str, collateralCoin: str, loanTerm: int, **kwargs): + """Crypto Loan Borrow (TRADE) + + POST /sapi/v1/loan/borrow + + https://binance-docs.github.io/apidocs/spot/en/#borrow-crypto-loan-borrow-trade + + Args: + loanCoin (str) + collateralCoin (str) + loanTerm (int): 7/14/30/90/180 days + Keyword Args: + loanAmount (float, optional): Mandatory when collateralAmount is empty + collateralAmount (float, optional): Mandatory when loanAmount is empty + recvWindow (int, optional): The value cannot be greater than 60000 + """ + + check_required_parameters( + [ + [loanCoin, "loanCoin"], + [collateralCoin, "collateralCoin"], + [loanTerm, "loanTerm"], + ] + ) + + payload = { + "loanCoin": loanCoin, + "collateralCoin": collateralCoin, + "loanTerm": loanTerm, + **kwargs, + } + return self.sign_request("POST", "/sapi/v1/loan/borrow", payload) + + +def loan_borrow_history(self, **kwargs): + """Get Loan Borrow History (USER_DATA) + + GET /sapi/v1/loan/borrow/history + + https://binance-docs.github.io/apidocs/spot/en/#borrow-get-loan-borrow-history-user_data + + Keyword Args: + orderId (int, optional): orderId in POST /sapi/v1/loan/borrow + loanCoin (str, optional) + collateralCoin (str, optional) + startTime (int, optional) + endTime (int, optional) + current (int, optional): Current querying page. Start from 1; default: 1; max: 1000. + limit (int, optional): Default: 10; max: 100 + recvWindow (int, optional): The value cannot be greater than 60000 + """ + + return self.sign_request("GET", "/sapi/v1/loan/borrow/history", kwargs) + + +def loan_ongoing_orders(self, **kwargs): + """Get Loan Ongoing Orders (USER_DATA) + + GET /sapi/v1/loan/ongoing/orders + + https://binance-docs.github.io/apidocs/spot/en/#borrow-get-loan-ongoing-orders-user_data + + Keyword Args: + orderId (int, optional): orderId in POST /sapi/v1/loan/borrow + loanCoin (str, optional) + collateralCoin (str, optional) + current (int, optional): Current querying page. Start from 1; default: 1; max: 1000 + limit (int, optional): Default: 10; max: 100 + recvWindow (int, optional): The value cannot be greater than 60000 + """ + + return self.sign_request("GET", "/sapi/v1/loan/ongoing/orders", kwargs) + + +def loan_repay(self, orderId: int, amount: float, **kwargs): + """Crypto Loan Repay (TRADE) + + POST /sapi/v1/loan/repay + + https://binance-docs.github.io/apidocs/spot/en/#repay-crypto-loan-repay-trade + + Args: + orderId (int) + amount (float) + Keyword Args: + type (int, optional): Default: 1. 1 for "repay with borrowed coin"; 2 for "repay with collateral" + collateralReturn (boolean, optional): Default: TRUE. TRUE: Return extra collateral to spot account; FALSE: Keep extra collateral in the order. + recvWindow (int, optional): The value cannot be greater than 60000 + """ + + check_required_parameters([[orderId, "orderId"], [amount, "amount"]]) + + payload = {"orderId": orderId, "amount": amount, **kwargs} + return self.sign_request("POST", "/sapi/v1/loan/repay", payload) + + +def loan_repay_history(self, **kwargs): + """Get Loan Repayment History (USER_DATA) + + GET /sapi/v1/loan/repay/history + + https://binance-docs.github.io/apidocs/spot/en/#repay-get-loan-repayment-history-user_data + + Keyword Args: + orderId (int, optional) + loanCoin (str, optional) + collateralCoin (str, optional) + startTime (int, optional) + endTime (int, optional) + current (int, optional): Current querying page. Start from 1; default: 1; max: 1000. + limit (int, optional): Default: 10; max: 100 + recvWindow (int, optional): The value cannot be greater than 60000 + """ + + return self.sign_request("GET", "/sapi/v1/loan/repay/history", kwargs) + + +def loan_adjust_ltv(self, orderId: int, amount: float, direction: str, **kwargs): + """Crypto Loan Adjust LTV (TRADE) + + POST /sapi/v1/loan/adjust/ltv + + https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-crypto-loan-adjust-ltv-trade + + Args: + orderId (int) + amount (float) + direction (str): "ADDITIONAL", "REDUCED" + Keyword Args: + recvWindow (int, optional): The value cannot be greater than 60000 + """ + + check_required_parameters( + [[orderId, "orderId"], [amount, "amount"], [direction, "direction"]] + ) + + payload = {"orderId": orderId, "amount": amount, "direction": direction, **kwargs} + return self.sign_request("POST", "/sapi/v1/loan/adjust/ltv", payload) + + +def loan_adjust_ltv_history(self, **kwargs): + """Get Loan LTV Adjustment History (USER_DATA) + + GET /sapi/v1/loan/ltv/adjustment/history + + https://binance-docs.github.io/apidocs/spot/en/#adjust-ltv-get-loan-ltv-adjustment-history-user_data + + Keyword Args: + orderId (int, optional) + loanCoin (str, optional) + collateralCoin (str, optional) + startTime (int, optional) + endTime (int, optional) + current (int, optional): Current querying page. Start from 1; default: 1; max: 1000 + limit (int, optional): Default: 10; max: 100 + recvWindow (int, optional): The value cannot be greater than 60000 + """ + + return self.sign_request("GET", "/sapi/v1/loan/ltv/adjustment/history", kwargs) diff --git a/binance/spot/market.py b/binance/spot/market.py index 2c57fe1e..bf516a57 100644 --- a/binance/spot/market.py +++ b/binance/spot/market.py @@ -35,7 +35,9 @@ def time(self): return self.query(url_path) -def exchange_info(self, symbol: str = None, symbols: list = None): +def exchange_info( + self, symbol: str = None, symbols: list = None, permissions: list = None +): """Exchange Information Current exchange trading rules and symbol information @@ -46,13 +48,24 @@ def exchange_info(self, symbol: str = None, symbols: list = None): Args: symbol (str, optional): the trading pair symbols (list, optional): list of trading pairs + permissions (list, optional): display all symbols with the permissions matching the parameter provided (eg.SPOT, MARGIN, LEVERAGED) """ url_path = "/api/v3/exchangeInfo" if symbol and symbols: raise ParameterArgumentError("symbol and symbols cannot be sent together.") + if symbol and permissions or symbols and permissions: + raise ParameterArgumentError( + "permissions cannot be sent together with symbol or symbols" + ) check_type_parameter(symbols, "symbols", list) - params = {"symbol": symbol, "symbols": convert_list_to_json_array(symbols)} + check_type_parameter(permissions, "permissions", list) + + params = { + "symbol": symbol, + "symbols": convert_list_to_json_array(symbols), + "permissions": convert_list_to_json_array(permissions), + } return self.query(url_path, params) diff --git a/binance/spot/savings.py b/binance/spot/savings.py index a05aa4fb..323f4a97 100644 --- a/binance/spot/savings.py +++ b/binance/spot/savings.py @@ -130,7 +130,7 @@ def savings_project_list(self, type: str, **kwargs): Keyword Args: asset (str, optional) status (str, optional): "ALL", "SUBSCRIBABLE", "UNSUBSCRIBABLE"; default "ALL" - isSortAsc (bool, optional): default "true" + isSortAsc (bool, optional): By default, it's True sortBy (str, optional): "START_TIME", "LOT_SIZE", "INTEREST_RATE", "DURATION"; default "START_TIME" current (int, optional): Currently querying page. Start from 1. Default:1 size (int, optional): Default:10, Max:100 diff --git a/binance/spot/sub_account.py b/binance/spot/sub_account.py index c9b726fa..56a6e82f 100644 --- a/binance/spot/sub_account.py +++ b/binance/spot/sub_account.py @@ -590,7 +590,7 @@ def sub_account_enable_leverage_token(self, email: str, enableBlvt: bool, **kwar Args: email (str): Sub-account email - enableBlvt (bool): Only true for now + enableBlvt (bool): Only True for now Keyword Args: recvWindow (int, optional): The value cannot be greater than 60000 """ @@ -688,6 +688,7 @@ def sub_account_api_toggle_ip_restriction( subAccountApiKey (str) ipRestrict (bool): True or False Keyword Args: + thirdParty (bool, optional): False by default recvWindow (int, optional) """ @@ -726,6 +727,7 @@ def sub_account_api_add_ip( subAccountApiKey (str) ipAddress (str): Can be added in batches, separated by commas Keyword Args: + thirdPartyName (str, optional) recvWindow (int, optional) """ @@ -791,6 +793,7 @@ def sub_account_api_delete_ip( subAccountApiKey (str) ipAddress (str): Can be added in batches, separated by commas Keyword Args: + thirdPartyName (str, optional) recvWindow (int, optional) """ diff --git a/binance/spot/wallet.py b/binance/spot/wallet.py index 339bddf4..c349bf56 100644 --- a/binance/spot/wallet.py +++ b/binance/spot/wallet.py @@ -103,7 +103,7 @@ def withdraw(self, coin: str, amount: float, address: str, **kwargs): withdrawOrderId (str, optional): Client id for withdraw network (str, optional) addressTag (str, optional): Secondary address identifier for coins like XRP,XMR etc. - 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. + 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. name (str, optional): Description of the address. Space in name should be encoded into %20. walletType (int, optional): The wallet type for withdraw,0-spot wallet,1-funding wallet. Default is spot wallet recvWindow (int, optional): The value cannot be greater than 60000 @@ -225,11 +225,11 @@ def dust_log(self, **kwargs): def user_universal_transfer(self, type: str, asset: str, amount: str, **kwargs): - """User Universal Transfer + """User Universal Transfer (USER_DATA) POST /sapi/v1/asset/transfer - https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer + https://binance-docs.github.io/apidocs/spot/en/#user-universal-transfer-user_data Args: type (str) @@ -247,11 +247,11 @@ def user_universal_transfer(self, type: str, asset: str, amount: str, **kwargs): def user_universal_transfer_history(self, type: str, **kwargs): - """Query User Universal Transfer History + """Query User Universal Transfer History (USER_DATA) GET /sapi/v1/asset/transfer - https://binance-docs.github.io/apidocs/spot/en/#query-user-universal-transfer-history + https://binance-docs.github.io/apidocs/spot/en/#query-user-universal-transfer-history-user_data Args: type (str) diff --git a/docs/source/CHANGELOG.rst b/docs/source/CHANGELOG.rst index 950d7c58..9f172fff 100644 --- a/docs/source/CHANGELOG.rst +++ b/docs/source/CHANGELOG.rst @@ -2,6 +2,31 @@ Changelog ========= +1.18.0 - 2022-09-29 +------------------- + +Added +^^^^^ + +* New endpoints for Crypto Loan: + + * ``POST /sapi/v1/loan/borrow`` - Crypto Loan Borrow + * ``GET /sapi/v1/loan/borrow/history`` - Get Loan Borrow History + * ``GET/sapi/v1/loan/ongoing/orders`` - Get Loan Ongoing Orders + * ``POST/sapi/v1/loan/repay`` - Crypto Loan Repay + * ``GET/sapi/v1/loan/repay/history`` - Get Loan Repayment History + * ``POST/sapi/v1/loan/adjust/ltv`` - Crypto Loan Adjust LTV + * ``GET/sapi/v1/loan/ltv/adjustment/history`` - Get Loan LTV Adjustment History + +Changed +^^^^^^^ + +* Changes to ``GET /api/v3/exchangeInfo``: + + * New optional parameter ``permissions`` added to display all symbols with the permissions matching the parameter provided (eg.SPOT, MARGIN, LEVERAGED). + * If not provided, the default value will be ``["SPOT","MARGIN", "LEVERAGED"]`` + * Cannot be combined with symbol or symbols + 1.17.0 - 2022-09-05 ------------------- @@ -9,7 +34,7 @@ Added ^^^^^ * New endpoint for Market: - * ``GET /api/v3/uiKlines`` + * ``GET /api/v3/uiKlines`` * New kline interval: ``1s`` @@ -17,10 +42,11 @@ Changed ^^^^^^^ * Changes to ``GET /api/v3/ticker`` and ``GET /api/v3/ticker/24hr`` - * New optional parameter type added - * Supported values for parameter type are ``FULL`` and ``MINI`` - * ``FULL`` is the default value and the response that is currently being returned from the endpoint - * ``MINI`` omits the following fields from the response: ``priceChangePercent``, ``weightedAvgPrice``, ``bidPrice``, ``bidQty``, ``askPrice``, ``askQty``, and ``lastQty`` + + * New optional parameter type added + * Supported values for parameter type are ``FULL`` and ``MINI`` + * ``FULL`` is the default value and the response that is currently being returned from the endpoint + * ``MINI`` omits the following fields from the response: ``priceChangePercent``, ``weightedAvgPrice``, ``bidPrice``, ``bidQty``, ``askPrice``, ``askQty``, and ``lastQty`` 1.16.0 - 2022-08-11 ------------------- @@ -29,6 +55,7 @@ Added ^^^^^ * New endpoint for Portfolio Margin: + * ``GET /sapi/v1/portfolio/pmLoan`` to query Portfolio Margin Bankruptcy Loan Record. * ``POST /sapi/v1/portfolio/repay`` to repay Portfolio Margin Bankruptcy Loan. * ``GET /sapi/v1/portfolio/collateralRate`` to get Portfolio Margin Collateral Rate. @@ -37,13 +64,17 @@ Update ^^^^^^ * Changes to ``POST /api/v3/order`` and ``POST /api/v3/order/cancelReplace`` + * New optional field ``strategyId`` is a parameter used to identify an order as part of a strategy. * New optional field ``strategyType`` is a parameter used to identify what strategy was running. (E.g. If all the orders are part of spot grid strategy, it can be set to strategyType=1000000) * Note: ``strategyType`` cannot be less than 1000000. + * Changes to ``POST /api/v3/order/oco`` + * New optional fields ``limitStrategyId``, ``limitStrategyType``, ``stopStrategyId``, ``stopStrategyType`` * These are the strategy metadata parameters for both legs of the OCO orders. * ``limitStrategyType`` and ``stopStrategyType`` both cannot be less than 1000000. + * ``asset`` is no longer mandatory in ``GET /sapi/v1/lending/project/position/list`` 1.15.0 - 2022-07-19 diff --git a/docs/source/binance.spot.loan.rst b/docs/source/binance.spot.loan.rst index c2d81632..af9fc5a5 100644 --- a/docs/source/binance.spot.loan.rst +++ b/docs/source/binance.spot.loan.rst @@ -4,3 +4,31 @@ Crypto Loans Endpoints Get Crypto Loans Income History (USER_DATA) ------------------------------------------- .. autofunction:: binance.spot.loan.loan_history + +Crypto Loan Borrow (TRADE) +-------------------------- +.. autofunction:: binance.spot.loan.loan_borrow + +Get Loan Borrow History (USER_DATA) +----------------------------------- +.. autofunction:: binance.spot.loan.loan_borrow_history + +Get Loan Ongoing Orders (USER_DATA) +----------------------------------- +.. autofunction:: binance.spot.loan.loan_ongoing_orders + +Crypto Loan Repay (TRADE) +------------------------- +.. autofunction:: binance.spot.loan.loan_repay + +Get Loan Repayment History (USER_DATA) +-------------------------------------- +.. autofunction:: binance.spot.loan.loan_repay_history + +Crypto Loan Adjust LTV (TRADE) +------------------------------ +.. autofunction:: binance.spot.loan.loan_adjust_ltv + +Get Loan LTV Adjustment History (USER_DATA) +------------------------------------------- +.. autofunction:: binance.spot.loan.loan_adjust_ltv_history \ No newline at end of file diff --git a/examples/spot/loan/loan_adjust_ltv.py b/examples/spot/loan/loan_adjust_ltv.py new file mode 100644 index 00000000..f4dec4b3 --- /dev/null +++ b/examples/spot/loan/loan_adjust_ltv.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import logging +from binance.spot import Spot as Client +from binance.lib.utils import config_logging + +config_logging(logging, logging.DEBUG) + +key = "" +secret = "" + + +client = Client(key, secret) +logging.info( + client.loan_adjust_ltv( + orderId=756783308056935434, amount=5.235, direction="ADDITIONAL" + ) +) diff --git a/examples/spot/loan/loan_adjust_ltv_history.py b/examples/spot/loan/loan_adjust_ltv_history.py new file mode 100644 index 00000000..3ee20623 --- /dev/null +++ b/examples/spot/loan/loan_adjust_ltv_history.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +import logging +from binance.spot import Spot as Client +from binance.lib.utils import config_logging + +config_logging(logging, logging.DEBUG) + +key = "" +secret = "" + + +client = Client(key, secret) +logging.info(client.loan_adjust_ltv_history(loanCoin="USDT")) diff --git a/examples/spot/loan/loan_borrow.py b/examples/spot/loan/loan_borrow.py new file mode 100644 index 00000000..c439a63e --- /dev/null +++ b/examples/spot/loan/loan_borrow.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import logging +from binance.spot import Spot as Client +from binance.lib.utils import config_logging + +config_logging(logging, logging.DEBUG) + +key = "" +secret = "" + + +client = Client(key, secret) +logging.info( + client.loan_borrow( + loanCoin="USDT", collateralCoin="BUSD", loanTerm=7, loanAmount=1.1 + ) +) diff --git a/examples/spot/loan/loan_borrow_history.py b/examples/spot/loan/loan_borrow_history.py new file mode 100644 index 00000000..14f5fd78 --- /dev/null +++ b/examples/spot/loan/loan_borrow_history.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +import logging +from binance.spot import Spot as Client +from binance.lib.utils import config_logging + +config_logging(logging, logging.DEBUG) + +key = "" +secret = "" + + +client = Client(key, secret) +logging.info(client.loan_borrow_history(loanCoin="USDT")) diff --git a/examples/spot/loan/loan_ongoing_orders.py b/examples/spot/loan/loan_ongoing_orders.py new file mode 100644 index 00000000..c38b0320 --- /dev/null +++ b/examples/spot/loan/loan_ongoing_orders.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +import logging +from binance.spot import Spot as Client +from binance.lib.utils import config_logging + +config_logging(logging, logging.DEBUG) + +key = "" +secret = "" + + +client = Client(key, secret) +logging.info(client.loan_ongoing_orders(loanCoin="USDT")) diff --git a/examples/spot/loan/loan_repay.py b/examples/spot/loan/loan_repay.py new file mode 100644 index 00000000..ef12a69f --- /dev/null +++ b/examples/spot/loan/loan_repay.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +import logging +from binance.spot import Spot as Client +from binance.lib.utils import config_logging + +config_logging(logging, logging.DEBUG) + +key = "" +secret = "" + + +client = Client(key, secret) +logging.info(client.loan_repay(orderId=100000001, amount=100.5)) diff --git a/examples/spot/loan/loan_repay_history.py b/examples/spot/loan/loan_repay_history.py new file mode 100644 index 00000000..2a8f3381 --- /dev/null +++ b/examples/spot/loan/loan_repay_history.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +import logging +from binance.spot import Spot as Client +from binance.lib.utils import config_logging + +config_logging(logging, logging.DEBUG) + +key = "" +secret = "" + + +client = Client(key, secret) +logging.info(client.loan_repay_history(loanCoin="BUSD")) diff --git a/examples/spot/market/exchange_info.py b/examples/spot/market/exchange_info.py index b02645aa..1f58407a 100644 --- a/examples/spot/market/exchange_info.py +++ b/examples/spot/market/exchange_info.py @@ -4,9 +4,12 @@ config_logging(logging, logging.DEBUG) -spot_client = Client(base_url="https://testnet.binance.vision") -symbols = ["BTCUSDT", "BNBUSDT"] -symbol = "BNBUSDT" +spot_client = Client() + logging.info(spot_client.exchange_info()) -logging.info(spot_client.exchange_info(symbol=symbol)) -logging.info(spot_client.exchange_info(symbols=symbols)) + +logging.info(spot_client.exchange_info(symbol="BNBUSDT")) +logging.info(spot_client.exchange_info(symbols=["BTCUSDT", "BNBUSDT"])) + +logging.info(spot_client.exchange_info(permissions=["MARGIN"])) +logging.info(spot_client.exchange_info(permissions=["MARGIN", "LEVERAGED"])) diff --git a/tests/spot/loan/test_loan_adjust_ltv.py b/tests/spot/loan/test_loan_adjust_ltv.py new file mode 100644 index 00000000..5a98cecf --- /dev/null +++ b/tests/spot/loan/test_loan_adjust_ltv.py @@ -0,0 +1,58 @@ +import responses + +from urllib.parse import urlencode +from tests.util import random_str +from tests.util import mock_http_response +from binance.spot import Spot as Client +from binance.error import ParameterRequiredError + +mock_item = {"key_1": "value_1", "key_2": "value_2"} + +key = random_str() +secret = random_str() +client = Client(key, secret) + +params = {"orderId": 756783308056935434, "amount": 100.1, "direction": "ADDITIONAL"} + + +def test_loan_adjust_ltv_without_orderId(): + """Tests the API endpoint to adjust LTV without orderId""" + + params = {"orderId": "", "amount": 100.1, "direction": "ADDITIONAL"} + + client.loan_adjust_ltv.when.called_with(**params).should.throw( + ParameterRequiredError + ) + + +def test_loan_adjust_ltv_without_amount(): + """Tests the API endpoint to adjust LTV without amount""" + + params = {"orderId": 756783308056935434, "amount": "", "direction": "ADDITIONAL"} + + client.loan_adjust_ltv.when.called_with(**params).should.throw( + ParameterRequiredError + ) + + +def test_loan_adjust_ltv_without_direction(): + """Tests the API endpoint to adjust LTV without direction""" + + params = {"orderId": 756783308056935434, "amount": 100.1, "direction": ""} + + client.loan_adjust_ltv.when.called_with(**params).should.throw( + ParameterRequiredError + ) + + +@mock_http_response( + responses.POST, + "/sapi/v1/loan/adjust/ltv\\?" + urlencode(params), + mock_item, + 200, +) +def test_loan_adjust_ltv(): + """Tests the API endpoint to adjust LTV""" + + response = client.loan_adjust_ltv(**params) + response.should.equal(mock_item) diff --git a/tests/spot/loan/test_loan_adjust_ltv_history.py b/tests/spot/loan/test_loan_adjust_ltv_history.py new file mode 100644 index 00000000..924184bf --- /dev/null +++ b/tests/spot/loan/test_loan_adjust_ltv_history.py @@ -0,0 +1,24 @@ +import responses + +from tests.util import random_str +from tests.util import mock_http_response +from binance.spot import Spot as Client + +mock_item = {"key_1": "value_1", "key_2": "value_2"} + +key = random_str() +secret = random_str() +client = Client(key, secret) + + +@mock_http_response( + responses.GET, + "/sapi/v1/loan/ltv/adjustment/history\\?loanCoin=BUSD", + mock_item, + 200, +) +def test_loan_adjust_ltv_history(): + """Tests the API endpoint to get LTV adjustment history""" + + response = client.loan_adjust_ltv_history(loanCoin="BUSD") + response.should.equal(mock_item) diff --git a/tests/spot/loan/test_loan_borrow.py b/tests/spot/loan/test_loan_borrow.py new file mode 100644 index 00000000..9f2c264f --- /dev/null +++ b/tests/spot/loan/test_loan_borrow.py @@ -0,0 +1,62 @@ +import responses + +from urllib.parse import urlencode +from tests.util import random_str +from tests.util import mock_http_response +from binance.spot import Spot as Client +from binance.error import ParameterRequiredError + +mock_item = {"key_1": "value_1", "key_2": "value_2"} +mock_exception = {"code": -1105, "msg": "error message."} + +key = random_str() +secret = random_str() +client = Client(key, secret) + +params = {"loanCoin": "BUSD", "collateralCoin": "BNB", "loanTerm": 7} + + +def test_loan_borrow_without_loanCoin(): + """Tests the API endpoint to borrow loan without loanCoin""" + + params = {"loanCoin": "", "collateralCoin": "BNB", "loanTerm": 7} + + client.loan_borrow.when.called_with(**params).should.throw(ParameterRequiredError) + + +def test_loan_borrow_without_collateralCoin(): + """Tests the API endpoint to borrow loan without collateralCoin""" + + params = { + "loanCoin": "USDT", + "collateralCoin": "", + "loanTerm": 7, + } + + client.loan_borrow.when.called_with(**params).should.throw(ParameterRequiredError) + + +def test_loan_borrow_without_loanTerm(): + """Tests the API endpoint to borrow loan without loanTerm""" + + params = { + "loanCoin": "USDT", + "collateralCoin": "BNB", + "loanTerm": "", + "loanAmount": 1.1, + } + + client.loan_borrow.when.called_with(**params).should.throw(ParameterRequiredError) + + +@mock_http_response( + responses.POST, + "/sapi/v1/loan/borrow\\?" + urlencode(params), + mock_item, + 200, +) +def test_loan_borrow(): + """Tests the API endpoint to loan""" + + response = client.loan_borrow(**params) + response.should.equal(mock_item) diff --git a/tests/spot/loan/test_loan_borrow_history.py b/tests/spot/loan/test_loan_borrow_history.py new file mode 100644 index 00000000..e51c17e0 --- /dev/null +++ b/tests/spot/loan/test_loan_borrow_history.py @@ -0,0 +1,24 @@ +import responses + +from tests.util import random_str +from tests.util import mock_http_response +from binance.spot import Spot as Client + +mock_item = {"key_1": "value_1", "key_2": "value_2"} + +key = random_str() +secret = random_str() +client = Client(key, secret) + + +@mock_http_response( + responses.GET, + "/sapi/v1/loan/borrow/history\\?loanCoin=BUSD", + mock_item, + 200, +) +def test_loan_borrow_history(): + """Tests the API endpoint to get borrow history""" + + response = client.loan_borrow_history(loanCoin="BUSD") + response.should.equal(mock_item) diff --git a/tests/spot/loan/test_loan_ongoing_orders.py b/tests/spot/loan/test_loan_ongoing_orders.py new file mode 100644 index 00000000..28d94de1 --- /dev/null +++ b/tests/spot/loan/test_loan_ongoing_orders.py @@ -0,0 +1,24 @@ +import responses + +from tests.util import random_str +from tests.util import mock_http_response +from binance.spot import Spot as Client + +mock_item = {"key_1": "value_1", "key_2": "value_2"} + +key = random_str() +secret = random_str() +client = Client(key, secret) + + +@mock_http_response( + responses.GET, + "/sapi/v1/loan/ongoing/orders\\?loanCoin=BUSD", + mock_item, + 200, +) +def test_loan_ongoing_orders(): + """Tests the API endpoint to get loan borrow ongoing orders""" + + response = client.loan_ongoing_orders(loanCoin="BUSD") + response.should.equal(mock_item) diff --git a/tests/spot/loan/test_loan_repay.py b/tests/spot/loan/test_loan_repay.py new file mode 100644 index 00000000..1a6421f3 --- /dev/null +++ b/tests/spot/loan/test_loan_repay.py @@ -0,0 +1,47 @@ +import responses + +from urllib.parse import urlencode +from tests.util import random_str +from tests.util import mock_http_response +from binance.spot import Spot as Client +from binance.error import ParameterRequiredError + +mock_item = {"key_1": "value_1", "key_2": "value_2"} + +key = random_str() +secret = random_str() +client = Client(key, secret) + +params = {"orderId": 100000001, "amount": 100.5} + + +def test_loan_repay_without_orderId(): + """Tests the API endpoint to repay loan without orderId""" + + params = {"orderId": "", "amount": 100.5} + + client.loan_repay.when.called_with(**params).should.throw(ParameterRequiredError) + + +def test_loan_repay_without_amount(): + """Tests the API endpoint to repay loan without amount""" + + params = { + "orderId": "USDT", + "amount": "", + } + + client.loan_repay.when.called_with(**params).should.throw(ParameterRequiredError) + + +@mock_http_response( + responses.POST, + "/sapi/v1/loan/repay\\?" + urlencode(params), + mock_item, + 200, +) +def test_loan_repay(): + """Tests the API endpoint to repay loan""" + + response = client.loan_repay(**params) + response.should.equal(mock_item) diff --git a/tests/spot/loan/test_loan_repay_history.py b/tests/spot/loan/test_loan_repay_history.py new file mode 100644 index 00000000..7d72dea0 --- /dev/null +++ b/tests/spot/loan/test_loan_repay_history.py @@ -0,0 +1,24 @@ +import responses + +from tests.util import random_str +from tests.util import mock_http_response +from binance.spot import Spot as Client + +mock_item = {"key_1": "value_1", "key_2": "value_2"} + +key = random_str() +secret = random_str() +client = Client(key, secret) + + +@mock_http_response( + responses.GET, + "/sapi/v1/loan/repay/history\\?loanCoin=BUSD", + mock_item, + 200, +) +def test_loan_repay_history(): + """Tests the API endpoint to get repay history""" + + response = client.loan_repay_history(loanCoin="BUSD") + response.should.equal(mock_item) diff --git a/tests/spot/market/test_exchange_info.py b/tests/spot/market/test_exchange_info.py index d3323b01..8c374f3e 100644 --- a/tests/spot/market/test_exchange_info.py +++ b/tests/spot/market/test_exchange_info.py @@ -6,7 +6,10 @@ from urllib.parse import urlencode mock_item = {"key_1": "value_1", "key_2": "value_2"} -params = {"symbols": '["BTCUSDT", "ETHUSDT", "BNBUSDT"]'} +symbols_params = {"symbols": '["BTCUSDT", "ETHUSDT", "BNBUSDT"]'} +permissions_params = {"permissions": '["MARGIN", "LEVERAGED"]'} + +api = Client() @mock_http_response(responses.GET, "/api/v3/exchangeInfo", mock_item, 200) @@ -31,7 +34,7 @@ def test_exchange_info_one_symbol(): @mock_http_response( - responses.GET, "/api/v3/exchangeInfo\\?" + urlencode(params), mock_item, 200 + responses.GET, "/api/v3/exchangeInfo\\?" + urlencode(symbols_params), mock_item, 200 ) def test_exchange_info_multiple_symbols(): """Tests the API endpoint to get exchange info with multiple symbols""" @@ -56,6 +59,35 @@ def test_exchange_info_with_double_parameter(): api = Client() symbol = "symbol" symbols = ["symbol1", "symbol2", "symbol3"] + permissions = ["MARGIN", "LEVERAGED"] api.exchange_info.when.called_with(symbol=symbol, symbols=symbols).should.throw( ParameterArgumentError ) + api.exchange_info.when.called_with( + permissions=permissions, symbols=symbols + ).should.throw(ParameterArgumentError) + api.exchange_info.when.called_with( + permissions=permissions, symbol=symbol + ).should.throw(ParameterArgumentError) + + +@mock_http_response( + responses.GET, + "/api/v3/exchangeInfo\\?" + urlencode(permissions_params), + mock_item, + 200, +) +def test_exchange_info_with_permissions(): + """Tests the API endpoint with permissions""" + + permissions = ["MARGIN", "LEVERAGED"] + response = api.exchange_info(permissions=permissions) + response.should.equal(mock_item) + + +def test_exchange_info_invalid_type_permissions(): + """Tests the API endpoint with invalid permissions data type""" + + api.exchange_info.when.called_with(permissions="MARGIN").should.throw( + ParameterTypeError + ) From 8f916ff82fb3838c51c48c3b1f86e96124619a9d Mon Sep 17 00:00:00 2001 From: "eabunassar@gmail.com" Date: Fri, 28 Oct 2022 15:12:00 +0300 Subject: [PATCH 2/6] Fix reactor stop hang --- CHANGELOG.md | 3 +++ binance/websocket/websocket_client.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d94bf146..0014b15c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ - If not provided, the default value will be `["SPOT","MARGIN", "LEVERAGED"]` - Cannot be combined with symbol or symbols +### Fixed +- Main thread not exiting due to reactor stop hang + ## 1.17.0 - 2022-09-05 ### Added diff --git a/binance/websocket/websocket_client.py b/binance/websocket/websocket_client.py index e0cca4b5..51dba550 100644 --- a/binance/websocket/websocket_client.py +++ b/binance/websocket/websocket_client.py @@ -11,7 +11,7 @@ def stop(self): try: self.close() finally: - reactor.stop() + reactor.callFromThread(reactor.stop) def _single_stream(self, stream): if isinstance(stream, str): From a4b29569c7c90729e5919e6d0da804e0e700db41 Mon Sep 17 00:00:00 2001 From: Carlos Moratelli Date: Wed, 30 Nov 2022 17:25:30 -0300 Subject: [PATCH 3/6] Allow to pass list of symbols to open multiple streams. --- binance/websocket/spot/websocket_client.py | 65 +++++++++++++++++++--- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/binance/websocket/spot/websocket_client.py b/binance/websocket/spot/websocket_client.py index b7b5305e..b40ce2b5 100644 --- a/binance/websocket/spot/websocket_client.py +++ b/binance/websocket/spot/websocket_client.py @@ -14,8 +14,13 @@ def agg_trade(self, symbol: str, id: int, callback, **kwargs): Update Speed: Real-time """ + if isinstance(symbol, list): + symbol = ["{}@aggTrade".format(x.lower()) for x in symbol] + else: + symbol = "{}@aggTrade".format(symbol.lower()) + self.live_subscribe( - "{}@aggTrade".format(symbol.lower()), id, callback, **kwargs + symbol, id, callback, **kwargs ) def trade(self, symbol: str, id: int, callback, **kwargs): @@ -27,7 +32,12 @@ def trade(self, symbol: str, id: int, callback, **kwargs): Update Speed: Real-time """ - self.live_subscribe("{}@trade".format(symbol.lower()), id, callback, **kwargs) + if isinstance(symbol, list): + symbol = ["{}@trade".format(x.lower()) for x in symbol] + else: + symbol = "{}@trade".format(symbol.lower()) + + self.live_subscribe(symbol, id, callback, **kwargs) def kline(self, symbol: str, id: int, interval: str, callback, **kwargs): """Kline/Candlestick Streams @@ -57,9 +67,13 @@ def kline(self, symbol: str, id: int, interval: str, callback, **kwargs): Update Speed: 2000ms """ + if isinstance(symbol, list): + symbol = ["{}@kline_{}".format(x.lower(), interval) for x in symbol] + else: + symbol = "{}@kline_{}".format(symbol.lower(), interval) self.live_subscribe( - "{}@kline_{}".format(symbol.lower(), interval), id, callback, **kwargs + symbol, id, callback, **kwargs ) def mini_ticker(self, id: int, callback, symbol=None, **kwargs): @@ -77,8 +91,14 @@ def mini_ticker(self, id: int, callback, symbol=None, **kwargs): if symbol is None: self.live_subscribe("!miniTicker@arr", id, callback, **kwargs) else: + if isinstance(symbol, list): + symbol = ["{}@miniTicker".format(x.lower()) for x in symbol] + else: + symbol = "{}@miniTicker".format(symbol.lower()) + + self.live_subscribe( - "{}@miniTicker".format(symbol.lower()), id, callback, **kwargs + symbol, id, callback, **kwargs ) def ticker(self, id: int, callback, symbol=None, **kwargs): @@ -96,8 +116,13 @@ def ticker(self, id: int, callback, symbol=None, **kwargs): if symbol is None: self.live_subscribe("!ticker@arr", id, callback, **kwargs) else: + if isinstance(symbol, list): + symbol = ["{}@ticker".format(x.lower()) for x in symbol] + else: + symbol = "{}@ticker".format(symbol.lower()) + self.live_subscribe( - "{}@ticker".format(symbol.lower()), id, callback, **kwargs + symbol, id, callback, **kwargs ) def book_ticker(self, id: int, callback, symbol=None, **kwargs): @@ -114,8 +139,13 @@ def book_ticker(self, id: int, callback, symbol=None, **kwargs): if symbol is None: self.live_subscribe("!bookTicker", id, callback, **kwargs) else: + if isinstance(symbol, list): + symbol = ["{}@bookTicker".format(x.lower()) for x in symbol] + else: + symbol = "{}@bookTicker".format(symbol.lower()) + self.live_subscribe( - "{}@bookTicker".format(symbol.lower()), id, callback, **kwargs + symbol, id, callback, **kwargs ) def partial_book_depth( @@ -129,8 +159,14 @@ def partial_book_depth( Update Speed: 1000ms or 100ms """ + + if isinstance(symbol, list): + symbol = ["{}@depth{}@{}ms".format(x.lower(), level, speed) for x in symbol] + else: + symbol = "{}@depth{}@{}ms".format(symbol.lower(), level, speed) + self.live_subscribe( - "{}@depth{}@{}ms".format(symbol.lower(), level, speed), + symbol, id, callback, **kwargs @@ -149,8 +185,14 @@ def rolling_window_ticker( Note: This stream is different from the @ticker stream. The open time "O" always starts on a minute, while the closing time "C" is the current time of the update. As such, the effective window might be up to 59999ms wider that . """ + + if isinstance(symbol, list): + symbol = ["{}@ticker_{}".format(x.lower(), windowSize) for x in symbol] + else: + symbol = "{}@ticker_{}".format(symbol.lower(), windowSize) + self.live_subscribe( - "{}@ticker_{}".format(symbol.lower(), windowSize), id, callback, **kwargs + symbol, id, callback, **kwargs ) def rolling_window_ticker_all_symbols( @@ -177,8 +219,13 @@ def diff_book_depth(self, symbol: str, id: int, speed, callback, **kwargs): Order book price and quantity depth updates used to locally manage an order book. """ + if isinstance(symbol, list): + symbol = ["{}@depth@{}ms".format(x.lower(), speed) for x in symbol] + else: + symbol = "{}@depth@{}ms".format(symbol.lower(), speed) + self.live_subscribe( - "{}@depth@{}ms".format(symbol.lower(), speed), id, callback, **kwargs + symbol, id, callback, **kwargs ) def user_data(self, listen_key: str, id: int, callback, **kwargs): From 308df2152ec399f4f59f9ced966ad3e729f916b0 Mon Sep 17 00:00:00 2001 From: jonte-z Date: Wed, 14 Dec 2022 17:25:27 +1100 Subject: [PATCH 4/6] Formatting. --- CHANGELOG.md | 2 +- binance/__version__.py | 2 +- docs/source/CHANGELOG.rst | 2 +- examples/spot/loan/loan_adjust_ltv.py | 2 +- examples/spot/loan/loan_adjust_ltv_history.py | 2 +- examples/spot/loan/loan_borrow.py | 2 +- examples/spot/loan/loan_borrow_history.py | 2 +- examples/spot/loan/loan_ongoing_orders.py | 2 +- examples/spot/loan/loan_repay.py | 2 +- examples/spot/loan/loan_repay_history.py | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3ab6579..7e4044eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -253,4 +253,4 @@ ## 1.0.0 - 2021-06-15 ### Added -- First release, please find details from `README.md` \ No newline at end of file +- First release, please find details from `README.md` diff --git a/binance/__version__.py b/binance/__version__.py index aee0b612..0ddcee84 100644 --- a/binance/__version__.py +++ b/binance/__version__.py @@ -1 +1 @@ -__version__ = "2.0.0rc2" \ No newline at end of file +__version__ = "2.0.0rc2" diff --git a/docs/source/CHANGELOG.rst b/docs/source/CHANGELOG.rst index b3c04e62..bf7012a9 100644 --- a/docs/source/CHANGELOG.rst +++ b/docs/source/CHANGELOG.rst @@ -399,4 +399,4 @@ Added ^^^^^ -* First release, please find details from ``README.md`` \ No newline at end of file +* First release, please find details from ``README.md`` diff --git a/examples/spot/loan/loan_adjust_ltv.py b/examples/spot/loan/loan_adjust_ltv.py index 473cb61b..900aa7e3 100644 --- a/examples/spot/loan/loan_adjust_ltv.py +++ b/examples/spot/loan/loan_adjust_ltv.py @@ -15,4 +15,4 @@ client.loan_adjust_ltv( orderId=756783308056935434, amount=5.235, direction="ADDITIONAL" ) -) \ No newline at end of file +) diff --git a/examples/spot/loan/loan_adjust_ltv_history.py b/examples/spot/loan/loan_adjust_ltv_history.py index eed91fc7..70cae9ee 100644 --- a/examples/spot/loan/loan_adjust_ltv_history.py +++ b/examples/spot/loan/loan_adjust_ltv_history.py @@ -11,4 +11,4 @@ client = Client(api_key, api_secret) -logging.info(client.loan_adjust_ltv_history(loanCoin="USDT")) \ No newline at end of file +logging.info(client.loan_adjust_ltv_history(loanCoin="USDT")) diff --git a/examples/spot/loan/loan_borrow.py b/examples/spot/loan/loan_borrow.py index a494d6bc..dab80c94 100644 --- a/examples/spot/loan/loan_borrow.py +++ b/examples/spot/loan/loan_borrow.py @@ -15,4 +15,4 @@ client.loan_borrow( loanCoin="USDT", collateralCoin="BUSD", loanTerm=7, loanAmount=1.1 ) -) \ No newline at end of file +) diff --git a/examples/spot/loan/loan_borrow_history.py b/examples/spot/loan/loan_borrow_history.py index 7ed5d40a..f2134809 100644 --- a/examples/spot/loan/loan_borrow_history.py +++ b/examples/spot/loan/loan_borrow_history.py @@ -11,4 +11,4 @@ client = Client(api_key, api_secret) -logging.info(client.loan_borrow_history(loanCoin="USDT")) \ No newline at end of file +logging.info(client.loan_borrow_history(loanCoin="USDT")) diff --git a/examples/spot/loan/loan_ongoing_orders.py b/examples/spot/loan/loan_ongoing_orders.py index 5c2c3f78..56aed7a2 100644 --- a/examples/spot/loan/loan_ongoing_orders.py +++ b/examples/spot/loan/loan_ongoing_orders.py @@ -11,4 +11,4 @@ client = Client(api_key, api_secret) -logging.info(client.loan_ongoing_orders(loanCoin="USDT")) \ No newline at end of file +logging.info(client.loan_ongoing_orders(loanCoin="USDT")) diff --git a/examples/spot/loan/loan_repay.py b/examples/spot/loan/loan_repay.py index 8bd1d97f..c4ca905b 100644 --- a/examples/spot/loan/loan_repay.py +++ b/examples/spot/loan/loan_repay.py @@ -11,4 +11,4 @@ client = Client(api_key, api_secret) -logging.info(client.loan_repay(orderId=100000001, amount=100.5)) \ No newline at end of file +logging.info(client.loan_repay(orderId=100000001, amount=100.5)) diff --git a/examples/spot/loan/loan_repay_history.py b/examples/spot/loan/loan_repay_history.py index daed071a..74230b61 100644 --- a/examples/spot/loan/loan_repay_history.py +++ b/examples/spot/loan/loan_repay_history.py @@ -11,4 +11,4 @@ client = Client(api_key, api_secret) -logging.info(client.loan_repay_history(loanCoin="BUSD")) \ No newline at end of file +logging.info(client.loan_repay_history(loanCoin="BUSD")) From c763e92b10079ecf9a2842b09feabcc875baa801 Mon Sep 17 00:00:00 2001 From: jonte-z Date: Fri, 16 Dec 2022 17:08:11 +1100 Subject: [PATCH 5/6] v2.0.0rc3 release --- .github/workflows/pythonpackage.yml | 6 +- CHANGELOG.md | 28 +- README.md | 12 +- binance/__version__.py | 2 +- binance/api.py | 11 +- binance/error.py | 4 +- binance/spot/__init__.py | 11 +- binance/spot/futures.py | 265 ------------------ binance/spot/margin.py | 14 + binance/websocket/spot/websocket_client.py | 36 +-- docs/source/binance.spot.futures.rst | 40 --- docs/source/binance.spot.margin.rst | 6 +- examples/config.ini | 5 + examples/spot/blvt/blvt_info.py | 8 +- examples/spot/blvt/redeem_blvt.py | 8 +- examples/spot/blvt/redemption_record.py | 8 +- examples/spot/blvt/subscribe_blvt.py | 8 +- examples/spot/blvt/subscription_record.py | 8 +- examples/spot/blvt/user_limit_info.py | 8 +- .../spot/bswap/bswap_add_liquidity_preview.py | 8 +- examples/spot/bswap/bswap_claim_rewards.py | 8 +- examples/spot/bswap/bswap_claimed_rewards.py | 8 +- examples/spot/bswap/bswap_liquidity.py | 8 +- examples/spot/bswap/bswap_liquidity_add.py | 8 +- .../bswap/bswap_liquidity_operation_record.py | 8 +- examples/spot/bswap/bswap_pool_configure.py | 8 +- examples/spot/bswap/bswap_pools.py | 8 +- examples/spot/bswap/bswap_remove_liquidity.py | 8 +- .../bswap/bswap_remove_liquidity_preview.py | 8 +- examples/spot/bswap/bswap_request_quote.py | 8 +- examples/spot/bswap/bswap_swap.py | 8 +- examples/spot/bswap/bswap_swap_history.py | 8 +- .../spot/bswap/bswap_unclaimed_rewards.py | 8 +- examples/spot/c2c/c2c_trade_history.py | 8 +- examples/spot/convert/convert.py | 8 +- examples/spot/fiat/fiat_order_history.py | 8 +- examples/spot/fiat/fiat_payment_history.py | 8 +- .../futures_loan_adjust_collateral_history.py | 8 +- .../futures/futures_loan_borrow_history.py | 8 +- .../futures/futures_loan_interest_history.py | 8 +- .../futures_loan_liquidation_history.py | 8 +- .../futures/futures_loan_repay_history.py | 8 +- examples/spot/futures/futures_loan_wallet.py | 8 +- examples/spot/futures/futures_transfer.py | 8 +- .../spot/futures/futures_transfer_history.py | 8 +- .../spot/gift_card/gift_card_create_code.py | 8 +- .../spot/gift_card/gift_card_redeem_code.py | 9 +- .../gift_card/gift_card_rsa_public_key.py | 8 +- .../spot/gift_card/gift_card_verify_code.py | 8 +- examples/spot/loan/loan_adjust_ltv.py | 8 +- examples/spot/loan/loan_adjust_ltv_history.py | 8 +- examples/spot/loan/loan_borrow.py | 8 +- examples/spot/loan/loan_borrow_history.py | 8 +- examples/spot/loan/loan_history.py | 8 +- examples/spot/loan/loan_ongoing_orders.py | 8 +- examples/spot/loan/loan_repay.py | 8 +- examples/spot/loan/loan_repay_history.py | 8 +- examples/spot/margin/bnbBurn_status.py | 8 +- .../margin/cancel_isolated_margin_account.py | 8 +- .../spot/margin/cancel_margin_oco_order.py | 8 +- examples/spot/margin/cancel_margin_order.py | 8 +- .../margin/enable_isolated_margin_account.py | 8 +- examples/spot/margin/get_margin_oco_order.py | 8 +- examples/spot/margin/get_margin_oco_orders.py | 8 +- .../spot/margin/get_margin_open_oco_orders.py | 8 +- .../spot/margin/isolated_margin_account.py | 8 +- .../margin/isolated_margin_account_limit.py | 8 +- .../spot/margin/isolated_margin_all_pairs.py | 8 +- examples/spot/margin/isolated_margin_fee.py | 8 +- examples/spot/margin/isolated_margin_pair.py | 8 +- examples/spot/margin/isolated_margin_tier.py | 8 +- .../spot/margin/isolated_margin_transfer.py | 8 +- .../isolated_margin_transfer_history.py | 8 +- examples/spot/margin/margin_account.py | 8 +- examples/spot/margin/margin_all_assets.py | 8 +- examples/spot/margin/margin_all_orders.py | 8 +- examples/spot/margin/margin_all_pairs.py | 8 +- examples/spot/margin/margin_asset.py | 8 +- examples/spot/margin/margin_borrow.py | 8 +- examples/spot/margin/margin_dust_log.py | 8 +- examples/spot/margin/margin_fee.py | 8 +- .../margin/margin_force_liquidation_record.py | 8 +- .../spot/margin/margin_interest_history.py | 8 +- .../margin/margin_interest_rate_history.py | 8 +- examples/spot/margin/margin_load_record.py | 8 +- examples/spot/margin/margin_max_borrowable.py | 8 +- .../spot/margin/margin_max_transferable.py | 8 +- examples/spot/margin/margin_my_trades.py | 8 +- examples/spot/margin/margin_open_orders.py | 8 +- .../margin/margin_open_orders_cancellation.py | 8 +- examples/spot/margin/margin_order.py | 8 +- examples/spot/margin/margin_order_usage.py | 8 +- examples/spot/margin/margin_pair.py | 8 +- examples/spot/margin/margin_pair_index.py | 8 +- examples/spot/margin/margin_repay.py | 8 +- examples/spot/margin/margin_repay_record.py | 8 +- examples/spot/margin/margin_transfer.py | 8 +- .../spot/margin/margin_transfer_history.py | 8 +- examples/spot/margin/new_margin_oco_order.py | 8 +- examples/spot/margin/new_margin_order.py | 8 +- .../spot/margin/summary_of_margin_account.py | 27 ++ examples/spot/margin/toggle_bnbBurn.py | 8 +- .../spot/mining/mining_account_earning.py | 8 +- examples/spot/mining/mining_account_list.py | 8 +- examples/spot/mining/mining_algo_list.py | 8 +- examples/spot/mining/mining_bonus_list.py | 8 +- examples/spot/mining/mining_coin_list.py | 6 +- examples/spot/mining/mining_earnings_list.py | 8 +- .../mining_hashrate_resale_cancellation.py | 8 +- .../mining/mining_hashrate_resale_details.py | 8 +- .../mining/mining_hashrate_resale_list.py | 8 +- .../mining/mining_hashrate_resale_request.py | 8 +- .../spot/mining/mining_statistics_list.py | 8 +- examples/spot/mining/mining_worker.py | 8 +- examples/spot/mining/mining_worker_list.py | 8 +- examples/spot/nft/nft_asset.py | 8 +- examples/spot/nft/nft_deposit_history.py | 8 +- examples/spot/nft/nft_transaction_history.py | 8 +- examples/spot/nft/nft_withdraw_history.py | 8 +- examples/spot/pay/pay_history.py | 8 +- .../portfolio_margin_account.py | 8 +- ...portfolio_margin_bankruptcy_loan_amount.py | 8 +- .../portfolio_margin_bankruptcy_loan_repay.py | 8 +- .../portfolio_margin_collateral_rate.py | 6 +- examples/spot/rebate/rebate_spot_history.py | 8 +- examples/spot/savings/savings_account.py | 8 +- .../spot/savings/savings_change_position.py | 8 +- .../savings_flexible_product_position.py | 8 +- .../spot/savings/savings_flexible_products.py | 8 +- .../spot/savings/savings_flexible_redeem.py | 8 +- .../savings_flexible_user_left_quota.py | 8 +- .../savings_flexible_user_redemption_quota.py | 8 +- .../spot/savings/savings_interest_history.py | 8 +- examples/spot/savings/savings_project_list.py | 8 +- .../spot/savings/savings_project_position.py | 8 +- .../savings_purchase_flexible_product.py | 8 +- .../spot/savings/savings_purchase_project.py | 8 +- .../spot/savings/savings_purchase_record.py | 8 +- .../spot/savings/savings_redemption_record.py | 8 +- examples/spot/staking/staking_history.py | 8 +- examples/spot/staking/staking_product_list.py | 8 +- .../spot/staking/staking_product_position.py | 8 +- .../spot/staking/staking_product_quota.py | 8 +- .../spot/staking/staking_purchase_product.py | 8 +- .../spot/staking/staking_redeem_product.py | 8 +- .../spot/staking/staking_set_auto_staking.py | 8 +- .../close_isolated_margin_listen_key.py | 6 +- .../new_isolated_margin_listen_key.py | 6 +- .../renew_isolated_margin_listen_key.py | 6 +- .../stream/margin/close_margin_listen_key.py | 6 +- .../stream/margin/new_margin_listen_key.py | 6 +- .../stream/margin/renew_margin_listen_key.py | 6 +- examples/spot/stream/spot/close_listen_key.py | 6 +- examples/spot/stream/spot/new_listen_key.py | 6 +- examples/spot/stream/spot/renew_listen_key.py | 6 +- .../sub_account/managed_sub_account_assets.py | 8 +- .../managed_sub_account_deposit.py | 8 +- .../managed_sub_account_get_snapshot.py | 8 +- .../managed_sub_account_withdraw.py | 8 +- .../sub_account/sub_account_api_add_ip.py | 8 +- .../sub_account/sub_account_api_delete_ip.py | 8 +- .../sub_account_api_get_ip_restriction.py | 8 +- .../sub_account_api_toggle_ip_restriction.py | 8 +- .../spot/sub_account/sub_account_assets.py | 8 +- .../spot/sub_account/sub_account_create.py | 8 +- .../sub_account_deposit_address.py | 8 +- .../sub_account_deposit_history.py | 8 +- .../sub_account/sub_account_enable_futures.py | 8 +- .../sub_account_enable_leverage_token.py | 8 +- .../sub_account/sub_account_enable_margin.py | 8 +- .../sub_account_futures_account.py | 8 +- .../sub_account_futures_account_summary.py | 8 +- .../sub_account_futures_asset_transfer.py | 8 +- ..._account_futures_asset_transfer_history.py | 8 +- .../sub_account_futures_position_risk.py | 8 +- .../sub_account_futures_transfer.py | 8 +- examples/spot/sub_account/sub_account_list.py | 8 +- .../sub_account/sub_account_margin_account.py | 8 +- .../sub_account_margin_account_summary.py | 8 +- .../sub_account_margin_transfer.py | 8 +- .../sub_account/sub_account_spot_summary.py | 8 +- .../sub_account_spot_transfer_history.py | 8 +- .../spot/sub_account/sub_account_status.py | 8 +- ...ub_account_transfer_sub_account_history.py | 8 +- .../sub_account_transfer_to_master.py | 8 +- .../sub_account_transfer_to_sub.py | 8 +- .../sub_account_universal_transfer.py | 8 +- .../sub_account_universal_transfer_history.py | 8 +- examples/spot/trade/cancel_and_replace.py | 8 +- examples/spot/trade/cancel_oco_order.py | 8 +- examples/spot/trade/cancel_open_orders.py | 8 +- examples/spot/trade/cancel_order.py | 8 +- examples/spot/trade/get_account.py | 10 +- examples/spot/trade/get_my_trades.py | 8 +- examples/spot/trade/get_oco_open_orders.py | 8 +- examples/spot/trade/get_oco_order.py | 8 +- examples/spot/trade/get_oco_orders.py | 8 +- examples/spot/trade/get_open_orders.py | 8 +- examples/spot/trade/get_order.py | 8 +- examples/spot/trade/get_order_rate_limit.py | 8 +- examples/spot/trade/get_orders.py | 8 +- examples/spot/trade/new_oco_order.py | 8 +- examples/spot/trade/new_order.py | 8 +- examples/spot/trade/new_order_testing.py | 8 +- examples/spot/wallet/account_snapshot.py | 8 +- examples/spot/wallet/account_status.py | 8 +- examples/spot/wallet/api_key_permissions.py | 8 +- examples/spot/wallet/api_trading_status.py | 8 +- examples/spot/wallet/asset_detail.py | 8 +- examples/spot/wallet/asset_dividend_record.py | 8 +- .../spot/wallet/bnb_convertible_assets.py | 8 +- examples/spot/wallet/coin_info.py | 8 +- examples/spot/wallet/deposit_address.py | 8 +- examples/spot/wallet/deposit_history.py | 8 +- examples/spot/wallet/disable_fast_withdraw.py | 8 +- examples/spot/wallet/dust_log.py | 8 +- examples/spot/wallet/enable_fast_withdraw.py | 8 +- examples/spot/wallet/funding_wallet.py | 8 +- examples/spot/wallet/trade_fee.py | 8 +- examples/spot/wallet/transfer_dust.py | 8 +- examples/spot/wallet/user_asset.py | 8 +- .../spot/wallet/user_universal_transfer.py | 8 +- .../wallet/user_universal_transfer_history.py | 8 +- examples/spot/wallet/withdraw.py | 8 +- examples/spot/wallet/withdraw_history.py | 8 +- examples/websocket/spot/agg_trade.py | 4 +- examples/websocket/spot/diff_book_depth.py | 10 + examples/websocket/spot/partial_book_depth.py | 2 +- .../websocket/spot/rolling_window_ticker.py | 7 + examples/websocket/spot/symbol_book_ticker.py | 2 +- examples/websocket/spot/symbol_kline.py | 4 +- examples/websocket/spot/symbol_mini_ticker.py | 2 +- examples/websocket/spot/test.py | 2 +- examples/websocket/spot/trade.py | 2 +- examples/websocket/spot/user_data.py | 5 +- requirements/requirements-dev.txt | 3 +- .../margin/test_summary_of_margin_account.py | 28 ++ 237 files changed, 1431 insertions(+), 776 deletions(-) create mode 100644 examples/config.ini create mode 100644 examples/spot/margin/summary_of_margin_account.py create mode 100644 tests/spot/margin/test_summary_of_margin_account.py diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index c8df44ff..1a1c2570 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -5,10 +5,10 @@ name: Python package on: push: - branches: + branches: - master pull_request: - branches: + branches: - master - rc-** @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"] + python-version: ["3.7", "3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e4044eb..bc90eaee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,32 @@ # Changelog -## 2.0.0rc3 - TBD +## 2.0.0rc3 - 2022-12-16 -### Fixed -- Main thread not exiting due to reactor stop hang +### Removed +- Python 3.6 Support Removed +- Futures Loan Endpoints: + - `POST /sapi/v1/futures/loan/borrow` - spot.futures_loan_borrow + - `POST /sapi/v1/futures/loan/repay` - spot.futures_loan_repay + - `GET /sapi/v2/futures/loan/configs` - spot.futures_loan_configs + - `GET /sapi/v2/futures/loan/calcAdjustLevel` - spot.futures_loan_calc_adjust_level + - `GET /sapi/v2/futures/loan/calcMaxAdjustAmount` - spot.futures_loan_calc_max_adjust_amount + - `POST /sapi/v2/futures/loan/adjustCollateral` - spot.futures_loan_adjust_collateral + - `GET /sapi/v1/futures/loan/collateralRepayLimit` - spot.futures_loan_collateral_repay_limit + - `GET /sapi/v1/futures/loan/collateralRepay` - spot.futures_loan_collateral_repay_quote + - `POST /sapi/v1/futures/loan/collateralRepay` - spot.futures_loan_repay + - `GET /sapi/v1/futures/loan/collateralRepayResult` - spot.futures_loan_collateral_repay_result +### Added +- New Margin Endpoint: + - `GET /sapi/v1/margin/tradeCoeff` - Get Summary of Margin Account +- Re: https://github.com/binance/binance-connector-python/issues/184 - Exception handling now returns Raw Data instead of just Error Codes and Error Messages. +- Websocket Enhancements + - Added support for passing list of symbols on all relevant Websocket endpoints to support subscription to multiple streams. + - Stream Identification for when multiple streams are subscribed to at once. Allows users to easily identify which data belongs to which stream. +- `examples/config.ini` to globally set API and Secret Keys to apply in all example files + +### Fixed +- Twisted reactor hanging in some situations due to the main thread not exiting cleanly ## 2.0.0rc2 - 2022-11-29 ### Changed diff --git a/README.md b/README.md index 67ae9b97..ef9d7bf1 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,14 @@ response = client.new_order(**params) print(response) ``` Please find `examples` folder to check for more endpoints. +- In order to set your API and Secret Key for use of the examples, edit the `examples/config.ini` file with your keys. +- Eg: + ```ini + # examples/config.ini + [keys] + api_key=abc123456 + api_secret=cba654321 + ``` ### Authentication @@ -199,11 +207,13 @@ Setting the log level to `DEBUG` will log the request URL, payload and response There are 2 types of error returned from the library: - `binance.error.ClientError` - This is thrown when server returns `4XX`, it's an issue from client side. - - It has 4 properties: + - It has 5 properties: - `status_code` - HTTP status code - `error_code` - Server's error code, e.g. `-1102` - `error_message` - Server's error message, e.g. `Unknown order sent.` - `header` - Full response header. + - `error_data`* - Additional detailed data which supplements the `error_message`. + - **Only applicable on select endpoints, eg. `cancelReplace`* - `binance.error.ServerError` - This is thrown when server returns `5XX`, it's an issue from server side. diff --git a/binance/__version__.py b/binance/__version__.py index 0ddcee84..e01623e2 100644 --- a/binance/__version__.py +++ b/binance/__version__.py @@ -1 +1 @@ -__version__ = "2.0.0rc2" +__version__ = "2.0.0rc3" diff --git a/binance/api.py b/binance/api.py index 0db49a77..34bdf283 100644 --- a/binance/api.py +++ b/binance/api.py @@ -169,6 +169,13 @@ def _handle_exception(self, response): try: err = json.loads(response.text) except JSONDecodeError: - raise ClientError(status_code, None, response.text, response.headers) - raise ClientError(status_code, err["code"], err["msg"], response.headers) + raise ClientError( + status_code, None, response.text, None, response.headers + ) + error_data = None + if "data" in err: + error_data = err["data"] + raise ClientError( + status_code, err["code"], err["msg"], response.headers, error_data + ) raise ServerError(status_code, response.text) diff --git a/binance/error.py b/binance/error.py index 6f66b8e3..4d83edca 100644 --- a/binance/error.py +++ b/binance/error.py @@ -3,7 +3,7 @@ class Error(Exception): class ClientError(Error): - def __init__(self, status_code, error_code, error_message, header): + def __init__(self, status_code, error_code, error_message, header, error_data=None): # https status code self.status_code = status_code # error code returned from server @@ -12,6 +12,8 @@ def __init__(self, status_code, error_code, error_message, header): self.error_message = error_message # the whole response header returned from server self.header = header + # return data if it's returned from server + self.error_data = error_data class ServerError(Error): diff --git a/binance/spot/__init__.py b/binance/spot/__init__.py index 66f4e170..323d45b9 100644 --- a/binance/spot/__init__.py +++ b/binance/spot/__init__.py @@ -97,6 +97,7 @@ def __init__(self, api_key=None, api_secret=None, **kwargs): from binance.spot.margin import isolated_margin_tier from binance.spot.margin import margin_order_usage from binance.spot.margin import margin_dust_log + from binance.spot.margin import summary_of_margin_account # SAVINGS from binance.spot.savings import savings_flexible_products @@ -200,21 +201,11 @@ def __init__(self, api_key=None, api_secret=None, **kwargs): # FUTURES from binance.spot.futures import futures_transfer from binance.spot.futures import futures_transfer_history - from binance.spot.futures import futures_loan_borrow from binance.spot.futures import futures_loan_borrow_history - from binance.spot.futures import futures_loan_repay from binance.spot.futures import futures_loan_repay_history from binance.spot.futures import futures_loan_wallet - from binance.spot.futures import futures_loan_configs - from binance.spot.futures import futures_loan_calc_adjust_level - from binance.spot.futures import futures_loan_calc_max_adjust_amount - from binance.spot.futures import futures_loan_adjust_collateral from binance.spot.futures import futures_loan_adjust_collateral_history from binance.spot.futures import futures_loan_liquidation_history - from binance.spot.futures import futures_loan_collateral_repay_limit - from binance.spot.futures import futures_loan_collateral_repay_quote - from binance.spot.futures import futures_loan_collateral_repay - from binance.spot.futures import futures_loan_collateral_repay_result from binance.spot.futures import futures_loan_interest_history # BLVTs diff --git a/binance/spot/futures.py b/binance/spot/futures.py index ae5502ed..bdb2e905 100644 --- a/binance/spot/futures.py +++ b/binance/spot/futures.py @@ -55,28 +55,6 @@ def futures_transfer_history(self, asset: str, startTime, **kwargs): return self.sign_request("GET", "/sapi/v1/futures/transfer", payload) -def futures_loan_borrow(self, coin: str, collateralCoin: str, **kwargs): - """Borrow For Cross-Collateral (TRADE) - - POST /sapi/v1/futures/loan/borrow - - https://binance-docs.github.io/apidocs/spot/en/#borrow-for-cross-collateral-trade - - Args: - coin (str) - collateralCoin (str) - Keyword Args: - amount (float, optional): mandatory when collateralAmount is empty - collateralAmount (float, optional): mandatory when amount is empty - recvWindow (int, optional): The value cannot be greater than 60000 - """ - - check_required_parameters([[coin, "coin"], [collateralCoin, "collateralCoin"]]) - - payload = {"coin": coin, "collateralCoin": collateralCoin, **kwargs} - return self.sign_request("POST", "/sapi/v1/futures/loan/borrow", payload) - - def futures_loan_borrow_history(self, **kwargs): """Cross-Collateral Borrow History (USER_DATA) @@ -95,34 +73,6 @@ def futures_loan_borrow_history(self, **kwargs): return self.sign_request("GET", "/sapi/v1/futures/loan/borrow/history", kwargs) -def futures_loan_repay(self, coin: str, collateralCoin: str, amount: float, **kwargs): - """Repay For Cross-Collateral (TRADE) - - POST /sapi/v1/futures/loan/repay - - https://binance-docs.github.io/apidocs/spot/en/#repay-for-cross-collateral-trade - - Args: - coin (str) - collateralCoin (str) - amount (float) - Keyword Args: - recvWindow (int, optional): The value cannot be greater than 60000 - """ - - check_required_parameters( - [[coin, "coin"], [collateralCoin, "collateralCoin"], [amount, "amount"]] - ) - - payload = { - "coin": coin, - "collateralCoin": collateralCoin, - "amount": amount, - **kwargs, - } - return self.sign_request("POST", "/sapi/v1/futures/loan/repay", payload) - - def futures_loan_repay_history(self, **kwargs): """Cross-Collateral Repayment History (USER_DATA) @@ -155,125 +105,6 @@ def futures_loan_wallet(self, **kwargs): return self.sign_request("GET", "/sapi/v2/futures/loan/wallet", kwargs) -def futures_loan_configs(self, **kwargs): - """Cross-Collateral Information (USER_DATA) - - GET /sapi/v2/futures/loan/configs - - https://binance-docs.github.io/apidocs/spot/en/#cross-collateral-information-v2-user_data - - Keyword Args: - loanCoin (str, optional) - collateralCoin (str, optional) - recvWindow (int, optional): The value cannot be greater than 60000 - """ - - return self.sign_request("GET", "/sapi/v2/futures/loan/configs", kwargs) - - -def futures_loan_calc_adjust_level( - self, loanCoin: str, collateralCoin: str, amount: float, direction: str, **kwargs -): - """Calculate Rate After Adjust Cross-Collateral LTV (USER_DATA) - - GET /sapi/v2/futures/loan/calcAdjustLevel - - https://binance-docs.github.io/apidocs/spot/en/#calculate-rate-after-adjust-cross-collateral-ltv-user_data - - Args: - loanCoin (str) - collateralCoin (str) - amount (float) - direction (str): "ADDITIONAL", "REDUCED" - Keyword Args: - recvWindow (int, optional): The value cannot be greater than 60000 - """ - - check_required_parameters( - [ - [loanCoin, "loanCoin"], - [collateralCoin, "collateralCoin"], - [amount, "amount"], - [direction, "direction"], - ] - ) - - payload = { - "loanCoin": loanCoin, - "collateralCoin": collateralCoin, - "amount": amount, - "direction": direction, - **kwargs, - } - - return self.sign_request("GET", "/sapi/v2/futures/loan/calcAdjustLevel", payload) - - -def futures_loan_calc_max_adjust_amount( - self, loanCoin: str, collateralCoin: str, **kwargs -): - """Get Max Amount for Adjust Cross-Collateral LTV (USER_DATA) - - GET /sapi/v2/futures/loan/calcMaxAdjustAmount - - https://binance-docs.github.io/apidocs/spot/en/#get-max-amount-for-adjust-cross-collateral-ltv-v2-user_data - - Args: - loanCoin (str) - collateralCoin (str) - Keyword Args: - recvWindow (int, optional): The value cannot be greater than 60000 - """ - - check_required_parameters( - [[loanCoin, "loanCoin"], [collateralCoin, "collateralCoin"]] - ) - - payload = {"loanCoin": loanCoin, "collateralCoin": collateralCoin, **kwargs} - - return self.sign_request( - "GET", "/sapi/v2/futures/loan/calcMaxAdjustAmount", payload - ) - - -def futures_loan_adjust_collateral( - self, loanCoin: str, collateralCoin: str, amount: float, direction: str, **kwargs -): - """Adjust Cross-Collateral LTV (TRADE) - - POST /sapi/v2/futures/loan/adjustCollateral - - https://binance-docs.github.io/apidocs/spot/en/#adjust-cross-collateral-ltv-v2-trade - - Args: - loanCoin (str) - collateralCoin (str) - amount (float) - direction (str): "ADDITIONAL", "REDUCED" - Keyword Args: - recvWindow (int, optional): The value cannot be greater than 60000 - """ - - check_required_parameters( - [ - [loanCoin, "loanCoin"], - [collateralCoin, "collateralCoin"], - [amount, "amount"], - [direction, "direction"], - ] - ) - - payload = { - "loanCoin": loanCoin, - "collateralCoin": collateralCoin, - "amount": amount, - "direction": direction, - **kwargs, - } - - return self.sign_request("POST", "/sapi/v2/futures/loan/adjustCollateral", payload) - - def futures_loan_adjust_collateral_history(self, **kwargs): """Adjust Cross-Collateral LTV History (USER_DATA) @@ -314,102 +145,6 @@ def futures_loan_liquidation_history(self, **kwargs): return self.sign_request("GET", "/sapi/v1/futures/loan/liquidationHistory", kwargs) -def futures_loan_collateral_repay_limit(self, coin: str, collateralCoin: str, **kwargs): - """Check Collateral Repay Limit (USER_DATA) - - GET /sapi/v1/futures/loan/collateralRepayLimit - - https://binance-docs.github.io/apidocs/spot/en/#check-collateral-repay-limit-user_data - - Args: - coin (str) - collateralCoin (str) - Keyword Args: - recvWindow (int, optional): The value cannot be greater than 60000 - """ - - check_required_parameters([[coin, "coin"], [collateralCoin, "collateralCoin"]]) - - payload = {"coin": coin, "collateralCoin": collateralCoin, **kwargs} - - return self.sign_request( - "GET", "/sapi/v1/futures/loan/collateralRepayLimit", payload - ) - - -def futures_loan_collateral_repay_quote( - self, coin: str, collateralCoin: str, amount, **kwargs -): - """Get Collateral Repay Quote (USER_DATA) - - GET /sapi/v1/futures/loan/collateralRepay - - https://binance-docs.github.io/apidocs/spot/en/#get-collateral-repay-quote-user_data - - Args: - coin (str) - collateralCoin (str) - amount (float): repay amount - Keyword Args: - recvWindow (int, optional): The value cannot be greater than 60000 - """ - - check_required_parameters( - [[coin, "coin"], [collateralCoin, "collateralCoin"], [amount, "amount"]] - ) - - payload = { - "coin": coin, - "collateralCoin": collateralCoin, - "amount": amount, - **kwargs, - } - - return self.sign_request("GET", "/sapi/v1/futures/loan/collateralRepay", payload) - - -def futures_loan_collateral_repay(self, quoteId: str, **kwargs): - """Repay with Collateral (USER_DATA) - - POST /sapi/v1/futures/loan/collateralRepay - - https://binance-docs.github.io/apidocs/spot/en/#repay-with-collateral-user_data - - Args: - quoteId (str) - Keyword Args: - recvWindow (int, optional): The value cannot be greater than 60000 - """ - - check_required_parameters([[quoteId, "quoteId"]]) - - payload = {"quoteId": quoteId, **kwargs} - - return self.sign_request("POST", "/sapi/v1/futures/loan/collateralRepay", payload) - - -def futures_loan_collateral_repay_result(self, quoteId: str, **kwargs): - """Collateral Repayment Result (USER_DATA) - - GET /sapi/v1/futures/loan/collateralRepayResult - - https://binance-docs.github.io/apidocs/spot/en/#collateral-repayment-result-user_data - - Args: - quoteId (str) - Keyword Args: - recvWindow (int, optional): The value cannot be greater than 60000 - """ - - check_required_parameters([[quoteId, "quoteId"]]) - - payload = {"quoteId": quoteId, **kwargs} - - return self.sign_request( - "GET", "/sapi/v1/futures/loan/collateralRepayResult", payload - ) - - def futures_loan_interest_history(self, **kwargs): """Cross-Collateral Interest History (USER_DATA) diff --git a/binance/spot/margin.py b/binance/spot/margin.py index f678e7d2..52748753 100644 --- a/binance/spot/margin.py +++ b/binance/spot/margin.py @@ -943,3 +943,17 @@ def margin_dust_log(self, **kwargs): url_path = "/sapi/v1/margin/dribblet" return self.sign_request("GET", url_path, {**kwargs}) + + +def summary_of_margin_account(self, **kwargs): + """Get Summary of Margin account (USER_DATA) + Get personal margin level information + + GET /sapi/v1/margin/tradeCoeff + + https://binance-docs.github.io/apidocs/spot/en/#get-summary-of-margin-account-user_data + + Keyword Args: + recvWindow (int, optional): The value cannot be greater than 60000 + """ + return self.sign_request("GET", "/sapi/v1/margin/tradeCoeff", kwargs) diff --git a/binance/websocket/spot/websocket_client.py b/binance/websocket/spot/websocket_client.py index b40ce2b5..154c2366 100644 --- a/binance/websocket/spot/websocket_client.py +++ b/binance/websocket/spot/websocket_client.py @@ -19,9 +19,7 @@ def agg_trade(self, symbol: str, id: int, callback, **kwargs): else: symbol = "{}@aggTrade".format(symbol.lower()) - self.live_subscribe( - symbol, id, callback, **kwargs - ) + self.live_subscribe(symbol, id, callback, **kwargs) def trade(self, symbol: str, id: int, callback, **kwargs): """Trade Streams @@ -72,9 +70,7 @@ def kline(self, symbol: str, id: int, interval: str, callback, **kwargs): else: symbol = "{}@kline_{}".format(symbol.lower(), interval) - self.live_subscribe( - symbol, id, callback, **kwargs - ) + self.live_subscribe(symbol, id, callback, **kwargs) def mini_ticker(self, id: int, callback, symbol=None, **kwargs): """Individual symbol or all symbols mini ticker @@ -96,10 +92,7 @@ def mini_ticker(self, id: int, callback, symbol=None, **kwargs): else: symbol = "{}@miniTicker".format(symbol.lower()) - - self.live_subscribe( - symbol, id, callback, **kwargs - ) + self.live_subscribe(symbol, id, callback, **kwargs) def ticker(self, id: int, callback, symbol=None, **kwargs): """Individual symbol or all symbols ticker @@ -121,9 +114,7 @@ def ticker(self, id: int, callback, symbol=None, **kwargs): else: symbol = "{}@ticker".format(symbol.lower()) - self.live_subscribe( - symbol, id, callback, **kwargs - ) + self.live_subscribe(symbol, id, callback, **kwargs) def book_ticker(self, id: int, callback, symbol=None, **kwargs): """Individual symbol or all book ticker @@ -144,9 +135,7 @@ def book_ticker(self, id: int, callback, symbol=None, **kwargs): else: symbol = "{}@bookTicker".format(symbol.lower()) - self.live_subscribe( - symbol, id, callback, **kwargs - ) + self.live_subscribe(symbol, id, callback, **kwargs) def partial_book_depth( self, symbol: str, id: int, level, speed, callback, **kwargs @@ -165,12 +154,7 @@ def partial_book_depth( else: symbol = "{}@depth{}@{}ms".format(symbol.lower(), level, speed) - self.live_subscribe( - symbol, - id, - callback, - **kwargs - ) + self.live_subscribe(symbol, id, callback, **kwargs) def rolling_window_ticker( self, symbol: str, windowSize: str, id: int, callback, **kwargs @@ -191,9 +175,7 @@ def rolling_window_ticker( else: symbol = "{}@ticker_{}".format(symbol.lower(), windowSize) - self.live_subscribe( - symbol, id, callback, **kwargs - ) + self.live_subscribe(symbol, id, callback, **kwargs) def rolling_window_ticker_all_symbols( self, windowSize: str, id: int, callback, **kwargs @@ -224,9 +206,7 @@ def diff_book_depth(self, symbol: str, id: int, speed, callback, **kwargs): else: symbol = "{}@depth@{}ms".format(symbol.lower(), speed) - self.live_subscribe( - symbol, id, callback, **kwargs - ) + self.live_subscribe(symbol, id, callback, **kwargs) def user_data(self, listen_key: str, id: int, callback, **kwargs): """Listen to user data by using the provided listen_key""" diff --git a/docs/source/binance.spot.futures.rst b/docs/source/binance.spot.futures.rst index 80feb6aa..bd9ebbaa 100644 --- a/docs/source/binance.spot.futures.rst +++ b/docs/source/binance.spot.futures.rst @@ -9,18 +9,10 @@ Get Future Account Transaction History List (USER_DATA) ------------------------------------------------------- .. autofunction:: binance.spot.futures.futures_transfer_history -Borrow For Cross-Collateral (TRADE) ------------------------------------ -.. autofunction:: binance.spot.futures.futures_loan_borrow - Cross-Collateral Borrow History (USER_DATA) ------------------------------------------- .. autofunction:: binance.spot.futures.futures_loan_borrow_history -Repay For Cross-Collateral (TRADE) ----------------------------------- -.. autofunction:: binance.spot.futures.futures_loan_repay - Cross-Collateral Repayment History (USER_DATA) ---------------------------------------------- .. autofunction:: binance.spot.futures.futures_loan_repay_history @@ -29,22 +21,6 @@ Cross-Collateral Wallet (USER_DATA) ----------------------------------- .. autofunction:: binance.spot.futures.futures_loan_wallet -Cross-Collateral Information (USER_DATA) ----------------------------------------- -.. autofunction:: binance.spot.futures.futures_loan_configs - -Calculate Rate After Adjust Cross-Collateral LTV (USER_DATA) ------------------------------------------------------------- -.. autofunction:: binance.spot.futures.futures_loan_calc_adjust_level - -Get Max Amount for Adjust Cross-Collateral LTV (USER_DATA) ----------------------------------------------------------- -.. autofunction:: binance.spot.futures.futures_loan_calc_max_adjust_amount - -Adjust Cross-Collateral LTV (TRADE) ------------------------------------ -.. autofunction:: binance.spot.futures.futures_loan_adjust_collateral - Adjust Cross-Collateral LTV History (USER_DATA) ----------------------------------------------- .. autofunction:: binance.spot.futures.futures_loan_adjust_collateral_history @@ -53,22 +29,6 @@ Cross-Collateral Liquidation History (USER_DATA) ------------------------------------------------ .. autofunction:: binance.spot.futures.futures_loan_liquidation_history -Check Collateral Repay Limit (USER_DATA) ----------------------------------------- -.. autofunction:: binance.spot.futures.futures_loan_collateral_repay_limit - -Get Collateral Repay Quote (USER_DATA) --------------------------------------- -.. autofunction:: binance.spot.futures.futures_loan_collateral_repay_quote - -Repay with Collateral (USER_DATA) ---------------------------------- -.. autofunction:: binance.spot.futures.futures_loan_collateral_repay - -Collateral Repayment Result (USER_DATA) ---------------------------------------- -.. autofunction:: binance.spot.futures.futures_loan_collateral_repay_result - Cross-Collateral Interest History (USER_DATA) --------------------------------------------- .. autofunction:: binance.spot.futures.futures_loan_interest_history diff --git a/docs/source/binance.spot.margin.rst b/docs/source/binance.spot.margin.rst index 758ce650..0b9eaae4 100644 --- a/docs/source/binance.spot.margin.rst +++ b/docs/source/binance.spot.margin.rst @@ -175,4 +175,8 @@ Query Current Margin Order Count Usage (TRADE) Margin Dust Log (USER_DATA) --------------------------- -.. autofunction:: binance.spot.margin.margin_dust_log \ No newline at end of file +.. autofunction:: binance.spot.margin.margin_dust_log + +Get Summary of Margin account (USER_DATA) +----------------------------------------- +.. autofunction:: binance.spot.margin.summary_of_margin_account \ No newline at end of file diff --git a/examples/config.ini b/examples/config.ini new file mode 100644 index 00000000..9dc8bf01 --- /dev/null +++ b/examples/config.ini @@ -0,0 +1,5 @@ + +# Enter your API and Secret Key for use in the example files +[keys] +api_key= +api_secret= \ No newline at end of file diff --git a/examples/spot/blvt/blvt_info.py b/examples/spot/blvt/blvt_info.py index 8a69ab76..6a4a7f27 100644 --- a/examples/spot/blvt/blvt_info.py +++ b/examples/spot/blvt/blvt_info.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/blvt/redeem_blvt.py b/examples/spot/blvt/redeem_blvt.py index 5f7b6bb1..a86b8823 100644 --- a/examples/spot/blvt/redeem_blvt.py +++ b/examples/spot/blvt/redeem_blvt.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.redeem_blvt(tokenName="LINKUP", amount="10.05022099")) diff --git a/examples/spot/blvt/redemption_record.py b/examples/spot/blvt/redemption_record.py index ecabb6fb..f740bd51 100644 --- a/examples/spot/blvt/redemption_record.py +++ b/examples/spot/blvt/redemption_record.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.redemption_record(tokenName="LINKUP")) diff --git a/examples/spot/blvt/subscribe_blvt.py b/examples/spot/blvt/subscribe_blvt.py index 10e8636c..b85c8243 100644 --- a/examples/spot/blvt/subscribe_blvt.py +++ b/examples/spot/blvt/subscribe_blvt.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.subscribe_blvt(tokenName="LINKUP", cost="9.99999995")) diff --git a/examples/spot/blvt/subscription_record.py b/examples/spot/blvt/subscription_record.py index 24504c23..65f25c8c 100644 --- a/examples/spot/blvt/subscription_record.py +++ b/examples/spot/blvt/subscription_record.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.subscription_record(tokenName="LINKUP")) diff --git a/examples/spot/blvt/user_limit_info.py b/examples/spot/blvt/user_limit_info.py index e89ef80f..d92e2fe5 100644 --- a/examples/spot/blvt/user_limit_info.py +++ b/examples/spot/blvt/user_limit_info.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.user_limit_info(tokenName="BTCDOWN")) diff --git a/examples/spot/bswap/bswap_add_liquidity_preview.py b/examples/spot/bswap/bswap_add_liquidity_preview.py index fcfd8f76..28ba9d84 100644 --- a/examples/spot/bswap/bswap_add_liquidity_preview.py +++ b/examples/spot/bswap/bswap_add_liquidity_preview.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/bswap/bswap_claim_rewards.py b/examples/spot/bswap/bswap_claim_rewards.py index 2a6f9771..2655ff20 100644 --- a/examples/spot/bswap/bswap_claim_rewards.py +++ b/examples/spot/bswap/bswap_claim_rewards.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/bswap/bswap_claimed_rewards.py b/examples/spot/bswap/bswap_claimed_rewards.py index 95da0784..e0f7d14b 100644 --- a/examples/spot/bswap/bswap_claimed_rewards.py +++ b/examples/spot/bswap/bswap_claimed_rewards.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/bswap/bswap_liquidity.py b/examples/spot/bswap/bswap_liquidity.py index 83cf4f2a..4156d505 100644 --- a/examples/spot/bswap/bswap_liquidity.py +++ b/examples/spot/bswap/bswap_liquidity.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.bswap_liquidity()) diff --git a/examples/spot/bswap/bswap_liquidity_add.py b/examples/spot/bswap/bswap_liquidity_add.py index 5b163aa2..c1bd5ec6 100644 --- a/examples/spot/bswap/bswap_liquidity_add.py +++ b/examples/spot/bswap/bswap_liquidity_add.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.bswap_liquidity_add("2", "BUSD", "1")) diff --git a/examples/spot/bswap/bswap_liquidity_operation_record.py b/examples/spot/bswap/bswap_liquidity_operation_record.py index 9ee2f957..a4d879af 100644 --- a/examples/spot/bswap/bswap_liquidity_operation_record.py +++ b/examples/spot/bswap/bswap_liquidity_operation_record.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.bswap_liquidity_operation_record()) diff --git a/examples/spot/bswap/bswap_pool_configure.py b/examples/spot/bswap/bswap_pool_configure.py index 20aaf36e..afe4db48 100644 --- a/examples/spot/bswap/bswap_pool_configure.py +++ b/examples/spot/bswap/bswap_pool_configure.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.bswap_pool_configure(poolId=2)) diff --git a/examples/spot/bswap/bswap_pools.py b/examples/spot/bswap/bswap_pools.py index 8152c132..8676d3b0 100644 --- a/examples/spot/bswap/bswap_pools.py +++ b/examples/spot/bswap/bswap_pools.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.bswap_pools()) diff --git a/examples/spot/bswap/bswap_remove_liquidity.py b/examples/spot/bswap/bswap_remove_liquidity.py index 00833b2d..dab38242 100644 --- a/examples/spot/bswap/bswap_remove_liquidity.py +++ b/examples/spot/bswap/bswap_remove_liquidity.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/bswap/bswap_remove_liquidity_preview.py b/examples/spot/bswap/bswap_remove_liquidity_preview.py index 3617b16b..a0c677e9 100644 --- a/examples/spot/bswap/bswap_remove_liquidity_preview.py +++ b/examples/spot/bswap/bswap_remove_liquidity_preview.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/bswap/bswap_request_quote.py b/examples/spot/bswap/bswap_request_quote.py index db2633c1..72810f85 100644 --- a/examples/spot/bswap/bswap_request_quote.py +++ b/examples/spot/bswap/bswap_request_quote.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/bswap/bswap_swap.py b/examples/spot/bswap/bswap_swap.py index 599e0222..c65e162d 100644 --- a/examples/spot/bswap/bswap_swap.py +++ b/examples/spot/bswap/bswap_swap.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/bswap/bswap_swap_history.py b/examples/spot/bswap/bswap_swap_history.py index f1f44f4c..d85b99e5 100644 --- a/examples/spot/bswap/bswap_swap_history.py +++ b/examples/spot/bswap/bswap_swap_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.bswap_swap_history()) diff --git a/examples/spot/bswap/bswap_unclaimed_rewards.py b/examples/spot/bswap/bswap_unclaimed_rewards.py index 3fa909f0..0539cb93 100644 --- a/examples/spot/bswap/bswap_unclaimed_rewards.py +++ b/examples/spot/bswap/bswap_unclaimed_rewards.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/c2c/c2c_trade_history.py b/examples/spot/c2c/c2c_trade_history.py index 72706225..1db1afd5 100644 --- a/examples/spot/c2c/c2c_trade_history.py +++ b/examples/spot/c2c/c2c_trade_history.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/convert/convert.py b/examples/spot/convert/convert.py index 6bf58413..3d14f6ea 100644 --- a/examples/spot/convert/convert.py +++ b/examples/spot/convert/convert.py @@ -5,11 +5,15 @@ from binance.spot import Spot from binance.lib.utils import config_logging from datetime import datetime +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Spot(api_key, api_secret) diff --git a/examples/spot/fiat/fiat_order_history.py b/examples/spot/fiat/fiat_order_history.py index 1c7548d6..875ad0e4 100644 --- a/examples/spot/fiat/fiat_order_history.py +++ b/examples/spot/fiat/fiat_order_history.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/fiat/fiat_payment_history.py b/examples/spot/fiat/fiat_payment_history.py index 2a6628df..2800a978 100644 --- a/examples/spot/fiat/fiat_payment_history.py +++ b/examples/spot/fiat/fiat_payment_history.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/futures/futures_loan_adjust_collateral_history.py b/examples/spot/futures/futures_loan_adjust_collateral_history.py index b888c01e..0477d28a 100644 --- a/examples/spot/futures/futures_loan_adjust_collateral_history.py +++ b/examples/spot/futures/futures_loan_adjust_collateral_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.futures_loan_adjust_collateral_history(collateralCoin="BTC")) diff --git a/examples/spot/futures/futures_loan_borrow_history.py b/examples/spot/futures/futures_loan_borrow_history.py index 51d2d5a7..d1a74aa0 100644 --- a/examples/spot/futures/futures_loan_borrow_history.py +++ b/examples/spot/futures/futures_loan_borrow_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.futures_loan_borrow_history(coin="USDT")) diff --git a/examples/spot/futures/futures_loan_interest_history.py b/examples/spot/futures/futures_loan_interest_history.py index 04929ac0..d0a7a74f 100644 --- a/examples/spot/futures/futures_loan_interest_history.py +++ b/examples/spot/futures/futures_loan_interest_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.futures_loan_interest_history()) diff --git a/examples/spot/futures/futures_loan_liquidation_history.py b/examples/spot/futures/futures_loan_liquidation_history.py index 34444f47..62a10da1 100644 --- a/examples/spot/futures/futures_loan_liquidation_history.py +++ b/examples/spot/futures/futures_loan_liquidation_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.futures_loan_liquidation_history(collateralCoin="BTC")) diff --git a/examples/spot/futures/futures_loan_repay_history.py b/examples/spot/futures/futures_loan_repay_history.py index 4c02dd9f..c8e37f45 100644 --- a/examples/spot/futures/futures_loan_repay_history.py +++ b/examples/spot/futures/futures_loan_repay_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.futures_loan_repay_history(coin="USDT")) diff --git a/examples/spot/futures/futures_loan_wallet.py b/examples/spot/futures/futures_loan_wallet.py index 7207319d..42d18c92 100644 --- a/examples/spot/futures/futures_loan_wallet.py +++ b/examples/spot/futures/futures_loan_wallet.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.futures_loan_wallet()) diff --git a/examples/spot/futures/futures_transfer.py b/examples/spot/futures/futures_transfer.py index 8e8b0d9b..bf848c49 100644 --- a/examples/spot/futures/futures_transfer.py +++ b/examples/spot/futures/futures_transfer.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.futures_transfer(asset="USDT", amount="1", type=1)) diff --git a/examples/spot/futures/futures_transfer_history.py b/examples/spot/futures/futures_transfer_history.py index bb9fc087..2869a4f1 100644 --- a/examples/spot/futures/futures_transfer_history.py +++ b/examples/spot/futures/futures_transfer_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.futures_transfer_history(asset="USDT", startTime="1597130241000")) diff --git a/examples/spot/gift_card/gift_card_create_code.py b/examples/spot/gift_card/gift_card_create_code.py index c5753503..df8ec5af 100644 --- a/examples/spot/gift_card/gift_card_create_code.py +++ b/examples/spot/gift_card/gift_card_create_code.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/gift_card/gift_card_redeem_code.py b/examples/spot/gift_card/gift_card_redeem_code.py index 71842e2c..03d00ed6 100644 --- a/examples/spot/gift_card/gift_card_redeem_code.py +++ b/examples/spot/gift_card/gift_card_redeem_code.py @@ -3,11 +3,16 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] + client = Client(api_key, api_secret) logger = logging.getLogger(__name__) diff --git a/examples/spot/gift_card/gift_card_rsa_public_key.py b/examples/spot/gift_card/gift_card_rsa_public_key.py index f3a8debd..f0ab08d7 100644 --- a/examples/spot/gift_card/gift_card_rsa_public_key.py +++ b/examples/spot/gift_card/gift_card_rsa_public_key.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/gift_card/gift_card_verify_code.py b/examples/spot/gift_card/gift_card_verify_code.py index bba11175..04b92711 100644 --- a/examples/spot/gift_card/gift_card_verify_code.py +++ b/examples/spot/gift_card/gift_card_verify_code.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/loan/loan_adjust_ltv.py b/examples/spot/loan/loan_adjust_ltv.py index 900aa7e3..90593696 100644 --- a/examples/spot/loan/loan_adjust_ltv.py +++ b/examples/spot/loan/loan_adjust_ltv.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/loan/loan_adjust_ltv_history.py b/examples/spot/loan/loan_adjust_ltv_history.py index 70cae9ee..ef50859e 100644 --- a/examples/spot/loan/loan_adjust_ltv_history.py +++ b/examples/spot/loan/loan_adjust_ltv_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/loan/loan_borrow.py b/examples/spot/loan/loan_borrow.py index dab80c94..2bf491bc 100644 --- a/examples/spot/loan/loan_borrow.py +++ b/examples/spot/loan/loan_borrow.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/loan/loan_borrow_history.py b/examples/spot/loan/loan_borrow_history.py index f2134809..79f8fd7a 100644 --- a/examples/spot/loan/loan_borrow_history.py +++ b/examples/spot/loan/loan_borrow_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/loan/loan_history.py b/examples/spot/loan/loan_history.py index 2631d24b..5f6c862e 100644 --- a/examples/spot/loan/loan_history.py +++ b/examples/spot/loan/loan_history.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/loan/loan_ongoing_orders.py b/examples/spot/loan/loan_ongoing_orders.py index 56aed7a2..bbe8ac67 100644 --- a/examples/spot/loan/loan_ongoing_orders.py +++ b/examples/spot/loan/loan_ongoing_orders.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/loan/loan_repay.py b/examples/spot/loan/loan_repay.py index c4ca905b..bceb5a81 100644 --- a/examples/spot/loan/loan_repay.py +++ b/examples/spot/loan/loan_repay.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/loan/loan_repay_history.py b/examples/spot/loan/loan_repay_history.py index 74230b61..fdac37ea 100644 --- a/examples/spot/loan/loan_repay_history.py +++ b/examples/spot/loan/loan_repay_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/margin/bnbBurn_status.py b/examples/spot/margin/bnbBurn_status.py index 94de9c9a..ec9147e5 100644 --- a/examples/spot/margin/bnbBurn_status.py +++ b/examples/spot/margin/bnbBurn_status.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.bnbBurn_status()) diff --git a/examples/spot/margin/cancel_isolated_margin_account.py b/examples/spot/margin/cancel_isolated_margin_account.py index 328d4376..6be1bd50 100644 --- a/examples/spot/margin/cancel_isolated_margin_account.py +++ b/examples/spot/margin/cancel_isolated_margin_account.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.cancel_isolated_margin_account(symbol="BNBUSDT")) diff --git a/examples/spot/margin/cancel_margin_oco_order.py b/examples/spot/margin/cancel_margin_oco_order.py index a170a281..4530f082 100644 --- a/examples/spot/margin/cancel_margin_oco_order.py +++ b/examples/spot/margin/cancel_margin_oco_order.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/margin/cancel_margin_order.py b/examples/spot/margin/cancel_margin_order.py index d49c4829..72872f67 100644 --- a/examples/spot/margin/cancel_margin_order.py +++ b/examples/spot/margin/cancel_margin_order.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.cancel_margin_order(symbol="BNBUSDT", orderId="539829370")) diff --git a/examples/spot/margin/enable_isolated_margin_account.py b/examples/spot/margin/enable_isolated_margin_account.py index f02e4ca7..c782802f 100644 --- a/examples/spot/margin/enable_isolated_margin_account.py +++ b/examples/spot/margin/enable_isolated_margin_account.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.enable_isolated_margin_account(symbol="BNBUSDT")) diff --git a/examples/spot/margin/get_margin_oco_order.py b/examples/spot/margin/get_margin_oco_order.py index d90933ee..a9db634b 100644 --- a/examples/spot/margin/get_margin_oco_order.py +++ b/examples/spot/margin/get_margin_oco_order.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/margin/get_margin_oco_orders.py b/examples/spot/margin/get_margin_oco_orders.py index eb82127d..11828878 100644 --- a/examples/spot/margin/get_margin_oco_orders.py +++ b/examples/spot/margin/get_margin_oco_orders.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/margin/get_margin_open_oco_orders.py b/examples/spot/margin/get_margin_open_oco_orders.py index a320dc4a..6b57a52c 100644 --- a/examples/spot/margin/get_margin_open_oco_orders.py +++ b/examples/spot/margin/get_margin_open_oco_orders.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/margin/isolated_margin_account.py b/examples/spot/margin/isolated_margin_account.py index 2748f31d..0d2ef56e 100644 --- a/examples/spot/margin/isolated_margin_account.py +++ b/examples/spot/margin/isolated_margin_account.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.isolated_margin_account(symbols="BTCUSDT,ETHUSDT")) diff --git a/examples/spot/margin/isolated_margin_account_limit.py b/examples/spot/margin/isolated_margin_account_limit.py index 3247f54f..ff8d9f23 100644 --- a/examples/spot/margin/isolated_margin_account_limit.py +++ b/examples/spot/margin/isolated_margin_account_limit.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.isolated_margin_account_limit(recvWindow=6000)) diff --git a/examples/spot/margin/isolated_margin_all_pairs.py b/examples/spot/margin/isolated_margin_all_pairs.py index f2a22699..82ffebf5 100644 --- a/examples/spot/margin/isolated_margin_all_pairs.py +++ b/examples/spot/margin/isolated_margin_all_pairs.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.isolated_margin_all_pairs()) diff --git a/examples/spot/margin/isolated_margin_fee.py b/examples/spot/margin/isolated_margin_fee.py index 2cebdd80..b3cd4739 100644 --- a/examples/spot/margin/isolated_margin_fee.py +++ b/examples/spot/margin/isolated_margin_fee.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) diff --git a/examples/spot/margin/isolated_margin_pair.py b/examples/spot/margin/isolated_margin_pair.py index b8a3f50f..dd220e20 100644 --- a/examples/spot/margin/isolated_margin_pair.py +++ b/examples/spot/margin/isolated_margin_pair.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.isolated_margin_pair(symbol="BTCUSDT")) diff --git a/examples/spot/margin/isolated_margin_tier.py b/examples/spot/margin/isolated_margin_tier.py index 30e81e65..78b802fa 100644 --- a/examples/spot/margin/isolated_margin_tier.py +++ b/examples/spot/margin/isolated_margin_tier.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) diff --git a/examples/spot/margin/isolated_margin_transfer.py b/examples/spot/margin/isolated_margin_transfer.py index 79dfd18c..f02d9c63 100644 --- a/examples/spot/margin/isolated_margin_transfer.py +++ b/examples/spot/margin/isolated_margin_transfer.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/margin/isolated_margin_transfer_history.py b/examples/spot/margin/isolated_margin_transfer_history.py index 34839be5..f57d6d2e 100644 --- a/examples/spot/margin/isolated_margin_transfer_history.py +++ b/examples/spot/margin/isolated_margin_transfer_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/margin/margin_account.py b/examples/spot/margin/margin_account.py index 60fc8daf..37b2092e 100644 --- a/examples/spot/margin/margin_account.py +++ b/examples/spot/margin/margin_account.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_account()) diff --git a/examples/spot/margin/margin_all_assets.py b/examples/spot/margin/margin_all_assets.py index d2cbccdd..4559e79c 100644 --- a/examples/spot/margin/margin_all_assets.py +++ b/examples/spot/margin/margin_all_assets.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_all_assets()) diff --git a/examples/spot/margin/margin_all_orders.py b/examples/spot/margin/margin_all_orders.py index 16e9a337..e71a08d2 100644 --- a/examples/spot/margin/margin_all_orders.py +++ b/examples/spot/margin/margin_all_orders.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_all_orders(symbol="BNBUSDT")) diff --git a/examples/spot/margin/margin_all_pairs.py b/examples/spot/margin/margin_all_pairs.py index 31b2a0ff..55120979 100644 --- a/examples/spot/margin/margin_all_pairs.py +++ b/examples/spot/margin/margin_all_pairs.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_all_pairs()) diff --git a/examples/spot/margin/margin_asset.py b/examples/spot/margin/margin_asset.py index 0ec91578..d4478f21 100644 --- a/examples/spot/margin/margin_asset.py +++ b/examples/spot/margin/margin_asset.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_asset(asset="BNB")) diff --git a/examples/spot/margin/margin_borrow.py b/examples/spot/margin/margin_borrow.py index 9366c0ec..5e4fe06b 100644 --- a/examples/spot/margin/margin_borrow.py +++ b/examples/spot/margin/margin_borrow.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_borrow(asset="BNB", amount="0.001")) diff --git a/examples/spot/margin/margin_dust_log.py b/examples/spot/margin/margin_dust_log.py index abda170b..560da36e 100644 --- a/examples/spot/margin/margin_dust_log.py +++ b/examples/spot/margin/margin_dust_log.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/margin/margin_fee.py b/examples/spot/margin/margin_fee.py index 3bac23b3..226b5a7e 100644 --- a/examples/spot/margin/margin_fee.py +++ b/examples/spot/margin/margin_fee.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) diff --git a/examples/spot/margin/margin_force_liquidation_record.py b/examples/spot/margin/margin_force_liquidation_record.py index 5af70112..25961460 100644 --- a/examples/spot/margin/margin_force_liquidation_record.py +++ b/examples/spot/margin/margin_force_liquidation_record.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_force_liquidation_record()) diff --git a/examples/spot/margin/margin_interest_history.py b/examples/spot/margin/margin_interest_history.py index 41e2ad92..072b812d 100644 --- a/examples/spot/margin/margin_interest_history.py +++ b/examples/spot/margin/margin_interest_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_interest_history(asset="BNB")) diff --git a/examples/spot/margin/margin_interest_rate_history.py b/examples/spot/margin/margin_interest_rate_history.py index 52344841..c5689a86 100644 --- a/examples/spot/margin/margin_interest_rate_history.py +++ b/examples/spot/margin/margin_interest_rate_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_interest_rate_history(asset="BNB")) diff --git a/examples/spot/margin/margin_load_record.py b/examples/spot/margin/margin_load_record.py index c2bb5045..86a2dc91 100644 --- a/examples/spot/margin/margin_load_record.py +++ b/examples/spot/margin/margin_load_record.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_load_record(asset="BNB", startTime="1580982895748")) diff --git a/examples/spot/margin/margin_max_borrowable.py b/examples/spot/margin/margin_max_borrowable.py index 8a463660..3e102835 100644 --- a/examples/spot/margin/margin_max_borrowable.py +++ b/examples/spot/margin/margin_max_borrowable.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_max_borrowable(asset="BNB")) diff --git a/examples/spot/margin/margin_max_transferable.py b/examples/spot/margin/margin_max_transferable.py index ac93edbb..54165476 100644 --- a/examples/spot/margin/margin_max_transferable.py +++ b/examples/spot/margin/margin_max_transferable.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_max_transferable(asset="BNB")) diff --git a/examples/spot/margin/margin_my_trades.py b/examples/spot/margin/margin_my_trades.py index cd12626a..06023c6d 100644 --- a/examples/spot/margin/margin_my_trades.py +++ b/examples/spot/margin/margin_my_trades.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_my_trades(symbol="BNBUSDT")) diff --git a/examples/spot/margin/margin_open_orders.py b/examples/spot/margin/margin_open_orders.py index 798ba705..1e8a9a57 100644 --- a/examples/spot/margin/margin_open_orders.py +++ b/examples/spot/margin/margin_open_orders.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_open_orders()) diff --git a/examples/spot/margin/margin_open_orders_cancellation.py b/examples/spot/margin/margin_open_orders_cancellation.py index ac78e80d..880f1f00 100644 --- a/examples/spot/margin/margin_open_orders_cancellation.py +++ b/examples/spot/margin/margin_open_orders_cancellation.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_open_orders_cancellation(symbol="BTCUSDT")) diff --git a/examples/spot/margin/margin_order.py b/examples/spot/margin/margin_order.py index d7d1d34d..50c9b0ec 100644 --- a/examples/spot/margin/margin_order.py +++ b/examples/spot/margin/margin_order.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_order(symbol="BNBUSDT", orderId="539829370")) diff --git a/examples/spot/margin/margin_order_usage.py b/examples/spot/margin/margin_order_usage.py index 90bca595..5f6f9e49 100644 --- a/examples/spot/margin/margin_order_usage.py +++ b/examples/spot/margin/margin_order_usage.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_order_usage(isIsolated="TRUE", symbol="BTCUSDT")) diff --git a/examples/spot/margin/margin_pair.py b/examples/spot/margin/margin_pair.py index 4e0f693b..300d0144 100644 --- a/examples/spot/margin/margin_pair.py +++ b/examples/spot/margin/margin_pair.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_pair(symbol="BNBUSDT")) diff --git a/examples/spot/margin/margin_pair_index.py b/examples/spot/margin/margin_pair_index.py index 7b8e04ac..57696782 100644 --- a/examples/spot/margin/margin_pair_index.py +++ b/examples/spot/margin/margin_pair_index.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_pair_index(symbol="BNBUSDT")) diff --git a/examples/spot/margin/margin_repay.py b/examples/spot/margin/margin_repay.py index 288dcf33..52bb0639 100644 --- a/examples/spot/margin/margin_repay.py +++ b/examples/spot/margin/margin_repay.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_repay(asset="BNB", amount="0.001")) diff --git a/examples/spot/margin/margin_repay_record.py b/examples/spot/margin/margin_repay_record.py index 055c2247..0e51ad8e 100644 --- a/examples/spot/margin/margin_repay_record.py +++ b/examples/spot/margin/margin_repay_record.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_repay_record(asset="BNB", startTime="1580982895748")) diff --git a/examples/spot/margin/margin_transfer.py b/examples/spot/margin/margin_transfer.py index b994b2ee..6841eb5e 100644 --- a/examples/spot/margin/margin_transfer.py +++ b/examples/spot/margin/margin_transfer.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_transfer(asset="BNB", amount="0.001", type=1)) diff --git a/examples/spot/margin/margin_transfer_history.py b/examples/spot/margin/margin_transfer_history.py index bcf73fb2..b2928e49 100644 --- a/examples/spot/margin/margin_transfer_history.py +++ b/examples/spot/margin/margin_transfer_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.margin_transfer_history(asset="BNB")) diff --git a/examples/spot/margin/new_margin_oco_order.py b/examples/spot/margin/new_margin_oco_order.py index f68e11d7..e52acc9f 100644 --- a/examples/spot/margin/new_margin_oco_order.py +++ b/examples/spot/margin/new_margin_oco_order.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = { "symbol": "BTCUSDT", diff --git a/examples/spot/margin/new_margin_order.py b/examples/spot/margin/new_margin_order.py index b4ca63f0..2f4b8f6c 100644 --- a/examples/spot/margin/new_margin_order.py +++ b/examples/spot/margin/new_margin_order.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/margin/summary_of_margin_account.py b/examples/spot/margin/summary_of_margin_account.py new file mode 100644 index 00000000..2f8c0481 --- /dev/null +++ b/examples/spot/margin/summary_of_margin_account.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +import logging +from binance.spot import Spot as Client +from binance.lib.utils import config_logging +from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") + +config_logging(logging, logging.DEBUG) + +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] + +client = Client(api_key, api_secret) + +try: + response = client.summary_of_margin_account(recvWindow=5000) + logging.info(response) +except ClientError as error: + logging.error( + "Found error. status: {}, error code: {}, error message: {}".format( + error.status_code, error.error_code, error.error_message + ) + ) diff --git a/examples/spot/margin/toggle_bnbBurn.py b/examples/spot/margin/toggle_bnbBurn.py index 22bd2b25..a65d51d2 100644 --- a/examples/spot/margin/toggle_bnbBurn.py +++ b/examples/spot/margin/toggle_bnbBurn.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.toggle_bnbBurn(spotBNBBurn="true", interestBNBBurn="false")) diff --git a/examples/spot/mining/mining_account_earning.py b/examples/spot/mining/mining_account_earning.py index a0cc11f5..916995a7 100644 --- a/examples/spot/mining/mining_account_earning.py +++ b/examples/spot/mining/mining_account_earning.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logger = logging.getLogger(__name__) diff --git a/examples/spot/mining/mining_account_list.py b/examples/spot/mining/mining_account_list.py index 6bb35387..f87c543c 100644 --- a/examples/spot/mining/mining_account_list.py +++ b/examples/spot/mining/mining_account_list.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.mining_account_list(algo="sha256", userName="a")) diff --git a/examples/spot/mining/mining_algo_list.py b/examples/spot/mining/mining_algo_list.py index 532d9843..b0e91f35 100644 --- a/examples/spot/mining/mining_algo_list.py +++ b/examples/spot/mining/mining_algo_list.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.mining_algo_list()) diff --git a/examples/spot/mining/mining_bonus_list.py b/examples/spot/mining/mining_bonus_list.py index 26680f52..3f06d7fa 100644 --- a/examples/spot/mining/mining_bonus_list.py +++ b/examples/spot/mining/mining_bonus_list.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.mining_bonus_list(algo="sha256", userName="user_name")) diff --git a/examples/spot/mining/mining_coin_list.py b/examples/spot/mining/mining_coin_list.py index 302012a3..732aad3b 100644 --- a/examples/spot/mining/mining_coin_list.py +++ b/examples/spot/mining/mining_coin_list.py @@ -3,10 +3,14 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key) logging.info(client.mining_coin_list()) diff --git a/examples/spot/mining/mining_earnings_list.py b/examples/spot/mining/mining_earnings_list.py index cf64e757..abad3d6a 100644 --- a/examples/spot/mining/mining_earnings_list.py +++ b/examples/spot/mining/mining_earnings_list.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.mining_earnings_list(algo="sha256", userName="a")) diff --git a/examples/spot/mining/mining_hashrate_resale_cancellation.py b/examples/spot/mining/mining_hashrate_resale_cancellation.py index 44ba1e38..0530d564 100644 --- a/examples/spot/mining/mining_hashrate_resale_cancellation.py +++ b/examples/spot/mining/mining_hashrate_resale_cancellation.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/mining/mining_hashrate_resale_details.py b/examples/spot/mining/mining_hashrate_resale_details.py index 2db689c6..04711c63 100644 --- a/examples/spot/mining/mining_hashrate_resale_details.py +++ b/examples/spot/mining/mining_hashrate_resale_details.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/mining/mining_hashrate_resale_list.py b/examples/spot/mining/mining_hashrate_resale_list.py index f32db53a..b1a9b0fc 100644 --- a/examples/spot/mining/mining_hashrate_resale_list.py +++ b/examples/spot/mining/mining_hashrate_resale_list.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.mining_hashrate_resale_list()) diff --git a/examples/spot/mining/mining_hashrate_resale_request.py b/examples/spot/mining/mining_hashrate_resale_request.py index 61c23c65..13ab97a0 100644 --- a/examples/spot/mining/mining_hashrate_resale_request.py +++ b/examples/spot/mining/mining_hashrate_resale_request.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = { "algo": "sha256", diff --git a/examples/spot/mining/mining_statistics_list.py b/examples/spot/mining/mining_statistics_list.py index e3cf19b2..d3c40e07 100644 --- a/examples/spot/mining/mining_statistics_list.py +++ b/examples/spot/mining/mining_statistics_list.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.mining_statistics_list(algo="sha256", userName="a")) diff --git a/examples/spot/mining/mining_worker.py b/examples/spot/mining/mining_worker.py index eae85846..7b16bb95 100644 --- a/examples/spot/mining/mining_worker.py +++ b/examples/spot/mining/mining_worker.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.mining_worker(algo="sha256", userName="a", workerName="b")) diff --git a/examples/spot/mining/mining_worker_list.py b/examples/spot/mining/mining_worker_list.py index f16422fe..5c9b4e04 100644 --- a/examples/spot/mining/mining_worker_list.py +++ b/examples/spot/mining/mining_worker_list.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.mining_worker_list(algo="sha256", userName="a")) diff --git a/examples/spot/nft/nft_asset.py b/examples/spot/nft/nft_asset.py index a52fc2ec..92992041 100644 --- a/examples/spot/nft/nft_asset.py +++ b/examples/spot/nft/nft_asset.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logger = logging.getLogger(__name__) diff --git a/examples/spot/nft/nft_deposit_history.py b/examples/spot/nft/nft_deposit_history.py index de918f20..19f28102 100644 --- a/examples/spot/nft/nft_deposit_history.py +++ b/examples/spot/nft/nft_deposit_history.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logger = logging.getLogger(__name__) diff --git a/examples/spot/nft/nft_transaction_history.py b/examples/spot/nft/nft_transaction_history.py index 27d48172..6c036ed2 100644 --- a/examples/spot/nft/nft_transaction_history.py +++ b/examples/spot/nft/nft_transaction_history.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logger = logging.getLogger(__name__) diff --git a/examples/spot/nft/nft_withdraw_history.py b/examples/spot/nft/nft_withdraw_history.py index 57115271..61125c53 100644 --- a/examples/spot/nft/nft_withdraw_history.py +++ b/examples/spot/nft/nft_withdraw_history.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logger = logging.getLogger(__name__) diff --git a/examples/spot/pay/pay_history.py b/examples/spot/pay/pay_history.py index 29d64f5e..8c96901c 100644 --- a/examples/spot/pay/pay_history.py +++ b/examples/spot/pay/pay_history.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/portfolio_margin/portfolio_margin_account.py b/examples/spot/portfolio_margin/portfolio_margin_account.py index 03e1933e..c70096fb 100644 --- a/examples/spot/portfolio_margin/portfolio_margin_account.py +++ b/examples/spot/portfolio_margin/portfolio_margin_account.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logger = logging.getLogger(__name__) diff --git a/examples/spot/portfolio_margin/portfolio_margin_bankruptcy_loan_amount.py b/examples/spot/portfolio_margin/portfolio_margin_bankruptcy_loan_amount.py index 4c115f64..4b7f8820 100644 --- a/examples/spot/portfolio_margin/portfolio_margin_bankruptcy_loan_amount.py +++ b/examples/spot/portfolio_margin/portfolio_margin_bankruptcy_loan_amount.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/portfolio_margin/portfolio_margin_bankruptcy_loan_repay.py b/examples/spot/portfolio_margin/portfolio_margin_bankruptcy_loan_repay.py index c5967a5e..2b778222 100644 --- a/examples/spot/portfolio_margin/portfolio_margin_bankruptcy_loan_repay.py +++ b/examples/spot/portfolio_margin/portfolio_margin_bankruptcy_loan_repay.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/portfolio_margin/portfolio_margin_collateral_rate.py b/examples/spot/portfolio_margin/portfolio_margin_collateral_rate.py index 582d7749..c1bed802 100644 --- a/examples/spot/portfolio_margin/portfolio_margin_collateral_rate.py +++ b/examples/spot/portfolio_margin/portfolio_margin_collateral_rate.py @@ -4,10 +4,14 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key) diff --git a/examples/spot/rebate/rebate_spot_history.py b/examples/spot/rebate/rebate_spot_history.py index 6311ca45..2716fe5e 100644 --- a/examples/spot/rebate/rebate_spot_history.py +++ b/examples/spot/rebate/rebate_spot_history.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/savings/savings_account.py b/examples/spot/savings/savings_account.py index 34264c9d..a6626aca 100644 --- a/examples/spot/savings/savings_account.py +++ b/examples/spot/savings/savings_account.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_account()) diff --git a/examples/spot/savings/savings_change_position.py b/examples/spot/savings/savings_change_position.py index 59875fdc..4e13526d 100644 --- a/examples/spot/savings/savings_change_position.py +++ b/examples/spot/savings/savings_change_position.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_change_position(projectId="USDT001", lot=1)) diff --git a/examples/spot/savings/savings_flexible_product_position.py b/examples/spot/savings/savings_flexible_product_position.py index a3a9e6df..c1650e76 100644 --- a/examples/spot/savings/savings_flexible_product_position.py +++ b/examples/spot/savings/savings_flexible_product_position.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_flexible_product_position()) diff --git a/examples/spot/savings/savings_flexible_products.py b/examples/spot/savings/savings_flexible_products.py index c71b3808..abc4a32f 100644 --- a/examples/spot/savings/savings_flexible_products.py +++ b/examples/spot/savings/savings_flexible_products.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_flexible_products()) diff --git a/examples/spot/savings/savings_flexible_redeem.py b/examples/spot/savings/savings_flexible_redeem.py index fc8326df..008c7d05 100644 --- a/examples/spot/savings/savings_flexible_redeem.py +++ b/examples/spot/savings/savings_flexible_redeem.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/savings/savings_flexible_user_left_quota.py b/examples/spot/savings/savings_flexible_user_left_quota.py index 5287a991..2a17f031 100644 --- a/examples/spot/savings/savings_flexible_user_left_quota.py +++ b/examples/spot/savings/savings_flexible_user_left_quota.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_flexible_user_left_quota(productId="BTC001")) diff --git a/examples/spot/savings/savings_flexible_user_redemption_quota.py b/examples/spot/savings/savings_flexible_user_redemption_quota.py index 9cd9e40c..108886a6 100644 --- a/examples/spot/savings/savings_flexible_user_redemption_quota.py +++ b/examples/spot/savings/savings_flexible_user_redemption_quota.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/savings/savings_interest_history.py b/examples/spot/savings/savings_interest_history.py index 80d67733..bef8030b 100644 --- a/examples/spot/savings/savings_interest_history.py +++ b/examples/spot/savings/savings_interest_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_interest_history(lendingType="DAILY")) diff --git a/examples/spot/savings/savings_project_list.py b/examples/spot/savings/savings_project_list.py index 082964e6..a6726164 100644 --- a/examples/spot/savings/savings_project_list.py +++ b/examples/spot/savings/savings_project_list.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_project_list(type="REGULAR")) diff --git a/examples/spot/savings/savings_project_position.py b/examples/spot/savings/savings_project_position.py index 763e3c17..f9e85bb4 100644 --- a/examples/spot/savings/savings_project_position.py +++ b/examples/spot/savings/savings_project_position.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_project_position()) diff --git a/examples/spot/savings/savings_purchase_flexible_product.py b/examples/spot/savings/savings_purchase_flexible_product.py index c362d997..3af705fa 100644 --- a/examples/spot/savings/savings_purchase_flexible_product.py +++ b/examples/spot/savings/savings_purchase_flexible_product.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_purchase_flexible_product(productId="BTC001", amount=0.01)) diff --git a/examples/spot/savings/savings_purchase_project.py b/examples/spot/savings/savings_purchase_project.py index c479e898..0c2f81f6 100644 --- a/examples/spot/savings/savings_purchase_project.py +++ b/examples/spot/savings/savings_purchase_project.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_purchase_project(projectId="USDT14DAYSS001", lot=1)) diff --git a/examples/spot/savings/savings_purchase_record.py b/examples/spot/savings/savings_purchase_record.py index 0e8331f4..29fe734d 100644 --- a/examples/spot/savings/savings_purchase_record.py +++ b/examples/spot/savings/savings_purchase_record.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_purchase_record(lendingType="DAILY")) diff --git a/examples/spot/savings/savings_redemption_record.py b/examples/spot/savings/savings_redemption_record.py index 8eee4806..f241fc47 100644 --- a/examples/spot/savings/savings_redemption_record.py +++ b/examples/spot/savings/savings_redemption_record.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) logging.info(client.savings_redemption_record(lendingType="DAILY")) diff --git a/examples/spot/staking/staking_history.py b/examples/spot/staking/staking_history.py index 467027b2..09705db3 100644 --- a/examples/spot/staking/staking_history.py +++ b/examples/spot/staking/staking_history.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = {"product": "STAKING", "txnType": "SUBSCRIPTION"} diff --git a/examples/spot/staking/staking_product_list.py b/examples/spot/staking/staking_product_list.py index 30ef9bb2..98cfde9e 100644 --- a/examples/spot/staking/staking_product_list.py +++ b/examples/spot/staking/staking_product_list.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = {"product": "STAKING"} diff --git a/examples/spot/staking/staking_product_position.py b/examples/spot/staking/staking_product_position.py index 316b92a5..828a54b5 100644 --- a/examples/spot/staking/staking_product_position.py +++ b/examples/spot/staking/staking_product_position.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = {"product": "STAKING"} diff --git a/examples/spot/staking/staking_product_quota.py b/examples/spot/staking/staking_product_quota.py index 21821edc..81590668 100644 --- a/examples/spot/staking/staking_product_quota.py +++ b/examples/spot/staking/staking_product_quota.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = {"product": "STAKING", "productId": "Axs*90"} diff --git a/examples/spot/staking/staking_purchase_product.py b/examples/spot/staking/staking_purchase_product.py index 9c10f18c..9f52c38e 100644 --- a/examples/spot/staking/staking_purchase_product.py +++ b/examples/spot/staking/staking_purchase_product.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = {"product": "STAKING", "productId": "Axs*90", "amount": 10.1} diff --git a/examples/spot/staking/staking_redeem_product.py b/examples/spot/staking/staking_redeem_product.py index b8673728..27b0af6e 100644 --- a/examples/spot/staking/staking_redeem_product.py +++ b/examples/spot/staking/staking_redeem_product.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = {"product": "STAKING", "productId": "Axs*90"} diff --git a/examples/spot/staking/staking_set_auto_staking.py b/examples/spot/staking/staking_set_auto_staking.py index 6fe8e01d..3b9ce783 100644 --- a/examples/spot/staking/staking_set_auto_staking.py +++ b/examples/spot/staking/staking_set_auto_staking.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = {"product": "STAKING", "positionId": "1234", "renewable": "true"} diff --git a/examples/spot/stream/isolated_margin/close_isolated_margin_listen_key.py b/examples/spot/stream/isolated_margin/close_isolated_margin_listen_key.py index 9daf8c38..0851c1d5 100644 --- a/examples/spot/stream/isolated_margin/close_isolated_margin_listen_key.py +++ b/examples/spot/stream/isolated_margin/close_isolated_margin_listen_key.py @@ -3,9 +3,13 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key) logging.info(client.close_isolated_margin_listen_key(symbol="BTCUSDT", listenKey="")) diff --git a/examples/spot/stream/isolated_margin/new_isolated_margin_listen_key.py b/examples/spot/stream/isolated_margin/new_isolated_margin_listen_key.py index 6fb7089b..2e21e3e7 100644 --- a/examples/spot/stream/isolated_margin/new_isolated_margin_listen_key.py +++ b/examples/spot/stream/isolated_margin/new_isolated_margin_listen_key.py @@ -3,9 +3,13 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key) logging.info(client.new_isolated_margin_listen_key(symbol="BTCUSDT")) diff --git a/examples/spot/stream/isolated_margin/renew_isolated_margin_listen_key.py b/examples/spot/stream/isolated_margin/renew_isolated_margin_listen_key.py index a671dbe9..723a6f1b 100644 --- a/examples/spot/stream/isolated_margin/renew_isolated_margin_listen_key.py +++ b/examples/spot/stream/isolated_margin/renew_isolated_margin_listen_key.py @@ -3,9 +3,13 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key) logging.info(client.renew_isolated_margin_listen_key(symbol="BTCUSDT", listenKey="")) diff --git a/examples/spot/stream/margin/close_margin_listen_key.py b/examples/spot/stream/margin/close_margin_listen_key.py index 69b8d54f..74b616ef 100644 --- a/examples/spot/stream/margin/close_margin_listen_key.py +++ b/examples/spot/stream/margin/close_margin_listen_key.py @@ -3,9 +3,13 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key) logging.info(client.close_margin_listen_key(listenKey="")) diff --git a/examples/spot/stream/margin/new_margin_listen_key.py b/examples/spot/stream/margin/new_margin_listen_key.py index 7a3ca64c..05e32fbb 100644 --- a/examples/spot/stream/margin/new_margin_listen_key.py +++ b/examples/spot/stream/margin/new_margin_listen_key.py @@ -3,9 +3,13 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key) logging.info(client.new_margin_listen_key()) diff --git a/examples/spot/stream/margin/renew_margin_listen_key.py b/examples/spot/stream/margin/renew_margin_listen_key.py index c420ac78..aee6a1cb 100644 --- a/examples/spot/stream/margin/renew_margin_listen_key.py +++ b/examples/spot/stream/margin/renew_margin_listen_key.py @@ -3,9 +3,13 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key) logging.info(client.renew_margin_listen_key(listenKey="")) diff --git a/examples/spot/stream/spot/close_listen_key.py b/examples/spot/stream/spot/close_listen_key.py index c2bc1d1d..14c35564 100644 --- a/examples/spot/stream/spot/close_listen_key.py +++ b/examples/spot/stream/spot/close_listen_key.py @@ -3,10 +3,14 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key, base_url="https://testnet.binance.vision") logging.info(client.close_listen_key("")) diff --git a/examples/spot/stream/spot/new_listen_key.py b/examples/spot/stream/spot/new_listen_key.py index 270b056c..9cbe7956 100644 --- a/examples/spot/stream/spot/new_listen_key.py +++ b/examples/spot/stream/spot/new_listen_key.py @@ -3,10 +3,14 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key, base_url="https://testnet.binance.vision") logging.info(client.new_listen_key()) diff --git a/examples/spot/stream/spot/renew_listen_key.py b/examples/spot/stream/spot/renew_listen_key.py index 33f0a88c..92571862 100644 --- a/examples/spot/stream/spot/renew_listen_key.py +++ b/examples/spot/stream/spot/renew_listen_key.py @@ -3,10 +3,14 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key, base_url="https://testnet.binance.vision") logging.info(client.renew_listen_key("")) diff --git a/examples/spot/sub_account/managed_sub_account_assets.py b/examples/spot/sub_account/managed_sub_account_assets.py index b806bf98..c5194363 100644 --- a/examples/spot/sub_account/managed_sub_account_assets.py +++ b/examples/spot/sub_account/managed_sub_account_assets.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.managed_sub_account_assets(email="alice@test.com")) diff --git a/examples/spot/sub_account/managed_sub_account_deposit.py b/examples/spot/sub_account/managed_sub_account_deposit.py index ff94ac2d..1db7f2c3 100644 --- a/examples/spot/sub_account/managed_sub_account_deposit.py +++ b/examples/spot/sub_account/managed_sub_account_deposit.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/sub_account/managed_sub_account_get_snapshot.py b/examples/spot/sub_account/managed_sub_account_get_snapshot.py index 4178a3f3..2dd22a3a 100644 --- a/examples/spot/sub_account/managed_sub_account_get_snapshot.py +++ b/examples/spot/sub_account/managed_sub_account_get_snapshot.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) diff --git a/examples/spot/sub_account/managed_sub_account_withdraw.py b/examples/spot/sub_account/managed_sub_account_withdraw.py index fb228285..39dbaa15 100644 --- a/examples/spot/sub_account/managed_sub_account_withdraw.py +++ b/examples/spot/sub_account/managed_sub_account_withdraw.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/sub_account/sub_account_api_add_ip.py b/examples/spot/sub_account/sub_account_api_add_ip.py index be4bfd5f..d9dad62b 100644 --- a/examples/spot/sub_account/sub_account_api_add_ip.py +++ b/examples/spot/sub_account/sub_account_api_add_ip.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) diff --git a/examples/spot/sub_account/sub_account_api_delete_ip.py b/examples/spot/sub_account/sub_account_api_delete_ip.py index 65052965..ea7f43e1 100644 --- a/examples/spot/sub_account/sub_account_api_delete_ip.py +++ b/examples/spot/sub_account/sub_account_api_delete_ip.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) diff --git a/examples/spot/sub_account/sub_account_api_get_ip_restriction.py b/examples/spot/sub_account/sub_account_api_get_ip_restriction.py index e357c905..908f2af6 100644 --- a/examples/spot/sub_account/sub_account_api_get_ip_restriction.py +++ b/examples/spot/sub_account/sub_account_api_get_ip_restriction.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) diff --git a/examples/spot/sub_account/sub_account_api_toggle_ip_restriction.py b/examples/spot/sub_account/sub_account_api_toggle_ip_restriction.py index 8fc3c6f3..ed3c3ec2 100644 --- a/examples/spot/sub_account/sub_account_api_toggle_ip_restriction.py +++ b/examples/spot/sub_account/sub_account_api_toggle_ip_restriction.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) diff --git a/examples/spot/sub_account/sub_account_assets.py b/examples/spot/sub_account/sub_account_assets.py index adeacf5f..21638b67 100644 --- a/examples/spot/sub_account/sub_account_assets.py +++ b/examples/spot/sub_account/sub_account_assets.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_assets(email="alice@test.com")) diff --git a/examples/spot/sub_account/sub_account_create.py b/examples/spot/sub_account/sub_account_create.py index 14a0d436..e764ccf2 100644 --- a/examples/spot/sub_account/sub_account_create.py +++ b/examples/spot/sub_account/sub_account_create.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_create(subAccountString="test.account")) diff --git a/examples/spot/sub_account/sub_account_deposit_address.py b/examples/spot/sub_account/sub_account_deposit_address.py index 6a971ca4..56510ada 100644 --- a/examples/spot/sub_account/sub_account_deposit_address.py +++ b/examples/spot/sub_account/sub_account_deposit_address.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/sub_account/sub_account_deposit_history.py b/examples/spot/sub_account/sub_account_deposit_history.py index 4cee48ad..992d86f7 100644 --- a/examples/spot/sub_account/sub_account_deposit_history.py +++ b/examples/spot/sub_account/sub_account_deposit_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_deposit_history(email="alice@test.com")) diff --git a/examples/spot/sub_account/sub_account_enable_futures.py b/examples/spot/sub_account/sub_account_enable_futures.py index 4719e6c0..8131529a 100644 --- a/examples/spot/sub_account/sub_account_enable_futures.py +++ b/examples/spot/sub_account/sub_account_enable_futures.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_enable_futures(email="alice@test.com")) diff --git a/examples/spot/sub_account/sub_account_enable_leverage_token.py b/examples/spot/sub_account/sub_account_enable_leverage_token.py index 6a7a97d9..bc752f9d 100644 --- a/examples/spot/sub_account/sub_account_enable_leverage_token.py +++ b/examples/spot/sub_account/sub_account_enable_leverage_token.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/sub_account/sub_account_enable_margin.py b/examples/spot/sub_account/sub_account_enable_margin.py index 3532b9fe..e742a38c 100644 --- a/examples/spot/sub_account/sub_account_enable_margin.py +++ b/examples/spot/sub_account/sub_account_enable_margin.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_enable_margin(email="alice@test.com")) diff --git a/examples/spot/sub_account/sub_account_futures_account.py b/examples/spot/sub_account/sub_account_futures_account.py index 8d18e044..7fdfef75 100644 --- a/examples/spot/sub_account/sub_account_futures_account.py +++ b/examples/spot/sub_account/sub_account_futures_account.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/sub_account/sub_account_futures_account_summary.py b/examples/spot/sub_account/sub_account_futures_account_summary.py index 3d304a43..c8a780aa 100644 --- a/examples/spot/sub_account/sub_account_futures_account_summary.py +++ b/examples/spot/sub_account/sub_account_futures_account_summary.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_futures_account_summary(futuresType=1)) diff --git a/examples/spot/sub_account/sub_account_futures_asset_transfer.py b/examples/spot/sub_account/sub_account_futures_asset_transfer.py index 1372a8b9..6acf19f6 100644 --- a/examples/spot/sub_account/sub_account_futures_asset_transfer.py +++ b/examples/spot/sub_account/sub_account_futures_asset_transfer.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/sub_account/sub_account_futures_asset_transfer_history.py b/examples/spot/sub_account/sub_account_futures_asset_transfer_history.py index e5b1c0fe..6afd23e9 100644 --- a/examples/spot/sub_account/sub_account_futures_asset_transfer_history.py +++ b/examples/spot/sub_account/sub_account_futures_asset_transfer_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/sub_account/sub_account_futures_position_risk.py b/examples/spot/sub_account/sub_account_futures_position_risk.py index 08ee6f73..b8db4102 100644 --- a/examples/spot/sub_account/sub_account_futures_position_risk.py +++ b/examples/spot/sub_account/sub_account_futures_position_risk.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/sub_account/sub_account_futures_transfer.py b/examples/spot/sub_account/sub_account_futures_transfer.py index 8a26f232..d3f95ae4 100644 --- a/examples/spot/sub_account/sub_account_futures_transfer.py +++ b/examples/spot/sub_account/sub_account_futures_transfer.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/sub_account/sub_account_list.py b/examples/spot/sub_account/sub_account_list.py index c5e08709..bf0baee5 100644 --- a/examples/spot/sub_account/sub_account_list.py +++ b/examples/spot/sub_account/sub_account_list.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_list()) diff --git a/examples/spot/sub_account/sub_account_margin_account.py b/examples/spot/sub_account/sub_account_margin_account.py index 1113a336..509c83b0 100644 --- a/examples/spot/sub_account/sub_account_margin_account.py +++ b/examples/spot/sub_account/sub_account_margin_account.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_margin_account(email="alice@test.com")) diff --git a/examples/spot/sub_account/sub_account_margin_account_summary.py b/examples/spot/sub_account/sub_account_margin_account_summary.py index aa0d3e67..bc0cbeb8 100644 --- a/examples/spot/sub_account/sub_account_margin_account_summary.py +++ b/examples/spot/sub_account/sub_account_margin_account_summary.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_margin_account_summary()) diff --git a/examples/spot/sub_account/sub_account_margin_transfer.py b/examples/spot/sub_account/sub_account_margin_transfer.py index d81ca4b2..b16c57c6 100644 --- a/examples/spot/sub_account/sub_account_margin_transfer.py +++ b/examples/spot/sub_account/sub_account_margin_transfer.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/sub_account/sub_account_spot_summary.py b/examples/spot/sub_account/sub_account_spot_summary.py index b643d886..da430084 100644 --- a/examples/spot/sub_account/sub_account_spot_summary.py +++ b/examples/spot/sub_account/sub_account_spot_summary.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_spot_summary(email="")) diff --git a/examples/spot/sub_account/sub_account_spot_transfer_history.py b/examples/spot/sub_account/sub_account_spot_transfer_history.py index 9fca3817..c905f1bc 100644 --- a/examples/spot/sub_account/sub_account_spot_transfer_history.py +++ b/examples/spot/sub_account/sub_account_spot_transfer_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_spot_transfer_history()) diff --git a/examples/spot/sub_account/sub_account_status.py b/examples/spot/sub_account/sub_account_status.py index f08fb12b..60cc31b3 100644 --- a/examples/spot/sub_account/sub_account_status.py +++ b/examples/spot/sub_account/sub_account_status.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_status(email="alice@test.com")) diff --git a/examples/spot/sub_account/sub_account_transfer_sub_account_history.py b/examples/spot/sub_account/sub_account_transfer_sub_account_history.py index f7a4815a..419f6bab 100644 --- a/examples/spot/sub_account/sub_account_transfer_sub_account_history.py +++ b/examples/spot/sub_account/sub_account_transfer_sub_account_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_transfer_sub_account_history()) diff --git a/examples/spot/sub_account/sub_account_transfer_to_master.py b/examples/spot/sub_account/sub_account_transfer_to_master.py index 41b9852b..03fb1427 100644 --- a/examples/spot/sub_account/sub_account_transfer_to_master.py +++ b/examples/spot/sub_account/sub_account_transfer_to_master.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.sub_account_transfer_to_master(asset="USDT", amount=0.01)) diff --git a/examples/spot/sub_account/sub_account_transfer_to_sub.py b/examples/spot/sub_account/sub_account_transfer_to_sub.py index 6a485af7..52b911eb 100644 --- a/examples/spot/sub_account/sub_account_transfer_to_sub.py +++ b/examples/spot/sub_account/sub_account_transfer_to_sub.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/sub_account/sub_account_universal_transfer.py b/examples/spot/sub_account/sub_account_universal_transfer.py index bd98af26..cc4bb4d0 100644 --- a/examples/spot/sub_account/sub_account_universal_transfer.py +++ b/examples/spot/sub_account/sub_account_universal_transfer.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) diff --git a/examples/spot/sub_account/sub_account_universal_transfer_history.py b/examples/spot/sub_account/sub_account_universal_transfer_history.py index a4a058ac..0ad8a516 100644 --- a/examples/spot/sub_account/sub_account_universal_transfer_history.py +++ b/examples/spot/sub_account/sub_account_universal_transfer_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) diff --git a/examples/spot/trade/cancel_and_replace.py b/examples/spot/trade/cancel_and_replace.py index 84a5fa25..cbd5fa8a 100644 --- a/examples/spot/trade/cancel_and_replace.py +++ b/examples/spot/trade/cancel_and_replace.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") diff --git a/examples/spot/trade/cancel_oco_order.py b/examples/spot/trade/cancel_oco_order.py index 516b2ac3..31e73759 100644 --- a/examples/spot/trade/cancel_oco_order.py +++ b/examples/spot/trade/cancel_oco_order.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") diff --git a/examples/spot/trade/cancel_open_orders.py b/examples/spot/trade/cancel_open_orders.py index 59da4052..8a0751f8 100644 --- a/examples/spot/trade/cancel_open_orders.py +++ b/examples/spot/trade/cancel_open_orders.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") diff --git a/examples/spot/trade/cancel_order.py b/examples/spot/trade/cancel_order.py index f8532495..e3c148d4 100644 --- a/examples/spot/trade/cancel_order.py +++ b/examples/spot/trade/cancel_order.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") diff --git a/examples/spot/trade/get_account.py b/examples/spot/trade/get_account.py index fce55a12..e97f2c84 100644 --- a/examples/spot/trade/get_account.py +++ b/examples/spot/trade/get_account.py @@ -3,13 +3,17 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser -config_logging(logging, logging.DEBUG) +config = ConfigParser() +config.read("../../config.ini") +config_logging(logging, logging.DEBUG) # HMAC authentication with API key and secret -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] + client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") logging.info(client.account(recvWindow=6000)) diff --git a/examples/spot/trade/get_my_trades.py b/examples/spot/trade/get_my_trades.py index f5c8866d..54154816 100644 --- a/examples/spot/trade/get_my_trades.py +++ b/examples/spot/trade/get_my_trades.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") logging.info(client.my_trades("BTCUSDT")) diff --git a/examples/spot/trade/get_oco_open_orders.py b/examples/spot/trade/get_oco_open_orders.py index 71b3350d..0758b9f3 100644 --- a/examples/spot/trade/get_oco_open_orders.py +++ b/examples/spot/trade/get_oco_open_orders.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") diff --git a/examples/spot/trade/get_oco_order.py b/examples/spot/trade/get_oco_order.py index 3b281ad6..f4b0db24 100644 --- a/examples/spot/trade/get_oco_order.py +++ b/examples/spot/trade/get_oco_order.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") diff --git a/examples/spot/trade/get_oco_orders.py b/examples/spot/trade/get_oco_orders.py index da650fd3..595330a2 100644 --- a/examples/spot/trade/get_oco_orders.py +++ b/examples/spot/trade/get_oco_orders.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") diff --git a/examples/spot/trade/get_open_orders.py b/examples/spot/trade/get_open_orders.py index fb3c5f63..06dd2443 100644 --- a/examples/spot/trade/get_open_orders.py +++ b/examples/spot/trade/get_open_orders.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") diff --git a/examples/spot/trade/get_order.py b/examples/spot/trade/get_order.py index 5d6df258..7cff9eb6 100644 --- a/examples/spot/trade/get_order.py +++ b/examples/spot/trade/get_order.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") diff --git a/examples/spot/trade/get_order_rate_limit.py b/examples/spot/trade/get_order_rate_limit.py index e0207742..a3baffeb 100644 --- a/examples/spot/trade/get_order_rate_limit.py +++ b/examples/spot/trade/get_order_rate_limit.py @@ -3,11 +3,15 @@ import logging from binance.lib.utils import config_logging from binance.spot import Spot as Client +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client( api_key=api_key, api_secret=api_secret, base_url="https://testnet.binance.vision" diff --git a/examples/spot/trade/get_orders.py b/examples/spot/trade/get_orders.py index 9c7eabae..32d29bd6 100644 --- a/examples/spot/trade/get_orders.py +++ b/examples/spot/trade/get_orders.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret, base_url="https://testnet.binance.vision") diff --git a/examples/spot/trade/new_oco_order.py b/examples/spot/trade/new_oco_order.py index ebd2e801..4a44ae8f 100644 --- a/examples/spot/trade/new_oco_order.py +++ b/examples/spot/trade/new_oco_order.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = { "symbol": "BTCUSDT", diff --git a/examples/spot/trade/new_order.py b/examples/spot/trade/new_order.py index daec5c5e..7ee83b44 100644 --- a/examples/spot/trade/new_order.py +++ b/examples/spot/trade/new_order.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = { "symbol": "BTCUSDT", diff --git a/examples/spot/trade/new_order_testing.py b/examples/spot/trade/new_order_testing.py index 679c9405..65bd1b52 100644 --- a/examples/spot/trade/new_order_testing.py +++ b/examples/spot/trade/new_order_testing.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] params = { "symbol": "BTCUSDT", diff --git a/examples/spot/wallet/account_snapshot.py b/examples/spot/wallet/account_snapshot.py index eed49f91..1e694ff9 100644 --- a/examples/spot/wallet/account_snapshot.py +++ b/examples/spot/wallet/account_snapshot.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.account_snapshot("SPOT")) diff --git a/examples/spot/wallet/account_status.py b/examples/spot/wallet/account_status.py index 97cbb100..19c8bcef 100644 --- a/examples/spot/wallet/account_status.py +++ b/examples/spot/wallet/account_status.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.account_status()) diff --git a/examples/spot/wallet/api_key_permissions.py b/examples/spot/wallet/api_key_permissions.py index db622d82..b6b6bd3a 100644 --- a/examples/spot/wallet/api_key_permissions.py +++ b/examples/spot/wallet/api_key_permissions.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret, show_header=True) logging.info(spot_client.api_key_permissions()) diff --git a/examples/spot/wallet/api_trading_status.py b/examples/spot/wallet/api_trading_status.py index e96991cf..bc549fa3 100644 --- a/examples/spot/wallet/api_trading_status.py +++ b/examples/spot/wallet/api_trading_status.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.api_trading_status()) diff --git a/examples/spot/wallet/asset_detail.py b/examples/spot/wallet/asset_detail.py index ae7325ff..8ce2fb1a 100644 --- a/examples/spot/wallet/asset_detail.py +++ b/examples/spot/wallet/asset_detail.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.asset_detail()) diff --git a/examples/spot/wallet/asset_dividend_record.py b/examples/spot/wallet/asset_dividend_record.py index 44950301..ace0495f 100644 --- a/examples/spot/wallet/asset_dividend_record.py +++ b/examples/spot/wallet/asset_dividend_record.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.asset_dividend_record()) diff --git a/examples/spot/wallet/bnb_convertible_assets.py b/examples/spot/wallet/bnb_convertible_assets.py index 73f725c7..57d7c2fe 100644 --- a/examples/spot/wallet/bnb_convertible_assets.py +++ b/examples/spot/wallet/bnb_convertible_assets.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] logger = logging.getLogger(__name__) spot_client = Client(api_key, api_secret, show_header=True) diff --git a/examples/spot/wallet/coin_info.py b/examples/spot/wallet/coin_info.py index 0bb6bfc7..a6018846 100644 --- a/examples/spot/wallet/coin_info.py +++ b/examples/spot/wallet/coin_info.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.coin_info()) diff --git a/examples/spot/wallet/deposit_address.py b/examples/spot/wallet/deposit_address.py index ef48ebff..6e3824ce 100644 --- a/examples/spot/wallet/deposit_address.py +++ b/examples/spot/wallet/deposit_address.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.deposit_address(coin="BNB")) diff --git a/examples/spot/wallet/deposit_history.py b/examples/spot/wallet/deposit_history.py index ed9fd1a8..63a1aad5 100644 --- a/examples/spot/wallet/deposit_history.py +++ b/examples/spot/wallet/deposit_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.deposit_history()) diff --git a/examples/spot/wallet/disable_fast_withdraw.py b/examples/spot/wallet/disable_fast_withdraw.py index 06a55358..4d04fa34 100644 --- a/examples/spot/wallet/disable_fast_withdraw.py +++ b/examples/spot/wallet/disable_fast_withdraw.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret, show_header=True) logging.info(spot_client.disable_fast_withdraw()) diff --git a/examples/spot/wallet/dust_log.py b/examples/spot/wallet/dust_log.py index 05355baa..39cb5918 100644 --- a/examples/spot/wallet/dust_log.py +++ b/examples/spot/wallet/dust_log.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.dust_log()) diff --git a/examples/spot/wallet/enable_fast_withdraw.py b/examples/spot/wallet/enable_fast_withdraw.py index 7b01837c..2ac6e2b7 100644 --- a/examples/spot/wallet/enable_fast_withdraw.py +++ b/examples/spot/wallet/enable_fast_withdraw.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret, show_header=True) logging.info(spot_client.enable_fast_withdraw()) diff --git a/examples/spot/wallet/funding_wallet.py b/examples/spot/wallet/funding_wallet.py index 01e2487f..11b192a3 100644 --- a/examples/spot/wallet/funding_wallet.py +++ b/examples/spot/wallet/funding_wallet.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret, show_header=True) logging.info(spot_client.funding_wallet(asset="BNB")) diff --git a/examples/spot/wallet/trade_fee.py b/examples/spot/wallet/trade_fee.py index cc84b36c..1ef56669 100644 --- a/examples/spot/wallet/trade_fee.py +++ b/examples/spot/wallet/trade_fee.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.trade_fee()) diff --git a/examples/spot/wallet/transfer_dust.py b/examples/spot/wallet/transfer_dust.py index 31ee2eeb..5b62af73 100644 --- a/examples/spot/wallet/transfer_dust.py +++ b/examples/spot/wallet/transfer_dust.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.transfer_dust(asset=["CTSI", "CHR"])) diff --git a/examples/spot/wallet/user_asset.py b/examples/spot/wallet/user_asset.py index 1eae7747..804bb273 100644 --- a/examples/spot/wallet/user_asset.py +++ b/examples/spot/wallet/user_asset.py @@ -4,11 +4,15 @@ from binance.spot import Spot as Client from binance.lib.utils import config_logging from binance.error import ClientError +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] client = Client(api_key, api_secret) diff --git a/examples/spot/wallet/user_universal_transfer.py b/examples/spot/wallet/user_universal_transfer.py index 4f8a5f9b..9d659f59 100644 --- a/examples/spot/wallet/user_universal_transfer.py +++ b/examples/spot/wallet/user_universal_transfer.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info( diff --git a/examples/spot/wallet/user_universal_transfer_history.py b/examples/spot/wallet/user_universal_transfer_history.py index 85e1a283..6db56393 100644 --- a/examples/spot/wallet/user_universal_transfer_history.py +++ b/examples/spot/wallet/user_universal_transfer_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.user_universal_transfer_history(type="MAIN_UMFUTURE")) diff --git a/examples/spot/wallet/withdraw.py b/examples/spot/wallet/withdraw.py index e24bf623..393c41f9 100644 --- a/examples/spot/wallet/withdraw.py +++ b/examples/spot/wallet/withdraw.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret, show_header=True) logging.info(spot_client.withdraw(coin="BNB", amount=0.01, address="")) diff --git a/examples/spot/wallet/withdraw_history.py b/examples/spot/wallet/withdraw_history.py index abb1b201..9dab105c 100644 --- a/examples/spot/wallet/withdraw_history.py +++ b/examples/spot/wallet/withdraw_history.py @@ -3,11 +3,15 @@ import logging from binance.spot import Spot as Client from binance.lib.utils import config_logging +from configparser import ConfigParser + +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) -api_key = "" -api_secret = "" +api_key = config["keys"]["api_key"] +api_secret = config["keys"]["api_secret"] spot_client = Client(api_key, api_secret) logging.info(spot_client.withdraw_history()) diff --git a/examples/websocket/spot/agg_trade.py b/examples/websocket/spot/agg_trade.py index 10e723d7..98d41246 100644 --- a/examples/websocket/spot/agg_trade.py +++ b/examples/websocket/spot/agg_trade.py @@ -15,6 +15,7 @@ def message_handler(message): my_client = Client() my_client.start() +# Subscribe to a single symbol stream my_client.agg_trade( symbol="btcusdt", id=1, @@ -23,8 +24,9 @@ def message_handler(message): time.sleep(2) +# Subscribe to a new stream for each symbol in the list my_client.agg_trade( - symbol="bnbusdt", + symbol=["bnbusdt", "ethusdt", "ltcusdt"], id=2, callback=message_handler, ) diff --git a/examples/websocket/spot/diff_book_depth.py b/examples/websocket/spot/diff_book_depth.py index 35d339dc..00f642dc 100644 --- a/examples/websocket/spot/diff_book_depth.py +++ b/examples/websocket/spot/diff_book_depth.py @@ -24,6 +24,16 @@ def message_handler(message): time.sleep(2) +# Subscribe to a new stream for each symbol in the list +my_client.diff_book_depth( + symbol=["ethusdt", "ltcusdt"], + speed=100, + id=1, + callback=message_handler, +) + +time.sleep(2) + my_client.diff_book_depth( symbol="btcusdt", speed=1000, diff --git a/examples/websocket/spot/partial_book_depth.py b/examples/websocket/spot/partial_book_depth.py index a0773cd7..910d312c 100644 --- a/examples/websocket/spot/partial_book_depth.py +++ b/examples/websocket/spot/partial_book_depth.py @@ -26,7 +26,7 @@ def message_handler(message): time.sleep(2) my_client.partial_book_depth( - symbol="btcusdt", + symbol=["btcusdt", "ltcusdt"], level=10, speed=100, id=2, diff --git a/examples/websocket/spot/rolling_window_ticker.py b/examples/websocket/spot/rolling_window_ticker.py index ffaa4947..7e3866b4 100644 --- a/examples/websocket/spot/rolling_window_ticker.py +++ b/examples/websocket/spot/rolling_window_ticker.py @@ -23,6 +23,13 @@ def message_handler(message): callback=message_handler, ) +my_client.rolling_window_ticker( + ["LTCUSDT", "ETHUSDT"], + "1h", + id=1, + callback=message_handler, +) + time.sleep(30) logging.debug("closing ws connection") diff --git a/examples/websocket/spot/symbol_book_ticker.py b/examples/websocket/spot/symbol_book_ticker.py index e109295f..90f6951c 100644 --- a/examples/websocket/spot/symbol_book_ticker.py +++ b/examples/websocket/spot/symbol_book_ticker.py @@ -24,7 +24,7 @@ def message_handler(message): time.sleep(2) my_client.book_ticker( - symbol="btcusdt", + symbol=["btcusdt", "ethusdt"], id=2, callback=message_handler, ) diff --git a/examples/websocket/spot/symbol_kline.py b/examples/websocket/spot/symbol_kline.py index 12aa45be..ecd0aa5e 100644 --- a/examples/websocket/spot/symbol_kline.py +++ b/examples/websocket/spot/symbol_kline.py @@ -19,7 +19,9 @@ def message_handler(message): time.sleep(5) -my_client.kline(symbol="bnbusdt", id=2, interval="3m", callback=message_handler) +my_client.kline( + symbol=["bnbusdt", "ethusdt"], id=2, interval="3m", callback=message_handler +) time.sleep(10) diff --git a/examples/websocket/spot/symbol_mini_ticker.py b/examples/websocket/spot/symbol_mini_ticker.py index 9051274d..4facb451 100644 --- a/examples/websocket/spot/symbol_mini_ticker.py +++ b/examples/websocket/spot/symbol_mini_ticker.py @@ -24,7 +24,7 @@ def message_handler(message): time.sleep(2) my_client.mini_ticker( - symbol="btcusdt", + symbol=["btcusdt", "ethusdt"], id=2, callback=message_handler, ) diff --git a/examples/websocket/spot/test.py b/examples/websocket/spot/test.py index 95d03972..f453d9a5 100644 --- a/examples/websocket/spot/test.py +++ b/examples/websocket/spot/test.py @@ -24,7 +24,7 @@ def message_handler(message): time.sleep(1) my_client.agg_trade( - symbol="bnbusdt", + symbol=["bnbusdt", "ethusdt"], id=2, callback=message_handler, ) diff --git a/examples/websocket/spot/trade.py b/examples/websocket/spot/trade.py index b5463059..2eefba7c 100644 --- a/examples/websocket/spot/trade.py +++ b/examples/websocket/spot/trade.py @@ -25,7 +25,7 @@ def message_handler(message): time.sleep(2) my_client.trade( - symbol="eosusdt", + symbol=["eosusdt", "ltcusdt"], interval="1m", id=2, callback=message_handler, diff --git a/examples/websocket/spot/user_data.py b/examples/websocket/spot/user_data.py index 6eb2ced8..d15e7495 100644 --- a/examples/websocket/spot/user_data.py +++ b/examples/websocket/spot/user_data.py @@ -5,7 +5,10 @@ from binance.lib.utils import config_logging from binance.spot import Spot as Client from binance.websocket.spot.websocket_client import SpotWebsocketClient +from configparser import ConfigParser +config = ConfigParser() +config.read("../../config.ini") config_logging(logging, logging.DEBUG) @@ -14,7 +17,7 @@ def message_handler(message): print(message) -api_key = "" +api_key = config["keys"]["api_key"] client = Client(api_key, base_url="https://testnet.binance.vision") response = client.new_listen_key() diff --git a/requirements/requirements-dev.txt b/requirements/requirements-dev.txt index 629d3954..583285fa 100644 --- a/requirements/requirements-dev.txt +++ b/requirements/requirements-dev.txt @@ -1,4 +1,5 @@ -r requirements-test.txt pre-commit sphinx -sphinx_rtd_theme \ No newline at end of file +sphinx_rtd_theme +configparser>=5.3.0 \ No newline at end of file diff --git a/tests/spot/margin/test_summary_of_margin_account.py b/tests/spot/margin/test_summary_of_margin_account.py new file mode 100644 index 00000000..22db6e1f --- /dev/null +++ b/tests/spot/margin/test_summary_of_margin_account.py @@ -0,0 +1,28 @@ +import responses + +from binance.spot import Spot as Client +from tests.util import random_str +from urllib.parse import urlencode +from tests.util import mock_http_response + +mock_item = {"key_1": "value_1", "key_2": "value_2"} +mock_exception = {"code": -1, "msg": "error message"} + +key = random_str() +secret = random_str() + +params = {"recvWindow": 5000} + + +@mock_http_response( + responses.GET, + "/sapi/v1/margin/tradeCoeff\\?" + urlencode(params), + mock_item, + 200, +) +def test_summary_of_margin_account(): + """Tests the API endpoint to margin dustlog""" + + client = Client(key, secret) + response = client.summary_of_margin_account(**params) + response.should.equal(mock_item) From e0c8d29985989cbd8d27560e51a50a89bc268264 Mon Sep 17 00:00:00 2001 From: jonte-z Date: Fri, 16 Dec 2022 17:16:29 +1100 Subject: [PATCH 6/6] deleted removed endpoint tests/examples --- .../futures/futures_loan_adjust_collateral.py | 17 ----- examples/spot/futures/futures_loan_borrow.py | 15 ---- .../futures/futures_loan_calc_adjust_level.py | 17 ----- .../futures_loan_calc_max_adjust_amount.py | 15 ---- .../futures/futures_loan_collateral_repay.py | 15 ---- .../futures_loan_collateral_repay_limit.py | 15 ---- .../futures_loan_collateral_repay_quote.py | 17 ----- .../futures_loan_collateral_repay_result.py | 17 ----- examples/spot/futures/futures_loan_configs.py | 13 ---- examples/spot/futures/futures_loan_repay.py | 13 ---- .../test_futures_loan_adjust_collateral.py | 73 ------------------- .../spot/futures/test_futures_loan_borrow.py | 51 ------------- .../test_futures_loan_calc_adjust_level.py | 72 ------------------ ...est_futures_loan_calc_max_adjust_amount.py | 44 ----------- .../test_futures_loan_collateral_repay.py | 39 ---------- ...est_futures_loan_collateral_repay_limit.py | 55 -------------- ...est_futures_loan_collateral_repay_quote.py | 63 ---------------- ...st_futures_loan_collateral_repay_result.py | 41 ----------- .../spot/futures/test_futures_loan_configs.py | 19 ----- tests/spot/futures/test_futures_loan_repay.py | 56 -------------- 20 files changed, 667 deletions(-) delete mode 100644 examples/spot/futures/futures_loan_adjust_collateral.py delete mode 100644 examples/spot/futures/futures_loan_borrow.py delete mode 100644 examples/spot/futures/futures_loan_calc_adjust_level.py delete mode 100644 examples/spot/futures/futures_loan_calc_max_adjust_amount.py delete mode 100644 examples/spot/futures/futures_loan_collateral_repay.py delete mode 100644 examples/spot/futures/futures_loan_collateral_repay_limit.py delete mode 100644 examples/spot/futures/futures_loan_collateral_repay_quote.py delete mode 100644 examples/spot/futures/futures_loan_collateral_repay_result.py delete mode 100644 examples/spot/futures/futures_loan_configs.py delete mode 100644 examples/spot/futures/futures_loan_repay.py delete mode 100644 tests/spot/futures/test_futures_loan_adjust_collateral.py delete mode 100644 tests/spot/futures/test_futures_loan_borrow.py delete mode 100644 tests/spot/futures/test_futures_loan_calc_adjust_level.py delete mode 100644 tests/spot/futures/test_futures_loan_calc_max_adjust_amount.py delete mode 100644 tests/spot/futures/test_futures_loan_collateral_repay.py delete mode 100644 tests/spot/futures/test_futures_loan_collateral_repay_limit.py delete mode 100644 tests/spot/futures/test_futures_loan_collateral_repay_quote.py delete mode 100644 tests/spot/futures/test_futures_loan_collateral_repay_result.py delete mode 100644 tests/spot/futures/test_futures_loan_configs.py delete mode 100644 tests/spot/futures/test_futures_loan_repay.py diff --git a/examples/spot/futures/futures_loan_adjust_collateral.py b/examples/spot/futures/futures_loan_adjust_collateral.py deleted file mode 100644 index 0ecbe6e1..00000000 --- a/examples/spot/futures/futures_loan_adjust_collateral.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python - -import logging -from binance.spot import Spot as Client -from binance.lib.utils import config_logging - -config_logging(logging, logging.DEBUG) - -api_key = "" -api_secret = "" - -client = Client(api_key, api_secret) -logging.info( - client.futures_loan_adjust_collateral( - loanCoin="BNB", collateralCoin="BTC", amount=1, direction="ADDITIONAL" - ) -) diff --git a/examples/spot/futures/futures_loan_borrow.py b/examples/spot/futures/futures_loan_borrow.py deleted file mode 100644 index 66147f01..00000000 --- a/examples/spot/futures/futures_loan_borrow.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import logging -from binance.spot import Spot as Client -from binance.lib.utils import config_logging - -config_logging(logging, logging.DEBUG) - -api_key = "" -api_secret = "" - -client = Client(api_key, api_secret) -logging.info( - client.futures_loan_borrow(coin="USDT", collateralCoin="BUSD", amount="0.01") -) diff --git a/examples/spot/futures/futures_loan_calc_adjust_level.py b/examples/spot/futures/futures_loan_calc_adjust_level.py deleted file mode 100644 index a26f51c0..00000000 --- a/examples/spot/futures/futures_loan_calc_adjust_level.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python - -import logging -from binance.spot import Spot as Client -from binance.lib.utils import config_logging - -config_logging(logging, logging.DEBUG) - -api_key = "" -api_secret = "" - -client = Client(api_key, api_secret) -logging.info( - client.futures_loan_calc_adjust_level( - loanCoin="BNB", collateralCoin="BTC", amount=1, direction="ADDITIONAL" - ) -) diff --git a/examples/spot/futures/futures_loan_calc_max_adjust_amount.py b/examples/spot/futures/futures_loan_calc_max_adjust_amount.py deleted file mode 100644 index f0910822..00000000 --- a/examples/spot/futures/futures_loan_calc_max_adjust_amount.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import logging -from binance.spot import Spot as Client -from binance.lib.utils import config_logging - -config_logging(logging, logging.DEBUG) - -api_key = "" -api_secret = "" - -client = Client(api_key, api_secret) -logging.info( - client.futures_loan_calc_max_adjust_amount(loanCoin="BNB", collateralCoin="BTC") -) diff --git a/examples/spot/futures/futures_loan_collateral_repay.py b/examples/spot/futures/futures_loan_collateral_repay.py deleted file mode 100644 index dd7502e1..00000000 --- a/examples/spot/futures/futures_loan_collateral_repay.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import logging -from binance.spot import Spot as Client -from binance.lib.utils import config_logging - -config_logging(logging, logging.DEBUG) - -api_key = "" -api_secret = "" - -client = Client(api_key, api_secret) -logging.info( - client.futures_loan_collateral_repay(quoteId="3eece81ca2734042b2f538ea0d9cbdd3") -) diff --git a/examples/spot/futures/futures_loan_collateral_repay_limit.py b/examples/spot/futures/futures_loan_collateral_repay_limit.py deleted file mode 100644 index 24a74130..00000000 --- a/examples/spot/futures/futures_loan_collateral_repay_limit.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python - -import logging -from binance.spot import Spot as Client -from binance.lib.utils import config_logging - -config_logging(logging, logging.DEBUG) - -api_key = "" -api_secret = "" - -client = Client(api_key, api_secret) -logging.info( - client.futures_loan_collateral_repay_limit(coin="USDT", collateralCoin="BTC") -) diff --git a/examples/spot/futures/futures_loan_collateral_repay_quote.py b/examples/spot/futures/futures_loan_collateral_repay_quote.py deleted file mode 100644 index 663f5494..00000000 --- a/examples/spot/futures/futures_loan_collateral_repay_quote.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python - -import logging -from binance.spot import Spot as Client -from binance.lib.utils import config_logging - -config_logging(logging, logging.DEBUG) - -api_key = "" -api_secret = "" - -client = Client(api_key, api_secret) -logging.info( - client.futures_loan_collateral_repay_quote( - coin="USDT", collateralCoin="BTC", amount=0.00222 - ) -) diff --git a/examples/spot/futures/futures_loan_collateral_repay_result.py b/examples/spot/futures/futures_loan_collateral_repay_result.py deleted file mode 100644 index c2047dc2..00000000 --- a/examples/spot/futures/futures_loan_collateral_repay_result.py +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env python - -import logging -from binance.spot import Spot as Client -from binance.lib.utils import config_logging - -config_logging(logging, logging.DEBUG) - -api_key = "" -api_secret = "" - -client = Client(api_key, api_secret) -logging.info( - client.futures_loan_collateral_repay_result( - quoteId="3eece81ca2734042b2f538ea0d9cbdd3" - ) -) diff --git a/examples/spot/futures/futures_loan_configs.py b/examples/spot/futures/futures_loan_configs.py deleted file mode 100644 index 947d2c35..00000000 --- a/examples/spot/futures/futures_loan_configs.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python - -import logging -from binance.spot import Spot as Client -from binance.lib.utils import config_logging - -config_logging(logging, logging.DEBUG) - -api_key = "" -api_secret = "" - -client = Client(api_key, api_secret) -logging.info(client.futures_loan_configs(collateralCoin="BTC")) diff --git a/examples/spot/futures/futures_loan_repay.py b/examples/spot/futures/futures_loan_repay.py deleted file mode 100644 index d8645bbc..00000000 --- a/examples/spot/futures/futures_loan_repay.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python - -import logging -from binance.spot import Spot as Client -from binance.lib.utils import config_logging - -config_logging(logging, logging.DEBUG) - -api_key = "" -api_secret = "" - -client = Client(api_key, api_secret) -logging.info(client.futures_loan_repay(coin="BTC", collateralCoin="USDT", amount="1")) diff --git a/tests/spot/futures/test_futures_loan_adjust_collateral.py b/tests/spot/futures/test_futures_loan_adjust_collateral.py deleted file mode 100644 index 3d618fe0..00000000 --- a/tests/spot/futures/test_futures_loan_adjust_collateral.py +++ /dev/null @@ -1,73 +0,0 @@ -import responses -import pytest - -from urllib.parse import urlencode -from tests.util import random_str -from tests.util import mock_http_response -from binance.spot import Spot as Client -from binance.error import ParameterRequiredError - -mock_item = {"key_1": "value_1", "key_2": "value_2"} - -key = random_str() -secret = random_str() - -complete_params = { - "loanCoin": "BTC", - "collateralCoin": "BNB", - "amount": "1", - "direction": "ADDITIONAL", -} - -parameterized_test_data = [ - ({"loanCoin": None, "collateralCoin": None, "amount": None, "direction": None}), - ( - { - "loanCoin": "", - "collateralCoin": "BTC", - "amount": "1", - "direction": "ADDITIONAL", - } - ), - ( - { - "loanCoin": "BNB", - "collateralCoin": "", - "amount": "1", - "direction": "ADDITIONAL", - } - ), - ( - { - "loanCoin": "BNB", - "collateralCoin": "BTC", - "amount": "", - "direction": "ADDITIONAL", - } - ), - ({"loanCoin": "BNB", "collateralCoin": "BTC", "amount": "1", "direction": ""}), -] - - -@pytest.mark.parametrize("params", parameterized_test_data) -def test_futures_loan_adjust_collateral_with_missing_field(params): - """Tests the API endpoint to Adjust Cross-Collateral LTV with missing field""" - - client = Client(key, secret) - client.futures_loan_adjust_collateral.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -@mock_http_response( - responses.POST, - "/sapi/v2/futures/loan/adjustCollateral\\?" + urlencode(complete_params), - mock_item, - 200, -) -def test_futures_loan_adjust_collateral(): - """Tests the API endpoint to Adjust Cross-Collateral LTV""" - - client = Client(key, secret) - response = client.futures_loan_adjust_collateral(**complete_params) - response.should.equal(mock_item) diff --git a/tests/spot/futures/test_futures_loan_borrow.py b/tests/spot/futures/test_futures_loan_borrow.py deleted file mode 100644 index 80ce9415..00000000 --- a/tests/spot/futures/test_futures_loan_borrow.py +++ /dev/null @@ -1,51 +0,0 @@ -import responses - -from urllib.parse import urlencode -from tests.util import random_str -from tests.util import mock_http_response -from binance.spot import Spot as Client -from binance.error import ParameterRequiredError - -mock_item = {"key_1": "value_1", "key_2": "value_2"} -mock_exception = {"code": -1105, "msg": "error message."} - -key = random_str() -secret = random_str() - -params = {"coin": "USDT", "collateralCoin": "BTC", "amount": "1"} - - -def test_futures_loan_borrow_without_coin(): - """Tests the API endpoint to borrow cross funds without coin""" - - params = {"coin": "", "collateralCoin": "BTC"} - - client = Client(key, secret) - client.futures_loan_borrow.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -def test_futures_loan_borrow_without_collateralCoin(): - """Tests the API endpoint to borrow cross funds without collateralCoin""" - - params = {"coin": "USDT", "collateralCoin": ""} - - client = Client(key, secret) - client.futures_loan_borrow.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -@mock_http_response( - responses.POST, - "/sapi/v1/futures/loan/borrow\\?" + urlencode(params), - mock_item, - 200, -) -def test_futures_loan_borrow(): - """Tests the API endpoint to borrow cross funds""" - - client = Client(key, secret) - response = client.futures_loan_borrow(**params) - response.should.equal(mock_item) diff --git a/tests/spot/futures/test_futures_loan_calc_adjust_level.py b/tests/spot/futures/test_futures_loan_calc_adjust_level.py deleted file mode 100644 index e2c9bb67..00000000 --- a/tests/spot/futures/test_futures_loan_calc_adjust_level.py +++ /dev/null @@ -1,72 +0,0 @@ -import responses -import pytest - -from urllib.parse import urlencode -from tests.util import random_str -from tests.util import mock_http_response -from binance.spot import Spot as Client -from binance.error import ParameterRequiredError - -mock_item = {"key_1": "value_1", "key_2": "value_2"} - -key = random_str() -secret = random_str() - -complete_params = { - "loanCoin": "BNB", - "collateralCoin": "BTC", - "amount": "1", - "direction": "ADDITIONAL", -} - -parameterized_test_data = [ - ({"loanCoin": None, "collateralCoin": None, "amount": None, "direction": None}), - ( - { - "loanCoin": "", - "collateralCoin": "BTC", - "amount": "1", - "direction": "ADDITIONAL", - } - ), - ( - { - "loanCoin": "BNB", - "collateralCoin": "", - "amount": "1", - "direction": "ADDITIONAL", - } - ), - ( - { - "loanCoin": "BNB", - "collateralCoin": "BTC", - "amount": "", - "direction": "ADDITIONAL", - } - ), - ({"loanCoin": "BNB", "collateralCoin": "BTC", "amount": "1", "direction": ""}), -] - - -@pytest.mark.parametrize("params", parameterized_test_data) -def test_futures_loan_calc_adjust_level_with_missing_field(params): - """Tests the API endpoint to get adjust level with missing mandatory field""" - client = Client(key, secret) - client.futures_loan_calc_adjust_level.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -@mock_http_response( - responses.GET, - "/sapi/v2/futures/loan/calcAdjustLevel\\?" + urlencode(complete_params), - mock_item, - 200, -) -def test_futures_loan_calc_adjust_level(): - """Tests the API endpoint to get adjust level""" - - client = Client(key, secret) - response = client.futures_loan_calc_adjust_level(**complete_params) - response.should.equal(mock_item) diff --git a/tests/spot/futures/test_futures_loan_calc_max_adjust_amount.py b/tests/spot/futures/test_futures_loan_calc_max_adjust_amount.py deleted file mode 100644 index ba587cf2..00000000 --- a/tests/spot/futures/test_futures_loan_calc_max_adjust_amount.py +++ /dev/null @@ -1,44 +0,0 @@ -import responses -import pytest - -from urllib.parse import urlencode -from tests.util import random_str -from tests.util import mock_http_response -from binance.spot import Spot as Client -from binance.error import ParameterRequiredError - -mock_item = {"key_1": "value_1", "key_2": "value_2"} - -key = random_str() -secret = random_str() - -params = {"loanCoin": "BNB", "collateralCoin": "BTC"} - -parameterized_test_data = [ - ({"loanCoin": "BNB", "collateralCoin": ""}), - ({"loanCoin": "", "collateralCoin": "BTC"}), -] - - -@pytest.mark.parametrize("params", parameterized_test_data) -def test_futures_loan_calc_max_adjust_amount_with_missing_field(params): - """Tests the API endpoint to Adjust Cross-Collateral LTV without collateralCoin""" - - client = Client(key, secret) - client.futures_loan_calc_max_adjust_amount.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -@mock_http_response( - responses.GET, - "/sapi/v2/futures/loan/calcMaxAdjustAmount\\?" + urlencode(params), - mock_item, - 200, -) -def test_futures_loan_calc_max_adjust_amount(): - """Tests the API endpoint to get Adjust Cross-Collateral LTV""" - - client = Client(key, secret) - response = client.futures_loan_calc_max_adjust_amount(**params) - response.should.equal(mock_item) diff --git a/tests/spot/futures/test_futures_loan_collateral_repay.py b/tests/spot/futures/test_futures_loan_collateral_repay.py deleted file mode 100644 index 7ec5c8b0..00000000 --- a/tests/spot/futures/test_futures_loan_collateral_repay.py +++ /dev/null @@ -1,39 +0,0 @@ -import responses - -from urllib.parse import urlencode -from tests.util import random_str -from tests.util import mock_http_response -from binance.spot import Spot as Client -from binance.error import ParameterRequiredError - -mock_item = {"key_1": "value_1", "key_2": "value_2"} -mock_exception = {"code": -1105, "msg": "error message."} - -key = random_str() -secret = random_str() - -params = {"quoteId": "3eece81ca2734042b2f538ea0d9cbdd3"} - - -def test_futures_loan_collateral_repay_without_quoteId(): - """Tests the API endpoint to Repay with Collateral without quoteId""" - - params = {"quoteId": ""} - client = Client(key, secret) - client.futures_loan_collateral_repay.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -@mock_http_response( - responses.POST, - "/sapi/v1/futures/loan/collateralRepay\\?" + urlencode(params), - mock_item, - 200, -) -def test_futures_loan_collateral_repay(): - """Tests the API endpoint to Repay with Collateral""" - - client = Client(key, secret) - response = client.futures_loan_collateral_repay(**params) - response.should.equal(mock_item) diff --git a/tests/spot/futures/test_futures_loan_collateral_repay_limit.py b/tests/spot/futures/test_futures_loan_collateral_repay_limit.py deleted file mode 100644 index 54cce466..00000000 --- a/tests/spot/futures/test_futures_loan_collateral_repay_limit.py +++ /dev/null @@ -1,55 +0,0 @@ -import responses - -from urllib.parse import urlencode -from tests.util import random_str -from tests.util import mock_http_response -from binance.spot import Spot as Client -from binance.error import ParameterRequiredError - -mock_item = {"key_1": "value_1", "key_2": "value_2"} -mock_exception = {"code": -1105, "msg": "error message."} - -key = random_str() -secret = random_str() - -params = {"coin": "USDT", "collateralCoin": "BTC"} - - -def test_futures_loan_collateral_repay_limit_without_coin(): - """Tests the API endpoint to Check Collateral Repay Limit without coin""" - - params = { - "coin": "", - "collateralCoin": "BTC", - } - client = Client(key, secret) - client.futures_loan_collateral_repay_limit.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -def test_futures_loan_collateral_repay_limit_without_collateralCoin(): - """Tests the API endpoint to Check Collateral Repay Limit without collateralCoin""" - - params = { - "coin": "USDT", - "collateralCoin": "", - } - client = Client(key, secret) - client.futures_loan_collateral_repay_limit.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -@mock_http_response( - responses.GET, - "/sapi/v1/futures/loan/collateralRepayLimit\\?" + urlencode(params), - mock_item, - 200, -) -def test_futures_loan_collateral_repay_limit(): - """Tests the API endpoint to Check Collateral Repay Limit""" - - client = Client(key, secret) - response = client.futures_loan_collateral_repay_limit(**params) - response.should.equal(mock_item) diff --git a/tests/spot/futures/test_futures_loan_collateral_repay_quote.py b/tests/spot/futures/test_futures_loan_collateral_repay_quote.py deleted file mode 100644 index 72449783..00000000 --- a/tests/spot/futures/test_futures_loan_collateral_repay_quote.py +++ /dev/null @@ -1,63 +0,0 @@ -import responses - -from urllib.parse import urlencode -from tests.util import random_str -from tests.util import mock_http_response -from binance.spot import Spot as Client -from binance.error import ParameterRequiredError - -mock_item = {"key_1": "value_1", "key_2": "value_2"} -mock_exception = {"code": -1105, "msg": "error message."} - -key = random_str() -secret = random_str() - -params = {"coin": "USDT", "collateralCoin": "BTC", "amount": "0.00222"} - - -def test_futures_loan_collateral_repay_quote_without_coin(): - """Tests the API endpoint to Get Collateral Repay Quote without coin""" - - params = { - "coin": "", - "collateralCoin": "BTC", - "amount": "0.00222", - } - client = Client(key, secret) - client.futures_loan_collateral_repay_quote.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -def test_futures_loan_collateral_repay_quote_without_collateralCoin(): - """Tests the API endpoint to Get Collateral Repay Quote without collateralCoin""" - - params = {"coin": "USDT", "collateralCoin": "", "amount": "0.00222"} - client = Client(key, secret) - client.futures_loan_collateral_repay_quote.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -def test_futures_loan_collateral_repay_quote_without_amount(): - """Tests the API endpoint to Get Collateral Repay Quote without amount""" - - params = {"coin": "USDT", "collateralCoin": "", "amount": ""} - client = Client(key, secret) - client.futures_loan_collateral_repay_quote.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -@mock_http_response( - responses.GET, - "/sapi/v1/futures/loan/collateralRepay\\?" + urlencode(params), - mock_item, - 200, -) -def test_futures_loan_collateral_repay_quote(): - """Tests the API endpoint to Get Collateral Repay Quote""" - - client = Client(key, secret) - response = client.futures_loan_collateral_repay_quote(**params) - response.should.equal(mock_item) diff --git a/tests/spot/futures/test_futures_loan_collateral_repay_result.py b/tests/spot/futures/test_futures_loan_collateral_repay_result.py deleted file mode 100644 index 3ec1e65f..00000000 --- a/tests/spot/futures/test_futures_loan_collateral_repay_result.py +++ /dev/null @@ -1,41 +0,0 @@ -import responses - -from urllib.parse import urlencode -from tests.util import random_str -from tests.util import mock_http_response -from binance.spot import Spot as Client -from binance.error import ParameterRequiredError - -mock_item = {"key_1": "value_1", "key_2": "value_2"} -mock_exception = {"code": -1105, "msg": "error message."} - -key = random_str() -secret = random_str() - -params = { - "quoteId": "3eece81ca2734042b2f538ea0d9cbdd3", -} - - -def test_futures_loan_collateral_repay_result_without_quoteId(): - """Tests the API endpoint to get Collateral Repayment Result without quoteId""" - - params = {"quoteId": ""} - client = Client(key, secret) - client.futures_loan_collateral_repay_result.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -@mock_http_response( - responses.GET, - "/sapi/v1/futures/loan/collateralRepayResult\\?" + urlencode(params), - mock_item, - 200, -) -def test_futures_loan_collateral_repay_result(): - """Tests the API endpoint to get Collateral Repayment Result""" - - client = Client(key, secret) - response = client.futures_loan_collateral_repay_result(**params) - response.should.equal(mock_item) diff --git a/tests/spot/futures/test_futures_loan_configs.py b/tests/spot/futures/test_futures_loan_configs.py deleted file mode 100644 index a966eee5..00000000 --- a/tests/spot/futures/test_futures_loan_configs.py +++ /dev/null @@ -1,19 +0,0 @@ -import responses - -from tests.util import random_str -from tests.util import mock_http_response -from binance.spot import Spot as Client - -mock_item = {"key_1": "value_1", "key_2": "value_2"} - -key = random_str() -secret = random_str() - - -@mock_http_response(responses.GET, "/sapi/v2/futures/loan/configs", mock_item, 200) -def test_futures_loan_configs(): - """Tests the API endpoint to get loan configs""" - - client = Client(key, secret) - response = client.futures_loan_configs() - response.should.equal(mock_item) diff --git a/tests/spot/futures/test_futures_loan_repay.py b/tests/spot/futures/test_futures_loan_repay.py deleted file mode 100644 index 9f0f951c..00000000 --- a/tests/spot/futures/test_futures_loan_repay.py +++ /dev/null @@ -1,56 +0,0 @@ -import responses - -from urllib.parse import urlencode -from tests.util import random_str -from tests.util import mock_http_response -from binance.spot import Spot as Client -from binance.error import ParameterRequiredError - -mock_item = {"key_1": "value_1", "key_2": "value_2"} -mock_exception = {"code": -1105, "msg": "error message."} - -key = random_str() -secret = random_str() - -params = {"coin": "BTC", "collateralCoin": "BNB", "amount": "1"} - - -def test_futures_loan_repay_without_coin(): - """Tests the API endpoint to repay futures loan without coin""" - - params = {"coin": "", "collateralCoin": "BNB", "amount": "1"} - client = Client(key, secret) - client.futures_loan_repay.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -def test_futures_loan_repay_without_collateralCoin(): - """Tests the API endpoint to repay futures loan without collateralCoin""" - - params = {"coin": "BTC", "collateralCoin": "", "amount": "1"} - client = Client(key, secret) - client.futures_loan_repay.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -def test_futures_loan_repay_without_amount(): - """Tests the API endpoint to repay futures loan without amount""" - - params = {"coin": "BTC", "collateralCoin": "BNB", "amount": ""} - client = Client(key, secret) - client.futures_loan_repay.when.called_with(**params).should.throw( - ParameterRequiredError - ) - - -@mock_http_response( - responses.POST, "/sapi/v1/futures/loan/repay\\?" + urlencode(params), mock_item, 200 -) -def test_futures_loan_repay(): - """Tests the API endpoint to repay futures loan""" - - client = Client(key, secret) - response = client.futures_loan_repay(**params) - response.should.equal(mock_item)