def setUpClass(cls):
     DB_TEST = 1
     cls.rdb = utils.get_redis_db(db_no=DB_TEST)
     cls.supported_tokens = config.SUPPORTED_TOKENS.keys()
     cls.user = '******'
     cls.balance_type = ['available', 'lock']
     cls.balance = BalanceHandler(cls.rdb, cls.supported_tokens)
Esempio n. 2
0
def import_order_book():
    if config.MODE == 'simulation':
        rdb = utils.get_redis_db()

        # import one big file container order books to redis
        # ob_file = 'data/full_ob.dat'
        # ob_file = 'data/sample_ob.dat'
        # utils.setup_data(rdb, ob_file)

        # import multiple order book file to redis
        ob_path = 'data/order_books/'
        utils.import_order_book_to_db(rdb, ob_path)
Esempio n. 3
0
def init_balance():
    rdb = utils.get_redis_db()
    supported_tokens = config.SUPPORTED_TOKENS
    balance_handler = BalanceHandler(rdb, supported_tokens.keys())

    # reset balance
    rdb.delete('INITIALIZED_BALANCES')
    for k in rdb.keys('balance*available'):
        rdb.delete(k)

    # init deposit
    initialized_balances = rdb.get('INITIALIZED_BALANCES')
    if not initialized_balances:
        for ex, balance in config.INITIAL_BALANCE.items():
            key = config.API_KEY[ex]
            for token, amount in balance.items():
                balance_handler.deposit(key, token, amount, 'available')
        rdb.set('INITIALIZED_BALANCES', True)
Esempio n. 4
0
def cancel_order(params):
    return bitfinex.cancel_order_api(**params)


@api.route('/v1/withdraw', methods=['POST'])
@action()
def withdraw(params):
    return bitfinex.withdraw_api(**params)


@api.route('/v1/history/movements', methods=['POST'])
@action()
def history(params):
    return bitfinex.history_api(**params)


rdb = utils.get_redis_db()
if config.MODE == 'simulation':
    order_handler = SimulationOrder(rdb)
else:
    order_handler = CoreOrder()
supported_tokens = config.SUPPORTED_TOKENS
balance_handler = BalanceHandler(rdb, supported_tokens.keys())
bitfinex = Bitfinex('liqui', config.PRIVATE_KEY['bitfinex'],
                    list(supported_tokens.values()), rdb, order_handler,
                    balance_handler, config.BITFINEX_ADDRESS)

if __name__ == '__main__':
    logger.info('Running in {} mode'.format(config.MODE))
    api.run(host='0.0.0.0', port=5400, debug=True)