Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2087544
Update readme examples
Jun 4, 2019
dc9632a
Update import decimal
Jun 4, 2019
e0c93d9
Update description
Jun 4, 2019
ce95ac9
Merge branch 'develop'
Jun 29, 2019
02eb7a5
Update to v0.1.20
Jun 29, 2019
28d86dc
Remove docs around custom api_url
Jul 11, 2019
12c32ea
Update Kucoin link
Jul 11, 2019
6c23fac
remove pywallet and replace with pycoin for bip32
cheeseandcereal Oct 8, 2019
f35a9e5
Update README.rst
oliver-zehentleitner Feb 1, 2020
f025f88
Add BIP39 passphrase and child wallets
mistdale Apr 27, 2020
b416e15
Update Wallet docs
mistdale Apr 27, 2020
fa490f9
set limit to 1000 of get_markets
Sep 1, 2020
de8bcd0
fix encode_number
Sep 7, 2020
16d9423
Update requirements.txt
Apr 29, 2021
3792a8b
Update setup.py
Apr 29, 2021
57f84f7
Merge pull request #30 from cheeseandcereal/remove_pywallet
Apr 29, 2021
516d29d
Merge pull request #37 from cbarraford/markets-limit
Apr 29, 2021
a1ac4d5
Merge pull request #34 from oliver-zehentleitner/patch-1
Apr 29, 2021
c62d6e1
Merge pull request #38 from cbarraford/round-float
Apr 29, 2021
b2bfb34
Merge pull request #13 from moonorblue/update_README
Apr 29, 2021
9632ecc
Merge branch 'master' into bip39_passphrase_and_child
Apr 29, 2021
acd0800
Merge pull request #36 from mistdale/bip39_passphrase_and_child
Apr 29, 2021
19d7d63
Update README.rst
Jun 1, 2021
d9d25d5
add .gitignore
Jul 31, 2026
39e22f5
regenerate dex_pb2.py so the package imports on protobuf 4+
Jul 31, 2026
1011b97
derive the requested child key in create_wallet_from_mnemonic
Jul 31, 2026
1288fc4
fix flake8 warnings
Jul 31, 2026
d036e66
replace travis with github actions
Jul 31, 2026
6f27cee
update packaging metadata and repo links
Jul 31, 2026
3ad2fe0
drop the other exchange links
Jul 31, 2026
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
53 changes: 53 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test

on:
push:
branches: [master, develop]
pull_request:
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libsecp256k1-dev

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements.txt
pip install -r test-requirements.txt

# Integration tests are excluded: they require a live Binance Chain node.
- name: Run unit tests
run: pytest tests/ -m "not integration" -v --cov binance_chain --cov-report term-missing

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install flake8
run: pip install flake8

- name: Run flake8
run: flake8 --exclude binance_chain/protobuf/dex_pb2.py binance_chain/
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
__pycache__/
*.py[cod]

build/
dist/
*.egg-info/
.eggs/

.venv/
venv/
env/

.tox/
.pytest_cache/
.coverage
.coverage.*
htmlcov/

docs/_build/

.idea/
.vscode/
.DS_Store
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

79 changes: 49 additions & 30 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=======================================
Welcome to python-binance-chain v0.1.19
Welcome to python-binance-chain v0.1.20
=======================================

.. image:: https://img.shields.io/pypi/v/python-binance-chain.svg
Expand All @@ -8,11 +8,8 @@ Welcome to python-binance-chain v0.1.19
.. image:: https://img.shields.io/pypi/l/python-binance-chain.svg
:target: https://pypi.python.org/pypi/python-binance-chain

.. image:: https://img.shields.io/travis/sammchardy/python-binance-chain.svg
:target: https://travis-ci.org/sammchardy/python-binance-chain

