Skip to content

Commit a1260fe

Browse files
aisling11Jacobjnuernberg
authored
Rc 1.9.0 (#121)
* Added the binance convert endpoint to the binance python connector * Implementation of remarks from pull request * Updated convert endpoint method name * Updated function call to new method name * Further adjustments as requested * Copy paste error resolved. Copy paste error resolved. Function name updated. * Types added Added types for mandatory arguments. * Update test_convert_trade_history.py Added second argument to function calls. * black format * correct convert test * remove testnet base url for convert example * v1.9.0 Co-authored-by: Jacob <jacob@jacob.com> Co-authored-by: jnuernberg <79695265+jnuernberg@users.noreply.github.com>
1 parent 88634cf commit a1260fe

33 files changed

+926
-11
lines changed

CHANGELOG.md

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

3+
## 1.9.0 - 2021-12-22
4+
5+
### Added
6+
- New endpoint for Convert:
7+
- `GET /sapi/v1/convert/tradeFlow` to support user query convert trade history records
8+
- New endpoint for Rebate:
9+
- `GET /sapi/v1/rebate/taxQuery` to support user query spot rebate history records
10+
- New endpoints for Margin:
11+
- `GET /sapi/v1/margin/crossMarginData` to get cross margin fee data collection
12+
- `GET /sapi/v1/margin/isolatedMarginData` to get isolated margin fee data collection
13+
- `GET /sapi/v1/margin/isolatedMarginTier` to get isolated margin tier data collection
14+
- New endpoints for NFT:
15+
- `GET /sapi/v1/nft/history/transactions` to get NFT transaction history
16+
- `GET /sapi/v1/nft/history/deposit` to get NFT deposit history
17+
- `GET /sapi/v1/nft/history/withdraw` to get NFT withdraw history
18+
- `GET /sapi/v1/nft/user/getAsset` to get NFT asset
19+
320
## 1.8.0 - 2021-11-25
421

522
### Added
@@ -46,7 +63,7 @@
4663
- `GET /sapi/v1/bswap/poolConfigure` to get pool configure
4764
- `GET /sapi/v1/bswap/addLiquidityPreview` to calculate expected share amount for adding liquidity in single or dual token
4865
- `GET /sapi/v1/bswap/removeLiquidityPreview` to calculate expected asset amount of single token redemption or dual token redemption
49-
66+
5067
## 1.5.0 - 2021-08-17
5168

5269
### Changed
@@ -60,8 +77,8 @@
6077

6178
### Added
6279
- New Fiat endpoints:
63-
- `GET /sapi/v1/fiat/orders` to query user fiat deposit and withdraw history
64-
- `GET /sapi/v1/fiat/payments` to query user fiat payments history
80+
- `GET /sapi/v1/fiat/orders` to query user fiat deposit and withdraw history
81+
- `GET /sapi/v1/fiat/payments` to query user fiat payments history
6582

6683
### Fixed
6784
- Typo in `margin_max_transferable`
@@ -71,7 +88,7 @@
7188
- New endpoints for Wallet:
7289
- `POST /sapi/v1/asset/get-funding-asset` to query funding wallet, includes Binance Pay, Binance Card, Binance Gift Card, Stock Token
7390
- `GET /sapi/v1/account/apiRestrictions` to query user API Key permission
74-
91+
7592
## 1.2.0 - 2021-07-12
7693

7794
### Changed

CONTRIBUTING.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Contributing
2+
3+
Love this package and want to help? Thanks so much, there's something to do for everybody!
4+
5+
Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.
6+
7+
Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features.
8+
9+
## Using the issue tracker
10+
11+
The [issue tracker](https://github.com/binance/binance-connector-python/issues) is the preferred channel for [bug reports](#bugs), [features requests](#features) and [submitting pull requests](#pull-requests).
12+
13+
<a name="bugs"></a>
14+
15+
## Bug reports
16+
17+
A bug is a _demonstrable problem_ that is caused by the code in the repository.
18+
Good bug reports are extremely helpful - thank you!
19+
20+
Guidelines for bug reports:
21+
22+
1. **Use the GitHub issue search** &mdash; check if the issue has already been reported.
23+
24+
2. **Check if the issue has been fixed** &mdash; try to reproduce it using the latest `master` or development branch in the repository.
25+
26+
3. **Isolate the problem** &mdash; ideally create a [reduced test case](https://css-tricks.com/reduced-test-cases/) and a live example.
27+
28+
4. **Use the bug report template** &mdash; please fill in the template which appears when you open a new issue.
29+
30+
A good bug report shouldn't leave others needing to chase you up for more information. Please try to be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What browser(s) and OS
31+
experience the problem? What would you expect to be the outcome? All these details will help people to fix any potential bugs.
32+
33+
<a name="features"></a>
34+
35+
## Feature requests
36+
37+
Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to _you_ to make a strong case to convince the project's developers of the merits of this feature. Please provide as many details and as much context as possible.
38+
39+
<a name="pull-requests"></a>
40+
41+
## Pull requests
42+
43+
Good pull requests - patches, improvements, new features - are a fantastic help. They should remain focused in scope and avoid containing unrelated commits.
44+
45+
**Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code, porting to a different language), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project.
46+
47+
Since the `master` branch is what people actually use in production, we have release candidate branches, which are usually name after `rc-`, that unstable changes get merged into first. Only when we consider that stable we merge it into the `master` branch and release the changes officially.
48+
49+
Adhering to the following process is the best way to get your work included in the project:
50+
51+
1. [Fork](https://help.github.com/articles/fork-a-repo/) the project, clone your fork, and configure the remotes:
52+
53+
```bash
54+
# Clone your fork of the repo into the current directory
55+
git clone https://github.com/<your-username>/binance-connector-python.git
56+
# Navigate to the newly cloned directory
57+
cd binance-connector-python
58+
# Assign the original repo to a remote called "upstream"
59+
git remote add upstream https://github.com/binance/binance-connector-python.git
60+
```
61+
62+
2. If you cloned a while ago, get the latest changes from upstream:
63+
64+
```bash
65+
git checkout <latest_rc_branch>
66+
git pull upstream <latest_rc_branch>
67+
```
68+
69+
3. Create a new topic branch (off the `rc-` branch) to contain your feature, change, or fix:
70+
71+
```bash
72+
git checkout -b <topic-branch-name>
73+
```
74+
75+
4. Work on your code, but please don't forget:
76+
- Add [Docstring](https://www.python.org/dev/peps/pep-0257/) to any new module, function, class, or method. You can consult files within `/binance` for references;
77+
- If reasonable (ex: new endpoint), add example file to the `/examples` folder - please use `logging`/`logger` with ideal logging level to log the messages;
78+
- If reasonable (ex: new endpoint), add test file to the `/tests` folder - use [pytest](https://docs.pytest.org/en/6.2.x/contents.html) to check if all tests are passed.
79+
- If reasonable (ex: new endpoint), add documentation to the `/docs` folder - please refer to [reStructuredText](https://devguide.python.org/documenting/);
80+
- Write changes to `CHANGELOG.md` and `CHANGELOG.rst` under the `Unreleased` section - please create the section if not existing yet, this is later to be converted into the verion and date of release;
81+
- Make sure there's no typos and the namings are simple and not ambiguous;
82+
83+
5. Commit your changes, taking in attention these [git commit message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
84+
85+
6. Locally merge (or rebase) the upstream rc branch into your topic branch:
86+
87+
```bash
88+
git pull [--rebase] upstream <latest_rc_branch>
89+
```
90+
91+
92+
7. Push your topic branch up to your fork:
93+
94+
```bash
95+
git push origin <topic-branch-name>
96+
```
97+
98+
8. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description.
99+
100+
**IMPORTANT**: By submitting a patch, you agree to allow the project
101+
owners to license your work under the terms of the MIT License.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Binance Public API Connector Python
2-
[![Python 3.6](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/downloads/release/python-360/)
2+
[![PyPI version](https://img.shields.io/pypi/v/binance-connector.svg)](https://pypi.python.org/pypi/binance-connector.svg)
3+
[![Python version](https://img.shields.io/pypi/pyversions/binance-connector)](https://www.python.org/downloads/)
4+
[![Documentation](https://img.shields.io/badge/docs-latest-blue)](https://binance-connector.readthedocs.io/en/stable/)
5+
[![Code Style](https://img.shields.io/badge/code_style-black-black)](https://black.readthedocs.io/en/stable/)
36
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
47

58
This is a lightweight library that works as a connector to [Binance public API](https://github.com/binance/binance-spot-api-docs)

binance/__version__.py

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

binance/spot/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ def __init__(self, key=None, secret=None, **kwargs):
8989
from binance.spot.margin import cancel_isolated_margin_account
9090
from binance.spot.margin import enable_isolated_margin_account
9191
from binance.spot.margin import isolated_margin_account_limit
92+
from binance.spot.margin import margin_fee
93+
from binance.spot.margin import isolated_margin_fee
94+
from binance.spot.margin import isolated_margin_tier
9295

9396
# SAVINGS
9497
from binance.spot.savings import savings_flexible_products
@@ -229,3 +232,15 @@ def __init__(self, key=None, secret=None, **kwargs):
229232

230233
# PAY
231234
from binance.spot.pay import pay_history
235+
236+
# CONVERT
237+
from binance.spot.convert import convert_trade_history
238+
239+
# REBATE
240+
from binance.spot.rebate import rebate_spot_history
241+
242+
# NFT
243+
from binance.spot.nft import nft_transaction_history
244+
from binance.spot.nft import nft_deposit_history
245+
from binance.spot.nft import nft_withdraw_history
246+
from binance.spot.nft import nft_asset

binance/spot/convert.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from binance.lib.utils import check_required_parameters
2+
3+
4+
def convert_trade_history(self, startTime: int, endTime: int, **kwargs):
5+
"""Convert Trade History (USER_DATA)
6+
7+
Get convert history for a specific account.
8+
9+
GET /sapi/v1/convert/tradeFlow
10+
11+
https://binance-docs.github.io/apidocs/spot/en/#convert-endpoints
12+
13+
Args:
14+
startTime (int)
15+
endTime (int)
16+
Keyword Args:
17+
limit (int, optional): Default Value: 100; Max Value: 1000
18+
recvWindow (int, optional)
19+
"""
20+
check_required_parameters([[startTime, "startTime"], [endTime, "endTime"]])
21+
22+
url_path = "/sapi/v1/convert/tradeFlow"
23+
payload = {"startTime": startTime, "endTime": endTime, **kwargs}
24+
return self.sign_request("GET", url_path, payload)

binance/spot/margin.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,3 +855,54 @@ def isolated_margin_account_limit(self, **kwargs):
855855
recvWindow (int, optional): The value cannot be greater than 60000
856856
"""
857857
return self.sign_request("GET", "/sapi/v1/margin/isolated/accountLimit", kwargs)
858+
859+
860+
def margin_fee(self, **kwargs):
861+
"""Query Cross Margin Fee Data (USER_DATA)
862+
Get cross margin fee data collection with any vip level or user's current specific data as https://www.binance.com/en/margin-fee
863+
864+
GET /sapi/v1/margin/crossMarginData
865+
866+
https://binance-docs.github.io/apidocs/spot/en/#query-cross-margin-fee-data-user_data
867+
868+
Keyword Args:
869+
vipLevel (int, optional): User's current specific margin data will be returned if vipLevel is omitted
870+
coin (str, optional)
871+
recvWindow (int, optional): The value cannot be greater than 60000
872+
"""
873+
return self.sign_request("GET", "/sapi/v1/margin/crossMarginData", kwargs)
874+
875+
876+
def isolated_margin_fee(self, **kwargs):
877+
"""Query Isolated Margin Fee Data (USER_DATA)
878+
Get isolated margin fee data collection with any vip level or user's current specific data as https://www.binance.com/en/margin-fee
879+
880+
GET /sapi/v1/margin/isolatedMarginData
881+
882+
https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-fee-data-user_data
883+
884+
Keyword Args:
885+
vipLevel (int, optional): User's current specific margin data will be returned if vipLevel is omitted
886+
symbol (str, optional)
887+
recvWindow (int, optional): The value cannot be greater than 60000
888+
"""
889+
return self.sign_request("GET", "/sapi/v1/margin/isolatedMarginData", kwargs)
890+
891+
892+
def isolated_margin_tier(self, symbol: str, **kwargs):
893+
"""Query Isolated Margin Tier Data (USER_DATA)
894+
Get isolated margin tier data collection with any tier as https://www.binance.com/en/margin-data
895+
896+
GET /sapi/v1/margin/isolatedMarginTier
897+
898+
https://binance-docs.github.io/apidocs/spot/en/#query-isolated-margin-tier-data-user_data
899+
900+
Args:
901+
symbol (str)
902+
Keyword Args:
903+
tier (int, optional): All margin tier data will be returned if tier is omitted
904+
recvWindow (int, optional): The value cannot be greater than 60000
905+
"""
906+
check_required_parameter(symbol, "symbol")
907+
payload = {"symbol": symbol, **kwargs}
908+
return self.sign_request("GET", "/sapi/v1/margin/isolatedMarginTier", payload)

binance/spot/nft.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
from binance.lib.utils import check_required_parameter
2+
3+
4+
def nft_transaction_history(self, orderType: int, **kwargs):
5+
"""Get NFT Transaction History (USER_DATA)
6+
7+
GET /sapi/v1/nft/history/transactions
8+
9+
https://binance-docs.github.io/apidocs/spot/en/#get-nft-transaction-history-user_data
10+
11+
Args:
12+
orderType (int): 0: purchase order, 1: sell order, 2: royalty income, 3: primary market order, 4: mint fee
13+
Keyword Args:
14+
startTime (int, optional)
15+
endTime (int, optional)
16+
limit (int, optional): Default 50, Max 50
17+
page (int, optional): Default 1
18+
recvWindow (int, optional): The value cannot be greater than 60000
19+
"""
20+
check_required_parameter(orderType, "orderType")
21+
params = {"orderType": orderType, **kwargs}
22+
return self.sign_request("GET", "/sapi/v1/nft/history/transactions", params)
23+
24+
25+
def nft_deposit_history(self, **kwargs):
26+
"""Get NFT Deposit History(USER_DATA)
27+
28+
GET /sapi/v1/nft/history/deposit
29+
30+
https://binance-docs.github.io/apidocs/spot/en/#get-nft-deposit-history-user_data
31+
32+
Keyword Args:
33+
startTime (int, optional)
34+
endTime (int, optional)
35+
limit (int, optional): Default 50, Max 50
36+
page (int, optional): Default 1
37+
recvWindow (int, optional): The value cannot be greater than 60000
38+
"""
39+
40+
return self.sign_request("GET", "/sapi/v1/nft/history/deposit", kwargs)
41+
42+
43+
def nft_withdraw_history(self, **kwargs):
44+
"""Get NFT Withdraw History (USER_DATA)
45+
46+
GET /sapi/v1/nft/history/withdraw
47+
48+
https://binance-docs.github.io/apidocs/spot/en/#get-nft-withdraw-history-user_data
49+
50+
Keyword Args:
51+
startTime (int, optional)
52+
endTime (int, optional)
53+
limit (int, optional): Default 50, Max 50
54+
page (int, optional): Default 1
55+
recvWindow (int, optional): The value cannot be greater than 60000
56+
"""
57+
58+
return self.sign_request("GET", "/sapi/v1/nft/history/withdraw", kwargs)
59+
60+
61+
def nft_asset(self, **kwargs):
62+
"""Get NFT Asset (USER_DATA)
63+
64+
GET /sapi/v1/nft/user/getAsset
65+
66+
https://binance-docs.github.io/apidocs/spot/en/#get-nft-asset-user_data
67+
68+
Keyword Args:
69+
limit (int, optional): Default 50, Max 50
70+
page (int, optional): Default 1
71+
recvWindow (int, optional): The value cannot be greater than 60000
72+
"""
73+
74+
return self.sign_request("GET", "/sapi/v1/nft/user/getAsset", kwargs)

binance/spot/rebate.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def rebate_spot_history(self, **kwargs):
2+
"""Get Spot Rebate History Records (USER_DATA)
3+
4+
GET /sapi/v1/rebate/taxQuery
5+
6+
https://binance-docs.github.io/apidocs/spot/en/#get-spot-rebate-history-records-user_data
7+
8+
Keyword Args:
9+
startTime (int, optional)
10+
endTime (int, optional)
11+
page (int, optional): default 1
12+
recvWindow (int, optional): The value cannot be greater than 60000
13+
"""
14+
15+
return self.sign_request("GET", "/sapi/v1/rebate/taxQuery", kwargs)

0 commit comments

Comments
 (0)