TqSdk Architecture: Asynchronous Data Channels and Trading Modes
Summary
This framework overview explains TqSdk’s component layout and message flow. It describes TqChan as a one-way queue between components and outlines how order messages travel from user code through TqApi and TqAccount to a trading gateway. In the reverse direction, market data arrives from a market gateway, passes through the account component, and is merged into TqApi’s in-memory data store.
The document also explains that the architecture supports different operating modes by replacing components, such as using a local simulation component in place of the live account component. It includes diagrams and names supporting modules for simulation, backtesting, technical analysis, exceptions, and data structures. This is an architectural description rather than a trading strategy or empirical evaluation; the excerpt is partial, and it does not assess latency, reliability, or trading performance.
Key ideas
- TqSdk uses asynchronous queues to pass messages in one direction between components.
- Order requests flow from user code through the API and account layer to the trading gateway.
- Market data flows from the gateway through the account layer into the API’s in-memory store.
- Replacing selected components allows the framework to support modes such as simulated trading.
- The overview identifies separate modules for backtesting, technical analysis, simulation, and core data structures.
Tags
Full text
# framework
.. _dev_framework:
TqSdk整体结构
====================================================
文件结构
----------------------------------------------------
========================== =========================================
File Description
========================== =========================================
api.py TqApi 接口主文件
tqhelper.py TqApi 辅助代码
exception.py 异常类型定义
objs.py 主要业务数据结构定义
sim.py 本地模拟交易
backtest.py 回测支持
lib.py 交易辅助工具
ta.py 技术指标
tafunc.py 技术分析函数
ctpse/* 穿透式监管信息采集模块
test/* 单元测试用例
demo/* 示例程序
========================== =========================================
数据流
----------------------------------------------------
TqSdk中以数据流的方式连接各组件。TqChan(本质是一个asyncio.Queue)被用作两个组件间的单向数据流管道,一个组件向 TqChan 中放入数据包,另一个组件从 TqChan 中依次取出数据包。
实盘运行时,整个数据流结构如下图:
.. raw:: html
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="484px" viewBox="-0.5 -0.5 484 281" style="max-width:100%;max-height:281px;"><defs/><g><rect x="0" y="0" width="200" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(37.5,6.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="124" height="26" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 124px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">Websocket Client<br />To OpenTradeGateway</div></div></foreignObject><text x="62" y="19" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">Websocket Client<br>To OpenTradeGateway</text></switch></g><rect x="280" y="0" width="200" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(324.5,6.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="110" height="26" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 110px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">Websocket Client<br />To OpenMdGateway</div></div></foreignObject><text x="55" y="19" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">Websocket Client<br>To OpenMdGateway</text></switch></g><rect x="0" y="120" width="480" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(210.5,133.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="58" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 58px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">TqAccount</div></div></foreignObject><text x="29" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">TqAccount</text></switch></g><path d="M 115 160.5 L 125 160.5 L 125 220.5 L 135.5 220.5 L 120 239.5 L 104.5 220.5 L 115 220.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(79.5,183.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="78" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">api_recv_chan</div></div></foreignObject><text x="39" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">api_recv_chan</text></switch></g><path d="M 365 239.5 L 355 239.5 L 355 179.5 L 344.5 179.5 L 360 160.5 L 375.5 179.5 L 365 179.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(321.5,205.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="81" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">api_send_chan</div></div></foreignObject><text x="41" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">api_send_chan</text></switch></g><rect x="0" y="240" width="480" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(223.5,253.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="32" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 32px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">TqApi</div></div></foreignObject><text x="16" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">TqApi</text></switch></g><path d="M 35 40.5 L 45 40.5 L 45 100.5 L 55.5 100.5 L 40 119.5 L 24.5 100.5 L 35 100.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(2.5,63.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="72" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">td_recv_chan</div></div></foreignObject><text x="36" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">td_recv_chan</text></switch></g><path d="M 165 119.5 L 155 119.5 L 155 59.5 L 144.5 59.5 L 160 40.5 L 175.5 59.5 L 165 59.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(124.5,85.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="75" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">td_send_chan</div></div></foreignObject><text x="38" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">td_send_chan</text></switch></g><path d="M 314.5 40.5 L 324.5 40.5 L 324.5 100.5 L 335 100.5 L 319.5 119.5 L 304 100.5 L 314.5 100.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(278.5,63.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="79" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">md_recv_chan</div></div></foreignObject><text x="40" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">md_recv_chan</text></switch></g><path d="M 444.5 119.5 L 434.5 119.5 L 434.5 59.5 L 424 59.5 L 439.5 40.5 L 455 59.5 L 444.5 59.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(400.5,85.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="82" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">md_send_chan</div></div></foreignObject><text x="41" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">md_send_chan</text></switch></g></g></svg>
数据包上行流程(以报单为例):
#. 用户程序调用 TqApi 中的某些需要发出数据包的功能函数, 以 TqApi.insert_order 为例
#. TqApi.insert_order 函数生成一个需要发出的数据包, 将此数据包放入 api_send_chan
#. TqAccount 从 api_send_chan 中取出此数据包,根据 aid 字段,决定将此数据包放入 td_send_chan
#. 连接到交易网关的 websocket client 从 td_send_chan 中取出此数据包,通过网络发出
数据包下行流程(以接收行情为例):
#. 连接到行情网关的 websocket client 从网络收到一个数据包,将其放入 md_recv_chan
#. TqAccount 从md_recv_chan中取出此数据包,将它放入 api_recv_chan
#. TqApi 从api_recv_chan中取出此数据包,将数据包中携带的行情数据合并到内存存储区中
基于这样的数据流结构,可以通过简单更换部分组件的方式实现不同工作模式。例如模拟交易时,我们用 TqSim 替换 TqAccount:
.. raw:: html
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="484px" viewBox="-0.5 -0.5 484 281" style="max-width:100%;max-height:281px;"><defs/><g><rect x="280" y="0" width="200" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(324.5,6.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="110" height="26" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 110px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">Websocket Client<br />To OpenMdGateway</div></div></foreignObject><text x="55" y="19" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">Websocket Client<br>To OpenMdGateway</text></switch></g><rect x="0" y="120" width="480" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(222.5,133.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="34" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 36px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">TqSim</div></div></foreignObject><text x="17" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">TqSim</text></switch></g><path d="M 115 160.5 L 125 160.5 L 125 220.5 L 135.5 220.5 L 120 239.5 L 104.5 220.5 L 115 220.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(79.5,183.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="78" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">api_recv_chan</div></div></foreignObject><text x="39" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">api_recv_chan</text></switch></g><path d="M 365 239.5 L 355 239.5 L 355 179.5 L 344.5 179.5 L 360 160.5 L 375.5 179.5 L 365 179.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(321.5,205.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="81" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">api_send_chan</div></div></foreignObject><text x="41" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">api_send_chan</text></switch></g><rect x="0" y="240" width="480" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(223.5,253.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="32" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 32px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">TqApi</div></div></foreignObject><text x="16" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">TqApi</text></switch></g><path d="M 314.5 40.5 L 324.5 40.5 L 324.5 100.5 L 335 100.5 L 319.5 119.5 L 304 100.5 L 314.5 100.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(278.5,63.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="79" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">md_recv_chan</div></div></foreignObject><text x="40" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">md_recv_chan</text></switch></g><path d="M 444.5 119.5 L 434.5 119.5 L 434.5 59.5 L 424 59.5 L 439.5 40.5 L 455 59.5 L 444.5 59.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(400.5,85.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="82" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">md_send_chan</div></div></foreignObject><text x="41" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">md_send_chan</text></switch></g></g></svg>
策略回测则是这样:
.. raw:: html
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="484px" viewBox="-0.5 -0.5 484 401" style="max-width:100%;max-height:401px;"><defs/><g><rect x="280" y="0" width="200" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(324.5,6.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="110" height="26" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 110px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">Websocket Client<br />To OpenMdGateway</div></div></foreignObject><text x="55" y="19" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">Websocket Client<br>To OpenMdGateway</text></switch></g><rect x="0" y="240" width="480" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(222.5,253.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="34" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 36px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">TqSim</div></div></foreignObject><text x="17" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">TqSim</text></switch></g><path d="M 115 280.5 L 125 280.5 L 125 340.5 L 135.5 340.5 L 120 359.5 L 104.5 340.5 L 115 340.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(79.5,303.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="78" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">api_recv_chan</div></div></foreignObject><text x="39" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">api_recv_chan</text></switch></g><path d="M 365 359.5 L 355 359.5 L 355 299.5 L 344.5 299.5 L 360 280.5 L 375.5 299.5 L 365 299.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(321.5,325.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="81" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">api_send_chan</div></div></foreignObject><text x="41" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">api_send_chan</text></switch></g><rect x="0" y="360" width="480" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(223.5,373.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="32" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 32px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">TqApi</div></div></foreignObject><text x="16" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">TqApi</text></switch></g><path d="M 314.5 40.5 L 324.5 40.5 L 324.5 100.5 L 335 100.5 L 319.5 119.5 L 304 100.5 L 314.5 100.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(278.5,63.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="79" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">md_recv_chan</div></div></foreignObject><text x="40" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">md_recv_chan</text></switch></g><path d="M 444.5 119.5 L 434.5 119.5 L 434.5 59.5 L 424 59.5 L 439.5 40.5 L 455 59.5 L 444.5 59.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(400.5,85.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="82" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">md_send_chan</div></div></foreignObject><text x="41" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">md_send_chan</text></switch></g><rect x="0" y="120" width="480" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(209.5,133.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="60" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 62px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">TqBacktest</div></div></foreignObject><text x="30" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">TqBacktest</text></switch></g><path d="M 115 160.5 L 125 160.5 L 125 220.5 L 135.5 220.5 L 120 239.5 L 104.5 220.5 L 115 220.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(64.5,183.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="107" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">backtest_recv_chan</div></div></foreignObject><text x="54" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">backtest_recv_chan</text></switch></g><path d="M 365 239.5 L 355 239.5 L 355 179.5 L 344.5 179.5 L 360 160.5 L 375.5 179.5 L 365 179.5 Z" fill="none" stroke="#000000" stroke-linejoin="round" stroke-miterlimit="10" pointer-events="none"/><g transform="translate(307.5,205.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="110" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; white-space: nowrap; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;background-color:#ffffff;">backtest_send_chan</div></div></foreignObject><text x="55" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">backtest_send_chan</text></switch></g></g></svg>
内存数据存储与更新
----------------------------------------------------
按照 DIFF 协议推荐的客户端最佳实践,TqApi 使用单一变量(TqApi._data)存储所有业务数据, 它的结构如下:
.. raw:: html
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="581px" viewBox="-0.5 -0.5 581 882" style="max-width:100%;max-height:882px;"><defs/><g><path d="M 40 40 L 40 880" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="0" y="0" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(37.5,13.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="4" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 4px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">/</div></div></foreignObject><text x="2" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">/</text></switch></g><path d="M 100 100 L 40 100" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 140 120 L 140 160 L 200 160" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="100" y="80" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(121.5,93.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="36" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 38px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">quotes</div></div></foreignObject><text x="18" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">quotes</text></switch></g><path d="M 240 180 L 240 210 L 300 210" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="200" y="140" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(202.5,153.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="74" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 76px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">SHFE.cu1901</div></div></foreignObject><text x="37" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">SHFE.cu1901</text></switch></g><rect x="300" y="200" width="80" height="20" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(313.5,203.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="52" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 52px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">last_price</div></div></foreignObject><text x="26" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">last_price</text></switch></g><path d="M 300 250 L 240 250 L 240 180" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="300" y="240" width="80" height="20" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(320.5,243.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="38" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 40px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">volume</div></div></foreignObject><text x="19" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">volume</text></switch></g><path d="M 200 300 L 140 300 L 140 120" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="200" y="280" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(202.5,293.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="74" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 76px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">SHFE.cu1902</div></div></foreignObject><text x="37" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">SHFE.cu1902</text></switch></g><path d="M 100 380 L 40 380 L 40 40" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="100" y="360" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(124.5,373.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="30" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 32px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">klines</div></div></foreignObject><text x="15" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">klines</text></switch></g><path d="M 100 440 L 40 440 L 40 40" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="100" y="420" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(127.5,433.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="24" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 25px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">ticks</div></div></foreignObject><text x="12" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">ticks</text></switch></g><path d="M 100 500 L 40 500 L 40 40" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="100" y="480" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(125.5,493.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="28" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 28px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">trade</div></div></foreignObject><text x="14" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">trade</text></switch></g><path d="M 200 560 L 140 560 L 140 520" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="200" y="540" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(224.5,553.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="30" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 32px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">user1</div></div></foreignObject><text x="15" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">user1</text></switch></g><path d="M 300 620 L 240 620 L 240 580" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="300" y="600" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(315.5,613.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="48" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 48px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">positions</div></div></foreignObject><text x="24" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">positions</text></switch></g><path d="M 400 680 L 340 680 L 340 640" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="400" y="660" width="80" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(402.5,673.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="74" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 76px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">SHFE.cu1901</div></div></foreignObject><text x="37" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">SHFE.cu1901</text></switch></g><path d="M 500 730 L 440 730 L 440 700" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="500" y="720" width="80" height="20" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(515.5,723.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="48" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 50px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">pos_long</div></div></foreignObject><text x="24" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">pos_long</text></switch></g><path d="M 500 770 L 440 770 L 440 700" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="500" y="760" width="80" height="20" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(513.5,763.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="52" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 54px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">pos_short</div></div></foreignObject><text x="26" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">pos_short</text></switch></g></g></svg>
在每次收到数据包时,TqApi都会将数据包内容合并到 TqApi._data 中. 具体的代码流程如下:
#. websocket client 收到数据包, 放入 TqApi._pending_diffs
#. wait_update 函数发现 TqApi._pending_diffs 有待处理数据包, 中止异步循环以处理此数据包::
while not self._wait_timeout and not self._pending_diffs: # 这里发现 self._pending_diffs 非空, 中止 while 循环
self._run_once()
#. wait_update 调用 self._merge_diff 函数::
for d in self._diffs:
self._merge_diff(self._data, d, self._prototype, False)
#. TqApi._merge_diff 函数将收到的数据包并入本地存储.
#. 对于k线之类的序列数据, 后续继续将更新的数据复制到 pandas dataframe 中
异步任务调度
----------------------------------------------------
TqApi 在 wait_update 函数中完成所有异步任务的调度执行. 每当用户程序执行 api.wait_update 函数时, 会调度所有 task 运行, 直到收到新数据包或超时 wait_update函数返回, 继续执行后续用户代码
.. raw:: html
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="401px" viewBox="-0.5 -0.5 401 601" style="max-width:100%;max-height:601px;"><defs/><g><path d="M 60 40 L 60 73.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 78.88 L 56.5 71.88 L 60 73.63 L 63.5 71.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="0" y="0" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(35.5,13.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="48" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 49px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">用户代码</div></div></foreignObject><text x="24" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">用户代码</text></switch></g><path d="M 60 120 L 60 153.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 158.88 L 56.5 151.88 L 60 153.63 L 63.5 151.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="0" y="80" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(17.5,93.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="84" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 86px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">api.wait_update</div></div></foreignObject><text x="42" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">api.wait_update</text></switch></g><path d="M 60 200 L 60 233.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 238.88 L 56.5 231.88 L 60 233.63 L 63.5 231.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="0" y="160" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(35.5,173.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="48" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 49px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">用户代码</div></div></foreignObject><text x="24" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">用户代码</text></switch></g><path d="M 60 280 L 60 313.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 318.88 L 56.5 311.88 L 60 313.63 L 63.5 311.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="0" y="240" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(17.5,253.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="84" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 86px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">api.wait_update</div></div></foreignObject><text x="42" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">api.wait_update</text></switch></g><rect x="280" y="180" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(295.5,186.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="88" height="26" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 90px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">websocket client<br />发送 task</div></div></foreignObject><text x="44" y="19" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">websocket client<br>发送 task</text></switch></g><rect x="280" y="220" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(295.5,226.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="88" height="26" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 90px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">websocket client<br />接收 task</div></div></foreignObject><text x="44" y="19" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">websocket client<br>接收 task</text></switch></g><rect x="280" y="300" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(286.5,313.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="106" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 108px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">用户创建的其它task</div></div></foreignObject><text x="53" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">用户创建的其它task</text></switch></g><rect x="280" y="260" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(289.5,273.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="100" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 100px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">TqSdk创建的tqsdk</div></div></foreignObject><text x="50" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">TqSdk创建的tqsdk</text></switch></g><path d="M 120 240 L 282.04 183" fill="none" stroke="#000000" stroke-miterlimit="10" stroke-dasharray="3 3" pointer-events="none"/><path d="M 122.04 280 L 280 338" fill="none" stroke="#000000" stroke-miterlimit="10" stroke-dasharray="3 3" pointer-events="none"/><path d="M 60 360 L 60 393.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 398.88 L 56.5 391.88 L 60 393.63 L 63.5 391.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="0" y="320" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(35.5,333.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="48" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 49px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">用户代码</div></div></foreignObject><text x="24" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">用户代码</text></switch></g><path d="M 60 440 L 60 473.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 478.88 L 56.5 471.88 L 60 473.63 L 63.5 471.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="0" y="400" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(17.5,413.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="84" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 86px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">api.wait_update</div></div></foreignObject><text x="42" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">api.wait_update</text></switch></g><path d="M 60 520 L 60 553.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><path d="M 60 558.88 L 56.5 551.88 L 60 553.63 L 63.5 551.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="none"/><rect x="0" y="480" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(35.5,493.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="48" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 49px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">用户代码</div></div></foreignObject><text x="24" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">用户代码</text></switch></g><rect x="0" y="560" width="120" height="40" fill="#ffffff" stroke="#000000" pointer-events="none"/><g transform="translate(17.5,573.5)"><switch><foreignObject style="overflow:visible;" pointer-events="none" width="84" height="12" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: inline-block; font-size: 12px; font-family: Helvetica; color: rgb(0, 0, 0); line-height: 1.2; vertical-align: top; width: 86px; white-space: nowrap; overflow-wrap: normal; text-align: center;"><div xmlns="http://www.w3.org/1999/xhtml" style="display:inline-block;text-align:inherit;text-decoration:inherit;white-space:normal;">api.wait_update</div></div></foreignObject><text x="42" y="12" fill="#000000" text-anchor="middle" font-size="12px" font-family="Helvetica">api.wait_update</text></switch></g></g></svg>Shown in full with attribution under the source's licence. Licence: Apache-2.0
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.