TWAP and VWAP Algorithm Examples for Order Execution
Summary
This documentation page introduces two example execution algorithms: TWAP, which distributes trading over time, and VWAP, which weights execution according to trading volume. It assumes readers already understand target-position tasks, order placement and cancellation, and the update loop used by the trading API. It also points readers to prerequisite material about splitting orders and scheduling tasks.
The page itself includes references to the example implementations rather than their code or operational details. It therefore names the execution approaches but does not specify scheduling logic, volume forecasts, order types, participation limits, or handling of partial fills. No experiments, cost comparisons, or performance results are presented. The examples can serve as starting points for understanding algorithmic execution within the documented API, but the supplied text alone is not enough to reproduce the algorithms or judge their suitability in live markets.
Key ideas
- The page introduces time-weighted and volume-weighted average execution examples.
- The examples are intended for readers familiar with target positions, order management, and the API update loop.
- Related learning material covers order splitting and scheduled tasks.
- The supplied page references implementation files but does not include algorithm details or performance evidence.
Tags
Full text
# algorithm .. _demo_algorithm: 算法模块示例 ==================================================== 这两组示例面向已经理解 :ref:`targetpostask`、下单/撤单和 :py:meth:`~tqsdk.TqApi.wait_update` 主循环的读者。 如果你还没接触过拆单和时间表任务,建议先看 :ref:`tutorial-t40`、:ref:`targetpostask` 和 :ref:`target_pos_scheduler`,再阅读本页。 .. contents:: 目录 .. _demo-algorithm-twap: twap_table - 时间平均加权算法 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. literalinclude:: ../../tqsdk/demo/algorithm/twap.py :language: python .. _demo-algorithm-vwap: vwap_table - 交易量平均加权算法 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. literalinclude:: ../../tqsdk/demo/algorithm/vwap.py :language: python
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.