Hedging Strategy logo

Hedging Strategy

OrganizationPopular
HKUDS
hedging-strategy

Hedging strategy design (beta hedge / option protection / tail risk / cross-asset hedging), including hedge-ratio calculation and cost evaluation.

Overview

PublisherHKUDS
RepositoryVibe-Trading
Skill namehedging-strategy
Stars
33.6K
Forks
5.5K
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by HKUDS on GitHub. Read the source before you install it.

Installation

Install the Hedging Strategy AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HKUDS/Vibe-Trading.git /tmp/Vibe-Trading
mkdir -p .claude/skills
cp -r /tmp/Vibe-Trading/agent/src/skills/hedging-strategy .claude/skills/hedging-strategy
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Hedging Strategy in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Hedging Strategy on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Hedging Strategy is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Hedging Strategy Design

Overview

Design systematic hedging plans for existing positions, covering linear hedges (futures / ETFs) and nonlinear hedges (options). Output hedge ratios, cost estimates, and execution plans. Core principle: hedging does not eliminate risk; it exchanges unknown losses for known costs.

Core Concepts

1. Beta Hedging (Futures / ETFs)

Principle: hedge portfolio systematic risk (beta) with index futures or ETFs while preserving single-stock alpha.

Hedge ratio calculation:

python
# Minimum-variance hedge ratio
hedge_ratio = beta_portfolio * (portfolio_value / futures_value)

# Example: hold a 10 million RMB China A-share portfolio, beta = 1.2
# CSI 300 futures (IF) contract value = index level × 300
# IF level = 4000, contract value = 4000 × 300 = 1.2 million
# Required number of short contracts = 1.2 × (1000 / 120) = 10

# Beta estimation method
import numpy as np
# OLS regression: portfolio_returns = alpha + beta * index_returns + epsilon
beta = np.cov(portfolio_returns, index_returns)[0][1] / np.var(index_returns)

China A-share beta hedging instruments:

InstrumentCodeContract MultiplierMarginSuitable Scale
IF (CSI 300 futures)IF2403300 RMB / point~12%> 5 million RMB
IC (CSI 500 futures)IC2403200 RMB / point~14%> 3 million RMB
IM (CSI 1000 futures)IM2403200 RMB / point~15%> 3 million RMB
CSI 300 ETF (510300)510300.SHUnleveredAny size

Note: stock-index futures have basis (spot-futures spread). Shorting futures when they trade at a discount brings extra return (basis convergence), while premium pricing adds extra cost.

2. Option Hedging Strategies

Protective Put
Hold the underlying + buy a put option
  • Cost: option premium (typically 1-3% of underlying value per month)
  • Protection range: fully protected below the strike price
  • Applicable scenario: worried about a large drawdown but do not want to sell the position

China A-share example (50ETF options):

python
# Hold 1 million shares of 50ETF (about 2.7 million RMB)
# Buy 100 contracts of 50ETF put 2700 (strike 2.700)
# Premium ≈ 0.05 RMB/share × 10000 shares/contract × 100 contracts = 50,000 RMB
# Cost ratio = 50,000 / 2,700,000 ≈ 1.85%
# Protection effect: losses are capped once ETF falls below 2.700
Collar
Hold the underlying + buy an OTM put + sell an OTM call
  • Cost: close to zero-cost (the call premium offsets the put premium)
  • Trade-off: gives up upside above the call strike
  • Applicable scenario: willing to cap upside in exchange for free downside protection

Parameter selection guide:

ParameterAggressiveBalancedConservative
Put strikeATM-5%ATM-8%ATM-10%
Call strikeATM+8%ATM+5%ATM+3%
Net costSlightly positiveNear zeroSlightly negative (income)
Maximum downside loss-5%-8%-10%
Maximum upside gain+8%+5%+3%
Put Spread (Bear Put Spread Hedge)
Buy a higher-strike put + sell a lower-strike put
  • Cost: 30-50% cheaper than buying a naked put
  • Protection range: only between the two strikes; no protection below the lower strike
  • Applicable scenario: hedging against moderate drawdowns while being cost-sensitive

