Loading...
Loading...
Wyckoff Method Trading Skill. Analyze stock trends based on the Wyckoff Method, identify accumulation/distribution phases, and determine entry and exit points (signals like Spring, JAC, UT, etc.). This skill is triggered when users mention stock trading, Wyckoff, stock analysis, buy signals, sell signals, etc.
npx skill4agent add cyrainfall/cyx_skills wyckoff-tradingThis skill uses Baostock library to get A-share stock data
pip install baostock pandasimport baostock as bs
import pandas as pd
def get_kline_data(stock_code, period='daily', limit=200):
"""Obtain historical K-line data for Wyckoff analysis
Args:
stock_code: Stock code, such as '300435' (Shenzhen Growth Enterprise Market) or '600519' (Shanghai Main Board)
period: Daily('daily')/Weekly('weekly')/Monthly('monthly')
limit: Number of days to retrieve
Returns:
list: List of K-line data dictionaries
"""
# Convert stock code format
if stock_code.startswith('6'):
code = f'sh.{stock_code}'
else:
code = f'sz.{stock_code}'
# Calculate date range
end_date = pd.Timestamp.now().strftime('%Y-%m-%d')
start_date = (pd.Timestamp.now() - pd.Timedelta(days=limit*2)).strftime('%Y-%m-%d')
# Log in to get data
bs.login()
rs = bs.query_history_k_data_plus(
code,
'date,code,open,high,low,close,volume,amount,pctChg',
start_date=start_date,
end_date=end_date,
frequency='d'
)
data_list = []
while (rs.error_code == '0') & rs.next():
data_list.append(rs.get_row_data())
bs.logout()
if data_list:
df = pd.DataFrame(data_list, columns=rs.fields)
df = df.rename(columns={
'date': 'trade_time', 'open': 'open', 'close': 'close',
'high': 'high', 'low': 'low', 'volume': 'volume',
'amount': 'amount', 'pctChg': 'pct_chg'
})
# Convert data types
df['close'] = df['close'].astype(float)
df['volume'] = df['volume'].astype(float)
df['high'] = df['high'].astype(float)
df['low'] = df['low'].astype(float)
return df.to_dict('records')
return []
def get_index_data(index_code='sh.000001', limit=200):
"""Obtain market index data
Args:
index_code: Index code, such as 'sh.000001' (Shanghai Composite Index), 'sz.399001' (Shenzhen Component Index)
limit: Number of days to retrieve
"""
end_date = pd.Timestamp.now().strftime('%Y-%m-%d')
start_date = (pd.Timestamp.now() - pd.Timedelta(days=limit*2)).strftime('%Y-%m-%d')
bs.login()
rs = bs.query_history_k_data_plus(
index_code,
'date,code,open,high,low,close,volume,amount,pctChg',
start_date=start_date,
end_date=end_date,
frequency='d'
)
data_list = []
while (rs.error_code == '0') & rs.next():
data_list.append(rs.get_row_data())
bs.logout()
if data_list:
df = pd.DataFrame(data_list, columns=rs.fields)
return df.to_dict('records')
return []
def get_stock_basics():
"""Obtain basic information of all A-share stocks"""
bs.login()
rs = bs.query_stock_basic()
data_list = []
while (rs.error_code == '0') & rs.next():
data_list.append(rs.get_row_data())
bs.logout()
return pd.DataFrame(data_list, columns=rs.fields)| Phase | Characteristics | Trading Direction |
|---|---|---|
| Accumulation | Price consolidates at low levels, volume shrinks then expands | Prepare to buy |
| Markup | Uptrend with volume confirmation | Hold/add positions |
| Distribution | Price consolidates at high levels, volume expands then shrinks | Prepare to sell |
| Markdown | Downtrend with increasing volume | Wait/short sell |
Phase A(Initial Phase)
├── SC:Panic selling, volume surges, price hits new low
├── AR:Automatic rally to test selling pressure
├── ST:Secondary test to verify SC support
└── Characteristic: Volume gradually shrinks
Phase B(Accumulation Phase)
├── Range consolidation: Price fluctuates between upper track and SC low
├── ST tests: Multiple tests of SC support level
├── Volume shrinkage on pullbacks: Volume decreases during each pullback
└── Characteristic: Fluctuation range gradually narrows
Phase C(Testing Phase)
├── Spring: Breaks support quickly then rebounds sharply (core buy signal)
├── Shakeout: Shakeout to accumulate shares
└── Characteristic: Obvious buy signals appear
Phase D(Breakout Phase)
├── SOS: Volume surge breaks above upper track of range (bullish signal)
├── Pullback: Volume shrinks as price pulls back to near upper track
├── LPS: Final support point, pullback does not break previous low
└── Characteristic: Uptrend is confirmed
Phase E(Departure Phase)
├── Price rises: Leaves accumulation zone
├── Volume expands: Demand dominates
└── Characteristic: Enters uptrendPhase A(Initial Phase)
├── BC:Frenzy buying, volume surges, price hits new high
├── AR:Automatic pullback to test buying pressure
├── ST:Secondary test to verify BC resistance
└── Characteristic: Volume starts to shrink
Phase B(Distribution Phase)
├── Range consolidation: Price fluctuates between lower track and BC high
├── UT: False breakout then pullback, tests resistance
├── UTAD: False breakout after distribution
└── Characteristic: Fluctuation range gradually narrows
Phase C(Distribution Confirmation)
├── UT: Price briefly breaks above range upper track then pulls back
├── SOW: Bearish signal, volume surge with downward break
└── Characteristic: Breaks below range lower edge
Phase D(Downtrend Confirmation)
├── SOS: Volume surge with downward move (false breakout reversal)
├── Weak rebounds: Each rebound fails to reach previous highs
└── Characteristic: Downtrend is confirmed
Phase E(Departure Phase)
├── Price falls: Leaves distribution zone
├── Volume expands: Supply dominates
└── Characteristic: Enters downtrendJudgment Criteria:
1. Context: Price is in lower half of consolidation range or near support
2. Breakdown: Briefly and sharply breaks below support zone (creates panic)
3. Rebound: Price quickly pulls back into range, closing above support
4. Volume: May surge during breakdown (panic selling), then shrinks after rebound
5. Confirmation: Subsequent pullback with shrinking volume finds supportJudgment Criteria:
1. Identify "Creek": Horizontal resistance formed by previous highs
2. Breakout: Long bullish candle with significant volume expansion (demand absorbs all supply)
3. Pullback: Price pulls back to near pre-breakout platform with shrinking volume
4. Confirmation: Volume is extremely low during pullback (supply exhausted)Judgment Criteria:
1. Context: Accumulation phase after long-term consolidation
2. Sharp drop: Sudden sharp decline in short term, creating illusion of distribution
3. Quick rebound: Quickly pulls back and hits new high
4. Volume: Huge volume during drop, shrinking after reboundJudgment Criteria:
1. Context: Appears after SC
2. Rebound amplitude: Usually significant
3. Volume: May expand
4. Significance: Tests intensity of selling pressureJudgment Criteria:
1. Context: After AR, price tests SC or BC again
2. Position: Close to SC low or BC high
3. Volume: Should shrink (verifies effective support/resistance)
4. Significance: Confirms shift in supply-demand relationshipJudgment Criteria:
1. Volume surge with rise: Volume increases significantly
2. Closing price: Closes at or near intraday high
3. Context: Appears after pullback
4. Significance: Strong demand, bullish outlookJudgment Criteria:
1. Volume surge with drop: Volume increases significantly
2. Closing price: Closes at or near intraday low
3. Context: Appears after rebound
4. Significance: Strong supply, bearish outlookJudgment Criteria:
1. Position: Pullback low in uptrend
2. Volume: Shrinks
3. Does not break previous low: Higher than previous low
4. Significance: Likely to rise againJudgment Criteria:
1. Context: After long-term uptrend or high-level consolidation
2. Breakout: Briefly breaks above range upper track or previous high
3. Pullback: Price quickly falls back into range, closing weakly
4. Volume: May surge during breakout (institutional distribution)
5. Confirmation: Subsequent break below range lower edge (SOW) → sell or shortJudgment Criteria:
1. Context: After distribution zone is formed
2. Breakout: Price breaks above distribution zone upper track
3. Pullback: Closes at low level
4. Confirmation: Subsequent break below distribution zone lower edge
5. Significance: Trend reversal signalUptrend Line:
- Connect two or more sequentially rising lows
- Price should trade above the trend line
- Breaking below may indicate pullback
Downtrend Line:
- Connect two or more sequentially falling highs
- Price should trade below the trend line
- Breaking above may indicate reversalAccumulation Zone Trend Line Characteristics:
- Breaks downtrend line during rise
- Pullbacks do not break previous lows
- Trend line angle gradually steepens
Distribution Zone Trend Line Characteristics:
- Breaks uptrend line during fall
- Rebounds do not reach previous highs
- Trend line angle gradually flattensVolume-Price Confirmation (Healthy Signal):
├── Rise with volume expansion: Demand follows
├── Fall with volume shrinkage: Supply exhausted
├── Breakout with volume expansion: Valid breakout
└── Pullback with volume shrinkage: Pullback may end
Volume-Price Divergence (Warning Signal):
├── Rise with volume shrinkage: Insufficient demand
├── Fall with volume expansion: Strong supply
├── Breakout with volume shrinkage: False breakout
└── Rebound with volume expansion: May continue fallingAccumulation Zone Volume Characteristics:
├── Initial phase: Huge volume during SC
├── Middle phase: Gradually shrinks
├── Late phase: Volume expands during breakout
└── Overall: Low volume at lows, high volume at highs
Distribution Zone Volume Characteristics:
├── Initial phase: Huge volume during BC
├── Middle phase: Volume expands at highs
├── Late phase: Volume expands during fall
└── Overall: High volume at highs, low volume at lows## Stock Analysis Report: [Stock Code]
### 1. Market Phase Judgment
- Current Phase: Accumulation/Markup/Distribution/Markdown
- Confidence: High/Medium/Low
### 2. Key Signals
[List identified signals and dates]
### 3. Buy/Sell Recommendation
- Signal Type: Spring / JAC / UT / ...
- Entry Price: XXX
- Stop-Loss Price: XXX
- Take-Profit Price: XXX
- Position Recommendation: X%
### 4. Nine Buy Test Results
1. Trend Test: ✓/✗
2. Relative Strength: ✓/✗
...
### 5. Risk Warning
[Explain current risks]