比特幣供應動態深度分析

深入分析比特幣供應動態,包括長期持有者行為模式、交易所比特幣流入流出、供應緊張程度指標與市場週期分析。

比特幣供應動態深度分析:長期持有者、交易所流向與供應週期

概述

比特幣的貨幣政策是明確且可預測的——總量固定 2100 萬枚,每四年減半一次。然而,深入理解比特幣的供應動態,包括長期持有者(HODLers)的行為模式、交易所的比特幣流入流出、供應緊張程度指標等,對於把握比特幣市場週期和價格走勢至關重要。本文從數據驅動的角度,深入分析比特幣的供應動態,幫助投資者和研究者理解比特幣市場的微觀結構。

一、比特幣供應結構解析

1.1 比特幣供應的層次分類

比特幣的供應並非均勻分布,而是存在顯著的層次結構。讓我們從多個維度分析比特幣的供應分類。

比特幣供應層次結構:

┌─────────────────────────────────────────────────────────────────────┐
│                     比特幣供應層次金字塔                              │
├─────────────────────────────────────────────────────────────────────┤
│                                                                     │
│                         ┌─────────┐                                 │
│                         │  休眠幣  │  5-7 年未移動   ~300萬 BTC      │
│                         │(Lost BTC)│                    │
│                         └────┬────┘                                 │
│                              │                                       │
│                    ┌─────────┴─────────┐                             │
│                    │   長期持有者供應   │  > 1 年未動  ~1000萬 BTC  │
│                    │   (HODL Supply)   │                    │
│                    └────────┬─────────┘                             │
│                             │                                        │
│               ┌─────────────┴─────────────┐                         │
│               │      短期持有者供應        │  < 1 年移動  ~500萬 BTC │
│               │   (Short-term Holder)     │                    │
│               └─────────────┬─────────────┘                         │
│                               │                                      │
│             ┌─────────────────┴─────────────────┐                  │
│             │          交易所可交易供應           │  ~300-400萬 BTC  │
│             │      (Exchange Tradable)          │                  │
│             └───────────────────────────────────┘                  │
│                                                                     │
│ 總流通供應:~1960萬 BTC (扣除估計的 300-400萬 休眠幣)             │
│                                                                     │
└─────────────────────────────────────────────────────────────────────┘

1.2 休眠比特幣分析

休眠比特幣是指長期(通常定義為 5 年以上)未在區塊鏈上移動的比特幣。這些比特幣可能因為私鑰丟失、持有者去世或其他原因而成為「永久」無法移動的資產。

#!/usr/bin/env python3
"""
比特幣休眠供應分析
分析長期未移動的比特幣數量及趨勢
"""

import pandas as pd
import numpy as np
from datetime import datetime, timedelta
import requests