3. Tail-Risk Hedging

Far OTM put strategy:

python
# Buy deep OTM puts (delta ≈ -0.05 ~ -0.10)
# Characteristics: expires worthless most of the time, but pays off massively during black swans

# Parameters
otm_put_strike = current_price * 0.85  # 15% OTM
cost_per_month = portfolio_value * 0.003  # about 0.3% / month
expected_payoff_in_crash = portfolio_value * 0.10  # ~10% payoff in a severe selloff

# Cost management: ongoing spend of about 3.6% / year, profitable only in tail events
# Taleb-style hedge: lose small amounts often, make large gains occasionally

VIX call strategy (US equities / options market):

python
# Buy OTM VIX calls (strike = current VIX + 10)
# If VIX jumps from 15 to 40, call value explodes
# Naturally negatively correlated with an equity portfolio

# China A-share substitutes:
# China has no VIX futures, so alternatives are:
# 1. Buy OTM 50ETF puts (similar tail protection)
# 2. Go long volatility: buy a straddle
# 3. Allocate to gold ETF (518880.SH) as a safe-haven asset

4. Cross-Asset Hedging

Stock-bond hedge:

Stock/Bond MixExpected VolatilityApplicable Scenario
80/20~15%Bull market environment, small bond buffer
60/40~10%Classic allocation, suitable for most environments
40/60~7%Bear market environment, bond-led
Risk Parity~8%Volatility-balanced allocation

Note: stock-bond correlation is not stable. In 2022, US stocks and bonds both fell (rising rates), and the traditional 60/40 mix failed. In China, negative stock-bond correlation has been relatively more stable.

Stock-commodity hedge (equities + commodities):

  • During rising inflation: commodities rise while equities come under pressure → commodities hedge inflation risk
  • During falling inflation: equities rise while commodities come under pressure → equities drive returns
  • Gold ETF (518880.SH): low correlation with China A-shares and effective for tail-risk hedging

5. Hedge-Ratio Calculation Methods

Comparison of three methods:

python
import numpy as np
from scipy import stats

# Method 1: OLS regression (simplest)
slope, intercept, r, p, se = stats.linregress(hedge_returns, portfolio_returns)
hedge_ratio_ols = slope

# Method 2: Minimum variance
covariance = np.cov(portfolio_returns, hedge_returns)[0][1]
variance_hedge = np.var(hedge_returns)
hedge_ratio_mv = covariance / variance_hedge

# Method 3: EWMA (exponentially weighted, more sensitive)
lambda_param = 0.94  # RiskMetrics default
ewma_cov = pd.Series(portfolio_returns * hedge_returns).ewm(alpha=1-lambda_param).mean()
ewma_var = pd.Series(hedge_returns**2).ewm(alpha=1-lambda_param).mean()
hedge_ratio_ewma = ewma_cov / ewma_var

# Selection guidance:
# Static hedge (monthly rebalance) -> OLS
# Dynamic hedge (weekly rebalance) -> EWMA
# Theoretical analysis -> minimum variance

6. Hedging Cost Evaluation

Cost components:

Cost ItemFutures HedgeOptions HedgeCross-Asset Hedge
Direct costMargin usage + feesPremiumAllocation to lower-yield assets
Opportunity costBasis cost (discount / premium)Time decay (Theta)Earn less in a bull market
Hidden costRoll costVolatility premiumRebalancing transaction costs
Annualized estimate2-5% (including basis)3-8% (depends on IV)1-3% (opportunity cost)

Cost-benefit decision framework:

python
# Is the hedge worth it?
hedge_cost_annual = 0.04           # 4% annualized
expected_loss_without_hedge = 0.15 # 15% expected max loss without hedge
prob_of_loss = 0.25                # 25% probability

expected_loss = expected_loss_without_hedge * prob_of_loss  # = 3.75%

