> ## Documentation Index
> Fetch the complete documentation index at: https://quant.5loi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Win paths

title: Winning Paths

description: Provides experimental paths from signals to decisions, enhancing investment confidence through simulation and testing

## draft: false

# Winning Paths

To succeed in the investment market, we need to transform theoretical knowledge into practical decision-making abilities. This experiment will help you progress from identifying signals to making investment decisions through specific paths and methods, gradually improving your investment skills.

## Investment Experiment Learning Path

```mermaid theme={null}
flowchart TD
    subgraph Investment Experiment Learning Path
        A[Signal Identification] --> B[Strategy Testing]
        B --> C[System Building]
        C --> D[Practical Application]
        D --> E[Continuous Optimization]
    end
```

## Experiment 1: Simulating Volume-Price Signal Analysis

Volume-price relationships are important tools for identifying market trends and institutional behavior. By programming to simulate volume-price signal analysis, we can more objectively evaluate market conditions and reduce the bias of subjective judgment.

### Experiment Objective

Develop a simple Python program to detect volume-price breakout signals and help identify potential institutional entry or exit timing.

### Code Implementation

```python theme={null}
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# Load historical data (using sample data here; in practice, you can obtain from sources like Yahoo Finance)
# Assume we have a CSV file containing 'Date', 'Close Price', and 'Volume'
# df = pd.read_csv('stock_data.csv')

# For demonstration, we create a simulated dataset
date_range = pd.date_range(start='2024-01-01', end='2025-01-01', freq='B')
n = len(date_range)
closing_price = 100 + np.cumsum(np.random.randn(n))  # Randomly generate price data
volume = np.random.randint(100000, 1000000, n)  # Randomly generate volume data

# Artificially add some volume-price breakout signals
# Add large volume increases at several random positions
breakout_indices = np.random.choice(n, 5, replace=False)
for i in breakout_indices:
    closing_price[i] = closing_price[i-1] * (1 + np.random.uniform(0.02, 0.05))
    volume[i] = volume[i] * 3

# Create DataFrame
df = pd.DataFrame({
    'Date': date_range,
    'Close Price': closing_price,
    'Volume': volume
})

# Calculate 5-day and 20-day moving averages
df['MA5'] = df['Close Price'].rolling(window=5).mean()
df['MA20'] = df['Close Price'].rolling(window=20).mean()

# Calculate 5-day average volume and set volume anomaly threshold
df['Volume_MA5'] = df['Volume'].rolling(window=5).mean()
volume_threshold = 2  # Volume exceeding 2 times the 5-day average is considered abnormal

# Detect volume-price breakout signals
df['Volume-Price Breakout'] = False
for i in range(20, n):
    # Price breaks through 20-day MA and volume abnormally increases
    if (df['Close Price'].iloc[i] > df['MA20'].iloc[i] and 
        df['Volume'].iloc[i] > volume_threshold * df['Volume_MA5'].iloc[i]):
        df['Volume-Price Breakout'].iloc[i] = True

# Visualize results
plt.figure(figsize=(14, 7))
plt.subplot(2, 1, 1)
plt.plot(df['Date'], df['Close Price'], label='Close Price')
plt.plot(df['Date'], df['MA5'], label='5-day MA')
plt.plot(df['Date'], df['MA20'], label='20-day MA')
# Mark volume-price breakout signals
breakout_dates = df[df['Volume-Price Breakout']]['Date']
breakout_prices = df[df['Volume-Price Breakout']]['Close Price']
plt.scatter(breakout_dates, breakout_prices, color='red', marker='^', label='Volume-Price Breakout Signal')
plt.title('Price Trend and Volume-Price Breakout Signals')
plt.legend()

plt.subplot(2, 1, 2)
plt.bar(df['Date'], df['Volume'], label='Volume')
plt.plot(df['Date'], df['Volume_MA5'], color='red', label='5-day Average Volume')
plt.title('Volume and Average Volume')
plt.legend()

plt.tight_layout()
plt.show()

# Output dates when volume-price breakout signals occurred
print("Dates when volume-price breakout signals occurred:")
print(df[df['Volume-Price Breakout']][['Date', 'Close Price', 'Volume']])
```

