Exemplo n.º 1
0
if deal:

    # Submit limit ask order.
    logger.debug(f'submitting {pair} frontrunning limit ask order.')
    post = askorder(pair, size)
    post = post.json()
    dump = json.dumps(post, sort_keys=True, indent=4, separators=(',', ': '))
    logger.debug(dump)

    # Define poststatus class.
    # Purpose: Stores the state of the orderid parameter upon exiting the websocket connection session.
    class Poststatus:
        def __init__(self, state):
            self.__state = state

        def getvalue(self):
            return self.__state

        def setvalue(self, state):
            self.__state = state

    poststatus = Poststatus('')

    # Determine if the order was filled.
    confirmexecution(orderid=post['order_id'], poststatus=poststatus)
    if 'filled' in poststatus.getvalue(): poststatus = True

    # Let the shell know we successfully made it this far!
    if poststatus: sys.exit(0)
    else: sys.exit(1)
Exemplo n.º 2
0
last = decimaldrop(pair, drop)
if last:

    # Set bid size.
    size = '0.01'

    # Define trigger and stop loss prices. Redefine last for submission.
    last = Decimal(last * Decimal(0.999)).quantize(Decimal('1.00'))
    trip = Decimal(last * Decimal(0.999)).quantize(Decimal('1.00'))
    stop = Decimal(trip * Decimal(0.999)).quantize(Decimal('1.00'))

    post = makeliquidity(pair, size, str(last))
    post = post.json()
    dump = json.dumps(post, sort_keys=True, indent=4, separators=(',', ': '))
    logger.info(dump)

    # Determine if the order was filled.
    load = json.loads(dump)
    swap = load['order_id']
    fill = confirmexecution(swap)
    if fill:

        # Submit stop loss order.
        post = limitstop(pair, size, str(trip), str(stop))
        post = post.json()
        dump = json.dumps(post,
                          sort_keys=True,
                          indent=4,
                          separators=(',', ': '))
        logger.info(dump)