Exemple #1
0
    def __init__(self, config):
        Checker.__init__(self, config)
        # Load config
        etherdelta_config = dict(config.items('etherdelta'))

        self.user_account = etherdelta_config.get('user_wallet_public_key')
        self.secret_key = etherdelta_config.get('user_wallet_private_key')

        # Load ed tokens
        self.tokens = parse_ed_tokens(etherdelta_config.get('tokens_file'))
        self.es = EtherDeltaClientService()
Exemple #2
0
class EtherDeltaChecker(Checker):
    def __init__(self, config):
        Checker.__init__(self, config)
        # Load config
        etherdelta_config = dict(config.items('etherdelta'))

        self.user_account = etherdelta_config.get('user_wallet_public_key')
        self.secret_key = etherdelta_config.get('user_wallet_private_key')

        # Load ed tokens
        self.tokens = parse_ed_tokens(etherdelta_config.get('tokens_file'))
        self.es = EtherDeltaClientService()

    def check_order_book(self, ticker, number_of_orders=10):
        symbol = '{}-ETH'.format(ticker.upper())
        token = self.tokens.get(ticker)

        if token is None:
            raise ValueError('No token found for {}'.format(ticker))

        def check_loop():
            logger.info("Getting order book")
            (ed_sells, ed_buys) = self.es.get_order_book()

            top_ed_sells = list(reversed(ed_sells[0:number_of_orders]))
            top_ed_buys = ed_buys[0:number_of_orders]

            if len(top_ed_sells) == 0 or len(top_ed_buys) == 0:
                return ()

            ed_sell_orders = list(
                map((lambda entry: Order(float(entry['price']),
                                         float(entry['ethAvailableVolume']))),
                    top_ed_sells))
            ed_buy_orders = list(
                map((lambda entry: Order(float(entry['price']),
                                         float(entry['ethAvailableVolume']))),
                    top_ed_buys))

            return (ed_sell_orders, ed_buy_orders)

        try:
            logger.info("EtherDelta token for ticker {}: {}".format(
                ticker, token))

            self.es.start(self.user_account, token)
            logger.info("EtherDeltaServiceClient started")

            self.es.printBalances(token, self.user_account)

            retries = 5
            for i in range(retries):
                orders = check_loop()
                if len(orders) == 0:
                    logger.info("No orders found, sleep for 10 seconds")
                    time.sleep(10)
                else:
                    return orders

            raise ValueError(
                'No orders found after {} retries in EtherDelta\'s API, try later'
                .format(retries))
        finally:
            self.es.terminate()
Exemple #3
0
from etherdeltaclientservice import EtherDeltaClientService

if __name__ == "__main__":
    print("taker.py: EtherDelta taker client")
    print("=================================")
    print("More info and details in this script's source code.")
    time.sleep(5)

    # Load config
    config = configparser.ConfigParser()
    config.read('config.ini')
    userAccount = config['DEFAULT']['user_wallet_public_key']
    user_wallet_private_key = config['DEFAULT']['user_wallet_private_key']
    token = config['DEFAULT']['token_to_trade']

    es = EtherDeltaClientService()
    es.start(userAccount, token)
    print("EtherDeltaService started")

    es.printBalances(token, userAccount)

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

    es.printOrderBook()
    es.printTrades()

    # Buy best order
    order = es.getBestSellOrder()
    es.trade(order, 0.0001, user_wallet_private_key)
Exemple #4
0
    token1 = config['DEFAULT']['token_to_trade1']
    token2 = config['DEFAULT']['token_to_trade2']
    token3 = config['DEFAULT']['token_to_trade3']
    token4 = config['DEFAULT']['token_to_trade4']
    token5 = config['DEFAULT']['token_to_trade5']
    token6 = config['DEFAULT']['token_to_trade6']
    token7 = config['DEFAULT']['token_to_trade7']
    token8 = config['DEFAULT']['token_to_trade8']
    token9 = config['DEFAULT']['token_to_trade9']
    token10 = config['DEFAULT']['token_to_trade10']
    tokens = [
        token1, token2, token3, token4, token5, token6, token7, token8, token9,
        token10
    ]
    for token in tokens:
        es = EtherDeltaClientService()

        es.start(userAccount, token)
        time.sleep(5)
        count = 0
        for x in range(0, 100):
            #balance = es.getBalance(token, userAccount)
            #print (balance)
            #balance = es.getBalance('ETH', userAccount)
            #print (balance)
            sells = es.orders_sells
            buys = es.orders_buys

            while len(sells) == 0:
                print("wait")
                time.sleep(10)
Exemple #5
0
# different EtherDelta maker and taker clients.
from etherdeltaclientservice import EtherDeltaClientService

if __name__ == "__main__":
    print("EtherDelta API client in python using websocket")
    print("More info and details in this script's source code.")
    time.sleep(1)

    # Load config
    config = configparser.ConfigParser()
    config.read('config.ini')
    userAccount = config['DEFAULT']['user_wallet_public_key']
    user_wallet_private_key = config['DEFAULT']['user_wallet_private_key']
    token = config['DEFAULT']['token_to_trade']

    es = EtherDeltaClientService()
    es.start(userAccount, token)
    print("EtherDeltaClientService started")

    es.printBalances(token, userAccount)

    while es.getBestSellOrder() == None or es.getBestBuyOrder() == None:
        print("Waiting until best sell and buy orders are known...")
        time.sleep(4)

    best_sell = es.getBestSellOrder()
    best_buy = es.getBestBuyOrder()
    best_sell_price = float(best_sell['price'])
    best_buy_price = float(best_buy['price'])
    market_width = abs((best_buy_price - best_sell_price) /
                       (best_buy_price + best_sell_price) / 2.0)