## Volume-Price Signal Analysis Process

```mermaid theme={null}
sequenceDiagram
    participant User as User
    participant Program as Analysis Program
    participant Data as Market Data
    participant Signal as Signal Generator
    participant Visual as Visualization Module

    User->>Program: Input stock data
    Program->>Data: Load historical price and volume
    Data-->>Program: Return dataset
    Program->>Signal: Calculate moving averages and volume mean
    Signal->>Signal: Detect volume-price breakout conditions
    Signal-->>Program: Generate signal points
    Program->>Visual: Plot price chart and signal markers
    Visual-->>User: Display analysis results
    
    note right of User: Start analysis process
    note left of Data: Contains OHLC and volume data
    note right of Signal: Apply technical analysis algorithms
    note left of Visual: Use matplotlib or plotly
```

### Experiment Explanation

1. **Data Preparation**: The program first loads or generates historical price and volume data for stocks

2. **Indicator Calculation**: Calculates 5-day and 20-day moving averages, as well as the 5-day average of trading volume

3. **Signal Detection**: Marks as a volume-price breakout signal when the price breaks through the 20-day moving average and trading volume exceeds twice the 5-day average

4. **Result Visualization**: Intuitively displays price trends, moving averages, and volume-price breakout signals through charts

<Callout type="info" title="Experiment Expansion" icon="brain-circuit">
  In practical applications, you can adjust parameters according to your needs, such as the period of moving averages, the threshold for volume anomalies, etc. You can also add more technical indicators, such as Relative Strength Index (RSI), Bollinger Bands, etc., to improve signal accuracy.
</Callout>

## Volume-Price Breakout Signal Detection Process

```mermaid theme={null}
flowchart TD
    subgraph Volume-Price Breakout Signal Detection Process
        A[Load Historical Data] --> B[Calculate Price Moving Averages]
        B --> C[Calculate Volume Moving Averages]
        C --> D{Price Breaks Moving Average?}
        D -->|Yes| E{Volume Abnormally Increased?}
        D -->|No| A
        E -->|Yes| F[Generate Volume-Price Breakout Signal]
        E -->|No| A
        F --> G[Record Signal Points]
    end
  
```

## Experiment 2: A/B Testing Take-Profit Strategies

Take-profit strategies are one of the key factors for investment success. Through A/B testing, we can compare the effects of different take-profit strategies and find the most suitable method for ourselves.

### Experiment Objective

Compare the performance of two common take-profit strategies in simulated trading: fixed percentage take-profit and trailing take-profit.

### Introduction to Take-Profit Strategies

