Skip to content
All library documents

Option Data, Moneyness, Greeks, Volatility, Arbitrage, and Margin Examples

Article TqSdk

Summary

This documentation page indexes a sequence of option-use examples for a trading SDK. The topics move from retrieving live option quotes and screening contracts to classifying options as in the money, at the money, or out of the money. Further examples cover calculating Greeks, implied and historical volatility, and obtaining an option volatility surface.

The later examples are listed as option arbitrage, retrieving option chains with their strike prices, alternative methods for classifying moneyness, and locally calculating opening margin for ETF option sellers. The page gives a learning order and links to code samples, but it does not include the implementations or explain the formulas, assumptions, market data conventions, or results. It is therefore a useful map of practical option tasks, rather than a complete tutorial or evidence that any trading method is profitable. Users would need to consult the referenced examples and verify the applicable contract and margin rules for their setting.

Key ideas

  • The examples cover quote retrieval and screening for option contracts.
  • They include moneyness classification and calculations for Greeks and volatility measures.
  • Additional topics include volatility surfaces, arbitrage examples, strike-price lookup, and seller margin.
  • The page is an index; method details and empirical results are in the referenced code samples.

Tags

Full text
# option base


.. _demo_options:

期权基本使用
====================================================

这组示例默认你已经熟悉 :ref:`quickstart` 中的基础行情、K 线和主循环写法。第一次接触期权功能时,建议按下面的顺序阅读:

* 先看 :ref:`option_tutorial-t10`、:ref:`option_tutorial-t20`,熟悉期权行情和筛选接口
* 再看 :ref:`option_tutorial-t30`、:ref:`option_tutorial-t40`、:ref:`option_tutorial-t41`,理解实值/平值/虚值分类与希腊值计算
* 最后看 :ref:`option_tutorial-t60` 到 :ref:`option_tutorial-t74`,处理波动率曲面、套利和保证金计算

.. contents:: 目录


.. _option_tutorial-t10:

o10 - 获取期权实时行情
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../tqsdk/demo/option_tutorial/o10.py
  :language: python


.. _option_tutorial-t20:

o20 - 查询符合要求的期权
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../tqsdk/demo/option_tutorial/o20.py
  :language: python


.. _option_tutorial-t30:

o30 - 查询平值/虚值/实值期权
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../tqsdk/demo/option_tutorial/o30.py
  :language: python


.. _option_tutorial-t40:

o40 - 计算期权的希腊字母
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../tqsdk/demo/option_tutorial/o40.py
  :language: python


.. _option_tutorial-t41:

o41 - 计算期权隐含波动率和历史波动率
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../tqsdk/demo/option_tutorial/o41.py
  :language: python


.. _option_tutorial-t60:

o60 - 获取期权波动率曲面
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../tqsdk/demo/option_tutorial/o60.py
  :language: python

.. _option_tutorial-t70:

o70 - 期权套利策略
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../tqsdk/demo/option_tutorial/o70.py
  :language: python

.. _option_tutorial-t71:

o71 - 获取一组期权和其对应行权价
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../tqsdk/demo/option_tutorial/o71.py
  :language: python

.. _option_tutorial-t72:

o72 - 查询标的对应期权按虚值平值实值分类方法一
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../tqsdk/demo/option_tutorial/o72.py
  :language: python

.. _option_tutorial-t73:

o73 - 查询标的对应期权按虚值平值实值分类方法二
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../tqsdk/demo/option_tutorial/o73.py
  :language: python

.. _option_tutorial-t74:

o74 - 本地计算ETF期权卖方开仓保证金
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. literalinclude:: ../../tqsdk/demo/option_tutorial/o74.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.