Millet Porridge

English version of https://corvo.myseu.cn

0%

Semi-Automated Trading System (V)

As the fifth post in the trading system series, this introduces recent optimizations and improvements to options strategies and system features. After enabling QMT permissions on the broker platform, I implemented automated options trading with Python. This post details the system architecture, feature implementation, and strategy improvements.

Broker Integration

For options automation, my main account is at Sinolink Securities, which happened to meet the requirements, so I use Sinolink’s QMT interface as the underlying trading channel. I previously used MiniQMT for stock trading, but options trading requires full QMT permissions.

Core functions used during integration include:

  1. get_trade_detail_data — get account fund information, order records, etc.
  2. get_comb_option — get option combination holdings
  3. make_option_combination — create option combinations; I mainly use it for spreads
  4. release_option_combination — release option combinations
  5. passorder — all order operations, including opening and closing positions
  6. get_full_tick — get tick-by-tick options data

For detailed API usage, the broker’s technical documentation already gives fairly complete explanations, so I won’t repeat them here. For technical consulting services, you can contact me privately to discuss specific requirements and fees.

Note that once QMT starts it monopolizes the trading channel — Yongjinbao and Sinolink’s other clients cannot trade simultaneously. For mobile operations, Sinolink’s Huidian Options App can serve as an alternative.

Page Feature Design

To manage options holdings more effectively, I developed a dedicated holdings management page. It not only displays holdings but also integrates position-adjustment features, allowing convenient construction and adjustment of option combinations.

As described in the earlier post “Options Strategy - A Variant Ratio Spread“, I currently focus on STAR 50 ETF options spread strategies. A single-underlying strategy lets the page design be more focused and efficient.

Holdings Overview

1767179952954.png

The image above shows the holdings page’s overall layout. The annotated part displays the current underlying and its real-time price — the core indicator for monitoring holdings.

Month-by-Month Holdings Management

Considering that option contracts with different expiration months have different time-value characteristics, the system categorizes holdings by expiration date for easier analysis and management.

1767180027632.png

The page displays from left to right: bull spread combination counts, covered combination counts, short position counts, and long position counts. This layout quickly presents the overall position structure.

In addition, the system color-codes the time value of different strikes, visually highlighting each contract’s time-value level and improving information readability.

Position Adjustment Interface

1767180121324.png

The adjustment page provides a clean interface. Users can directly modify target holding quantities, and the system automatically computes the trades to execute.

The page integrates real-time market data, displaying current bid/ask quotes live. STAR 50 ETF options have good liquidity with relatively small bid-ask spreads. The current version implements opposite-price ordering; limit orders are planned for later versions.

The page bottom displays complete holdings information in JSON format, including each contract’s quantity and price, for final confirmation before ordering.

Combination Strategy Management

1767180206595.png

Option combinations are the core of strategy implementation. The page provides a combination adjustment interface supporting convenient construction and modification of various spread combinations.

Strategy Optimization and Implementation

The “Options Strategy - A Variant Ratio Spread“ article detailed the strategy’s theoretical framework. In actual implementation, some adaptive adjustments and optimizations were made for better programmatic trading.

Strategy Parameter Optimization

For position management, previous scattered operations were adjusted into standardized configuration: at each price band, combinations are uniformly built with a standard ratio of 10 long positions + 12-15 short positions, complemented by small naked sales of at-the-money option short positions.

This standardized configuration’s advantages: more precise position control, avoiding the trouble of rounding to integers, making overall position management more standardized and controllable.

Risk Control Mechanism Design

In derivatives trading, risk control is the foundation of stable system operation. The system implements complete risk control and position adjustment logic. From my perspective, what risk control looks like doesn’t matter — what matters is definitely having one. It can remind you of current risk exposure and give adjustment suggestions when necessary. I just thought of a simplest set and had AI generate it.

Around the core goal of capturing time value, a three-layer risk control mechanism was designed for short positions:

  1. High-risk adjustment mechanism: when holdings’ risk score exceeds a preset threshold, the system automatically identifies and suggests a more conservative adjustment plan, reducing risk exposure
  2. Out-of-the-money parallel roll mechanism: when OTM contracts’ time value decays rapidly and next month’s contract time value reaches more than 2x the current month’s, the system suggests a parallel roll — capturing higher time value while appropriately reducing holding quantity
  3. Low-value liquidation mechanism: for option contracts with time value below 50 yuan, the system suggests closing, to improve margin usage efficiency

The system also implements risk score mechanism recording, computing risk scores in real time from holdings and underlying prices, and recording risk change trends as charts.

1767184797272.png

Through this risk control system, potential risks can be identified and controlled in time.

Summary and Outlook

This post introduced the options automated trading system’s main functional modules and strategy implementation — from broker interface integration and page feature design to strategy optimization and risk control mechanisms, the system now has basic automated trading capability.

The current system still has much room for improvement. Limit orders, more diverse strategy combinations, and finer risk control algorithms are all in planning. Continuous optimization and refinement of the system will be the focus of subsequent work.

Readers interested in options trading automation are welcome to discuss.