Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
# Changelog

## 3.10.0 - 2024-11-29
### Added
- Margin
- `POST /sapi/v1/margin/order/oto`
- `POST /sapi/v1/margin/order/otoco`

- Portfolio
- `GET /sapi/v2/portfolio/account`
- `GET /sapi/v1/portfolio/balance`
- `GET /sapi/v2/portfolio/collateralRate`

- Simple Earn
- `POST /sapi/v1/simple-earn/locked/setRedeemOption`

- Staking
- `GET /sapi/v2/eth-staking/account`
- `GET /sapi/v1/eth-staking/eth/quota`
- `POST /sapi/v2/eth-staking/eth/stake`
- `POST /sapi/v1/eth-staking/eth/redeem`
- `POST /sapi/v1/eth-staking/wbeth/wrap`
- `GET /sapi/v1/eth-staking/eth/history/stakingHistory`
- `GET /sapi/v1/eth-staking/eth/history/redemptionHistory`
- `GET /sapi/v1/eth-staking/eth/history/rewardsHistory`
- `GET /sapi/v1/eth-staking/eth/history/wbethRewardsHistory`
- `GET /sapi/v1/eth-staking/eth/history/rateHistory`
- `GET /sapi/v1/eth-staking/wbeth/history/wrapHistory`
- `GET /sapi/v1/eth-staking/wbeth/history/unwrapHistory`

- Wallet
- `POST /sapi/v1/localentity/withdraw/apply`
- `GET /sapi/v1/localentity/withdraw/history`
- `PUT /sapi/v1/localentity/deposit/provide-info`
- `GET /sapi/v1/localentity/deposit/history`

- Websocket Stream
- `<symbol>kline_<interval>+08:00`

### Updated
- Add parameters showPermissionSets and symbolStatus to `GET /api/v3/exchangeInfo`
- Add parameter timeZone to `GET /api/v3/klines`, `GET /api/v3/uiKlines`, `klines` and `uiKlines`
- Add parameter redeemTo to `POST /sapi/v1/simple-earn/locked/subscribe`
- Add parameters `txId` and `includeSource` to `GET /sapi/v1/capital/deposit/hisrec`
- Add parameter `idList` to `GET /sapi/v1/capital/withdraw/history` and `GET /sapi/v1/capital/deposit/subHisrec`
- Update Documentation
- Update `JSONDecodeError` error response

### Removed
- Crypto-loans
- `GET /sapi/v1/loan/collateral/data`
- `POST /sapi/v1/loan/borrow`
- `POST /sapi/v1/loan/repay`
- `POST /sapi/v1/loan/adjust/ltv`
- `POST /sapi/v1/loan/customize/margin_call`
- `GET /sapi/v1/loan/ongoing/orders`


## 3.9.0 - 2024-10-02

### Removed
Expand Down
2 changes: 1 addition & 1 deletion binance/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.9.0"
__version__ = "3.10.0"
2 changes: 1 addition & 1 deletion binance/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _handle_exception(self, response):
err = json.loads(response.text)
except JSONDecodeError:
raise ClientError(
status_code, None, response.text, None, response.headers
status_code, None, response.text, response.headers, None
)
error_data = None
if "data" in err:
Expand Down
30 changes: 24 additions & 6 deletions binance/spot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def __init__(self, api_key=None, api_secret=None, **kwargs):
from binance.spot._margin import adjust_cross_margin_max_leverage
from binance.spot._margin import margin_available_inventory
from binance.spot._margin import margin_manual_liquidation
from binance.spot._margin import margin_new_oto_order
from binance.spot._margin import margin_new_otoco_order
from binance.spot._margin import liability_coin_leverage_bracket

# WALLET
Expand All @@ -126,6 +128,10 @@ def __init__(self, api_key=None, api_secret=None, **kwargs):
from binance.spot._wallet import funding_wallet
from binance.spot._wallet import user_asset
from binance.spot._wallet import api_key_permissions
from binance.spot._wallet import local_entity_withdraw
from binance.spot._wallet import local_entity_withdraw_history
from binance.spot._wallet import local_entity_submit_deposit_questionnaire
from binance.spot._wallet import local_entity_deposit_history
from binance.spot._wallet import bnb_convertible_assets
from binance.spot._wallet import list_deposit_address
from binance.spot._wallet import cloud_mining_trans_history
Expand Down Expand Up @@ -206,21 +212,15 @@ def __init__(self, api_key=None, api_secret=None, **kwargs):

# Crypto LOANS
from binance.spot._crypto_loan import loan_history
from binance.spot._crypto_loan import loan_borrow
from binance.spot._crypto_loan import loan_borrow_history
from binance.spot._crypto_loan import loan_ongoing_orders
from binance.spot._crypto_loan import loan_repay
from binance.spot._crypto_loan import loan_repay_history
from binance.spot._crypto_loan import loan_adjust_ltv
from binance.spot._crypto_loan import loan_adjust_ltv_history
from binance.spot._crypto_loan import loan_vip_ongoing_orders
from binance.spot._crypto_loan import loan_vip_repay
from binance.spot._crypto_loan import loan_vip_repay_history
from binance.spot._crypto_loan import loan_vip_collateral_account
from binance.spot._crypto_loan import loan_loanable_data
from binance.spot._crypto_loan import loan_collateral_data
from binance.spot._crypto_loan import loan_collateral_rate
from binance.spot._crypto_loan import loan_customize_margin_call

