RAPTOR v18.4: Исправлена отчетность, активированы выходные
This commit is contained in:
46
invest-python-master/examples/easy_async_stream_client.py
Normal file
46
invest-python-master/examples/easy_async_stream_client.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import asyncio
|
||||
import os
|
||||
|
||||
from t_tech.invest import (
|
||||
AsyncClient,
|
||||
CandleInstrument,
|
||||
InfoInstrument,
|
||||
MarketDataResponse,
|
||||
SubscriptionInterval,
|
||||
TradeInstrument,
|
||||
)
|
||||
from t_tech.invest.async_services import AsyncMarketDataStreamManager
|
||||
|
||||
TOKEN = os.environ["INVEST_TOKEN"]
|
||||
|
||||
|
||||
async def main():
|
||||
async with AsyncClient(TOKEN) as client:
|
||||
market_data_stream: AsyncMarketDataStreamManager = (
|
||||
client.create_market_data_stream()
|
||||
)
|
||||
market_data_stream.candles.waiting_close().subscribe(
|
||||
[
|
||||
CandleInstrument(
|
||||
figi="BBG004730N88",
|
||||
interval=SubscriptionInterval.SUBSCRIPTION_INTERVAL_ONE_MINUTE,
|
||||
)
|
||||
]
|
||||
)
|
||||
market_data_stream.trades.subscribe(
|
||||
[
|
||||
TradeInstrument(
|
||||
figi="BBG004730N88",
|
||||
)
|
||||
]
|
||||
)
|
||||
async for marketdata in market_data_stream:
|
||||
marketdata: MarketDataResponse = marketdata
|
||||
print(marketdata)
|
||||
market_data_stream.info.subscribe([InfoInstrument(figi="BBG004730N88")])
|
||||
if marketdata.subscribe_info_response:
|
||||
market_data_stream.stop()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user