class DormantSupplyAnalysis:
    """
    比特幣休眠供應分析類
    """
    
    def __init__(self):
        self.blockchain_data = None
        
    def fetch_utxo_data(self):
        """
        獲取比特幣 UTXO 數據
        
        實際實現需要連接比特幣節點或使用區塊鏈 API
        這裡使用模擬數據進行概念說明
        """
        # 模擬 UTXO 數據集
        np.random.seed(42)
        
        # 總 UTXO 數量(實際值約 1.5 億個)
        n_utxos = 100000
        
        # 生成隨機的 UTXO 年齡
        # 使用,指數分佈模擬真實情況
        ages_days = np.random.exponential(scale=500, size=n_utxos)
        ages_days = np.clip(ages_days, 1, 5000)
        
        # 生成隨機的 UTXO 金額(比特幣)
        # 使用對數正態分佈
        amounts = np.random.lognormal(mean=-3, sigma=2, size=n_utxos)
        amounts = np.clip(amounts, 0.0001, 10000)
        
        df = pd.DataFrame({
            'utxo_id': range(n_utxos),
            'amount_btc': amounts,
            'age_days': ages_days
        })
        
        return df
    
    def calculate_dormant_supply(self, threshold_years=5):
        """
        計算休眠比特幣供應
        
        參數:
        - threshold_years: 休眠閾值(年)
        """
        df = self.fetch_utxo_data()
        
        threshold_days = threshold_years * 365
        
        # 分類 UTXO
        dormant = df[df['age_days'] >= threshold_days]
        active = df[df['age_days'] < threshold_days]
        
        return {
            'dormant_supply_btc': dormant['amount_btc'].sum(),
            'active_supply_btc': active['amount_btc'].sum(),
            'dormant_utxo_count': len(dormant),
            'active_utxo_count': len(active),
            'dormant_percentage': (dormant['amount_btc'].sum() / df['amount_btc'].sum()) * 100,
            'threshold_years': threshold_years
        }
    
    def age_distribution_analysis(self):
        """
        分析比特幣 UTXO 年齡分佈
        """
        df = self.fetch_utxo_data()
        
        # 年齡分組
        age_groups = {
            '< 1 month': (0, 30),
            '1-3 months': (30, 90),
            '3-6 months': (90, 180),
            '6-12 months': (180, 365),
            '1-2 years': (365, 730),
            '2-3 years': (730, 1095),
            '3-5 years': (1095, 1825),
            '5-7 years': (1825, 2555),
            '> 7 years': (2555, float('inf'))
        }
        
        results = {}
        total_supply = df['amount_btc'].sum()
        
        for group_name, (min_age, max_age) in age_groups.items():
            group_df = df[(df['age_days'] >= min_age) & (df['age_days'] < max_age)]
            group_supply = group_df['amount_btc'].sum()
            
            results[group_name] = {
                'supply_btc': group_supply,
                'percentage': (group_supply / total_supply) * 100,
                'utxo_count': len(group_df),
                'avg_amount': group_df['amount_btc'].mean() if len(group_df) > 0 else 0
            }
        
        return results
    
    def dormant_supply_trend(self, lookback_days=365):
        """
        計算休眠供應的趨勢變化
        
        這需要歷史數據的支援
        """
        # 簡化實現:基於當前數據推斷
        
        current_dormant = self.calculate_dormant_supply(threshold_years=5)
        
        # 估算歷史趨勢(實際需要真實歷史數據)
        # 假設每年有約 2-3% 的比特幣進入休眠
        annual_dormant_rate = 0.025
        
        trend = {
            'current_dormant_btc': current_dormant['dormant_supply_btc'],
            'estimated_annual_increase': current_dormant['dormant_supply_btc'] * annual_dormant_rate,
            'projected_1_year': current_dormant['dormant_supply_btc'] * (1 + annual_dormant_rate),
            'projected_5_years': current_dormant['dormant_supply_btc'] * ((1 + annual_dormant_rate) ** 5),
            'note': '基於歷史趨勢推斷,實際值可能有所不同'
        }
        
        return trend
    
    def lost_bitcoin_estimation(self):
        """
        估算丟失的比特幣數量
        
        方法:
        1. 最後一次移動超過 10 年的比特幣視為可能丟失
        2. 考慮早期比特幣的流動性模式
        """
        # 10 年閾值
        very_old = self.calculate_dormant_supply(threshold_years=10)
        
        # 早期比特幣(2010 年以前開採的)
        # 這是一個估算值
        early_miners_estimate = {
            'block_reward_era_1': 50,  # 2009-2012 每區塊 50 BTC
            'blocks_era_1': 210000 * 0.9,  # 約 90% 的區塊
            'total_early_btc': 210000 * 50 * 0.9,
            'estimated_lost_era_1': 210000 * 50 * 0.9 * 0.3,  # 假設 30% 丟失
        }
        
        return {
            '>10_year_dormant': very_old['dormant_supply_btc'],
            'estimated_early_lost': early_miners_estimate['estimated_lost_era_1'],
            'total_lost_estimate': (
                very_old['dormant_supply_btc'] * 0.5 +  # 50% 可能真的丟失
                early_miners_estimate['estimated_lost_era_1']
            ),
            'lost_percentage_of_circulating': (
                (very_old['dormant_supply_btc'] * 0.5 + early_miners_estimate['estimated_lost_era_1']) /
                19600000 * 100
            )
        }

1.3 長期持有者供應分析

長期持有者(Long-term Holders, LTH)是指持有比特幣超過 155 天(約 5 個月)的投資者群體。這一群體的行為對比特幣的市場週期有重要影響。

# 長期持有者供應分析

