# Get Option Strategy

get_option_strategy(code, option_strategy, expire_time, spread=None, far_expire_time=None, index_option_type=IndexOptionType.NORMAL, option_type=OptionType.ALL, strike_price=None)

  • Description

    Query option chain legs by strategy type. Supports vertical spread, straddle, collar, butterfly, and other standard strategies.

  • Parameters

    Parameter Type Description
    code str Underlying stock code
    option_strategy OptionStrategyType Option strategy type
    expire_time str Expiration date
    spread float Spread
    far_expire_time str Far expiration date
    index_option_type IndexOptionType Index option type
    option_type OptionType Option call/put type
    strike_price float Strike price
    • Required parameters by strategy type:

      • expire_time Required for:CALENDAR_SPREAD(Calendar spread)、DIAGONAL_SPREAD(Diagonal spread)
      • spread Required for:SPREAD(Vertical spread)、STRANGLE(Strangle)、COLLAR(Collar)、BUTTERFLY(Butterfly)、CONDOR(Condor)、IRON_BUTTERFLY(Iron butterfly)、IRON_CONDOR(Iron condor)、DIAGONAL_SPREAD(Diagonal spread)
      • far_expire_time Required for:CALENDAR_SPREAD(Calendar spread)、DIAGONAL_SPREAD(Diagonal spread)
  • Return

    Parameter Type Description
    ret RET_CODE API call result
    data pd.DataFrame When ret == RET_OK, returns strategy list data
    str When ret != RET_OK, returns error description
    • DataFrame fields:

      Field Type Description
      code str Strategy identifier code
      name str Strategy name
      option_strategy str Option strategy type
      stock_owner str Underlying stock
      legs list Combo leg list
    • OptionStrategyLeg fields:

      Field Type Description
      code str Option contract code
      action str Buy/sell direction
      quantity float Quantity
  • Example

from futu import *

quote_ctx = OpenQuoteContext(host='127.0.0.1', port=11111)
ret,data = quote_ctx.get_option_strategy(code='HK.00700', option_strategy=OptionStrategyType.STRADDLE)
if ret == RET_OK:
    print(data)
    print(data['legs'][0])
else:
    print('error:', data)
quote_ctx.close() # Remember to close the connection to avoid exhausting connection quota
1
2
3
4
5
6
7
8
9
10
  • Output
               code     name option_strategy stock_owner                                               legs
0   TCH260522C/P330  Tencent Straddle        STRADDLE    HK.00700  [OptionStrategyLeg(code=HK.TCH260522P330000, action=BUY, quantity=1.0), OptionStrategyLeg(code=HK.TCH260522C330000, action=BUY, quantity=1.0)]
1   TCH260522C/P340  Tencent Straddle        STRADDLE    HK.00700  [OptionStrategyLeg(code=HK.TCH260522P340000, a...
2   TCH260522C/P350  Tencent Straddle        STRADDLE    HK.00700  [OptionStrategyLeg(code=HK.TCH260522P350000, a...
...
26  TCH260522C/P590  Tencent Straddle        STRADDLE    HK.00700  [OptionStrategyLeg(code=HK.TCH260522P590000, a...
[OptionStrategyLeg(code=HK.TCH260522P330000, action=BUY, quantity=1.0), OptionStrategyLeg(code=HK.TCH260522C330000, action=BUY, quantity=1.0)]
1
2
3
4
5
6
7

API Restrictions

  • Maximum 30 requests per 30 seconds.