.. image:: https://img.shields.io/coveralls/sammchardy/python-binance-chain.svg
:target: https://coveralls.io/github/sammchardy/python-binance-chain
.. image:: https://github.com/mchardysam/python-binance-chain/actions/workflows/test.yml/badge.svg
:target: https://github.com/mchardysam/python-binance-chain/actions/workflows/test.yml

.. image:: https://img.shields.io/pypi/wheel/python-binance-chain.svg
:target: https://pypi.python.org/pypi/python-binance-chain
Expand All @@ -27,7 +24,7 @@ PyPi
https://pypi.python.org/pypi/python-binance-chain

Source code
https://github.com/sammchardy/python-binance-chain
https://github.com/mchardysam/python-binance-chain


Features
Expand All @@ -45,7 +42,7 @@ Features
- `Sign transactions <#sign-transaction>`_ and use the signed message how you want
- `Ledger hardware wallet <#ledger>`_ device (Ledger Blue, Nano S & Nano X) support for signing messages
- Async `Depth Cache <#depth-cache>`_ to keep a copy of the order book locally
- `Signing Service Support <#signing-service>`_ for `binance-chain-signing-service <https://github.com/sammchardy/binance-chain-signing-service>`_
- `Signing Service Support <#signing-service>`_ for `binance-chain-signing-service <https://github.com/mchardysam/binance-chain-signing-service>`_
- Support for HTTP and HTTPS proxies and to override `Requests and AioHTTP settings <requests-and-aiohttp-settings>`_
- `UltraJson <https://github.com/esnme/ultrajson>`_ the ultra fast JSON parsing library for efficient message handling
- Strong Python3 typing to reduce errors
Expand Down Expand Up @@ -89,8 +86,7 @@ If using the production server there is no need to pass the environment variable
# Alternatively pass no env to get production
prod_client = HttpApiClient()

# connect client to different URL
client = HttpApiClient(api_url='https://yournet.com')
# connect client to different URL using custom environments, see below

# get node time
time = client.get_time()
Expand Down Expand Up @@ -128,16 +124,16 @@ If using the production server there is no need to pass the environment variable
# get open orders
open_orders = client.get_open_orders('tbnb185tqzq3j6y7yep85lncaz9qeectjxqe5054cgn')

# get open orders
# get ticker
ticker = client.get_ticker('NNB-0AD_BNB')

# get open orders
# get trades
trades = client.get_trades(limit=2)

# get open orders
# get order
order = client.get_order('9D0537108883C68B8F43811B780327CE97D8E01D-2')

# get open orders
# get trades
trades = client.get_trades()

# get transactions
Expand All @@ -162,6 +158,7 @@ All methods are otherwise the same as the HttpApiClient

from binance_chain.http import AsyncHttpApiClient
from binance_chain.environment import BinanceEnvironment
import asyncio

loop = None

Expand Down Expand Up @@ -226,6 +223,8 @@ You may also use the `Ledger Wallet class <#ledger>`_ to utilise your Ledger Har

It can be initialised with your private key or your mnemonic phrase.

You can additionally provide BIP39 passphrase and derived wallet id.

Note that the BinanceEnvironment used for the wallet must match that of the HttpApiClient, testnet addresses will not
work on the production system.

Expand Down Expand Up @@ -254,7 +253,10 @@ see examples below
from binance_chain.environment import BinanceEnvironment

testnet_env = BinanceEnvironment.get_testnet_env()
wallet = Wallet.create_wallet_from_mnemonic('mnemonic word string', env=testnet_env)
wallet = Wallet.create_wallet_from_mnemonic('mnemonic word string',
passphrase='optional passphrase',
child=0,
env=testnet_env)
print(wallet.address)
print(wallet.private_key)
print(wallet.public_key_hex)
Expand Down Expand Up @@ -292,6 +294,8 @@ General case
from binance_chain.http import HttpApiClient
from binance_chain.messages import NewOrderMsg
from binance_chain.wallet import Wallet
from binance_chain.constants import TimeInForce, OrderSide, OrderType
from decimal import Decimal

