From ad43e7b9433c7966d076e5bb168a50bc647bc0c9 Mon Sep 17 00:00:00 2001 From: PyWaves Date: Wed, 21 Jun 2017 12:42:08 +0200 Subject: [PATCH] Add files via upload --- README.md | 2 ++ __init__.py | 2 +- address.py | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f982ba9..e214b06 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ __pywaves.Address(address, publicKey, privateKey, seed)__ _Creates a new Address `buy(assetPair, amount price, maxLifetime=30*86400, matcherFee=DEFAULT_MATCHER_FEE)` post a buy order +`tradableBalance(assetPair)` get tradable balance for the specified asset pair + `sell(assetPair, amount, price, maxLifetime=30*86400, matcherFee=DEFAULT_MATCHER_FEE)` post a sell order `lease(recipient, amount, txFee=DEFAULT_LEASE_FEE)` post a lease transaction diff --git a/__init__.py b/__init__.py index c438f0f..d70ea7f 100644 --- a/__init__.py +++ b/__init__.py @@ -31,7 +31,7 @@ CHAIN = 'mainnet' CHAIN_ID = 'W' PYWAVES_DIR='/Users/paolo/.pywaves' -MATCHER = 'http://dev.pywaves.org:6886' +MATCHER = 'https://nodes.wavesnodes.com' MATCHER_PUBLICKEY = '' DATAFEED = 'http://marketdata.wavesplatform.com' diff --git a/address.py b/address.py index 9a32cf0..8fb2692 100644 --- a/address.py +++ b/address.py @@ -501,6 +501,16 @@ def sell(self, assetPair, amount, price, maxLifetime=30 * 86400, matcherFee=pywa if id!=-1: return pywaves.Order(id, assetPair, self) + def tradableBalance(self, assetPair): + try: + balances = pywaves.wrapper('/matcher/orderbook/%s/%s/tradableBalance/%s' % ('WAVES' if assetPair.asset1.assetId == '' else assetPair.asset1.assetId, 'WAVES' if assetPair.asset2.assetId == '' else assetPair.asset2.assetId, self.address), host=pywaves.MATCHER) + amountBalance = balances['WAVES' if assetPair.asset1.assetId == '' else assetPair.asset1.assetId] + priceBalance = balances['WAVES' if assetPair.asset2.assetId == '' else assetPair.asset2.assetId] + except: + amountBalance = 0 + priceBalance = 0 + return amountBalance, priceBalance + def lease(self, recipient, amount, txFee=pywaves.DEFAULT_LEASE_FEE): if not self.privateKey: logging.error('Private key required')