Skip to content

Commit

Permalink
Generalize printBalances
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanbraeckel committed Dec 3, 2017
1 parent 1694d7b commit 9638be3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
8 changes: 8 additions & 0 deletions python/etherdeltaclientservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,13 @@ def printMyTrades(self):
for trade in self.my_trades[0:numTrades]:
print(trade['date'] + " " + trade['side'] + " " + trade['amount'] + " @ " + trade['price'])

def printBalances(self, token, userAccount):
print("Account balances:")
print("=================")
print("Wallet account balance: %.18f ETH" % self.getBalance('ETH', userAccount))
print("Wallet token balance: %.18f tokens" % self.getBalance(token, userAccount))
print("EtherDelta ETH balance: %.18f ETH" % self.getEtherDeltaBalance('ETH', userAccount))
print("EtherDelta token balance: %.18f tokens" % self.getEtherDeltaBalance(token, userAccount))

def createOrder(self, side, expires, price, amount, token, userAccount, user_wallet_private_key, randomseed = None):
global addressEtherDelta, web3
Expand Down Expand Up @@ -324,6 +331,7 @@ def trade(self, order, etherAmount, user_wallet_private_key=''):
# Build binary representation of the function call with arguments
abidata = self.contractEtherDelta.encodeABI('trade', kwargs=kwargs)
print("abidata: " + str(abidata))
# Use the transaction count as the nonce
nonce = web3.eth.getTransactionCount(self.userAccount)
# Override to have same as other transaction:
#nonce = 53
Expand Down
9 changes: 1 addition & 8 deletions python/maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@
es.start(userAccount, token)
print("EtherDeltaClientService started")

print("")
print("Account balances:")
print("=================")
print("Wallet account balance: %.18f ETH" % es.getBalance('ETH', userAccount))
print("Wallet token balance: %.18f tokens" % es.getBalance(token, userAccount))
print("EtherDelta ETH balance: %.18f ETH" % es.getEtherDeltaBalance('ETH', userAccount))
print("EtherDelta token balance: %.18f tokens" % es.getEtherDeltaBalance(token, userAccount))
print("")
es.printBalances(token, userAccount)

while es.getBestSellOrder() == None or es.getBestBuyOrder() == None:
print("Waiting until best sell and buy orders are known...")
Expand Down
9 changes: 1 addition & 8 deletions python/taker.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,7 @@
es.start(userAccount, token)
print("EtherDeltaService started")

print("")
print("Account balances:")
print("=================")
print("Wallet account balance: %.18f ETH" % es.getBalance('ETH', userAccount))
print("Wallet token balance: %.18f tokens" % es.getBalance(token, userAccount))
print("EtherDelta ETH balance: %.18f ETH" % es.getEtherDeltaBalance('ETH', userAccount))
print("EtherDelta token balance: %.18f tokens" % es.getEtherDeltaBalance(token, userAccount))
print("")
es.printBalances(token, userAccount)

while es.getBestSellOrder() == None:
print("Waiting until best sell order to buy is known...")
Expand Down

0 comments on commit 9638be3

Please sign in to comment.