# If hedge_cost > expected_loss -> hedge is relatively expensive
# If hedge_cost < expected_loss -> hedge is cost-effective
# Here 4% > 3.75%, so the hedge is marginally expensive, but it may still be worth it because of tail risk

Analysis Framework

Five-Step Hedging Design Process

  1. Identify the risk: what kind of risk does the portfolio face? Systematic (beta) or idiosyncratic (single-name events)?
  2. Choose the instrument: linear (futures / ETF) or nonlinear (options)? This depends on the risk shape and budget
  3. Calculate the ratio: determine the number of hedge contracts or option lots
  4. Evaluate the cost: what is the annualized cost, and is it acceptable?
  5. Monitor and adjust: hedge ratios require dynamic adjustment (beta changes, options expire)

Risk Scenario → Hedge Instrument Mapping

Risk ScenarioRecommended InstrumentCost Level
Systematic broad-market selloffShort IF / IC futuresLow (margin)
Moderate drawdown (5-10%)Collar / Put SpreadLow (zero-cost collar)
Black swan (>20% crash)Far OTM putMedium (continuous spending)
Rising ratesShort government bond futures (TF / T)Low
Currency depreciationFX forwards / optionsMedium
Inflation upside surpriseAllocate to commodities / goldLow (opportunity cost)

Output Format

## Hedging Plan — [Portfolio Name]

### Portfolio Overview
- Portfolio size: [X ten-thousand RMB]
- Portfolio beta: [X.XX] (vs [benchmark index])
- Main risk: [systematic / sector concentration / tail]

### Hedging Plan
- Instrument: [short IF futures / Collar / Put Spread / ...]
- Hedge ratio: [X.XX]
- Number of contracts / option lots: [N]
- Hedge coverage: [X%] (full / partial hedge)

### Cost Evaluation
- Direct cost: [X ten-thousand RMB / year]
- Annualized cost ratio: [X%]
- Margin / premium usage: [X ten-thousand RMB]

### Scenario Analysis
| Market Move | PnL Without Hedge | PnL With Hedge | Hedge Effect |
|---------|-----------|-----------|---------|
| Down 10% | -X | -X | Reduce loss by X |
| Down 20% | -X | -X | Reduce loss by X |
| Up 10% | +X | +X | Give up X of upside |

### Execution Notes
- Entry timing: [specific time / condition]
- Rebalance frequency: [monthly / quarterly / event-driven]
- Exit condition: [risk resolution criterion]

Notes

  • China A-share index futures have trading restrictions (intraday opening limits, margin requirements), so actual usable size may be limited
  • Option liquidity is concentrated in near-month and near-the-money contracts; deep OTM options have wide bid-ask spreads
  • Beta is unstable: beta tends to be lower in bull markets and higher in bear markets (meaning the hedge is least sufficient when it is needed most)
  • Collar strategies cap upside, so large rallies in the underlying can materially drag portfolio performance
  • Tail hedging (far OTM puts) loses money most of the time and requires discipline to execute continuously; do not abandon it halfway because it "feels wasteful"
  • Correlations in cross-asset hedges can change violently during crises (trending toward 1), failing exactly when they are needed most
  • Hedge plans should be re-evaluated regularly (at least monthly) for beta and cost
  • This framework is for research backtesting only, does not constitute investment advice, and does not involve live trading execution

Frequently asked questions

What does the Hedging Strategy AI skill do?

Hedging strategy design (beta hedge / option protection / tail risk / cross-asset hedging), including hedge-ratio calculation and cost evaluation.

Why use Hedging Strategy on TypingMind?

Because you install it once and use it with any model. Hedging Strategy is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Hedging Strategy in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/HKUDS/Vibe-Trading/tree/main/agent/src/skills/hedging-strategy. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Hedging Strategy?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Hedging Strategy?

As many as you like. As long as a model supports skills, you can use Hedging Strategy with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Hedging Strategy AI skill free?

Yes. It is published on GitHub by HKUDS under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