ºÚÂí¾¯Ê¾Ö¸±ê¹«Ê½Éî¶È½âÎö£ºÍÚ¾òDZÔÚ·çÏÕ£¬½ÒʾÕæÏàµÄ¾ö²ß¹¤¾ß
[Ö¸±ê¹«Ê½] ÏÂÃæÊǺÚÂí¾¯Ê¾Ö¸±ê¹«Ê½µÄÂß¼ºÍÔ´Âë½âÊÍ¡£ ###½âÊÍ###£º·çÏÕÔ¤¾¯Ö¸±ê¹«Ê½£¬¹ÉƱͶ×Ê£¬ºÚÂíµÄÕæÏà Ò»¡¢ºÚÂí¾¯Ê¾Ö¸±ê¹«Ê½µÄÂß¼·ÖÎö£º ºÚÂí¾¯Ê¾Ö¸±ê¹«Ê½ÊÇͨ¹ý¶Ô¹ÉƱÊг¡Êý¾ÝµÄÉî¶ÈÍÚ¾òºÍ·ÖÎö£¬´Ó¶øÔ¤²â¿ÉÄÜ´æÔڵķçÏÕ£¬²¢ÌáÐÑͶ×ÊÕß×¢ÒâDZÔÚ·çÏÕµÄÒ»ÖÖ¹¤¾ßËüͨ¹ýÌض¨µÄËã·¨ºÍÄ£ÐÍ£¬½«Êг¡Êý¾Ý½øÐзÖÀàºÍÆÀ¹À£¬×îÖյóöÒ»¸ö¹ØÓÚ·çÏÕÔ¤¾¯µÄÖ¸±êÖµ¸ÃÖ¸±êÖµµÄ¸ßµÍ¿ÉÒÔ·´Ó³¹ÉƱÊг¡µÄÎȶ¨ÐÔÓ밲ȫÐÔºÚÂí¾¯Ê¾Ö¸±ê¹«Ê½¹Ø×¢µÄÊÇÕûÌåÊг¡·çÏÕ¶ø²»Êǵ¥Ò»¹ÉƱ£¬¸üÈ«ÃæµØ²¶×½Êг¡·çÏÕ¶ÔÓÚ¹ÉƱµÄͶ»úÕßÀ´Ëµ£¬¾ßÓÐÇ°Õ°ÐԵľ¯Ê¾Ö¸±êÄܹ»¸üºÃµØ°ÑÎÕÊг¡µÄÂö²«£¬¼°Ê±¹æ±ÜDZÔÚ·çÏÕ ¶þ¡¢ºÚÂí¾¯Ê¾Ö¸±ê¹«Ê½µÄÔ´Âë½âÎö£º ºÚÂí¾¯Ê¾Ö¸±ê¹«Ê½¿ÉÒÔͨ¹ý¶àÖÖÈí¼þº¯ÊýʵÏÖÒÔÏÂÊÇÒ»¸ö¼ò»¯°æµÄÔ´ÂëʾÀý£¨¼ÙÉèʹÓõÄÊÇPythonÓïÑÔ£©£º # ÒýÈë±ØÒªµÄ¿â import pandas as pd import numpy as np import datetime as dt from statsmodels.tsa.stattools import rolling_mean, rolling_std from sklearn.linear_model import LinearRegression # ¼ÓÔعÉƱÊý¾Ý data = pd.read_csv('stock_data.csv') # ¶¨ÒåºÚÂí¾¯Ê¾Ö¸±êº¯Êý def black_horse_warning(data, window_size=20): # ¼ÆËãÒƶ¯Æ½¾ùÏߣ¨´ú±í³¤ÆÚÇ÷ÊÆ£© rolling_avg = rolling_mean(data['Close'], window=window_size) # ¼ÆËãÒƶ¯±ê×¼²î£¨´ú±í¶ÌÆÚ²¨¶¯£© rolling_std_dev = rolling_std(data['Close'], window=window_size) # ¹¹½¨ÏßÐԻعéÄ£ÐÍÔ¤²â¹É¼ÛÇ÷ÊÆ model = LinearRegression().fit(pd.DataFrame({'time': data['Date']}), data['Close']) # ¼ÆËãÔ¤²âÎó²î£¨²Ð²î£© residuals = data['Close'] - model.predict(pd.DataFrame({'time': data['Date']})) # ¸ù¾ÝÒƶ¯Æ½¾ùÏß¡¢Òƶ¯±ê×¼²îºÍ²Ð²î¼ÆËã·çÏÕÔ¤¾¯Ö¸±êÖµ warning_index = np.sqrt((rolling_std_dev2) (residuals2)) return warning_index # ʹÓú¯Êý¼ÆËã·çÏÕÔ¤¾¯Ö¸±êÖµ²¢±£´æ½á¹û warning_index = black_horse_warning(data) data['Warning_Index'] = warning_index data.to_csv('stock_data_with_warning_index.csv') ÔÚÕâ¸ö¼òµ¥µÄʾÀýÖУ¬ºÚÂí¾¯Ê¾Ö¸±ê¹«Ê½µÄ¼ÆËãÖ÷Òª°üÀ¨ÁËÒƶ¯Æ½¾ùÏß¼ÆËã¡¢Òƶ¯±ê×¼²î¼ÆËãÒÔ¼°»ùÓÚÏßÐԻعéÄ£Ð͵ÄÔ¤²âÎó²î¼ÆËãÈ»ºó»ùÓÚÕâÈý¸ö½á¹ûÀ´¼ÆËã·çÏÕÔ¤¾¯Ö¸±êÖµ Èý¡¢ #ºÚÂí¾¯Ê¾Ö¸±ê¹«Ê½ #·çÏÕÔ¤¾¯ #¹ÉƱÊг ¡#Êý¾ÝÍÚ¾ò #·çÏÕ·ÖÎö #¾ö²ß¹¤¾ß #¹ÉÊÐͶ×Ê #Òƶ¯Æ½¾ùÏß #Òƶ¯±ê×¼²î #ÏßÐԻعéÄ£ÐÍ |
ÍƼöÖ÷Ìâ
- ♡ ´óÕ¹ºêͼ ¹ÉƱ³Ø×Ô¶¯Ñ¡¹É+¸ÅÄî+Ç÷Êƹ²Õñ+ÂòÂôµã£¬ÅÌÖÐÌáÐÑ+Ñ¡¹ÉÅÅÐò
- ♡ ¡°ÁúÑýÖ®ÐÄ¡±·ùͼָ±ê¡¢Ñ¡¹ÉÖ¸±ê£¬ÕæÕý×öµ½¾«×¼Âñ·üÑý¹ÉÆô¶¯µã¡£
- ♡ ¼¸¸öAI×Ô¶¯»¯¹ÉƱ½»Ò×Èí¼þ
- ♡ ¡¾µÍ·çÏÕ¸úׯʵսϵÁÐÖ® No. 9¡¿ÕÇÍ£Ô¤¾¯£¬×¥Ñý¹Éʵʱ¼àÊÓÓÎ×ʸÒËÀ×ʽðÈ볡£¡
- ♡ Ìâ²Ä¸ÅÄîÁúÍ·¹É²é¿´Ãæ°å
- ♡ 145¸ö°æÃæ
- ♡ Ö÷Á¦È«ÄÜÇ÷ÊÆÍ»ÆÆÖ÷ÉýÀËÖ÷ͼ¸±Í¼ºÍÑ¡¹ÉÖ¸±ê Ö÷Á¦KÏß¾ùÏß¹²ÕñÍ»ÆÆƽ̨׽ÁúÅ£
- ♡ ³ïÂë³É±¾Í»ÆÆÇÜÁúÖ÷ͼ¸±Í¼ºÍÑ¡¹ÉÖ¸±ê Ö÷Á¦³ïÂëÍ»ÆƾùÏ߳ɱ¾Çø×½ÁúÍ·ÐźÅ×¼
´ò°åµÄµÚÒ»µÀÐÄÀíÕÏ°ÊÇÄã±ØÐëÏû³ýÄãÏà±ÈÓÚ±ðÈ˵ÄÓÅÔ½¸Ð¡£ |
Â¥Ö÷ |
2Â¥ |