RAPTOR v18.4: Исправлена отчетность, активированы выходные
This commit is contained in:
41
invest-python-master/examples/async_stream_client.py
Normal file
41
invest-python-master/examples/async_stream_client.py
Normal file
@@ -0,0 +1,41 @@
|
||||
import asyncio
|
||||
import os
|
||||
from typing import AsyncIterable
|
||||
|
||||
from t_tech.invest import (
|
||||
AsyncClient,
|
||||
CandleInstrument,
|
||||
MarketDataRequest,
|
||||
SubscribeCandlesRequest,
|
||||
SubscriptionAction,
|
||||
SubscriptionInterval,
|
||||
)
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
async def main():
|
||||
async def request_iterator():
|
||||
yield MarketDataRequest(
|
||||
subscribe_candles_request=SubscribeCandlesRequest(
|
||||
subscription_action=SubscriptionAction.SUBSCRIPTION_ACTION_SUBSCRIBE,
|
||||
instruments=[
|
||||
CandleInstrument(
|
||||
figi="BBG004730N88",
|
||||
interval=SubscriptionInterval.SUBSCRIPTION_INTERVAL_ONE_MINUTE,
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
while True:
|
||||
await asyncio.sleep(1)
|
||||
|
||||
async with AsyncClient(TOKEN) as client:
|
||||
async for marketdata in client.market_data_stream.market_data_stream(
|
||||
request_iterator()
|
||||
):
|
||||
print(marketdata)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user