class LongTermHolderAnalysis:
    """
    比特幣長期持有者分析
    """
    
    def __init__(self):
        self.price_data = None
        
    def define_long_term_holders(self, threshold_days=155):
        """
        定義長期持有者
        
        標準:比特幣未移動超過 155 天(約 5 個月)
        """
        self.threshold_days = threshold_days
        
    def calculate_lth_supply(self, blockchain_data):
        """
        計算長期持有者持有的比特幣數量
        """
        # 根據 UTXO 年齡計算
        lth_utxos = blockchain_data[
            blockchain_data['age_days'] >= self.threshold_days
        ]
        
        lth_supply = lth_utxos['amount_btc'].sum()
        total_supply = blockchain_data['amount_btc'].sum()
        
        return {
            'lth_supply_btc': lth_supply,
            'total_supply_btc': total_supply,
            'lth_percentage': (lth_supply / total_supply) * 100,
            'threshold_days': self.threshold_days
        }
    
    def lth_supply_ratio_analysis(self, historical_data):
        """
        長期持有者供應比率分析
        
        LTH 供應比率是評估市場週期的重要指標:
        - 高 LTH 比率:累積階段,拋售壓力低
        - 低 LTH 比率:分配階段,拋售壓力高
        """
        # 模擬歷史數據分析
        results = []
        
        for date, row in historical_data.iterrows():
            lth_ratio = row['lth_supply'] / row['total_supply']
            
            #TH 比率判 根據 L斷市場階段
            if lth_ratio > 0.75:
                stage = 'accumulation'
            elif lth_ratio > 0.60:
                stage = 'bull_market'
            elif lth_ratio > 0.45:
                stage = 'distribution'
            else:
                stage = 'bear_market'
            
            results.append({
                'date': date,
                'lth_supply_ratio': lth_ratio,
                'stage': stage,
                'btc_price': row.get('price', 0)
            })
        
        return pd.DataFrame(results)
    
    def lth_cost_basis_analysis(self):
        """
        長期持有者成本基礎分析
        
        計算 LTH 群體的平均買入價格
        """
        # 這需要複雜的鏈上數據分析
        # 簡化實現:
        
        # 假設數據
        price_data = {
            '2017_bull': {'price': 20000, 'lth_percent': 0.30},
            '2018_bear': {'price': 3500, 'lth_percent': 0.55},
            '2019_bull': {'price': 13000, 'lth_percent': 0.45},
            '2020_covid': {'price': 5000, 'lth_percent': 0.65},
            '2021_bull': {'price': 69000, 'lth_percent': 0.35},
            '2022_bear': {'price': 16000, 'lth_percent': 0.70},
            '2023_recovery': {'price': 45000, 'lth_percent': 0.55},
            '2024_new_high': {'price': 100000, 'lth_percent': 0.40}
        }
        
        results = []
        
        for period, data in price_data.items():
            # 估算 LTH 平均成本
            # 這是一個簡化的近似
            if data['lth_percent'] < 0.5:
                # 低 LTH 比率通常在價格高點
                estimated_cost = data['price'] * 0.5
            else:
                # 高 LTH 比率通常在價格低點
                estimated_cost = data['price'] * 0.3
            
            results.append({
                'period': period,
                'btc_price': data['price'],
                'lth_percent': data['lth_percent'] * 100,
                'estimated_lth_cost_basis': estimated_cost,
                'unrealized_gain_pct': ((data['price'] - estimated_cost) / estimated_cost) * 100
            })
        
        return pd.DataFrame(results)
    
    def lth_market_dynamics(self, price_history, lth_history):
        """
        長期持有者與市場動態關係分析
        """
        merged = pd.merge(price_history, lth_history, on='date')
        
        # 計算相關性
        price_returns = merged['price'].pct_change()
        lth_changes = merged['lth_supply'].pct_change()
        
        correlation = price_returns.corr(lth_changes)
        
        # 分析 LTH 比率變化對價格的影響
        # 領先/落後關係
        results = {
            'correlation_price_lth': correlation,
            'interpretation': self._interpret_correlation(correlation)
        }
        
        return results
    
    def _interpret_correlation(self, corr):
        """
        解讀相關性
        """
        if corr > 0.3:
            return "正相關:LTH 供應增加時價格傾向上漲"
        elif corr < -0.3:
            return "負相關:LTH 供應增加時價格傾向下跌"
        else:
            return "弱相關:LTH 供應與價格沒有明顯線性關係"

二、交易所比特幣流向分析

2.1 交易所流入流出機制

交易所是比特幣市場的核心樞紐,交易所的比特幣流入流出數據是判斷市場情緒的重要指標。

# 交易所比特幣流向分析

