
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
To install Notbank use pip
pip install notbank
This sdk makes use of the api of Notbank.
There are two communication protocols supported by the Notbank client. Communication via websocket, and via rest. Communication via websocket requires connection and permits subscriptions, other than that they are equivalent.
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)
All internal notbank client and notbank server errors inherit from NotbankException, and all client methods may throw it (e.g. invalid request, request timeout, ...)
# client : NotbankClient : ....
try:
orderbook = client.get_order_book(OrderBookRequest("BTCUSDT", 1, 1))
except NotbankException as e:
print(e)
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()
FAQs
Notbank API client library
We found that notbank demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.