<Tabs>
  <Tab icon="fixed-profit" title="Fixed Percentage Take-Profit">
    <div className="space-y-4">
      <p>Sell all or part of the holdings when the investment return reaches a preset percentage (such as 15%, 20%, or 30%).</p>

      ```mermaid theme={null}
      flowchart TD
          subgraph Fixed Percentage Take-Profit Process
              A[Buy and Hold] --> B{Price Rises?}
              B -->|Yes| C{Reach Preset Percentage?}
              B -->|No| B
              C -->|Yes| D[Sell for Profit]
              C -->|No| B
          end
          
          style A fill:#F5DEB3,stroke:#CD853F,stroke-width:2px,color:#8B4513,font-weight:bold
          style B fill:#E0FFFF,stroke:#4682B4,stroke-width:2px,color:#00008B,font-weight:bold
          style C fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px,color:#8B008B,font-weight:bold
          style D fill:#90EE90,stroke:#32CD32,stroke-width:2px,color:#006400,font-weight:bold
          
          classDef process fill:#F5DEB3,stroke:#CD853F,stroke-width:2px,color:#8B4513,font-weight:bold;
          classDef decision fill:#E0FFFF,stroke:#4682B4,stroke-width:2px,color:#00008B,font-weight:bold;
      ```

      <h4 className="text-lg font-medium">Advantages</h4>

      <ul className="list-disc pl-5 space-y-2">
        <li>Simple and clear, easy to execute</li>
        <li>Can ensure a certain level of profit</li>
        <li>Avoid profit retracement caused by greed</li>
      </ul>

      <h4 className="text-lg font-medium">Disadvantages</h4>

      <ul className="list-disc pl-5 space-y-2">
        <li>May sell too early and miss larger upward opportunities</li>
        <li>May be triggered frequently in volatile markets</li>
      </ul>
    </div>
  </Tab>

  <Tab icon="trailing-profit" title="Trailing Take-Profit">
    <div className="space-y-4">
      <p>Continuously adjust take-profit points as prices rise. For example, sell when the price pulls back a certain percentage (such as 5% or 10%) from the highest point.</p>

      ```mermaid theme={null}
      flowchart TD
          subgraph Trailing Take-Profit Process
              A[Buy and Hold] --> B{Price Rises?}
              B -->|Yes| C[Update Highest Point]
              B -->|No| D{Pull Back from Highest?}
              C --> D
              D -->|Yes| E{Reach Pullback Percentage?}
              D -->|No| B
              E -->|Yes| F[Sell for Profit]
              E -->|No| B
          end
          
          style A fill:#F5DEB3,stroke:#CD853F,stroke-width:2px,color:#8B4513,font-weight:bold
          style B fill:#E0FFFF,stroke:#4682B4,stroke-width:2px,color:#00008B,font-weight:bold
          style C fill:#90EE90,stroke:#32CD32,stroke-width:2px,color:#006400,font-weight:bold
          style D fill:#E0FFFF,stroke:#4682B4,stroke-width:2px,color:#00008B,font-weight:bold
          style E fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px,color:#8B008B,font-weight:bold
          style F fill:#90EE90,stroke:#32CD32,stroke-width:2px,color:#006400,font-weight:bold
      ```

      <h4 className="text-lg font-medium">Advantages</h4>

      <ul className="list-disc pl-5 space-y-2">
        <li>Can capture larger profits when trends continue</li>
        <li>Reduce frequent trading and lower transaction costs</li>
        <li>Better adapted to trending markets</li>
      </ul>

      <h4 className="text-lg font-medium">Disadvantages</h4>

      <ul className="list-disc pl-5 space-y-2">
        <li>May result in more profit retracement in range-bound markets</li>
        <li>Requires continuous attention to price changes to adjust take-profit points</li>
      </ul>
    </div>
  </Tab>
</Tabs>

### Experiment Steps

<Steps>
  <Step title="Prepare Test Data">
    Select historical data of multiple stocks as test samples, covering different industries and market environments
  </Step>

  <Step title="Set Test Parameters">
    * Fixed percentage take-profit: Set different take-profit percentages (such as 10%, 15%, 20%, 25%, 30%)
    * Trailing take-profit: Set different retracement percentages (such as 3%, 5%, 8%, 10%)
    * Initial capital: 100,000 yuan
    * Transaction costs: Commission 0.025%, stamp duty 0.1%
  </Step>

  <Step title="Simulate Trading Process">
    For each stock and each take-profit strategy, perform the following simulation:

    1. Buy stocks at random time points
    2. Apply the take-profit strategy, record selling time and returns
    3. Calculate final return rate and win rate
  </Step>

  <Step title="Analyze Test Results">
    Compare the performance of different take-profit strategies, including:

    * Average return rate
    * Win rate (percentage of profitable trades)
    * Trading frequency
    * Maximum drawdown
  </Step>

  <Step title="Optimize Strategy Parameters">
    Adjust parameters of take-profit strategies based on test results to find the optimal combination
  </Step>
</Steps>

### Experiment Result Example

The following are the simulation test results using 2024 historical data of 5 stocks (Kweichow Moutai, Tencent Holdings, Alibaba, Contemporary Amperex Technology, BYD):

<Columns cols={2}>
  <Card title="Fixed 15% Take-Profit" icon="trending-up"> Average return rate: 12.8%, Win rate: 68%, Trading frequency: 0.8 times/month </Card>
  <Card title="Fixed 25% Take-Profit" icon="trending-up"> Average return rate: 19.5%, Win rate: 52%, Trading frequency: 0.4 times/month </Card>
  <Card title="Trailing 5% Take-Profit" icon="activity"> Average return rate: 15.6%, Win rate: 61%, Trading frequency: 0.6 times/month </Card>
  <Card title="Trailing 10% Take-Profit" icon="activity"> Average return rate: 21.3%, Win rate: 48%, Trading frequency: 0.3 times/month </Card>
