async def run(): api_key = os.environ['BITVAVOAPIKEY'] sec_key = os.environ['BITVAVOSECKEY'] client = CryptoXLib.create_bitvavo_client(api_key, sec_key) print("Time:") await client.get_time() print("Exchange info:") await client.get_exchange_info() print("Assets:") await client.get_assets() print("Open orders:") await client.get_open_orders() print("Create order:") try: await client.create_order(pair = Pair("BTC", "EUR"), side = enums.OrderSide.BUY, type = enums.OrderType.LIMIT, amount = "10000", price = "1") except BitvavoException as e: print(e) print("Cancel order:") try: await client.cancel_order(pair = Pair("BTC", "EUR"), order_id = "1") except BitvavoException as e: print(e) print("Balance:") await client.get_balance() await client.close()
async def run(): api_key = os.environ['BITVAVOAPIKEY'] sec_key = os.environ['BITVAVOSECKEY'] client = CryptoXLib.create_bitvavo_client(api_key, sec_key) # Bundle several subscriptions into a single websocket client.compose_subscriptions([ AccountSubscription(pairs = [Pair("BTC", "EUR")]), TickerSubscription([Pair("BTC", "EUR")], callbacks = [ticker_update]), Ticker24Subscription([Pair("BTC", "EUR")], callbacks = [ticker24_update]), OrderbookSubscription([Pair("BTC", "EUR")], callbacks = [order_book_update]), ]) # Bundle another subscriptions into a separate websocket client.compose_subscriptions([ CandlesticksSubscription(pairs = [Pair("BTC", "EUR")], intervals = [enums.CandelstickInterval.I_1MIN]) ]) # Execute all websockets asynchronously await client.start_websockets()