Skip to content

Commit

Permalink
v2.0.0rc3 release
Browse files Browse the repository at this point in the history
  • Loading branch information
jonte-z committed Dec 16, 2022
2 parents a8e8d72 + e0c8d29 commit ccad32e
Show file tree
Hide file tree
Showing 258 changed files with 1,481 additions and 1,441 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ name: Python package

on:
push:
branches:
branches:
- master
pull_request:
branches:
branches:
- master
- rc-**

Expand All @@ -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
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# Changelog

## 2.0.0rc3 - 2022-12-16

### 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
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion binance/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0.0rc2"
__version__ = "2.0.0rc3"
11 changes: 9 additions & 2 deletions binance/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion binance/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
11 changes: 1 addition & 10 deletions binance/spot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit ccad32e

Please sign in to comment.