{"id":1521,"date":"2024-10-15T07:34:00","date_gmt":"2024-10-14T23:34:00","guid":{"rendered":"https:\/\/blog.laoyulaoyu.top\/?p=1521"},"modified":"2024-09-18T22:38:42","modified_gmt":"2024-09-18T14:38:42","slug":"%e7%94%a8%e8%82%a1%e7%a5%a8%e5%8a%a0%e6%95%b0%e5%ad%97%e8%b4%a7%e5%b8%81%e6%9e%84%e5%bb%ba%e9%85%8d%e5%af%b9%e4%ba%a4%e6%98%93%e7%ad%96%e7%95%a5","status":"publish","type":"post","link":"https:\/\/laoyulaoyu.com\/index.php\/2024\/10\/15\/%e7%94%a8%e8%82%a1%e7%a5%a8%e5%8a%a0%e6%95%b0%e5%ad%97%e8%b4%a7%e5%b8%81%e6%9e%84%e5%bb%ba%e9%85%8d%e5%af%b9%e4%ba%a4%e6%98%93%e7%ad%96%e7%95%a5\/","title":{"rendered":"\u7528\u80a1\u7968\u52a0\u6570\u5b57\u8d27\u5e01\u6784\u5efa\u914d\u5bf9\u4ea4\u6613\u7b56\u7565"},"content":{"rendered":"\n<p>\u4f5c\u8005\uff1a<a href=\"https:\/\/www.laoyulaoyu.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u8001\u4f59\u635e\u9c7c<\/a><\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002<\/mark><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/image-166.png\" alt=\"\" class=\"wp-image-2131\"\/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<pre class=\"wp-block-verse\"><strong>\u5199\u5728\u524d\u9762\u7684\u8bdd\uff1a<\/strong>\u672c\u6587\u9610\u8ff0\u901a\u8fc7\u5206\u6790\u52a0\u5bc6\u8d27\u5e01\u548c\u4f20\u7edf\u91d1\u878d\u5de5\u5177\u4e4b\u95f4\u7684\u76f8\u5173\u6027\u548c\u534f\u6574\u6027\uff0c\u4ee5\u53ca\u5b9e\u65bd Z-score \u65b9\u6cd5\u6765\u751f\u6210\u4ea4\u6613\u4fe1\u53f7\uff0c\u7136\u540e<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528 Python \u6784\u5efa\u914d\u5bf9\u4ea4\u6613\u7b56\u7565\uff0c\u4ece\u800c\u5728\u5e02\u573a\u4e2d\u5bfb\u627e\u4ea4\u6613\u673a\u4f1a\u3002<\/mark>\u6700\u540e\u8fd8\u8ba8\u8bba\u4e86\u5b9e\u9645\u9047\u5230\u7684\u4ea4\u6613\u6311\u6218\uff0c\u5f3a\u8c03\u8bc4\u4f30\u7b56\u7565\u8981\u8003\u8651\u98ce\u9669\u8c03\u6574\u6307\u6807\u3002<\/pre>\n<\/blockquote>\n\n\n\n<p>\u914d\u5bf9\u4ea4\u6613\u4f5c\u4e3a\u4e00\u79cd\u590d\u6742\u7684\u7b56\u7565\uff0c\u5e38\u5e38\u88ab\u4ea4\u6613\u8005\u8fd0\u7528\u4ee5\u7ba1\u7406\u6295\u8d44\u7ec4\u5408\uff0c\u800c\u975e\u4ec5\u4ec5\u805a\u7126\u4e8e\u5355\u4e2a\u8d44\u4ea7\u3002\u672c\u6587\u5c06\u6df1\u5165\u63a2\u8ba8\u8fd9\u79cd\u5e02\u573a\u4e2d\u6027\u7b56\u7565\uff0c\u5176\u65e8\u5728\u4ece\u4e24\u79cd\u5bc6\u5207\u76f8\u5173\u7684\u91d1\u878d\u5de5\u5177\u7684\u76f8\u5bf9\u4ef7\u683c\u53d8\u52a8\u4e2d\u83b7\u53d6\u5229\u6da6\u3002\u672c\u6587\u6211\u4eec\u8fd8\u662f\u501f\u52a9\u53ef\u514d\u8d39\u83b7\u53d6\u7684\u96c5\u864e\u8d22\u7ecf\u6570\u636e\u5c55\u5f00\u6a21\u62df\u5206\u6790\u3002<\/p>\n\n\n\n<p>\u8fd9\u79cd\u7b56\u7565\u7684\u6838\u5fc3\u662f\u76f8\u4fe1\uff0c\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u4e24\u79cd\u8d44\u4ea7\u7684\u4ef7\u683c\u4f1a\u4fdd\u6301\u7a33\u5b9a\u7684\u4ef7\u5dee\u3002\u56e0\u6b64\uff0c\u65e0\u8bba\u5e02\u573a\u5927\u8d8b\u52bf\u5982\u4f55\uff0c\u4ea4\u6613\u8005\u90fd\u80fd\u4ece\u4ef7\u683c\u8d8b\u540c\u4e2d\u83b7\u5229\u3002\u914d\u5bf9\u4ea4\u6613\u7684\u76ee\u6807\u662f\u6240\u9009\u8d44\u4ea7\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u800c\u4e0d\u662f\u6574\u4f53\u5e02\u573a\u65b9\u5411\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. \u73af\u5883\u914d\u7f6e<\/strong><\/h3>\n\n\n\n<p>\u8981\u5728 Jupyter \u73af\u5883\u4e2d\u8bbe\u7f6e\u5fc5\u8981\u7684\u5e93\uff0c\u8bf7\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>!pip install numpy\n!pip install pandas\n!pip install yfinance<\/code><\/pre>\n\n\n\n<p>\u5728 Jupyter Notebook \u5355\u5143\u91cc\u8fd0\u884c\u8fd9\u4e9b\u547d\u4ee4\uff0c\u4fbf\u80fd\u5c06\u6307\u5b9a\u7684\u5e93\u76f4\u63a5\u5b89\u88c5\u5230\u73af\u5883\u5f53\u4e2d\u3002\u5b89\u88c5\u5b8c\u6bd5\u540e\uff0c\u6211\u4eec\u5c31\u80fd\u591f\u7ee7\u7eed\u5c55\u5f00\u5206\u6790\u4e86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. \u6536\u96c6\u6570\u636e<\/strong><\/h3>\n\n\n\n<p>\u8981\u4f7f\u7528 Yahoo Finance \u6570\u636e\u4e3a\u6d89\u53ca\u52a0\u5bc6\u8d27\u5e01\u7684\u914d\u5bf9\u4ea4\u6613\u7b56\u7565\u5b9e\u65bd\u6570\u636e\u6536\u96c6\u548c\u6e05\u7406\uff0c\u8bf7\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u63d2\u8865\u7f3a\u5931\u503c\uff1a<\/strong>\u586b\u8865\u6570\u636e\u4e2d\u7684\u7a7a\u767d\uff0c\u4ee5\u4fdd\u6301\u6570\u636e\u7684\u8fde\u7eed\u6027\u3002<\/li>\n\n\n\n<li><strong>\u5e73\u6ed1\u5f02\u5e38\u503c\uff1a<\/strong>\u5e94\u7528\u5e73\u6ed1\u6781\u7aef\u6570\u636e\u70b9\u7684\u65b9\u6cd5\uff0c\u4ee5\u907f\u514d\u5206\u6790\u5931\u771f\u3002<\/li>\n\n\n\n<li><strong>\u786e\u4fdd\u65f6\u95f4\u5e8f\u5217\u957f\u5ea6\u4e00\u81f4\uff1a<\/strong>\u5c3d\u7ba1\u52a0\u5bc6\u8d27\u5e01\u5e02\u573a\u5b58\u5728\u6301\u7eed\u7684\u4ea4\u6613\u6d3b\u52a8\uff0c\u4f46\u8981\u5bf9\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u8fdb\u884c\u6807\u51c6\u5316\uff0c\u4ee5\u786e\u4fdd\u957f\u5ea6\u4e00\u81f4\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4e0b\u9762\u662f Python \u7684\u5b9e\u73b0\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>crypto_forex_stocks = &#91;'BTC-USD', 'ETH-USD', 'BNB-USD', 'XRP-USD', 'ADA-USD', 'DOGE-USD', 'ETC-USD', 'XLM-USD', 'AAVE-USD', 'EOS-USD', 'XTZ-USD', 'ALGO-USD', 'XMR-USD', 'KCS-USD',\n                       'MKR-USD', 'BSV-USD', 'RUNE-USD', 'DASH-USD', 'KAVA-USD', 'ICX-USD', 'LINA-USD', 'WAXP-USD', 'LSK-USD', 'EWT-USD', 'XCN-USD', 'HIVE-USD', 'FTX-USD', 'RVN-USD', 'SXP-USD', 'BTCB-USD']\nbank_stocks = &#91;'JPM', 'BAC', 'WFC', 'C', 'GS', 'MS', 'DB', 'UBS', 'BBVA', 'SAN', 'ING', ' BNPQY', 'HSBC', 'SMFG', 'PNC', 'USB', 'BK', 'STT', 'KEY', 'RF', 'HBAN', 'FITB',  'CFG',\n               'BLK', 'ALLY', 'MTB', 'NBHC', 'ZION', 'FFIN', 'FHN', 'UBSI', 'WAL', 'PACW', 'SBCF', 'TCBI', 'BOKF', 'PFG', 'GBCI', 'TFC', 'CFR', 'UMBF', 'SPFI', 'FULT', 'ONB', 'INDB', 'IBOC', 'HOMB']\nglobal_indexes = &#91;'^DJI', '^IXIC', '^GSPC', '^FTSE', '^N225', '^HSI', '^AXJO', '^KS11', '^BFX', '^N100',\n                  '^RUT', '^VIX', '^TNX']\n\nSTART_DATE = '2021-01-01'\nEND_DATE = '2023-10-31'\nuniverse_tickers = crypto_forex_stocks + bank_stocks + global_indexes\nuniverse_tickers_ts_map = {ticker: load_ticker_ts_df(\n    ticker, START_DATE, END_DATE) for ticker in universe_tickers}\n\ndef sanitize_data(data_map):\n    TS_DAYS_LENGTH = (pd.to_datetime(END_DATE) -\n                      pd.to_datetime(START_DATE)).days\n    data_sanitized = {}\n    date_range = pd.date_range(start=START_DATE, end=END_DATE, freq='D')\n    for ticker, data in data_map.items():\n        if data is None or len(data) &lt; (TS_DAYS_LENGTH \/ 2):\n            # We cannot handle shorter TSs\n            continue\n        if len(data) &gt; TS_DAYS_LENGTH:\n            # Normalize to have the same length (TS_DAYS_LENGTH)\n            data = data&#91;-TS_DAYS_LENGTH:]\n        # Reindex the time series to match the date range and fill in any blanks (Not Numbers)\n        data = data.reindex(date_range)\n        data&#91;'Adj Close'].replace(&#91;np.inf, -np.inf], np.nan, inplace=True)\n        data&#91;'Adj Close'].interpolate(method='linear', inplace=True)\n        data&#91;'Adj Close'].fillna(method='pad', inplace=True)\n        data&#91;'Adj Close'].fillna(method='bfill', inplace=True)\n        assert not np.any(np.isnan(data&#91;'Adj Close'])) and not np.any(\n            np.isinf(data&#91;'Adj Close']))\n        data_sanitized&#91;ticker] = data\n    return data_sanitized\n# Sample some\nuts_sanitized = sanitize_data(universe_tickers_ts_map)\nuts_sanitized&#91;'JPM'].shape, uts_sanitized&#91;'BTC-USD'].shape<\/code><\/code><\/pre>\n\n\n\n<p>\u65e5\u671f\u8303\u56f4 &#8220;\u53d8\u91cf\u7528 &#8220;pd.date_range(start=START_DATE, end=END_DATE, freq=&#8217;D&#8217;) &#8220;\u5b9a\u4e49\uff0c\u4e3a\u6570\u636e\u5efa\u7acb\u6240\u9700\u7684\u65f6\u95f4\u8303\u56f4\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u4f7f\u7528\u7ebf\u6027\u63d2\u503c\u6cd5\u586b\u8865\u6240\u6709\u7f3a\u5931\u503c\uff08NaN \u6216 Nones\uff09\uff0c\u5982\u679c\u7ebf\u6027\u63d2\u503c\u6cd5\u5931\u8d25\uff0c\u5219\u4f7f\u7528\u6700\u8fd1\u7684\u6709\u6548\u503c\u8fdb\u884c\u56de\u586b\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u8fd0\u7528\u65ad\u8a00\u8bed\u53e5\u6765\u6821\u9a8c\u6570\u636e\u7684\u5b8c\u6574\u6027\uff0c\u540c\u65f6\u68c0\u67e5\u968f\u673a\u9009\u53d6\u7684\u4e24\u4e2a\u4eea\u5668\u7684\u5f62\u72b6\uff0c\u4ee5\u786e\u4fdd\u5b83\u4eec\u80fd\u76f8\u5339\u914d\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. \u6df1\u5165\u63a2\u8ba8<\/strong><\/h3>\n\n\n\n<p>\u5927\u5bb6\u4e5f\u8bb8\u8fd8\u8bb0\u5f97 FTX \u7684\u4e11\u95fb\u5427\uff1f\u4f34\u968f\u8fd9\u5bb6\u4ea4\u6613\u6240\u7684\u5012\u95ed\uff0c\u6295\u8d44\u8005\u6216\u8bb8\u4f1a\u5bf9\u52a0\u5bc6\u8d27\u5e01\u4ea4\u6613\u6240\u4e27\u5931\u4fe1\u5fc3\uff0c\u6682\u4e14\u8f6c\u5411\u4f20\u7edf\u94f6\u884c\u8fdb\u884c\u91d1\u878d\u4ea4\u6613\uff0c\u76f4\u81f3\u4e11\u95fb\u88ab\u6de1\u5fd8\u3002<\/p>\n\n\n\n<p>\u4e3a\u4e86\u63a2\u7a76\u8fd9\u4e00\u5047\u8bbe\uff0c\u6211\u4eec\u80fd\u591f\u8fd0\u7528\u76f8\u5173\u6027\u5206\u6790\u4e0e\u534f\u6574\u5206\u6790\uff0c\u6765\u5224\u5b9a\u52a0\u5bc6\u8d27\u5e01\u5e02\u573a\u548c\u4f20\u7edf\u94f6\u884c\u4e1a\u8868\u73b0\u4e4b\u95f4\u7684\u4efb\u4f55\u6a21\u5f0f\u6216\u8005\u5173\u7cfb\u3002\u76f8\u5173\u6027\u5206\u6790\u4f1a\u52a9\u529b\u6211\u4eec\u77e5\u6653\u4e24\u4e2a\u6570\u636e\u96c6\u4e4b\u95f4\u7684\u7ebf\u6027\u5173\u7cfb\u7a0b\u5ea6\uff0c\u800c\u534f\u6574\u6027\u5206\u6790\u5219\u4f1a\u660e\u786e\u5b83\u4eec\u4e4b\u95f4\u662f\u5426\u5b58\u5728\u957f\u671f\u5173\u7cfb\uff0c\u8fdb\u800c\u63d0\u793a\u6f5c\u5728\u7684\u914d\u5bf9\u4ea4\u6613\u5951\u673a\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u7814\u7a76\u8fd9\u4e9b\u6307\u6807\uff0c\u6211\u4eec\u53ef\u4ee5\u8bc4\u4f30\u4e11\u95fb\u662f\u5426\u5f71\u54cd\u4e86\u5e02\u573a\u5bf9\u52a0\u5bc6\u8d27\u5e01\u548c\u4f20\u7edf\u94f6\u884c\u4e1a\u7684\u60c5\u7eea\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. \u76f8\u5173\u6027\u548c\u534f\u6574\u6027<\/strong><\/h3>\n\n\n\n<p>\u76f8\u5173\u6027\u4f7f\u7528\u76ae\u5c14\u900a\u76f8\u5173\u7cfb\u6570<strong> Pearson correlation coefficient (r) <\/strong>\u6765\u8861\u91cf\u4e24\u4e2a\u53d8\u91cf\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u5176\u8303\u56f4\u4e3a-1 \u5230 1\u30021 \u8868\u793a\u5b8c\u5168\u7684\u8d1f\u7ebf\u6027\u5173\u7cfb\uff0c0 \u8868\u793a\u6ca1\u6709\u7ebf\u6027\u5173\u7cfb\uff0c1 \u8868\u793a\u5b8c\u5168\u7684\u6b63\u7ebf\u6027\u5173\u7cfb\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/image-167.png\" alt=\"\" class=\"wp-image-2132\"\/><\/figure>\n\n\n\n<p>\u800c\u534f\u6574\u5219\u662f\u8bc4\u4f30\u4e24\u79cd\u8d44\u4ea7\u662f\u5426\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\u800c\u8054\u7cfb\u5728\u4e00\u8d77\uff0c\u8868\u660e\u5b83\u4eec\u7684\u4ef7\u5dee\u503e\u5411\u4e8e\u56de\u5f52\u5747\u503c\u3002\u5f53\u5b83\u4eec\u6682\u65f6\u504f\u79bb\u5386\u53f2\u5173\u7cfb\u65f6\uff0c\u8fd9\u5c31\u4e3a\u4ea4\u6613\u521b\u9020\u4e86\u673a\u4f1a\u3002\u534f\u6574\u5173\u7cfb\u662f\u901a\u8fc7\u7edf\u8ba1\u68c0\u9a8c\u6765\u8bc4\u4f30\u7684\uff0c\u5982\u6269\u589e\u8fea\u57fa-\u5bcc\u52d2<strong> Dickey-Fuller (ADF)&nbsp;<\/strong>\u68c0\u9a8c\uff0c\u8be5\u68c0\u9a8c\u53ef\u68c0\u67e5\u4e24\u79cd\u8d44\u4ea7\u4e4b\u95f4\u7684\u4ef7\u5dee\u662f\u5426\u9759\u6b62\u3002\u5982\u679c\u4ef7\u5dee\u662f\u9759\u6001\u7684\uff0c\u5219\u8868\u660e\u8fd9\u4e24\u79cd\u8d44\u4ea7\u662f\u534f\u6574\u7684\uff0c\u5e76\u4e14\u5177\u6709\u957f\u671f\u5173\u7cfb\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/image-168.png\" alt=\"\" class=\"wp-image-2133\"\/><\/figure>\n\n\n\n<p>\u5e78\u8fd0\u7684\u662f\uff0cnumpy \u548c stats \u5e93\u63d0\u4f9b\u4e86\u7b80\u5316\u8fd9\u4e9b\u7edf\u8ba1\u6d4b\u8bd5\u7684\u51fd\u6570\uff0c\u4f7f\u76f8\u5173\u6027\u548c\u534f\u6574\u5206\u6790\u7684\u6267\u884c\u53d8\u5f97\u66f4\u52a0\u5bb9\u6613\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. \u5bfb\u627e\u914d\u5bf9<\/strong><\/h3>\n\n\n\n<p>\u5728\u4ea4\u6613\u4e2d\uff0c\u5f53\u8d44\u4ea7\u95f4\u7684\u4ef7\u5dee\u80cc\u79bb\u5386\u53f2\u5747\u503c\u4e4b\u9645\uff0c\u5206\u6790\u5e08\u4f1a\u501f\u52a9\u534f\u6574\u68c0\u9a8c\u6765\u751f\u6210\u4e70\u5165\u4e0e\u5356\u51fa\u4fe1\u53f7\u3002\u5f53\u4ef7\u5dee\u56de\u5f52\u81f3\u957f\u671f\u5747\u8861\u72b6\u6001\u65f6\uff0c\u6b64\u822c\u504f\u79bb\u4fbf\u4f1a\u9020\u5c31\u83b7\u5229\u5951\u673a\u3002\u6545\u800c\uff0c\u5bf9\u8fd9\u79cd\u5206\u6790\u800c\u8a00\uff0c\u638c\u63a7\u5168\u9762\u7684\u6570\u636e\u6781\u4e3a\u5173\u952e\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u7684\u4ee3\u7801\u5c06\u68c0\u9a8c\u4e00\u7cfb\u5217\u80a1\u7968\u548c\u5176\u4ed6\u91d1\u878d\u5de5\u5177\uff0c\u4ee5\u53d1\u73b0\u4efb\u4f55\u9690\u85cf\u7684\u5173\u7cfb\u3002\u5b83\u5c06\u68c0\u9a8c\u96f6\u5047\u8bbe (H0)\uff0c\u5373\u5047\u8bbe\u8d44\u4ea7\u4e4b\u95f4\u6ca1\u6709\u5f71\u54cd\u6216\u5173\u7cfb\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u5982\u679c\u68c0\u9a8c\u7684 <strong>p \u503c<\/strong> \u4f4e\u4e8e 0.02\uff0c\u5219\u62d2\u7edd\u96f6\u5047\u8bbe (H0)\uff0c\u8868\u660e\u8fd9\u5bf9\u8d44\u4ea7\u4e4b\u95f4\u5b58\u5728\u4e00\u5b9a\u7a0b\u5ea6\u7684\u534f\u6574\u5173\u7cfb\u6216\u503c\u5f97\u8fdb\u4e00\u6b65\u7814\u7a76\u7684\u5173\u7cfb\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>from statsmodels.tsa.stattools import coint\nfrom itertools import combinations\nfrom statsmodels.tsa.stattools import coint\n\ndef find_cointegrated_pairs(tickers_ts_map, p_value_threshold=0.2):\n    \"\"\"\n    Find cointegrated pairs of stocks based on the Augmented Dickey-Fuller (ADF) test.\n    Parameters:\n    - tickers_ts_map (dict): A dictionary where keys are stock tickers and values are time series data.\n    - p_value_threshold (float): The significance level for cointegration testing.\n    Returns:\n    - pvalue_matrix (numpy.ndarray): A matrix of cointegration p-values between stock pairs.\n    - pairs (list): A list of tuples representing cointegrated stock pairs and their p-values.\n    \"\"\"\n    tickers = list(tickers_ts_map.keys())\n    n = len(tickers)\n    # Extract 'Adj Close' prices into a matrix (each column is a time series)\n    adj_close_data = np.column_stack(\n        &#91;tickers_ts_map&#91;ticker]&#91;'Adj Close'].values for ticker in tickers])\n    pvalue_matrix = np.ones((n, n))\n    # Calculate cointegration p-values for unique pair combinations\n    for i, j in combinations(range(n), 2):\n        result = coint(adj_close_data&#91;:, i], adj_close_data&#91;:, j])\n        pvalue_matrix&#91;i, j] = result&#91;1]\n    pairs = &#91;(tickers&#91;i], tickers&#91;j], pvalue_matrix&#91;i, j])\n             for i, j in zip(*np.where(pvalue_matrix &lt; p_value_threshold))]\n    return pvalue_matrix, pairs\n# This section can take up to 5mins\nP_VALUE_THRESHOLD = 0.02\npvalues, pairs = find_cointegrated_pairs(\n    uts_sanitized, p_value_threshold=P_VALUE_THRESHOLD)<\/code><\/code><\/pre>\n\n\n\n<p>\u5c06\u8d44\u4ea7\u95f4\u7684\u5173\u7cfb\u4e88\u4ee5\u53ef\u89c6\u5316\uff0c\u5bf9\u4e8e\u4eba\u5de5\u89e3\u8bfb\u4e0e\u51b3\u7b56\u800c\u8a00\u81f3\u5173\u91cd\u8981\uff0c\u5373\u4fbf\u5728\u7b97\u6cd5\u4ea4\u6613\u4e2d\u4ea6\u662f\u5982\u6b64\u3002\u70ed\u56fe\u80fd\u591f\u4f9d\u636e\u534f\u6574\u68c0\u9a8c\u6240\u5f97\u51fa\u7684<strong> p \u503c<\/strong>\uff0c\u76f4\u89c2\u5730\u5c55\u73b0\u54ea\u4e9b\u8d44\u4ea7\u5c5e\u4e8e\u914d\u5bf9\u8d44\u4ea7\u3002\u8be5\u70ed\u56fe\u6709\u76ca\u4e8e\u8bc6\u522b\u5177\u6709\u91cd\u8981\u5173\u7cfb\u7684\u6f5c\u5728\u914d\u5bf9\uff0c\u4ece\u800c\u4e3a\u8fdb\u4e00\u6b65\u5206\u6790\u4ee5\u53ca\u63a2\u5bfb\u4ea4\u6613\u673a\u4f1a\u63d0\u4f9b\u52a9\u529b\u3002<\/p>\n\n\n\n<p><strong>5.1 \u521b\u5efa\u548c\u663e\u793a\u70ed\u56fe<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>import seaborn as sns\n\nplt.figure(figsize=(26, 26))\nheatmap = sns.heatmap(pvalues, xticklabels=uts_sanitized.keys(),\n                      yticklabels=uts_sanitized.keys(), cmap='RdYlGn_r',\n                      mask=(pvalues &gt; (P_VALUE_THRESHOLD)),\n                      linecolor='gray', linewidths=0.5)\nheatmap.set_xticklabels(heatmap.get_xticklabels(), size=14)\nheatmap.set_yticklabels(heatmap.get_yticklabels(), size=14)\nplt.show()<\/code><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/image-169.png\" alt=\"\" class=\"wp-image-2135\"\/><\/figure>\n\n\n\n<p>\u4e3a\u4e86\u7b80\u5316\u6211\u4eec\u7684\u5206\u6790\uff0c\u5e76\u4e13\u6ce8\u4e8e\u52a0\u5bc6\u8d27\u5e01\u4e4b\u95f4\u6700\u7d27\u5bc6\u7684\u5173\u7cfb\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9 <strong>p \u503c<\/strong> \u6700\u4f4e\u7684\u524d\u4e09\u4e2a\u8d27\u5e01\u5bf9\u3002\u8fd9\u4e9b\u8d27\u5e01\u5bf9\u8868\u660e\u4e86\u6700\u5f3a\u7684\u534f\u6574\u5173\u7cfb\uff0c\u56e0\u6b64\u4e5f\u662f\u6f5c\u5728\u7684\u4ea4\u6613\u673a\u4f1a\u3002\u6211\u4eec\u53ef\u4ee5\u7528\u67f1\u72b6\u56fe\u6765\u76f4\u89c2\u5730\u663e\u793a\u8fd9\u4e9b\u8d27\u5e01\u5bf9\u53ca\u5176\u5404\u81ea\u7684<strong> p \u503c<\/strong>\u3002\u4e0b\u9762\u4ecb\u7ecd\u5982\u4f55\u5b9e\u73b0\u8fd9\u4e00\u70b9\uff1a<\/p>\n\n\n\n<p><strong>5.2  \u62bd\u53d6\u524d\u4e09\u540d<\/strong>\uff0c<strong>\u7ed8\u5236\u67f1\u5f62\u56fe\uff0c\u76f4\u89c2\u663e\u793a P \u503c<\/strong>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>sorted_pairs = sorted(pairs, key=lambda x: x&#91;2], reverse=False)\nsorted_pairs = sorted_pairs&#91;0:35]\nsorted_pairs_labels, pairs_p_values = zip(\n    *&#91;(f'{y1} &lt;-&gt; {y2}', p*1000) for y1, y2, p in sorted_pairs])\nplt.figure(figsize=(12, 18))\nplt.barh(sorted_pairs_labels,\n         pairs_p_values, color='red')\nplt.xlabel('P-Values (1000)', fontsize=8)\nplt.ylabel('Pairs', fontsize=6)\nplt.title('Cointegration P-Values (in 1000s)', fontsize=20)plt.grid(axis='both', linestyle='--', alpha=0.7)\nplt.show()<\/code><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/image-170.png\" alt=\"\" class=\"wp-image-2136\"\/><\/figure>\n\n\n\n<p>\u4e3a\u4e86\u5c06\u5df2\u786e\u5b9a\u7684\u8d27\u5e01\u5bf9\u4ea4\u6613\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff08\u82b1\u65d7\u96c6\u56e2\u7684 AAVE-USD \u4ea4\u6613\u3001\u82b1\u65d7\u96c6\u56e2\u7684 XMR-USD \u4ea4\u6613\u4ee5\u53ca Ally Financial Inc (ALLY) \u7684 FTX-USD \u4ea4\u6613\uff09\u8fdb\u884c\u53ef\u89c6\u5316\uff0c\u540c\u65f6\u4fbf\u4e8e\u5bf9\u52a0\u5bc6\u8d27\u5e01\u548c\u80a1\u7968\u8fdb\u884c\u6bd4\u8f83\uff0c\u6211\u4eec\u5c06\u91c7\u7528 scikit-learn \u7684 MinMax \u7f29\u653e\u529f\u80fd\u6765\u5bf9\u4ef7\u683c\u8fdb\u884c\u7f29\u653e\u5904\u7406\u3002\u53e6\u5916\uff0c\u6211\u4eec\u8fd8\u4f1a\u8fd0\u7528\u6eda\u52a8\u7a97\u53e3\u8fdb\u884c\u5e73\u6ed1\u64cd\u4f5c\uff0c\u4ee5\u589e\u5f3a\u8d27\u5e01\u5bf9\u4e4b\u95f4\u56fa\u5b9a\u6027\u7684\u53ef\u89c6\u7a0b\u5ea6\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u662f\u5982\u4f55\u5b9e\u73b0\u8fd9\u4e00\u70b9\u7684\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>from sklearn.preprocessing import MinMaxScaler\n\nticker_pairs = &#91;(\"AAVE-USD\", \"C\"), (\"XMR-USD\", \"C\"), (\"FTX-USD\", \"ALLY\")]\nfig, axs = plt.subplots(3, 1, figsize=(18, 14))\nscaler = MinMaxScaler()\nfor i, (ticker1, ticker2) in enumerate(ticker_pairs):\n    # Scale the price data for each pair using MIN MAX\n    scaled_data1 = scaler.fit_transform(\n        uts_sanitized&#91;ticker1]&#91;'Adj Close'].values.reshape(-1, 1))\n    scaled_data2 = scaler.fit_transform(\n        uts_sanitized&#91;ticker2]&#91;'Adj Close'].values.reshape(-1, 1))\n    axs&#91;i].plot(scaled_data1, label=f'{ticker1}', color='lightgray', alpha=0.7)\n    axs&#91;i].plot(scaled_data2, label=f'{ticker2}', color='lightgray', alpha=0.7)\n    # Apply rolling mean with a window of 15\n    scaled_data1_smooth = pd.Series(scaled_data1.flatten()).rolling(\n        window=15, min_periods=1).mean()\n    scaled_data2_smooth = pd.Series(scaled_data2.flatten()).rolling(\n        window=15, min_periods=1).mean()\n    axs&#91;i].plot(scaled_data1_smooth, label=f'{ticker1} SMA', color='red')\n    axs&#91;i].plot(scaled_data2_smooth, label=f'{ticker2} SMA', color='blue')\n    axs&#91;i].set_ylabel('*Scaled* Price $', fontsize=12)\n    axs&#91;i].set_title(f'{ticker1} vs {ticker2}', fontsize=18)\n    axs&#91;i].legend()\n    axs&#91;i].set_xticks(&#91;])\nplt.tight_layout()\nplt.show()<\/code><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/image-171.png\" alt=\"\" class=\"wp-image-2137\"\/><\/figure>\n\n\n\n<p><strong>\u4ee5\u4e0b\u662f\u5bf9\u4e0a\u8ff0\u5185\u5bb9\u7684\u89e3\u91ca\uff1a<\/strong><\/p>\n\n\n\n<p>\u4e3a\u4e86\u63a2\u7a76 AAVE-USD \u548c\u82b1\u65d7\u96c6\u56e2\u4e4b\u95f4\u7684\u6f5c\u5728\u4ea4\u6613\u4fe1\u53f7\uff0c\u6211\u4eec\u89c2\u5bdf\u5230\uff0c\u5c3d\u7ba1\u5e8f\u5217\u4e2d\u6700\u521d\u5b58\u5728\u5dee\u5f02\uff0c\u4f46\u5b83\u4eec\u7684\u4ef7\u683c\u8868\u73b0\u51fa\u76f8\u5bf9\u7a33\u5b9a\u3002\u5728\u751f\u6210\u4ea4\u6613\u4fe1\u53f7\u65f6\uff0c\u6211\u4eec\u5c06\u91c7\u7528\u6eda\u52a8\u7a97\u53e3\u6cd5\u7684 Z \u503c\u6cd5\uff0c\u4ece\u800c\u65e0\u9700\u5355\u72ec\u7684\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\u3002Z \u503c\u5c06\u4ef7\u683c\u5e8f\u5217\u4e0e\u5176\u5386\u53f2\u5747\u503c\u6807\u51c6\u5316\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/image-173.png\" alt=\"\" class=\"wp-image-2139\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6. Where\uff1f<\/strong><\/h3>\n\n\n\n<p>X \u662f\u6807\u51c6\u5316\u7684\u4ef7\u683c\uff1bU \u662f\u6eda\u52a8\u7a97\u53e3\u7684\u5747\u503c\uff08\u5e73\u5747\u503c\uff09\uff1bSigma \u662f\u6eda\u52a8\u7a97\u53e3\u7684\u6807\u51c6\u5dee\u3002<\/p>\n\n\n\n<p>Z \u503c\u8861\u91cf\u5f53\u524d\u4ef7\u683c\u6bd4\u504f\u79bb\u5386\u53f2\u5e73\u5747\u503c\u7684\u7a0b\u5ea6\u3002Z \u503c\u9ad8\u4e8e +1 \u6216\u4f4e\u4e8e -1 \u901a\u5e38\u4f1a\u89e6\u53d1\u4ea4\u6613\u4fe1\u53f7\u3002Z \u503c\u9ad8\u4e8e +1 \u8868\u660e\u4e00\u79cd\u8d44\u4ea7\u76f8\u5bf9\u4e8e\u53e6\u4e00\u79cd\u8d44\u4ea7\u88ab\u9ad8\u4f30\u4e86\uff0c\u8fd9\u610f\u5473\u7740\u5356\u51fa\u88ab\u9ad8\u4f30\u7684\u8d44\u4ea7\uff0c\u4e70\u5165\u88ab\u4f4e\u4f30\u7684\u8d44\u4ea7\u3002<\/p>\n\n\n\n<p>\u53cd\u4e4b\uff0c\u5982\u679c Z \u503c\u4f4e\u4e8e-1\uff0c\u5219\u8868\u660e\u88ab\u4f4e\u4f30\u7684\u8d44\u4ea7\u5df2\u88ab\u9ad8\u4f30\uff0c\u5efa\u8bae\u5356\u51fa\u524d\u8005\uff0c\u4e70\u5165\u540e\u8005\u3002\u8be5\u7b56\u7565\u5229\u7528\u5747\u503c\u56de\u590d\u52a8\u6001\uff0c\u5145\u5206\u5229\u7528\u6682\u65f6\u6027\u80cc\u79bb\u548c\u9884\u671f\u56de\u5f52\u5386\u53f2\u5747\u503c\u7684\u673a\u4f1a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>TRAIN = int(len(uts_sanitized&#91;\"AAVE-USD\"]) * 0.85)\nTEST = len(uts_sanitized&#91;\"AAVE-USD\"]) - TRAIN\nAAVE_ts = uts_sanitized&#91;\"AAVE-USD\"]&#91;\"Adj Close\"]&#91;:TRAIN]\nC_ts = uts_sanitized&#91;\"C\"]&#91;\"Adj Close\"]&#91;:TRAIN]\n# Calculate price ratio (AAVE-USD price \/ C price)\nratios = C_ts\/AAVE_ts\nfig, ax = plt.subplots(figsize=(12, 8))\nratios_mean = np.mean(ratios)\nratios_std = np.std(ratios)\nratios_zscore = (ratios - ratios_mean) \/ ratios_std\nax.plot(ratios.index, ratios_zscore, label=\"Z-Score\", color='blue')\n# Plot reference lines\nax.axhline(1.0, color=\"green\", linestyle='--', label=\"Upper Threshold (1.0)\")\nax.axhline(-1.0, color=\"red\", linestyle='--', label=\"Lower Threshold (-1.0)\")\nax.axhline(0, color=\"black\", linestyle='--', label=\"Mean\")\nax.set_title('AAVE-USD \/ C: Price Ratio and Z-Score', fontsize=18)\nax.set_xlabel('Date')\nax.set_ylabel('Price Ratio \/ Z-Score')\nax.legend()\nplt.tight_layout()\nplt.show()<\/code><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/image-174.png\" alt=\"\" class=\"wp-image-2140\"\/><\/figure>\n\n\n\n<p>\u4e0b\u56fe\u662f\u4e00\u79cd\u53ef\u89c6\u5316\u8868\u793a\u6cd5\uff0c\u5176\u4e2d\u7eff\u8272\u6c34\u5e73\u7ebf\u8868\u793a\u4e70\u5165 Citigroup Inc \u00a9\uff0c\u4ea4\u53c9\u65f6\u8868\u793a\u5356\u51fa Aave (AAVE)\uff0c\u800c\u7ea2\u7ebf\u5219\u8868\u793a\u76f8\u53cd\u3002\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u8be5\u56fe\u8868\u4e3b\u8981\u662f\u5c06\u9759\u6b62\u72b6\u6001\u53ef\u89c6\u5316\u3002\u5b9e\u9645\u4e0a\uff0c\u5728\u5e94\u7528\u6211\u4eec\u7684\u4ea4\u6613\u4fe1\u53f7\u65f6\uff0c\u9608\u503c\u4f1a\u968f\u7740\u6eda\u52a8\u7a97\u53e3\u8fdb\u884c\u8c03\u6574\uff0c\u4ee5\u9002\u5e94\u5e02\u573a\u52a8\u6001\u7684\u53d8\u5316\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/image-175.png\" alt=\"\" class=\"wp-image-2141\"\/><\/figure>\n\n\n\n<p>\u73b0\u5728\uff0c\u8ba9\u6211\u4eec\u5f00\u59cb\u6267\u884c\u4ea4\u6613\u4fe1\u53f7\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>def signals_zscore_evolution(ticker1_ts, ticker2_ts, window_size=15, first_ticker=True):\n    \"\"\"\n    Generate trading signals based on z-score analysis of the ratio between two time series.\n    Parameters:\n    - ticker1_ts (pandas.Series): Time series data for the first security.\n    - ticker2_ts (pandas.Series): Time series data for the second security.\n    - window_size (int): The window size for calculating z-scores and ratios' statistics.\n    - first_ticker (bool): Set to True to use the first ticker as the primary signal source, and False to use the second.Returns:\n    - signals_df (pandas.DataFrame): A DataFrame with 'signal' and 'orders' columns containing buy (1) and sell (-1) signals.\n    \"\"\"\n    ratios = ticker1_ts \/ ticker2_ts\n    ratios_mean = ratios.rolling(\n        window=window_size, min_periods=1, center=False).mean()\n    ratios_std = ratios.rolling(\n        window=window_size, min_periods=1, center=False).std()\n    z_scores = (ratios - ratios_mean) \/ ratios_std\n    buy = ratios.copy()\n    sell = ratios.copy()\n    if first_ticker:\n        # These are empty zones, where there should be no signal\n        # the rest is signalled by the ratio.\n        buy&#91;z_scores &gt; -1] = 0\n        sell&#91;z_scores &lt; 1] = 0\n    else:\n        buy&#91;z_scores &lt; 1] = 0\n        sell&#91;z_scores &gt; -1] = 0\n    signals_df = pd.DataFrame(index=ticker1_ts.index)\n    signals_df&#91;'signal'] = np.where(buy &gt; 0, 1, np.where(sell &lt; 0, -1, 0))\n    signals_df&#91;'orders'] = signals_df&#91;'signal'].diff()\n    signals_df.loc&#91;signals_df&#91;'orders'] == 0, 'orders'] = None\n    return signals_df\n\nAAVE_ts = uts_sanitized&#91;\"AAVE-USD\"]&#91;\"Adj Close\"]\nC_ts = uts_sanitized&#91;\"C\"]&#91;\"Adj Close\"]\nplt.figure(figsize=(26, 18))\nsignals_df1 = signals_zscore_evolution(AAVE_ts, C_ts)\nprofit_df1 = calculate_profit(signals_df1, AAVE_ts)\nax1, _ = plot_strategy(AAVE_ts, signals_df1, profit_df1)\nsignals_df2 = signals_zscore_evolution(AAVE_ts, C_ts, first_ticker=False)\nprofit_df2 = calculate_profit(signals_df2, C_ts)\nax2, _ = plot_strategy(C_ts, signals_df2, profit_df2)\nax1.legend(loc='upper left', fontsize=10)\nax1.set_title(f'Citigroup Paired with Aave', fontsize=18)\nax2.legend(loc='upper left', fontsize=10)\nax2.set_title(f'Aave Paired with Citigroup', fontsize=18)\nplt.tight_layout()\nplt.show()<\/code><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/image-177.png\" alt=\"\" class=\"wp-image-2143\"\/><\/figure>\n\n\n\n<p>\u5728\u7b97\u6cd5\u4ea4\u6613\u7cfb\u7edf\u4e2d\uff0c\u591a\u4e2a\u4ea4\u6613\u4fe1\u53f7\u5f80\u5f80\u540c\u65f6\u8fd0\u884c\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u6355\u6349\u6574\u4f53\u8868\u73b0\uff0c\u901a\u5e38\u4f1a\u6c47\u603b\u6240\u6709\u4fe1\u53f7\u7684\u6536\u76ca\u3002\u8ba9\u6211\u4eec\u7ee7\u7eed\u8ba1\u7b97\u76f8\u5e94\u7684\u7d2f\u8ba1\u56de\u62a5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>plt.figure(figsize=(12, 6))\ncumulative_profit_combined = profit_df1 + profit_df2\nax2_combined = cumulative_profit_combined.plot(\n    label='Profit%', color='green')\nplt.legend(loc='upper left', fontsize=10)\nplt.title(f'Aave &amp; Citigroup Paired - Cumulative Profit', fontsize=18)\nplt.tight_layout()\nplt.show()<\/code><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/www.laoyulaoyu.com\/wp-content\/uploads\/2024\/09\/image-178.png\" alt=\"\" class=\"wp-image-2144\"\/><\/figure>\n\n\n\n<p>\u5728\u5206\u6790\u7684\u8fd9\u6bb5\u65f6\u95f4\u91cc\uff0c\u5c3d\u7ba1\u8d27\u5e01\u5bf9\u4ea4\u6613\u7b56\u7565\u7f29\u6c34\u4e86 50%\uff0c\u4f46\u5b83\u7684\u8868\u73b0\u4f9d\u7136\u5f3a\u52b2\uff0c\u8d26\u9762\u56de\u62a5\u7387\u9ad8\u8fbe 100%\u3002\u8fd9\u4e00\u6210\u7ee9\u8d85\u8fc7\u4e86\u6807\u51c6\u666e\u5c14 500 \u6307\u6570\u4e24\u5e74 10% \u7684\u56de\u62a5\u7387\u3002\u4e0d\u8fc7\uff0c\u8be5\u7b56\u7565\u7684\u65b9\u5dee\u8f83\u9ad8\uff0c\u8fd9\u53ef\u80fd\u662f\u7531\u4e8e\u4e0e\u82b1\u65d7\u96c6\u56e2\u914d\u5bf9\u7684\u52a0\u5bc6\u8d27\u5e01\u5b58\u5728\u4e0d\u7a33\u5b9a\u6027\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6. \u89c2\u70b9\u56de\u987e<\/strong><\/h3>\n\n\n\n<p>\u5728\u5b9e\u8df5\u4e2d\uff0c\u91cf\u5316\u5206\u6790\u5e08\u4f7f\u7528\u98ce\u9669\u8c03\u6574\u6307\u6807\uff08\u5982 Sortino \u6bd4\u7387\uff09\u6765\u8bc4\u4f30\u7b56\u7565\u7ee9\u6548\uff0c\u8be5\u6307\u6807\u4fa7\u91cd\u4e8e\u4e0b\u884c\u98ce\u9669\u3002<\/p>\n\n\n\n<p>\u603b\u4e4b\uff0c\u6211\u4eec\u5bf9\u914d\u5bf9\u4ea4\u6613\u7b56\u7565\u7684\u5173\u952e\u8981\u70b9\u8fdb\u884c\u4e86\u63a2\u8ba8\uff0c\u6db5\u76d6\u4e86\u5176\u5e02\u573a\u4e2d\u6027\u7684\u65b9\u5f0f\u3001\u5bf9 Z \u503c\u548c\u534f\u6574\u7b49\u7edf\u8ba1\u5de5\u5177\u7684\u4f9d\u8d56\uff0c\u4ee5\u53ca\u5bf9\u5747\u503c\u56de\u5f52\u7684\u8fd0\u7528\u3002\u4e0d\u8fc7\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u8fd9\u4e00\u7b56\u7565\u65f6\uff0c\u53ef\u80fd\u4f1a\u9762\u4e34\u4e00\u4e9b\u6311\u6218\uff0c\u4f8b\u5982\u4ea4\u6613\u6210\u672c\u4ee5\u53ca\u8d44\u4ea7\u76f8\u5173\u6027\u6216\u534f\u6574\u6027\u7684\u975e\u5e73\u7a33\u6027\u98ce\u9669\u3002\u6700\u540e\u56de\u987e\u672c\u6587\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p><strong>\u914d\u5bf9\u4ea4\u6613\u7b56\u7565<\/strong>\uff1a\u4f9d\u8d56\u4e8e\u4e24\u4e2a\u8d44\u4ea7\u4ef7\u683c\u7a33\u5b9a\u6027\u7684\u7b56\u7565\uff0c\u5229\u7528\u4ef7\u683c\u8d8b\u540c\u83b7\u5229\u3002<\/p>\n\n\n\n<p><strong>\u6570\u636e\u5904\u7406<\/strong>\uff1a\u91cd\u8981\u6027\u5728\u4e8e\u786e\u4fdd\u6570\u636e\u7684\u5b8c\u6574\u6027\u548c\u51c6\u786e\u6027\uff0c\u4ee5\u4fbf\u8fdb\u884c\u51c6\u786e\u7684\u5206\u6790\u3002<\/p>\n\n\n\n<p><strong>\u5e02\u573a\u4e8b\u4ef6\u5f71\u54cd<\/strong>\uff1a\u5e02\u573a\u4e8b\u4ef6\uff08\u5982 FTX \u4e11\u95fb\uff09\u53ef\u80fd\u5f71\u54cd\u8d44\u4ea7\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u534f\u6574\u6027\u5206\u6790\u6709\u52a9\u4e8e\u8bc6\u522b\u8fd9\u4e9b\u53d8\u5316\u3002<\/p>\n\n\n\n<p><strong>\u7edf\u8ba1\u65b9\u6cd5<\/strong>\uff1a\u4f7f\u7528\u76f8\u5173\u6027\u3001\u534f\u6574\u6027\u548c Z-score \u7b49\u7edf\u8ba1\u65b9\u6cd5\u6765\u8bc6\u522b\u4ea4\u6613\u673a\u4f1a\u548c\u751f\u6210\u4ea4\u6613\u4fe1\u53f7\u3002<\/p>\n\n\n\n<p><strong>\u98ce\u9669\u548c\u5b9e\u9645\u5e94\u7528<\/strong>\uff1a\u5728\u5b9e\u9645\u4ea4\u6613\u4e2d\uff0c\u9700\u8981\u8003\u8651\u4ea4\u6613\u6210\u672c\u548c\u8d44\u4ea7\u76f8\u5173\u6027\u7684\u975e\u5e73\u7a33\u6027\uff0c\u5e76\u4f7f\u7528\u98ce\u9669\u8c03\u6574\u6307\u6807\u6765\u8bc4\u4f30\u7b56\u7565\u8868\u73b0\u3002<\/p>\n\n\n\n<p><strong>\u53ef\u89c6\u5316<\/strong>\uff1a\u901a\u8fc7\u70ed\u56fe\u548c\u67f1\u72b6\u56fe\u7b49\u53ef\u89c6\u5316\u5de5\u5177\uff0c\u6709\u52a9\u4e8e\u76f4\u89c2\u5730\u7406\u89e3\u8d44\u4ea7\u5173\u7cfb\u548c\u4ea4\u6613\u7b56\u7565\u7684\u6548\u679c\u3002<\/p>\n\n\n\n<p><strong>\u7b56\u7565\u8bc4\u4f30<\/strong>\uff1a\u4f7f\u7528\u98ce\u9669\u8c03\u6574\u7684\u6307\u6807\uff08\u5982 Sortino \u6bd4\u7387\uff09\u6765\u8bc4\u4f30\u7b56\u7565\u7684\u5b9e\u9645\u8868\u73b0\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u672c\u6587\u5185\u5bb9\u4ec5\u4ec5\u662f\u6280\u672f\u63a2\u8ba8\u548c\u5b66\u4e60\uff0c\u5e76\u4e0d\u6784\u6210\u4efb\u4f55\u6295\u8d44\u5efa\u8bae\u3002<\/mark><\/strong><\/p>\n\n\n\n<p class=\"has-text-align-center\"><strong><mark style=\"background-color:#ffffff\" class=\"has-inline-color has-cyan-bluish-gray-color\">\u8f6c\u53d1\u8bf7\u6ce8\u660e\u539f\u4f5c\u8005\u548c\u51fa\u5904\u3002<\/mark><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u8001\u4f59\u635e\u9c7c \u539f\u521b\u4e0d\u6613\uff0c\u8f6c\u8f7d\u8bf7\u6807\u660e\u51fa\u5904\u53ca\u539f\u4f5c\u8005\u3002&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/laoyulaoyu.com\/index.php\/2024\/10\/15\/%e7%94%a8%e8%82%a1%e7%a5%a8%e5%8a%a0%e6%95%b0%e5%ad%97%e8%b4%a7%e5%b8%81%e6%9e%84%e5%bb%ba%e9%85%8d%e5%af%b9%e4%ba%a4%e6%98%93%e7%ad%96%e7%95%a5\/\">Continue reading<span class=\"screen-reader-text\">\u7528\u80a1\u7968\u52a0\u6570\u5b57\u8d27\u5e01\u6784\u5efa\u914d\u5bf9\u4ea4\u6613\u7b56\u7565<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[4,5],"class_list":{"0":"post-1521","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-aiinvest","7":"tag-ai","9":"entry"},"_links":{"self":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/comments?post=1521"}],"version-history":[{"count":1,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1521\/revisions"}],"predecessor-version":[{"id":1522,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/posts\/1521\/revisions\/1522"}],"wp:attachment":[{"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/media?parent=1521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/categories?post=1521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/laoyulaoyu.com\/index.php\/wp-json\/wp\/v2\/tags?post=1521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}