wallet = Wallet('private_key_string')
client = HttpApiClient()
Expand All @@ -300,7 +304,7 @@ General case
new_order_msg = NewOrderMsg(
wallet=wallet,
symbol="ANN-457_BNB",
time_in_force=TimeInForce.GTE,
time_in_force=TimeInForce.GOOD_TILL_EXPIRE,
order_type=OrderType.LIMIT,
side=OrderSide.BUY,
price=Decimal(0.000396000),
Expand Down Expand Up @@ -363,6 +367,7 @@ General case
from binance_chain.http import HttpApiClient
from binance_chain.messages import FreezeMsg
from binance_chain.wallet import Wallet
from decimal import Decimal

wallet = Wallet('private_key_string')
client = HttpApiClient()
Expand All @@ -384,6 +389,7 @@ General case
from binance_chain.http import HttpApiClient
from binance_chain.messages import UnFreezeMsg
from binance_chain.wallet import Wallet
from decimal import Decimal

wallet = Wallet('private_key_string')
client = HttpApiClient()
Expand Down Expand Up @@ -510,7 +516,7 @@ See `API <https://python-binance-chain.readthedocs.io/en/latest/binance-chain.ht
print(msg)

# connect to testnet env
bcsm = await BinanceChainSocketManager.create(loop, handle_evt, address2, env=testnet_env)
bcsm = await BinanceChainSocketManager.create(loop, handle_evt, address, env=testnet_env)

# subscribe to relevant endpoints
await bcsm.subscribe_orders(address)
Expand Down Expand Up @@ -599,6 +605,7 @@ All methods are the same as the binance_chain.node_rpc.http.HttpRpcClient.
from binance_chain.node_rpc.http import AsyncHttpRpcClient
from binance_chain.http import AsyncHttpApiClient, PeerType
from binance_chain.environment import BinanceEnvironment
import asyncio

loop = None

Expand Down Expand Up @@ -849,7 +856,7 @@ The service holds the private keys of the accounts and supplies a username and p

This client re-uses the binance_chain.messages types. In this case no wallet parameter is required.

This client interacts with the `binance-chain-signing-service <https://github.com/sammchardy/binance-chain-signing-service>`_ read the docs there
This client interacts with the `binance-chain-signing-service <https://github.com/mchardysam/binance-chain-signing-service>`_ read the docs there
to create our own signing service.

**Signing and then broadcasting**
Expand All @@ -858,6 +865,7 @@ to create our own signing service.

from binance_chain.messages import NewOrderMsg
from binance_chain.signing.http import HttpApiSigningClient
from binance_chain.constants import TimeInForce, OrderSide, OrderType

signing_client = HttpApiSigningClient('http://localhost:8000', username='sam', password='mypass')

Expand Down Expand Up @@ -902,6 +910,7 @@ To sign and broadcast an order use the `broadcast_order` method. This returns th

from binance_chain.messages import NewOrderMsg
from binance_chain.signing.http import HttpApiSigningClient
from binance_chain.constants import TimeInForce, OrderSide, OrderType

signing_client = HttpApiSigningClient('http://localhost:8000', username='sam', password='mypass')

Expand All @@ -928,6 +937,8 @@ Like all other libraries there is an async version.
from binance_chain.signing.http import AsyncHttpApiSigningClient
from binance_chain.http import AsyncHttpApiClient, PeerType
from binance_chain.environment import BinanceEnvironment
from binance_chain.constants import TimeInForce, OrderSide, OrderType
import asyncio

loop = None

Expand Down Expand Up @@ -1076,13 +1087,31 @@ Running Tests

.. code-block:: bash

git clone https://github.com/sammchardy/python-binance-chain.git
git clone https://github.com/mchardysam/python-binance-chain.git
cd python-binance-chain
pip install -r requirements.txt
pip install -r test-requirements.txt

# unit tests only, no network access required
python -m pytest tests/ -m "not integration"

# the full suite, including tests that need a live Binance Chain node
python -m pytest tests/


Regenerating Protobuf
---------------------

The transaction schema lives in ``binance_chain/protobuf/dex.proto``. If you need to
regenerate ``dex_pb2.py``:

.. code-block:: bash

pip install grpcio-tools
python -m grpc_tools.protoc -I binance_chain/protobuf \
--python_out=binance_chain/protobuf binance_chain/protobuf/dex.proto


Donate
------

Expand All @@ -1102,14 +1131,4 @@ Thanks
Other Exchanges
---------------

If you use `Binance <https://www.binance.com/?ref=10099792>`_ check out my `python-binance <https://github.com/sammchardy/python-binance>`_ library.

If you use `Kucoin <https://www.kucoin.com/ucenter/signup?rcode=E42cWB>`_ check out my `python-kucoin <https://github.com/sammchardy/python-kucoin>`_ library.

If you use `Allcoin <https://www.allcoin.com/Account/RegisterByPhoneNumber/?InviteCode=MTQ2OTk4MDgwMDEzNDczMQ==>`_ check out my `python-allucoin <https://github.com/sammchardy/python-allcoin>`_ library.

If you use `IDEX <https://idex.market>`_ check out my `python-idex <https://github.com/sammchardy/python-idex>`_ library.

If you use `BigONE <https://big.one>`_ check out my `python-bigone <https://github.com/sammchardy/python-bigone>`_ library.

.. image:: https://analytics-pixel.appspot.com/UA-111417213-1/github/python-kucoin?pixel
If you use `IDEX <https://idex.market>`_ check out my `python-idex <https://github.com/mchardysam/python-idex>`_ library.
2 changes: 1 addition & 1 deletion binance_chain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

"""

__version__ = '0.1.19'
__version__ = '0.1.20'
12 changes: 6 additions & 6 deletions binance_chain/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def _get_request_kwargs(self, method, **kwargs):

if kwargs['data'] and method == 'get':
kwargs['params'] = kwargs['data']
del(kwargs['data'])
del kwargs['data']

if method == 'post':
kwargs['headers']['content-type'] = 'text/plain'
Expand Down Expand Up @@ -289,7 +289,7 @@ def get_markets(self):
:return: API Response

"""
return self._get("markets")
return self._get("markets?limit=1000")

def get_fees(self):
"""Gets the current trading fees settings
Expand Down Expand Up @@ -371,7 +371,7 @@ def broadcast_msg(self, msg: binance_chain.messages.Msg, sync: bool = False):

req_path = 'broadcast'
if sync:
req_path += f'?sync=1'
req_path += '?sync=1'

res = self._post(req_path, data=data)
msg.wallet.increment_account_sequence()
Expand Down Expand Up @@ -419,7 +419,7 @@ def broadcast_hex_msg(self, hex_msg: str, sync: bool = False):
"""
req_path = 'broadcast'
if sync:
req_path += f'?sync=1'
req_path += '?sync=1'

res = self._post(req_path, data=hex_msg)
return res
Expand Down Expand Up @@ -864,7 +864,7 @@ async def broadcast_msg(self, msg: binance_chain.messages.Msg, sync: bool = Fals

req_path = 'broadcast'
if sync:
req_path += f'?sync=1'
req_path += '?sync=1'

res = await self._post(req_path, data=data)
msg.wallet.increment_account_sequence()
Expand All @@ -874,7 +874,7 @@ async def broadcast_msg(self, msg: binance_chain.messages.Msg, sync: bool = Fals
async def broadcast_hex_msg(self, hex_msg: str, sync: bool = False):
req_path = 'broadcast'
if sync:
req_path += f'?sync=1'
req_path += '?sync=1'

res = await self._post(req_path, data=hex_msg)
return res
Expand Down
Loading
Loading