### Install Notbank Python SDK Source: https://github.com/notbank-exchange/notbank-python/blob/master/README.md Installs the Notbank Python SDK using pip. This is the primary method for integrating Notbank's services into your Python projects. ```bash pip install notbank ``` -------------------------------- ### Place Order at Top of Book Source: https://github.com/notbank-exchange/notbank-python/blob/master/README.md A comprehensive example of placing a buy order for a cryptocurrency at the top of the order book. This includes client authentication, retrieving account balances, calculating order parameters, and sending the order, with subsequent handling of the order status. ```python import random from decimal import Decimal from notbank_python_sdk.notbank_client import NotbankClient from notbank_python_sdk.client_connection_factory import new_rest_client_connection account_id: int = 13 # must be user account id # instantiate client connection = new_rest_client_connection() client = NotbankClient(connection) # authentication (same for rest client or websocket client) authenticate = client.authenticate( AuthenticateRequest( api_public_key="api-public-key", api_secret_key="api-secret-key", user_id="user-id", ) ) if not authenticate.authenticated: raise Exception("client not authenticated") # get USDT user balance (also known as position) positions = client.get_account_positions( GetAccountPositionsRequest(account_id)) usdt_balance = None product = "USDT" market_pair = "BTCUSDT" for position in positions: if position.product_symbol == product: usdt_balance = position if usdt_balance is None: raise Exception("user has no balance") # define order_amount (between all usdt_balance and half usdt_balance) total_balance = usdt_balance.amount quantity_to_spend = total_balance - \ Decimal(random.random()) * (total_balance/2) # define order_price (around market top) orderbook = client.get_order_book( OrderBookRequest(market_pair, level=2, depth=5)) top_orderbook = orderbook.bids[0] delta = Decimal(random.randrange(10, 100))/1000 order_price = top_orderbook.price + delta order_quantity = quantity_to_spend / order_price # send order instrument = client.get_instrument_by_symbol(market_pair) request = SendOrderRequest( instrument=instrument, account_id=account_id, time_in_force=TimeInForce.GTC, side=Side.Buy, quantity=order_quantity, limit_price=order_price, order_type=OrderType.Limit, ) response = client.send_order(request) # handle order result if response.status == SendOrderStatus.REJECTED: # order was rejected raise Exception("rejected order") else: # order was accepted order_id = response.order_id print(order_id) # close client client.close() ``` -------------------------------- ### Create Notbank REST Client Source: https://github.com/notbank-exchange/notbank-python/blob/master/README.md Demonstrates how to create a Notbank client that communicates via REST. It includes setting up the connection and handling potential NotbankExceptions during client initialization. ```python from notbank_python_sdk.requests_models import * from notbank_python_sdk.client_connection_factory import new_rest_client_connection from notbank_python_sdk.error import NotbankException from notbank_python_sdk.notbank_client import NotbankClient try: # an rest client via http rest_connection = new_rest_client_connection() client = NotbankClient(rest_connection) except NotbankException as e: print(e) ``` -------------------------------- ### Python Project Dependencies Source: https://github.com/notbank-exchange/notbank-python/blob/master/requirements.txt This snippet details the Python packages and their version constraints necessary for the project's environment. It includes core libraries for network requests, encoding, and WebSocket communication. ```python certifi==2025.7.9 ; python_version >= '3.7' charset-normalizer==2.0.12 dacite==1.9.2 idna==3.3 requests==2.27.1 simplejson==3.20.1 typing-extensions==4.7.1 urllib3==1.26.9 websocket-client==1.6.1 ``` -------------------------------- ### Handle Notbank Exceptions Source: https://github.com/notbank-exchange/notbank-python/blob/master/README.md Illustrates how to handle errors that may occur during Notbank client operations. All Notbank-related errors inherit from NotbankException, covering issues like invalid requests or timeouts. ```python # client : NotbankClient : .... try: orderbook = client.get_order_book(OrderBookRequest("BTCUSDT", 1, 1)) except NotbankException as e: print(e) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.