Skip to main content

Unofficial T-Bank wrapper

Project description

Bondana Client

PyPI - Python Version

Неофициальная обертка официального Tinkoff Invest API v2, оптимизированная для торговли облигациями на языке Python.

:warning: На данный момент отлажена работа на облигациях номиналом 1000 рублей, на других номиналах не тестировалось

Установка клиента

$ pip install bondana-client

Как пользоваться

Инициализация клиента

from bondana_client import Bondana

TOKEN = 'token'

client = Bondana(TOKEN)

Получить баланс свободных денег в рублях

balance_rub, blocked = client.get_balance('rub')

Получение списка бумаг в портфеле

client.portfolio.portfolio_get()
for bond in portfolio.positions:
    print(bond)

Получение истории операций

from datetime import datetime, timedelta

nw = datetime.now() - timedelta(days=1) # получим сделки за последний день
d1 = datetime(nw.year, nw.month, nw.day, 0, 0, 0, tzinfo=timezone('Europe/Moscow'))  
d2 = datetime.now(tz=timezone('Europe/Moscow')) 

ops = client.operations.operations_get(limit=1000, from_=d1, to=d2)

ops.reverse()
for op in ops:
    print(op.get("figi"), op.get("price"), op.get("payment"), op.get("quantity"))

Постановка лимитной заявки

# лимитная заявка на покупку
lots  = 1
price = 987.65
figi = "BBG00Y9B45C2"
order_limit = client.orders.orders_limit_order_post(figi, 
	limit_order_request = {"lots": lots, "operation": "Buy", "price":price, })  

# лимитная заявка на продажу
lots  = 1
price = 997.65
figi = "BBG00Y9B45C2"
order_limit = client.orders.orders_limit_order_post(figi, 
	limit_order_request = {"lots": lots, "operation": "Sell", "price":price, })                

Получение списка активных заявок

client.orders.orders_get() # список заявок в формате объектов Tinkoff API
client.orders.orders_get_json() # список заявок в формате JSON

for order in client.orders.orders_get_json():
	print(order.get("order_id"), order.get("operation"), order.get("figi"))

Отмена заявки на покупку

# последовательная отмена всех активных заявок, для примера
for order in client.orders.orders_get_json():
	client.orders.orders_cancel_post(order.get("order_id"))

Просмотр стакана по figi

figi = "BBG00Y9B45C2"
orderbook = client.market.market_orderbook_get_dict(figi, 20)

Получение списка всех доступных облигаций

bonds = client.market.market_bonds_get()
for bond in bonds:
	print(bond)

Получение свечей

candles = client.market.candles(figi, from_, to, interval, candle_source_type)
for candle in candles:
	print(candle)

TODO:

получение лотности

шаг цены

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bondana_client-2025.6.2064233.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bondana_client-2025.6.2064233-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file bondana_client-2025.6.2064233.tar.gz.

File metadata

  • Download URL: bondana_client-2025.6.2064233.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for bondana_client-2025.6.2064233.tar.gz
Algorithm Hash digest
SHA256 81f4b271d0b68cfb29fbfa4d091d84dde71ddbe45fe285f5b22e8783d72458c0
MD5 29e6d2a02323d7f1ca49393e9e05c626
BLAKE2b-256 4a634bb7c10a9e2bb75b50dc07a87d5b8fd8abf2ffae2bf597e8e1f7d9e12bd3

See more details on using hashes here.

File details

Details for the file bondana_client-2025.6.2064233-py3-none-any.whl.

File metadata

File hashes

Hashes for bondana_client-2025.6.2064233-py3-none-any.whl
Algorithm Hash digest
SHA256 1cfcb4c9d0f266bebff4aa8f656a3808525f8d44f302ebd1bd75291f9b5f49d9
MD5 1b4729be49277a74b3cfab7120d01b7e
BLAKE2b-256 d93ee990a431514df36a396f6c0435b1c1e0391ac92b940af94cb77f2c19f017

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page