class ExchangeFlowAnalysis:
    """
    比特幣交易所流向分析
    """
    
    def __init__(self):
        self.exchanges = [
            'Binance', 'Coinbase', 'Kraken', 
            'Bitfinex', 'Gemini', 'KuCoin'
        ]
        
    def fetch_exchange_data(self, exchange, start_date, end_date):
        """
        獲取交易所比特幣餘額變化數據
        
        數據來源:區塊鏈分析公司或交易所公開錢包地址
        """
        # 模擬數據
        np.random.seed(42)
        
        dates = pd.date_range(start=start_date, end=end_date, freq='D')
        
        # 模擬餘額變化(真實數據波動更大)
        base_balance = np.random.uniform(50000, 500000)
        balances = []
        current = base_balance
        
        for _ in dates:
            change = np.random.normal(0, current * 0.02)
            current = max(0, current + change)
            balances.append(current)
        
        df = pd.DataFrame({
            'date': dates,
            'exchange': exchange,
            'btc_balance': balances,
            'daily_change': np.diff([base_balance] + balances)
        })
        
        return df
    
    def calculate_net_flows(self, exchange_data):
        """
        計算淨流入/淨流出
        
        正值:淨流入(投資者存入比特幣到交易所)
        負值:淨流出(投資者從交易所提走比特幣)
        """
        results = []
        
        for exchange in exchange_data['exchange'].unique():
            exchange_df = exchange_data[exchange_data['exchange'] == exchange]
            
            # 日變化的總和
            total_inflow = exchange_df[exchange_df['daily_change'] > 0]['daily_change'].sum()
            total_outflow = abs(
                exchange_df[exchange_df['daily_change'] < 0]['daily_change'].sum()
            )
            
            net_flow = total_inflow - total_outflow
            
            results.append({
                'exchange': exchange,
                'total_inflow': total_inflow,
                'total_outflow': total_outflow,
                'net_flow': net_flow,
                'current_balance': exchange_df['btc_balance'].iloc[-1]
            })
        
        return pd.DataFrame(results)
    
    def aggregate_market_flows(self, all_exchange_data):
        """
        計算市場整體流向
        """
        daily_flows = all_exchange_data.groupby('date')['daily_change'].sum()
        
        # 計算累計淨流入
        cumulative_flows = daily_flows.cumsum()
        
        return {
            'daily_flows': daily_flows,
            'cumulative_flows': cumulative_flows,
            'total_net_inflow': cumulative_flows.iloc[-1],
            'flow_trend': 'accumulation' if cumulative_flows.iloc[-1] > 0 else 'distribution'
        }
    
    def flow_price_correlation(self, price_data, flow_data):
        """
        分析流向與價格的相關性
        
        假設:
        - 交易所比特幣餘額增加 -> 潛在拋售壓力增加
        - 交易所比特幣餘額減少 -> 潛在拋售壓力減少
        """
        merged = pd.merge(
            price_data[['date', 'price']], 
            flow_data.groupby('date')['daily_change'].sum().reset_index(),
            on='date'
        ).dropna()
        
        # 計算相關性
        price_change = merged['price'].pct_change()
        flow_change = merged['daily_change']
        
        correlation = price_change.corr(flow_change)
        
        # 領先落後分析
        lead_corrs = {}
        for lead in range(-7, 8):
            if lead < 0:
                corr = price_change.iloc[abs(lead):].corr(
                    flow_change.iloc[:lead].reset_index(drop=True)
                )
            elif lead > 0:
                corr = price_change.iloc[:-lead].reset_index(drop=True).corr(
                    flow_change.iloc[lead:].reset_index(drop=True)
                )
            else:
                corr = price_change.corr(flow_change)
            
            lead_corrs[lead] = corr
        
        return {
            'contemporaneous_correlation': correlation,
            'lead_lag_correlations': lead_corrs,
            'interpretation': self._interpret_flow_correlation(lead_corrs)
        }
    
    def _interpret_flow_correlation(self, lead_corrs):
        """
        解讀流向相關性
        """
        best_lead = max(lead_corrs.items(), key=lambda x: abs(x[1]) if not np.isnan(x[1]) else 0)
        
        if best_lead[1] > 0.3:
            return f"價格上漲伴隨交易所流入增加(最佳領先期: {best_lead[0]} 天)"
        elif best_lead[1] < -0.3:
            return f"價格上漲伴隨交易所流出增加(最佳領先期: {best_lead[0]} 天)- 可能是機構增持"
        else:
            return "流向與價格沒有顯著相關性"

2.2 交易所餘額趨勢分析

# 交易所比特幣餘額趨勢分析

