Tinkoff / invest-python

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

[Bug] Не удается разместить заказ на покупку опциона #223

Closed Zakharlik closed 1 year ago

Zakharlik commented 1 year ago

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

При попытке разместить заказ для опциона выдается ошибка '30008', message="missing parameter: 'figi'" Но у опциона нет параметра Figi

Если пытаюсь использовать неправильный uid, то получу ошибку: message='instrument not found' что нормально.

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

import os
import time

from tinkoff.invest import Client
from tinkoff.invest.constants import INVEST_GRPC_API
from tinkoff.invest.grpc.common_pb2 import Quotation
from tinkoff.invest.grpc.orders_pb2 import ORDER_DIRECTION_BUY, ORDER_TYPE_LIMIT

TOKEN = os.getenv('TOKEN')

with Client(TOKEN, target=INVEST_GRPC_API) as client:
    accounts = client.users.get_accounts().accounts
    account_id = accounts[0].id
    data = {
        "figi": "account_id",
        "instrument_id": "9ca009f7-367c-4aa2-935e-b1bcb0515225",
        "direction": ORDER_DIRECTION_BUY,
        "quantity": 1,
        "price": Quotation(units=0, nano=1000000000),
        "account_id": account_id,
        "order_type": ORDER_TYPE_LIMIT,
        "order_id": time.ctime()
    }
    res = client.orders.post_order(**data)

Tinkoff Invest Version

0.2.0-beta54

Python Version

3.10

OS

Linux

Логи

6437a145993ace954ffd0b1594577fc1 PostOrder INVALID_ARGUMENT 30008
Traceback (most recent call last):
  File "/home/z/.venv/lib/python3.10/site-packages/tinkoff/invest/_errors.py", line 23, in wrapper
    return func(*args, **kwargs)
  File "/home/z/.venv/lib/python3.10/site-packages/tinkoff/invest/services.py", line 1274, in post_order
    response, call = self.stub.PostOrder.with_call(
  File "/home/z/.venv/lib/python3.10/site-packages/grpc/_channel.py", line 1043, in with_call
    return _end_unary_response_blocking(state, call, True, None)
  File "/home/z/.venv/lib/python3.10/site-packages/grpc/_channel.py", line 910, in _end_unary_response_blocking
    raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.INVALID_ARGUMENT
    details = "30008"
    debug_error_string = "UNKNOWN:Error received from peer ipv4:91.194.227.80:443 {created_time:"2023-04-17T17:38:47.029470082+07:00", grpc_status:3, grpc_message:"30008"}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/z/test.py", line 24, in <module>
    res = client.orders.post_order(**data)
  File "/home/z/.venv/lib/python3.10/site-packages/tinkoff/invest/_errors.py", line 41, in wrapper
    raise RequestError(status_code, details, metadata) from e
tinkoff.invest.exceptions.RequestError: (<StatusCode.INVALID_ARGUMENT: (3, 'invalid argument')>, '30008', Metadata(tracking_id='6437a145993ace954ffd0b1594577fc1', ratelimit_limit='300, 300;w=60', ratelimit_remaining=299, ratelimit_reset=26, message="missing parameter: 'figi'"))

Process finished with exit code 1
AlexanderVolkovTCS commented 1 year ago

Исправлено