def test_getTicker(self):
     connection = liqui_client.BTCEConnection()
     info = liqui_client.APIInfo(connection)
     for pair in info.pair_names:
         liqui_client.getTicker(pair, connection, info)
         liqui_client.getTicker(pair, connection)
         liqui_client.getTicker(pair, info=info)
         liqui_client.getTicker(pair)
    def test_scrape_main_page(self):
        with liqui_client.BTCEConnection() as connection:
            info = liqui_client.APIInfo(connection)
            mainPage = info.scrapeMainPage()

            for message in mainPage.messages:
                msgId, user, time, text = message
                assert type(time) is datetime
                if sys.version_info[0] == 2:
                    # python2.x
                    assert type(msgId) in (str, unicode)
                    assert type(user) in (str, unicode)
                    assert type(text) in (str, unicode)
                else:
                    # python3.x
                    self.assertIs(type(msgId), str)
                    self.assertIs(type(user), str)
                    self.assertIs(type(text), str)
Пример #3
0
#!/usr/bin/env python
import liqui_client

btce_domain = "api.liqui.io"

with liqui_client.BTCEConnection(btce_domain) as connection:
    info = liqui_client.APIInfo(connection)

    mainPage = info.scrapeMainPage()
    for message in mainPage.messages:
        msgId, user, time, text = message
        print("%s %s: %s" % (time, user, text))

    print()

    print("dev online: %s" % ('yes' if mainPage.devOnline else 'no'))
    print("support online: %s" % ('yes' if mainPage.supportOnline else 'no'))
    print("admin online: %s" % ('yes' if mainPage.adminOnline else 'no'))
Пример #4
0
 def setUp(self):
     self.connection = liqui_client.BTCEConnection()
Пример #5
0
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":
                            print("\t%s balance: %s" %
#!/usr/bin/env python
import liqui_client

domain = "api.liqui.io"

attrs = ('high', 'low', 'avg', 'vol', 'vol_cur', 'last',
         'buy', 'sell', 'updated')

print("Tickers:")
connection = liqui_client.BTCEConnection(domain)

info = liqui_client.APIInfo(connection)
for pair in info.pair_names:
    ticker = liqui_client.getTicker(pair, connection)
    print(pair)
    for a in attrs:
        print("\t%s %s" % (a, getattr(ticker, a)))
Пример #7
0
 def setUp(self):
     self.key_handler = liqui_client.KeyHandler(TEST_KEY_FILE)
     self.connection = liqui_client.BTCEConnection()