class ExchangeBalanceTrend:
    """
    交易所比特幣餘額趨勢分析
    """
    
    def __init__(self):
        pass
    
    def calculate_balance_metrics(self, exchange_balance_history):
        """
        計算交易所餘額的關鍵指標
        """
        results = []
        
        for exchange in exchange_balance_history['exchange'].unique():
            data = exchange_balance_history[
                exchange_balance_history['exchange'] == exchange
            ].sort_values('date')
            
            # 計算趨勢
            data['balance_change_30d'] = data['btc_balance'].diff(30)
            data['balance_change_pct_30d'] = data['btc_balance'].pct_change(30)
            
            # 計算波動性
            volatility_30d = data['btc_balance'].rolling(30).std()
            
            # 趨勢判斷
            if data['balance_change_pct_30d'].iloc[-1] > 0.05:
                trend = 'increasing'
            elif data['balance_change_pct_30d'].iloc[-1] < -0.05:
                trend = 'decreasing'
            else:
                trend = 'stable'
            
            results.append({
                'exchange': exchange,
                'current_balance': data['btc_balance'].iloc[-1],
                'change_30d': data['balance_change_30d'].iloc[-1],
                'change_pct_30d': data['balance_change_pct_30d'].iloc[-1] * 100,
                'volatility_30d': volatility_30d.iloc[-1],
                'trend': trend
            })
        
        return pd.DataFrame(results)
    
    def market_depth_analysis(self, exchange_balances, total_supply=19600000):
        """
        市場深度分析
        
        交易所比特幣餘額 / 總流通供應
        """
        total_exchange_balance = exchange_balances['current_balance'].sum()
        
        return {
            'total_exchange_balance': total_exchange_balance,
            'exchange_supply_ratio': (total_exchange_balance / total_supply) * 100,
            'days_of_volume': self._estimate_days_of_volume(
                total_exchange_balance, 
                exchange_balances
            ),
            'liquidity_assessment': self._assess_liquidity(
                total_exchange_balance / total_supply
            )
        }
    
    def _estimate_days_of_volume(self, balance, exchange_data):
        """
        估算交易所餘額相當於多少天的交易量
        """
        # 假設日交易量約為流通供應的 2-5%
        daily_volume_ratio = 0.035  # 3.5%
        estimated_daily_volume = 19600000 * daily_volume_ratio
        
        return balance / estimated_daily_volume
    
    def _assess_liquidity(self, exchange_ratio):
        """
        評估流動性
        """
        if exchange_ratio < 0.10:
            return '極低流動性 - 比特幣可能被長期持有'
        elif exchange_ratio < 0.20:
            return '較低流動性 - 大部分比特幣被持有'
        elif exchange_ratio < 0.30:
            return '適中流動性'
        else:
            return '較高流動性 - 更多比特幣在市場上交易'
    
    def institutional_indicator(self, exchange_data):
        """
        機構活動指標
        
        某些交易所(如 Coinbase Prime)的餘額變化可能反映機構活動
        """
        institutional_exchanges = ['Coinbase', 'BitGo', 'Fidelity']
        
        retail_exchanges = ['Coinbase (Standard)', 'Binance', 'Kraken']
        
        inst_data = exchange_data[
            exchange_data['exchange'].isin(institutional_exchanges)
        ]
        retail_data = exchange_data[
            exchange_data['exchange'].isin(retail_exchanges)
        ]
        
        inst_balance = inst_data['current_balance'].sum()
        retail_balance = retail_data['current_balance'].sum()
        
        return {
            'institutional_balance': inst_balance,
            'retail_balance': retail_balance,
            'institutional_ratio': (inst_balance / (inst_balance + retail_balance)) * 100,
            'institutional_trend': 'increasing' if inst_balance > retail_balance * 0.3 else 'stable'
        }

三、比特幣供應週期模型

3.1 減半週期與供應衝擊

比特幣減半是理解比特幣供應動態的關鍵事件。讓我們量化分析減半對比特幣供應的影響。

# 比特幣減半與供應分析

class HalvingSupplyAnalysis:
    """
    比特幣減半週期供應分析
    """
    
    # 減半時間表(區塊高度)
    HALVING_HEIGHTS = [210000, 420000, 630000, 840000]
    HALVING_DATES = [
        datetime(2012, 11, 28),
        datetime(2016, 7, 9),
        datetime(2020, 5, 11),
        datetime(2024, 4, 20)
    ]
    
    # 每個時代的區塊獎勵
    BLOCK_REWARDS = [50, 25, 12.5, 6.25, 3.125]
    
    def __init__(self):
        self.current_block_reward = 3.125  # 減半後
        
    def calculate_circulating_supply_at_halving(self, halving_date):
        """
        計算減半時的流通供應量
        
        理論公式:
        supply = 50 * 210000 * (1 + 1/2 + 1/4 + ...) - 估計丟失
        """
        # 減半次數
        halving_number = self.HALVING_DATES.index(halving_date) + 1 if halving_date in self.HALVING_DATES else 0
        
        # 計算理論供應(不考慮丟失)
        theoretical_supply = 0
        for i in range(halving_number):
            theoretical_supply += self.BLOCK_REWARDS[i] * 210000
        
        # 考慮每年的區塊(第一個時代是 210,000 區塊,後續各 420,000)
        theoretical_supply = 50 * 210000  # 第一個時代
        for i in range(1, halving_number):
            theoretical_supply += self.BLOCK_REWARDS[i] * 210000 * 2
        
        # 估算流通供應(扣除約 15-20% 的估計丟失)
        lost_estimate = 0.15
        circulating_supply = theoretical_supply * (1 - lost_estimate)
        
        return {
            'halving_number': halving_number,
            'theoretical_supply': theoretical_supply,
            'estimated_circulating_supply': circulating_supply,
            'block_reward': self.BLOCK_REWARDS[halving_number] if halving_number < len(self.BLOCK_REWARDS) else 0,
            'lost_estimate_pct': lost_estimate * 100
        }
    
    def supply_issuance_analysis(self):
        """
        分析比特幣供應發行率
        """
        results = []
        
        for i, date in enumerate(self.HALVING_DATES):
            halving_supply = self.calculate_circulating_supply_at_halving(date)
            
            # 年化發行率
            annual_blocks = 210000 * 2  # 每年區塊數(平均 10 分鐘)
            annual_issuance = halving_supply['block_reward'] * annual_blocks
            annual_issuance_rate = (annual_issuance / halving_supply['estimated_circulating_supply']) * 100
            
            results.append({
                'halving': i + 1,
                'date': date,
                'block_reward': halving_supply['block_reward'],
                'circulating_supply': halving_supply['estimated_circulating_supply'],
                'annual_issuance_rate': annual_issuance_rate,
                'inflation_rate': annual_issuance_rate / 100  # 純通膨率
            })
        
        return pd.DataFrame(results)
    
    def future_supply_projection(self, years_ahead=10):
        """
        未來供應預測
        """
        current_supply = 19700000  # 近似當前流通量
        current_block_reward = 3.125
        
        projections = []
        current_date = datetime.now()
        
        for year in range(1, years_ahead + 1):
            # 計算年度發行
            annual_blocks = 210000 * 2
            annual_issuance = current_block_reward * annual_blocks
            
            # 下一次減半(2028 年)
            if current_date.year + year >= 2028:
                current_block_reward = 1.5625
            
            # 第二次減半(2032 年)
            if current_date.year + year >= 2032:
                current_block_reward = 0.78125
            
            current_supply += annual_issuance
            
            projections.append({
                'year': current_date.year + year,
                'projected_supply': min(current_supply, 21000000),
                'block_reward': current_block_reward,
                'annual_issuance': annual_issuance,
                'cumulative_mined': current_supply,
                'remaining': 21000000 - current_supply,
                'pct_of_total': (current_supply / 21000000) * 100
            })
        
        return pd.DataFrame(projections)

