Tinkoff / invest-python

Tinkoff Invest Python gRPC client
https://tinkoff.github.io/invest-python/
Apache License 2.0
303 stars 88 forks source link

[Bug] В списке операций по инструменту parent_operation_id стали указывать на неизвестные операции #162

Closed neumond closed 1 year ago

neumond commented 1 year ago

Что случилось?

Всегда получалось соотнести OPERATION_TYPE_BROKER_FEE с конкретной операцией BUY/SELL, но теперь не получается. BROKER_FEE приходят, но parent_operation_id теперь указывают на операции, которых нет в ответе.

Обновление версии до beta43 не помогло, точно такая же проблема.

Воспроизведение

resp = await client.get().operations.get_operations(
    account_id=account_id,
    from_=datetime(1990, 1, 1),
    to=datetime.utcnow() + timedelta(days=1),
    state=OperationState.OPERATION_STATE_EXECUTED,
    figi=figi,
)
ops = {}
for op in resp.operations:
    if op.parent_operation_id:
        continue
    ... # здесь дополнительная логика для OVERNIGHT/DIVIDEND/DIVIDEND_TAX
    # сюда добираются только BUY/SELL
    ops[op.id] = {...}
for op in resp.operations:
    if not op.parent_operation_id:
        continue
    assert op.operation_type is OperationType.OPERATION_TYPE_BROKER_FEE
    # дальше падает, потому что не нашёлся parent_operation_id
    parent_op = ops[op.parent_operation_id]

Tinkoff Invest Version

0.2.0-beta43

Python Version

3.10

OS

Linux

Логи

No response

neumond commented 1 year ago

Кажется порешалось, снова работает.