コード例 #1
0
#!/usr/bin/env python
import sys
import liqui_client

if len(sys.argv) < 2:
    print("Usage: compute-account-value.py <key file>")
    print("    key file - Path to a file containing key/secret/nonce data")
    sys.exit(1)

key_file = sys.argv[1]
with liqui_client.KeyHandler(key_file) as handler:
    if not handler.keys:
        print("No keys in key file.")
    else:
        for key in handler.keys:
            print("Computing value for key %s" % key)
            with liqui_client.BTCEConnection() as connection:
                t = liqui_client.TradeAPI(key, handler, connection)

                try:
                    r = t.getInfo()

                    exchange_rates = {}
                    for pair in t.apiInfo.pair_names:
                        asks, bids = liqui_client.getDepth(pair)
                        exchange_rates[pair] = bids[0][0]

                    btc_total = 0
                    for currency in t.apiInfo.currencies:
                        balance = r.funds[currency]
                        if currency == "btc":
コード例 #2
0
 def setUp(self):
     self.key_handler = liqui_client.KeyHandler(TEST_KEY_FILE)
     self.connection = liqui_client.BTCEConnection()