# PAY
from binance.spot._pay import pay_history
Expand Down Expand Up @@ -256,11 +256,14 @@ def __init__(self, api_key=None, api_secret=None, **kwargs):
# Portfolio Margin
from binance.spot._portfolio_margin import portfolio_margin_account
from binance.spot._portfolio_margin import portfolio_margin_collateral_rate
from binance.spot._portfolio_margin import portfolio_margin_tiered_collateral_rate
from binance.spot._portfolio_margin import portfolio_margin_bankruptcy_loan_amount
from binance.spot._portfolio_margin import portfolio_margin_bankruptcy_loan_repay
from binance.spot._portfolio_margin import (
query_classic_portfolio_margin_negative_balance_interest_history,
)
from binance.spot._portfolio_margin import get_portfolio_margin_span_account_info
from binance.spot._portfolio_margin import get_portfolio_margin_account_balance
from binance.spot._portfolio_margin import query_portfolio_margin_asset_index_price
from binance.spot._portfolio_margin import fund_auto_collection
from binance.spot._portfolio_margin import bnb_transfer
Expand Down Expand Up @@ -291,6 +294,7 @@ def __init__(self, api_key=None, api_secret=None, **kwargs):
from binance.spot._simple_earn import get_locked_personal_left_quota
from binance.spot._simple_earn import get_flexible_subscription_preview
from binance.spot._simple_earn import get_locked_subscription_preview
from binance.spot._simple_earn import set_locked_product_redeem_option
from binance.spot._simple_earn import get_rate_history
from binance.spot._simple_earn import get_collateral_record

Expand All @@ -310,3 +314,17 @@ def __init__(self, api_key=None, api_secret=None, **kwargs):
from binance.spot._auto_invest import index_linked_plan_redemption
from binance.spot._auto_invest import get_index_linked_plan_redemption_history
from binance.spot._auto_invest import index_linked_plan_rebalance_details

# Staking
from binance.spot._staking import eth_staking_account
from binance.spot._staking import get_eth_staking_quota
from binance.spot._staking import subscribe_eth_staking
from binance.spot._staking import redeem_eth
from binance.spot._staking import wrap_beth
from binance.spot._staking import get_eth_staking_history
from binance.spot._staking import get_eth_redemption_history
from binance.spot._staking import get_beth_rewards_distribution_history
from binance.spot._staking import get_wbeth_rewards_history
from binance.spot._staking import get_wbeth_rate_history
from binance.spot._staking import get_wbeth_wrap_history
from binance.spot._staking import get_wbeth_unwrap_history
135 changes: 0 additions & 135 deletions binance/spot/_crypto_loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,40 +26,6 @@ def loan_history(self, asset: str, **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://developers.binance.com/docs/crypto_loan/stable-rate/trade/Crypto-Loan-Borrow

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)

Expand All @@ -81,47 +47,6 @@ def loan_borrow_history(self, **kwargs):
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://developers.binance.com/docs/crypto_loan/stable-rate/user-information/Get-Loan-Ongoing-Orders

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://developers.binance.com/docs/crypto_loan/stable-rate/trade/Crypto-Loan-Repay

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)

Expand All @@ -143,29 +68,6 @@ def loan_repay_history(self, **kwargs):
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://developers.binance.com/docs/crypto_loan/stable-rate/trade/Crypto-Loan-Adjust-LTV

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)

Expand Down Expand Up @@ -279,22 +181,6 @@ def loan_loanable_data(self, **kwargs):
return self.sign_request("GET", "/sapi/v1/loan/loanable/data", kwargs)


def loan_collateral_data(self, **kwargs):
"""Get Collateral Assets Data (USER_DATA)

GET /sapi/v1/loan/collateral/data

https://developers.binance.com/docs/crypto_loan/stable-rate/market-data/Get-Collateral-Assets-Data

Keyword Args:
collateralCoin (str, optional)
vipLevel (int, optional)
recvWindow (int, optional): The value cannot be greater than 60000
"""

return self.sign_request("GET", "/sapi/v1/loan/collateral/data", kwargs)


def loan_collateral_rate(
self, loanCoin: str, collateralCoin: str, repayAmount: float, **kwargs
):
Expand Down Expand Up @@ -327,24 +213,3 @@ def loan_collateral_rate(
**kwargs,
}
return self.sign_request("GET", "/sapi/v1/loan/repay/collateral/rate", payload)


def loan_customize_margin_call(self, marginCall: float, **kwargs):
"""Customize Margin Call (USER_DATA)

POST /sapi/v1/loan/customize/margin_call

https://developers.binance.com/docs/crypto_loan/stable-rate/trade/Crypto-Loan-Customize-Margin-Call

Args:
marginCall (float)
Keyword Args:
orderId (int, optional)
collateralCoin (str, optional)
recvWindow (int, optional): The value cannot be greater than 60000
"""

check_required_parameter(marginCall, "marginCall")

payload = {"marginCall": marginCall, **kwargs}
return self.sign_request("POST", "/sapi/v1/loan/customize/margin_call", payload)
Loading
Loading