</Columns>

**Conclusion**: From the test results, although the trailing 10% take-profit strategy has a slightly lower win rate, it has the highest average return rate; the fixed 15% take-profit strategy achieves a good balance between return rate and win rate. In actual investment, you can choose a suitable take-profit strategy based on personal risk preference and market environment.

## Take-Profit Strategy Comparison Analysis

```mermaid theme={null}
flowchart LR
    subgraph Take-Profit Strategy Comparison
        A[Fixed 15% Take-Profit] --> B[Fixed 25% Take-Profit]
        C[Trailing 5% Take-Profit] --> D[Trailing 10% Take-Profit]
    end
```

## Experiment 3: Building a Personal Investment System

Integrating the knowledge and methods learned earlier to build an investment system suitable for yourself is a crucial step from novice to mature investor.

### Core Components of an Investment System

```mermaid theme={null}
flowchart TD
    subgraph Investment System Core Architecture
        subgraph Environment Analysis Layer
            A[Market Environment Judgment] 
        end
        
        subgraph Decision Execution Layer
            B[Target Selection Criteria] --> C[Buying Strategy] --> D[Selling Strategy]
        end
        
        subgraph Risk Control and Optimization Layer
            E[Risk Control] --> F[Investment Records and Summary]
        end
        
        A --> B
        D --> E
        F -.-> A
    end
    
    subgraph Market Environment Judgment Includes
        A1[Macroeconomic Analysis] & A2[Market Sentiment Assessment] & A3[Technical Analysis]
    end
    
    subgraph Target Selection Criteria Includes
        B1[Fundamental Screening] & B2[Technical Screening] & B3[Valuation Analysis]
    end
    
    subgraph Risk Control Includes
        E1[Position Management] & E2[Stop-Loss Strategy] & E3[Portfolio Diversification]
    end
    
    A --- A1
    B --- B1
    E --- E1
```

<AccordionGroup type="default">
  <Accordion title="Market Environment Judgment">
    * Macroeconomic analysis (GDP, CPI, PMI and other indicators)
    * Market sentiment assessment (trading volume, margin financing and securities lending balance, investor sentiment index, etc.)
    * Technical analysis (market index trends, moving average systems, trading volume changes, etc.)
  </Accordion>

  <Accordion title="Selection Criteria">
    * Fundamental screening (financial indicators, industry position, competitive advantages, etc.)
    * Technical screening (volume-price relationships, trend strength, relative strength, etc.)
    * Valuation analysis (P/E, P/B, PEG and other valuation indicators)
  </Accordion>

  <Accordion title="Buying Strategy">
    * Entry signal confirmation (breakout, retracement, reversal and other technical signals)
    * Position management (single position size, total position control)
    * Staged buying plan (price range, time interval, etc.)
  </Accordion>

  <Accordion title="Selling Strategy">
    * Take-profit strategies (fixed percentage, trailing take-profit, etc.)
    * Stop-loss strategies (percentage stop-loss, technical level stop-loss, etc.)
    * Position adjustment (gradual reduction, liquidation conditions, etc.)
  </Accordion>

  <Accordion title="Risk Control">
    * Diversification (industry, region, asset class, etc.)
    * Capital management (total risk exposure, maximum drawdown control, etc.)
    * Hedging strategies (used in high-risk periods)
  </Accordion>

  <Accordion title="Investment Records and Summary">
    * Trading journal (record the decision-making process and results of each trade)
    * Regular review (analyze the reasons for success and failure)
    * System optimization (adjust strategies based on market changes and experience)
  </Accordion>
</AccordionGroup>

### Steps to Build an Investment System

1. **Clarify Investment Goals**: Determine your investment goals (such as long-term wealth growth, short-term returns, retirement planning, etc.) and risk tolerance

2. **Learn and Research**: Systematically learn investment theories and methods, understand different investment strategies and tools

