from tinkoff.invest import (
AsyncClient,
CandleInstrument,
InfoInstrument,
SubscriptionInterval,
)
from tinkoff.invest.async_services import AsyncMarketDataStreamManager
async def main():
async with AsyncClient(TOKEN) as client:
market_data_stream: AsyncMarketDataStreamManager = (
client.create_market_data_stream()
)
market_data_stream.candles.subscribe(
[
CandleInstrument(
figi="BBG004730N88",
interval=SubscriptionInterval.SUBSCRIPTION_INTERVAL_ONE_MINUTE,
)
]
)
async for marketdata in market_data_stream:
print(marketdata)
market_data_stream.info.subscribe([InfoInstrument(figi="BBG004730N88")])
if name == "main":
asyncio.run(main())
Tinkoff Invest Version
0.2.0-beta29
Python Version
3.10
OS
Linux
Логи
Traceback (most recent call last):
File "test.py", line 49, in <module>
asyncio.run(main())
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
return future.result()
File "test.py", line 43, in main
async for marketdata in market_data_stream:
File "venv/lib/python3.10/site-packages/tinkoff/invest/_errors.py", line 91, in wrapper
async for result in func(*args, **kwargs):
File "venv/lib/python3.10/site-packages/tinkoff/invest/async_services.py", line 747, in market_data_stream
yield _grpc_helpers.protobuf_to_dataclass(response, MarketDataResponse)
File "venv/lib/python3.10/site-packages/tinkoff/invest/_grpc_helpers.py", line 269, in protobuf_to_dataclass
field_value = protobuf_to_dataclass(pb_value, field_type)
File "venv/lib/python3.10/site-packages/tinkoff/invest/_grpc_helpers.py", line 278, in protobuf_to_dataclass
field_value = [
File "venv/lib/python3.10/site-packages/tinkoff/invest/_grpc_helpers.py", line 279, in <listcomp>
protobuf_to_dataclass(item, first_arg) for item in pb_value
File "venv/lib/python3.10/site-packages/tinkoff/invest/_grpc_helpers.py", line 271, in protobuf_to_dataclass
field_value = field_type(pb_value)
File "/usr/local/lib/python3.10/enum.py", line 385, in __call__
return cls.__new__(cls, value)
File "/usr/local/lib/python3.10/enum.py", line 710, in __new__
raise ve_exc
ValueError: 8 is not a valid SubscriptionStatus
Что случилось?
Ошибка при подписке на свечи
Воспроизведение
import asyncio import os
from tinkoff.invest import ( AsyncClient, CandleInstrument, InfoInstrument, SubscriptionInterval, ) from tinkoff.invest.async_services import AsyncMarketDataStreamManager
async def main(): async with AsyncClient(TOKEN) as client: market_data_stream: AsyncMarketDataStreamManager = ( client.create_market_data_stream() ) market_data_stream.candles.subscribe( [ CandleInstrument( figi="BBG004730N88", interval=SubscriptionInterval.SUBSCRIPTION_INTERVAL_ONE_MINUTE, ) ] ) async for marketdata in market_data_stream: print(marketdata) market_data_stream.info.subscribe([InfoInstrument(figi="BBG004730N88")])
if name == "main": asyncio.run(main())
Tinkoff Invest Version
0.2.0-beta29
Python Version
3.10
OS
Linux
Логи