def setup(request): _main = Main(CONFIG.MAIN_INDEX) _tenant = Tenant(CONFIG.TENANT_INDEX) markets = _tenant.list_markets() _main.free_charge(8, 100000000000) _main.free_charge(417, 100000000000) assert markets, "No markets!" print("market:", markets[0]) market_id = markets[0].id precision = int(_main.get_market_details(market_id=market_id).price_places) trading_pair = markets[0].trading_pair print(_tenant.get_market_details(market_id=market_id)) def finalize(): time.sleep(5) orders = _main.get_orders(status=["entrusting"]) for i in orders: logger.error(f"canceling: {i}") try: _main.withdraw(i.order_id) except Exception as e: logger.error(e) else: print("No entrusting orders") orders = _main.get_orders(status=["entrusting"]) for i in orders: logger.error(f"cancel failed: {i}") else: print("No entrusting orders") request.addfinalizer(finalize) return _main, market_id, trading_pair, precision
def main(): _venture = Venture(CONFIG.VENTURE_INDEX) usdt_id = _venture.get_usdt_coin_id() _tenant = Tenant(CONFIG.TENANT_INDEX) _faucet = Faucet(CONFIG.FAUCET_INDEX) _project = _venture.get_project(CONFIG.PROJECT_INDEX) assert _project, "Must have a project first to create market" _market = _tenant.get_market(buy=usdt_id, sell=_project.coin_id) print("list markets: ", _tenant.list_markets()) if not _market: _faucet.free_charge(coin_id=_venture.get_usdt_coin_id(), account_id=_tenant.account_id) logger.info( "========== Faucet(%s) charge Tenant(%u) Done ==========" % (CONFIG.FAUCET_INDEX, CONFIG.TENANT_INDEX)) _market, create_order_id = _tenant.create_market( usdt_id, _project.coin_id, "6", "0") assert create_order_id, "Market create order id should not be null" print( "coin verify ==>", _tenant.verify_market_trading_coin(buy_coin=usdt_id, sell_coin=_project.coin_id)) assert _tenant.list_markets()