Ejemplo n.º 1
0
 def test_getTicker(self):
     connection = tidexapi.Connection()
     info = tidexapi.APIInfo(connection)
     for pair in info.pair_names:
         tidexapi.getTicker(pair, connection, info)
         tidexapi.getTicker(pair, connection)
         tidexapi.getTicker(pair, info=info)
         tidexapi.getTicker(pair)
Ejemplo n.º 2
0
 def test_getDepth(self):
     connection = tidexapi.Connection()
     info = tidexapi.APIInfo(connection)
     for pair in info.pair_names:
         tidexapi.getDepth(pair, connection, info)
         sleep(0.21)
         tidexapi.getDepth(pair, connection)
         sleep(0.21)
         tidexapi.getDepth(pair, info=info)
         sleep(0.21)
         tidexapi.getDepth(pair)
         sleep(0.21)
Ejemplo n.º 3
0
    print("    pair - A currency pair, such as btc_usd")
    print("    order type - Type of orders to process, either 'buy' or 'sell'")
    sys.exit(1)

key_file = sys.argv[1]
pair = sys.argv[2]
order_type = sys.argv[3]

with tidexapi.KeyHandler(key_file) as handler:
    if not handler.keys:
        print("No keys in key file.")
    else:
        for key in handler.keys:
            print("Canceling orders for key {}".format(key))

            with tidexapi.Connection() as connection:
                t = tidexapi.TradeAPI(key, handler, connection)

                try:
                    # Get a list of orders for the given pair, and cancel the ones
                    # with the correct order type.
                    orders = t.activeOrders(pair=pair)
                    for o in orders:
                        if o.type == order_type:
                            print("  Canceling {} {} order for {:f} @ {:f}".
                                  format(pair, order_type, o.amount, o.rate))
                            t.cancelOrder(o.order_id)

                    if not orders:
                        print("  There are no {} {} orders".format(
                            pair, order_type))
Ejemplo n.º 4
0
#!/usr/bin/env python
import tidexapi

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

print("Tickers:")
connection = tidexapi.Connection()
info = tidexapi.APIInfo(connection)
for pair in info.pair_names:
    ticker = tidexapi.getTicker(pair, connection)
    print(pair)
    for a in attrs:
        print("\t%s %s" % (a, getattr(ticker, a)))
Ejemplo n.º 5
0
 def setUp(self):
     self.key_handler = tidexapi.KeyHandler(TEST_KEY_FILE)
     self.connection = tidexapi.Connection()
Ejemplo n.º 6
0
from collections import namedtuple
import sys, tidexapi
import numpy as np
import pandas as pd
import datetime

with tidexapi.KeyHandler('/home/aslepnev/a/tidi.txt') as handler:
    if not handler.keys:
        print("No keys in key file.")
    else:
        for key in handler.keys:
            print("Printing info for key %s" % key)

            with tidexapi.Connection() as connection:
                t = tidexapi.TradeAPI(key, handler, connection)

                try:
                    th = t.tradeHistory()
                    for h in th:
                        print("\t\t        id: %r" % h.transaction_id)
                        print("\t\t      type: %r" % h.type)
                        print("\t\t    amount: %r" % h.amount)
                        print("\t\t  currency: %r" % h.currency)
                        print("\t\t      desc: %s" % h.desc)
                        print("\t\t    status: %r" % h.status)
                        print("\t\t timestamp: %r" % h.timestamp)
                        print()
                except Exception as e:
                    print("  An error occurred: %s" % e)