Skip to content

Commit

Permalink
added examples/py/hitbtc2-withdraw.py ccxt#406
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Nov 30, 2017
1 parent a172f25 commit e1f4224
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions examples/py/hitbtc2-withdraw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-

from pprint import pprint

import os
import sys

root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
sys.path.append(root + '/python')

import ccxt # noqa: E402


def get_positive_accounts(balance):
result = {}
currencies = list(balance.keys())
for currency in currencies:
if balance[currency] and balance[currency] > 0:
result[currency] = balance[currency]
return result


exchange = ccxt.hitbtc2({
"apiKey": "a34ca826b430bdfcca969241b0f7bd2d",
"secret": "7b28d6b17aea18ae39903add0dae048a",
"enableRateLimit": True,
})


trading_balance = exchange.fetch_balance()
account_balance = exchange.fetch_balance({'type': 'account'})

pprint('Trading balance:')
pprint(get_positive_accounts(trading_balance['total']))
pprint('Account balance:')
pprint(get_positive_accounts(account_balance['total']))

# fetch account balance from the exchange
withdraw = exchange.withdraw('ETH', 0.01, '0x811DCfeb6dC0b9ed825808B6B060Ca469b83fB81')


# output the result
pprint('Withdraw:')
pprint(withdraw)

0 comments on commit e1f4224

Please sign in to comment.