3. **Develop Initial Framework**: Based on your goals and preferences, develop the basic framework of your investment system

4. **Simulate and Test**: Verify the effectiveness of the investment system through simulated trading or small position testing

5. **Optimize and Perfect**: Continuously optimize and perfect the investment system based on test results and market changes

6. **Strictly Execute**: Strictly execute the investment system in actual investment and avoid emotional decision-making

<Image src="/images/investment-system.png" alt="Investment System Framework" caption="A complete investment system should include core components such as market judgment, target selection, trading strategies, risk control, and summary optimization" />

## Experiment Task: Create Your Investment Journal

```mermaid theme={null}
flowchart TD
    subgraph Investment Journal Creation Process
        A[Prepare Investment Record Template] --> B[Record Investment Decision Reasons]
        B --> C[Record Buy/Sell Operations]
        C --> D[Record Market Environment]
        D --> E[Regular Review and Summary]
        E --> F[Update Investment Strategy]
    end
    
    style A fill:#F5DEB3,stroke:#CD853F,stroke-width:2px,color:#8B4513,font-weight:bold
    style B fill:#E0FFFF,stroke:#4682B4,stroke-width:2px,color:#00008B,font-weight:bold
    style C fill:#90EE90,stroke:#32CD32,stroke-width:2px,color:#006400,font-weight:bold
    style D fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px,color:#8B008B,font-weight:bold
    style E fill:#DDA0DD,stroke:#8B008B,stroke-width:2px,color:#4B0082,font-weight:bold
    style F fill:#FFD700,stroke:#DAA520,stroke-width:2px,color:#8B4513,font-weight:bold
```

A good investment journal can help you record the investment process, analyze decision-making effects, and continuously improve your investment level. Now, let's create a standardized investment journal template.

### Investment Journal Template

<CodeBlock language="markdown">
  # Investment Journal

  ## Basic Information

  * Date: 2025-03-15
  * Market Environment: Consolidating downward
  * Investment Objective: Medium-term (3-6 months)

  ## Target Analysis

  * Stock Code: 600519 (Kweichow Moutai)
  * Industry: Food and Beverage
  * Buying Reasons:
    1. Reasonable valuation (P/E 28x, lower than historical average)
    2. Stable fundamentals (continuous growth in revenue and profits)
    3. Technical signs of stabilization (shrinking volume and stabilization, MACD golden cross)
  * Risk Factors:
    1. Macroeconomic downward pressure
    2. Intensifying industry competition

  ## Trading Plan

  * Buying Price Range: 1650-1700 yuan
  * Buying Position: 10% of total funds
  * Stop-Loss Point: 1530 yuan (7% decline)
  * Take-Profit Target: 2000 yuan (18% increase) or use trailing take-profit

  ## Actual Trading Record

  * Buying Date: 2025-03-16
  * Buying Price: 1680 yuan
  * Buying Quantity: 50 shares
  * Total Cost: 84,000 yuan

  ## Follow-up Tracking

  * 2025-03-20: Price 1720 yuan, up 2.38%, continue holding
  * 2025-03-25: Price 1780 yuan, up 5.95%, approaching target, consider partial profit-taking
  * 2025-04-01: Price 1850 yuan, up 10.12%, sell 20 shares, lock in partial profits
  * 2025-04-10: Price 1980 yuan, up 17.86%, sell all, complete trade

  ## Trading Summary

  * Final Return Rate: 17.86%
  * Successful Experience: Strictly executed trading plan, sold in batches when approaching target
  * Areas for Improvement: Could consider appropriately relaxing take-profit targets when fundamentals remain unchanged

  ## Lessons Learned

  * When market volatility is high, staged buying and selling can effectively reduce risk
  * Fundamental analysis is the basis for long-term investment, while technical analysis can help grasp entry timing
  * Strict risk control is the key to investment success
</CodeBlock>

<Callout type="primary" title="Continuous Learning, Continuous Progress" icon="brain-circuit">
  Investment is a process of continuous learning and progress. Through systematic experiments and practice, you can gradually improve your investment skills and find a winning path suitable for yourself. Remember, successful investment requires a combination of knowledge, discipline, and patience.
</Callout>