3.2 供應緊張指標

# 比特幣供應緊張程度指標

class SupplySqueezeIndicator:
    """
    比特幣供應緊張程度指標
    """
    
    def __init__(self):
        self.price_data = None
        self.supply_data = None
        
    def calculate_supply_demand_ratio(self, trading_volume, circulating_supply):
        """
        計算供需比率
        
        比率越高表示供應越緊張
        """
        daily_volume = trading_volume
        supply_ratio = daily_volume / circulating_supply
        
        return {
            'supply_demand_ratio': supply_ratio,
            'interpretation': self._interpret_ratio(supply_ratio)
        }
    
    def _interpret_ratio(self, ratio):
        if ratio < 0.01:
            return "供應充足 - 買賣壓力相對平衡"
        elif ratio < 0.03:
            return "供應適中"
        elif ratio < 0.05:
            return "供應緊張 - 可能推動價格上漲"
        else:
            return "極度供應緊張 - 價格上漲壓力大"
    
    def realized_cap_hodl_wave(self, price_data, supply_data):
        """
        實現市值和 HODL 波形分析
        
        實現市值 (Realized Cap):
        所有比特幣的最後一次移動價值的總和
        
        HODL 波形:
        不同年齡段的比特幣供應比例
        """
        # 模擬數據
        # 實際需要完整的鏈上數據
        
        realized_cap = 0
        for age_group, data in supply_data['age_distribution'].items():
            # 假設每個年齡段的平均成本
            avg_cost = self._estimate_cost_basis(age_group, price_data)
            realized_cap += data['supply_btc'] * avg_cost
        
        market_cap = price_data['current_price'] * supply_data['total_supply']
        
        # HODL 波形指標
        lth_supply = sum(
            data['supply_btc'] 
            for age_group, data in supply_data['age_distribution'].items()
            if 'year' in age_group and int(age_group.split('-')[0].replace('>', '')) >= 1
        )
        
        return {
            'realized_cap': realized_cap,
            'market_cap': market_cap,
            'mvrv_ratio': market_cap / realized_cap,
            'lth_supply_btc': lth_supply,
            'lth_supply_ratio': lth_supply / supply_data['total_supply'],
            'interpretation': self._interpret_mvrv(market_cap / realized_cap)
        }
    
    def _estimate_cost_basis(self, age_group, price_data):
        """
        估算不同年齡段比特幣的成本基礎
        """
        # 簡化實現
        age_map = {
            '< 1 month': 0.9,
            '1-3 months': 0.8,
            '3-6 months': 0.7,
            '6-12 months': 0.6,
            '1-2 years': 0.4,
            '2-3 years': 0.3,
            '3-5 years': 0.2,
            '5-7 years': 0.15,
            '> 7 years': 0.1
        }
        
        multiplier = age_map.get(age_group, 0.5)
        return price_data['current_price'] * multiplier
    
    def _interpret_mvrv(self, mvrv):
        """
        解讀 MVRV 比率
        
        MVRV = 市值 / 實現市值
        
        - MVRV < 1: 比特幣被低估(持有人平均獲利為負)
        - MVRV ~ 1.5-2: 合理估值
        - MVRV > 3-4: 比特幣被高估
        """
        if mvrv < 1:
            return "嚴重低估 - 持有人普遍虧損"
        elif mvrv < 2:
            return "低估 - 增持機會"
        elif mvrv < 3:
            return "合理估值"
        elif mvrv < 4:
            return "適度高估"
        else:
            return "嚴重高估 - 泡沫風險"
    
    def stock_to_flow_model_analysis(self):
        """
        庫存流量比模型分析
        
        S2F = Stock (庫存) / Flow (年產量)
        """
        # 當前數據
        current_stock = 19700000  # BTC
        annual_flow = 328500  # 每年約產 6.25 BTC/區塊 * 6*24*365
        
        s2f = current_stock / annual_flow
        
        # S2F 價格模型(基於歷史數據的回歸)
        # 價格 = exp(12.5) * S2F^3.3
        # 這是一個簡化的模型
        
        predicted_price = np.exp(12.5) * (s2f ** 3.3)
        
        return {
            'stock': current_stock,
            'flow': annual_flow,
            'stock_to_flow': s2f,
            'predicted_price': predicted_price,
            'current_price': 100000,  # 假設
            'model_vs_current': (predicted_price / 100000 - 1) * 100
        }

