semvec/pypi-packages huggingface dataset:
do-relative 1.0.0
Open and import relatively
Keywords: import, open, relative

# do-relative
Open and import relatively. 
Open files relative to the module you are in, instead of \_\_main__ module. 
Import modules relatively, directly using ```import module``` syntax, without using the ```from .``` syntax. 
Or use ```from .``` even if you are not in a package.
Import relative to given custom paths, including root directory so you can do an absolute import.

# Installation
```pip install do-relative```

# Api Reference
_class_ do_relative.**RelativeOpener**()

Constructor of this class returns an ```open``` function, instead of its instance. 
The paths you give to this function will be treated as relative to the directory calling module resides in. 

do_relative.**relative_import**(import_statement, folder = None)

Executes the _import_statement_ in caller's scope and relative to the calling module's location. 
Calling this function from another function is not supported. 
In that case, no new names will be introduced to caller's scope. 
_import_statement_ must be a string. Examples: "import module", "from module import func" or "from .. import module".
As a side note, you don't have to be in a package to use the syntax shown in the last example.
If supplied, _folder_ must be a path string. If _folder_ is provided import will be relative to that path instead of calling module's location.
_folder_ can either be relative to current working directory or absolute.
You can pass "/" as the _folder_ and make an absolute import. On windows "/" will be converted to the root directory of some drive.
Drive is determined by the current working directory.
bondana-client 2025.10.17171328
Unofficial T-Bank wrapper
Requires Python: >=3.5

# Bondana Client

[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tinkoff-investments)](https://www.python.org/downloads/)

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

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

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

<!-- termynal -->

```
$ pip install bondana-client

```

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

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

```python
from bondana_client import Bondana

TOKEN = 'token'

client = Bondana(TOKEN)
```
 
### Получить баланс свободных денег в рублях 

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

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

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

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

```python
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"))

```

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

```python
# лимитная заявка на покупку
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, })                
```

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

```python
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"))
```

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

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

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

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

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

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

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

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

## TODO:

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

шаг цены