Skip to main content

Unofficial T-Bank wrapper

Project description

Bondana Client

PyPI - Python Version

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

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

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

$ pip install tinkoff-investments

$ git clone https://github.com/Mixolap/bondana_client.git

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

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

from bondana_client.bondana_client import Bondana

TOKEN = 'token'

client = Bondana(TOKEN)

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

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

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

client.portfolio.portfolio_get()

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

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)

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-0.1.1.tar.gz (5.4 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-0.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bondana_client-0.1.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for bondana_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0e5e59492141c4704d9b5e5d912bded540ae60126e30bcacace57b413b6adde2
MD5 1c0ed0696ce25284299049279ffdc5dc
BLAKE2b-256 9d7299e256eff2e1b2d72fd0d114e65645e6431b9f6a97652287f542e7c59c42

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bondana_client-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for bondana_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0132a042fcab4bb603013c09c4a41f3b6f5dffb2a1102b7a3003bc69b6aaa2d0
MD5 cf6e9d91de3e32bd9b73e6e1d996914a
BLAKE2b-256 1f799c52c62da0073e6d0638b34b478739f784690aae1fb31e40e5ab7f863374

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