四、實際應用:市場週期分析框架

4.1 供應動態綜合指標

# 比特幣供應動態綜合儀表板

class SupplyDynamicsDashboard:
    """
    比特幣供應動態綜合儀表板
    """
    
    def __init__(self):
        pass
    
    def generate_market_cycle_signal(self, indicators):
        """
        根據供應動態指標生成市場週期信號
        """
        # 評分權重
        weights = {
            'lth_supply_ratio': 0.25,
            'exchange_balance_trend': 0.20,
            'mvrv_ratio': 0.25,
            'stock_to_flow': 0.15,
            'supply_demand_ratio': 0.15
        }
        
        # 評分函數
        scores = {}
        
        # LTH 供應比率
        if indicators['lth_supply_ratio'] > 0.65:
            scores['lth_supply_ratio'] = 100  # 累積階段
        elif indicators['lth_supply_ratio'] > 0.50:
            scores['lth_supply_ratio'] = 60
        elif indicators['lth_supply_ratio'] > 0.40:
            scores['lth_supply_ratio'] = 40
        else:
            scores['lth_supply_ratio'] = 20  # 分配階段
        
        # 交易所餘額趨勢
        if indicators['exchange_balance_trend'] < -0.05:
            scores['exchange_balance_trend'] = 80  # 流出,積极增持
        elif indicators['exchange_balance_trend'] < 0:
            scores['exchange_balance_trend'] = 60
        elif indicators['exchange_balance_trend'] < 0.05:
            scores['exchange_balance_trend'] = 40
        else:
            scores['exchange_balance_trend'] = 20
        
        # MVRV
        if indicators['mvrv_ratio'] < 1:
            scores['mvrv_ratio'] = 90
        elif indicators['mvrv_ratio'] < 1.5:
            scores['mvrv_ratio'] = 70
        elif indicators['mvrv_ratio'] < 2.5:
            scores['mvrv_ratio'] = 50
        elif indicators['mvrv_ratio'] < 3.5:
            scores['mvrv_ratio'] = 30
        else:
            scores['mvrv_ratio'] = 10
        
        # 計算加權分數
        total_score = sum(
            scores[key] * weights[key] 
            for key in weights.keys()
        )
        
        # 生成信號
        if total_score > 70:
            signal = 'STRONG_BUY'
            description = '供應緊張,長期持有者累積,建議增持'
        elif total_score > 55:
            signal = 'BUY'
            description = '供應偏緊,適合建倉'
        elif total_score > 40:
            signal = 'HOLD'
            description = '供應適中,建議觀望'
        elif total_score > 25:
            signal = 'SELL'
            description = '供應過剩,考慮減倉'
        else:
            signal = 'STRONG_SELL'
            description = '嚴重供應過剩,建議大幅減倉'
        
        return {
            'signal': signal,
            'description': description,
            'total_score': total_score,
            'component_scores': scores,
            'weights': weights
        }
    
    def backtest_strategy(self, historical_data, strategy='lth_based'):
        """
        回測供應動態策略
        """
        results = []
        
        for date, data in historical_data.iterrows():
            indicators = {
                'lth_supply_ratio': data.get('lth_ratio', 0.5),
                'exchange_balance_trend': data.get('exchange_change', 0),
                'mvrv_ratio': data.get('mvrv', 2.0),
                'stock_to_flow': data.get('s2f', 50),
                'supply_demand_ratio': data.get('sd_ratio', 0.02)
            }
            
            signal = self.generate_market_cycle_signal(indicators)
            
            # 根據信號決定倉位
            if signal['signal'] == 'STRONG_BUY':
                position = 1.0
            elif signal['signal'] == 'BUY':
                position = 0.7
            elif signal['signal'] == 'HOLD':
                position = 0.5
            elif signal['signal'] == 'SELL':
                position = 0.3
            else:
                position = 0.1
            
            results.append({
                'date': date,
                'signal': signal['signal'],
                'position': position,
                'btc_price': data.get('price', 0),
                'score': signal['total_score']
            })
        
        return pd.DataFrame(results)
    
    def calculate_strategy_performance(self, backtest_results, initial_capital=10000):
        """
        計算策略績效
        """
        df = backtest_results.sort_values('date')
        
        # 計算持倉價值變化
        df['position_value'] = initial_capital
        
        for i in range(1, len(df)):
            price_change = df.iloc[i]['btc_price'] / df.iloc[i-1]['btc_price']
            position_change = df.iloc[i]['position'] / df.iloc[i-1]['position']
            df.iloc[i, df.columns.get_loc('position_value')] = (
                df.iloc[i-1]['position_value'] * price_change * position_change
            )
        
        # 計算關鍵指標
        total_return = (df['position_value'].iloc[-1] / initial_capital - 1) * 100
        
        # 最大回撤
        cummax = df['position_value'].cummax()
        drawdown = (df['position_value'] - cummax) / cummax
        max_drawdown = drawdown.min() * 100
        
        # 夏普比率(簡化)
        returns = df['position_value'].pct_change().dropna()
        sharpe = (returns.mean() / returns.std()) * np.sqrt(252) if returns.std() > 0 else 0
        
        return {
            'total_return': total_return,
            'max_drawdown': max_drawdown,
            'sharpe_ratio': sharpe,
            'win_rate': (returns > 0).sum() / len(returns) * 100
        }

五、結論

本文深入分析了比特幣的供應動態,包括以下關鍵發現:

5.1 主要結論

比特幣供應動態關鍵發現:

┌─────────────────────────────────────────────────────────────────────────┐
│                         供應結構                                        │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                         │
│ • 流通供應:~1960 萬 BTC(扣除約 300-400 萬休眠/丟失幣)                 │
│ • 長期持有者供應:~1000 萬 BTC(50-55%)                               │
│ • 交易所可交易供應:~300-400 萬 BTC(15-20%)                          │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────┤
│                         減半週期                                        │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                         │
│ • 減半後發行率持續下降:6.25 → 3.125 → 1.5625 → 0.78125 BTC/區塊      │
│ • 年通膨率從初始的 ~9% 降至當前的 ~1.7%                                │
│ • 2140 年達到 2100 萬上限                                              │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────┤
│                         市場週期信號                                    │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                         │
│ • LTH 比率 > 60%:累積階段,價格可能上漲                               │
│ • 交易所餘額下降:持有人增持,拋售壓力低                               │
│ • MVRV < 1.5:比特幣相對低估                                          │
│ • S2F > 50:比特幣相對稀缺                                            │
│                                                                         │
├─────────────────────────────────────────────────────────────────────────┤
│                         投資啟示                                        │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                         │
│ • 供應動態指標有助於判斷市場週期階段                                    │
│ • 長期持有者行為是價格走勢的重要領先指標                                │
│ • 交易所流向反映短期交易者情緒                                          │
│ • 綜合多個指標比單一指標更具可靠性                                      │
│                                                                         │
└─────────────────────────────────────────────────────────────────────────┘

5.2 數據來源與局限性

數據來源:
1. Blockchain.com - 比特幣區塊鏈數據
2. Glassnode - 鏈上指標
3. CoinMetrics - 網路數據
4. 交易所公開錢包地址

分析局限性:
1. 休眠比特幣難以精確統計
2. 交易所錢包識別可能不完整
3. 歷史數據覆蓋範圍有限
4. 模型預測存在不確定性

建議:
- 將供應動態指標與其他分析方法結合使用
- 關注趨勢變化而非絕對值
- 定期更新數據以反映最新市場狀態

參考資料

  1. Glassnode - "The Week On-chain"
  2. CoinMetrics - "State of the Network"
  3. Nakamoto Terminal - Bitcoin Supply Dynamics
  4. Blockchain.com - Bitcoin Statistics
  5. Bitcoin Wiki - Controlled Supply

延伸閱讀與來源

這篇文章對您有幫助嗎?

評論

發表評論

注意:由於這是靜態網站,您的評論將儲存在本地瀏覽器中,不會公開顯示。

目前尚無評論,成為第一個發表評論的人吧!