浜ゆ槗绛栫暐瀹炴垬鎸囧崡
鍦ㄦ尝娑涙惫娑岀殑閲戣瀺甯傚満涓紝浜ゆ槗绛栫暐鏄氦鏄撹€呯敓瀛樹笌鍙戝睍鐨勫叧閿€傛湰鏂囧皢甯︿綘娣卞叆浜嗚В浜ゆ槗绛栫暐鐨勬牳蹇冩蹇碉紝瀹炴垬搴旂敤锛屼互鍙婂浣曢€氳繃鎶€鏈垎鏋愬拰鍩烘湰闈㈠垎鏋愭潵閫夋嫨鍜屼紭鍖栫瓥鐣ワ紝浠庤€岃揪鍒扮泩鍒╃殑鐩爣銆?/p>
涓€銆佷氦鏄撶瓥鐣ュ熀纭€姒傚康
浜ゆ槗绛栫暐锛屾槸浜ゆ槗鑰呭湪甯傚満琛屼负銆佹妧鏈垎鏋愩€佸熀鏈潰鍒嗘瀽绛変俊鎭熀纭€涓婏紝鍒跺畾鐨勪竴濂楀彲閲嶅鐨勬搷浣滆鍒欍€備笉鍚岀殑浜ゆ槗绛栫暐閫傜敤浜庝笉鍚岀殑甯傚満鐜鍜屾姇璧勮€呴闄╁亸濂姐€傛帉鎻′氦鏄撶瓥鐣ワ紝灏辩瓑浜庢嫢鏈変簡鍦ㄨ繖涓競鍦轰腑鍐崇瓥鐨勫埄鍣ㄣ€?/p>
浜屻€佺瓥鐣ョ被鍨嬩笌閫夋嫨
浜ゆ槗绛栫暐澶ц嚧鍒嗕负琚姩鍨嬪拰涓诲姩鍨嬩袱澶х被銆傝鍔ㄥ瀷绛栫暐鍩轰簬鍘嗗彶鏁版嵁杩涜娴嬭瘯锛屽瓒嬪娍璺熼殢绛栫暐锛涜€屼富鍔ㄥ瀷绛栫暐鍒欐洿渚濊禆浜庡疄鏃跺競鍦哄姩鍚戯紝濡傞噺鍖栦氦鏄撲腑鐨勭粺璁″鍒╃瓥鐣ャ€傚浣曢€夋嫨绛栫暐锛熷競鍦烘潯浠躲€佷釜浜洪闄╁亸濂姐€佽祫閲戣妯$瓑閮芥槸閲嶈鑰冮噺鍥犵礌銆傜瓥鐣ョ殑閫傚簲鎬ф槸鍏剁敓鍛藉姏鎵€鍦ㄣ€?/p>
涓夈€佷釜鎬у寲璋冩暣
鍦ㄥ疄闄呬氦鏄撲腑锛岀瓥鐣ラ渶瑕佹牴鎹競鍦虹幆澧冨拰涓汉缁忛獙杩涜璋冩暣銆傝繖鍖呮嫭浼樺寲绛栫暐鎬ц兘鐨勫弬鏁拌皟鏁达紝浠ュ強鍦ㄥ競鍦哄紓甯告儏鍐典笅鐨勭伒娲诲簲瀵广€傛瘡涓€涓垚鍔熺殑浜ゆ槗鑰咃紝閮芥槸涓€涓笉鏂涔犲拰璋冩暣鐨勫疄璺佃€呫€?/p>
鍥涖€佹妧鏈垎鏋愪笌瀹炴垬妗堜緥
鎶€鏈垎鏋愭槸閫氳繃鍥捐〃銆佹寚鏍囩瓑宸ュ叿棰勬祴甯傚満璧板娍鐨勬柟娉曘€傜Щ鍔ㄥ钩鍧囩嚎銆佺浉瀵瑰己寮辨寚鏁扮瓑閮芥槸甯哥敤鐨勬妧鏈寚鏍囥€傞€氳繃瀹炴垬妗堜緥锛屾垜浠皢娣卞叆瑙f瀽杩欎簺宸ュ叿鐨勪娇鐢ㄦ柟娉曞拰鍦烘櫙銆備緥濡傦紝鍋囪鎴戜滑姝e湪鍒嗘瀽涓€瀹跺叕鍙哥殑鑲$エ鏁版嵁锛岄€氳繃璁$畻绠€鍗曠Щ鍔ㄥ钩鍧囩嚎锛圫MA锛夛紝鎴戜滑鍙互鏇村噯纭湴鍒ゆ柇鑲$エ鐨勮秼鍔裤€?/p>
浜斻€佸熀鏈潰鍒嗘瀽涓庡疄鎴樻渚?/h3>
鍩烘湰闈㈠垎鏋愪晶閲嶄簬鐮旂┒鍏徃鐨勮储鍔℃姤琛ㄣ€佽涓氬湴浣嶇瓑锛屼互璇勪及鍏跺唴鍦ㄤ环鍊煎拰鏈潵澧為暱娼滃姏銆傞€氳繃瀹炴垬妗堜緥锛屾垜浠皢瀛︿範濡備綍閫氳繃鍒嗘瀽鍏徃鐨勬敹鍏ュ闀跨巼鍜屽競鐩堢巼鏉ヨ瘎浼拌偂绁ㄤ环鍊笺€備緥濡傦紝閫氳繃鑾峰彇鍏徃鑲$エ鏁版嵁锛岃绠楁敹鍏ュ闀跨巼锛屽苟浜嗚В甯傜泩鐜囷紝鎴戜滑鍙互鏇村叏闈㈠湴璇勪及鍏徃鐨勪环鍊煎拰娼滃姏銆?/p>
鍏€侀闄╃鐞嗙瓥鐣?/h3>
椋庨櫓绠$悊鏄氦鏄撶瓥鐣ヤ腑涓嶅彲鎴栫己鐨勪竴閮ㄥ垎銆傞€氳繃璁剧疆姝㈡崯鐐广€佽祫閲戠鐞嗚鍒欑瓑锛屼氦鏄撹€呭彲浠ユ帶鍒舵綔鍦ㄦ崯澶憋紝淇濋殰鑷繁鐨勫埄鐩娿€傚湪瀹炴垬涓紝椋庨櫓绠$悊鐨勯噸瑕佹€т笉瑷€鑰屽柣銆傛瘡涓€涓垚鍔熺殑浜ゆ槗鑰咃紝閮芥槸涓€涓噦寰楅闄╀笌鏀剁泭骞宠 鐨勯珮鎵嬨€?/p>
---
绛栫暐鎵ц涓庝紭鍖栫殑杩涢樁鎸囧崡
鍦ㄩ噾铻嶄氦鏄撶殑骞块様涓栫晫涓紝绛栫暐鍜屾墽琛屽姏鏄垚鍔熺殑鍏抽敭銆傝鎴戜滑娣卞叆浜嗚В濡備綍鎵ц浜ゆ槗绛栫暐锛屽苟瀵瑰叾杩涜浼樺寲锛屼互鍦ㄥ競鍦虹殑娴疆涓壘鍒版渶浣虫椂鏈恒€?/p>
绛栫暐鎵ц
绛栫暐鎵ц鏄氦鏄撹繃绋嬩腑鑷冲叧閲嶈鐨勪竴鐜€傛兂璞′竴涓嬶紝浣犲熀浜庢煇绉嶇畻娉曟垨妯″紡璇嗗埆鍒颁簡涔板叆鎴栧崠鍑虹殑鏈轰細锛岄偅涔堝浣曞皢杩欎簺淇″彿杞寲涓哄疄闄呯殑浜ゆ槗鎿嶄綔鍛紵
鍋囪鎴戜滑浣跨敤鐨勬槸鍩轰簬SMA锛堢畝鍗曠Щ鍔ㄥ钩鍧囩嚎锛変氦鍙夌殑涔板崠淇″彿绛栫暐銆傚綋SMA鍙戝嚭涔板叆淇″彿鏃讹紝鎴戜滑鏋滄柇鍦版墽琛屼氦鏄擄紝鎹曟崏甯傚満鐨勪笂娑ㄨ秼鍔匡紱褰撳彂鍑哄崠鍑轰俊鍙锋椂锛屾垜浠悓鏍疯繀閫熻鍔紝閿佸畾鍒╂鼎銆?/p>
杩欓噷鏄瓥鐣ユ墽琛岀殑绠€鍖栫増浠g爜绀轰緥锛?/p>
```python
def execute_strategy_with_emotion(current_price, sma_signal):
if sma_signal > current_price: 涔板叆淇″彿锛屽績璺冲姞閫燂紝鍑嗗鎹曟崏鏈轰細
print("馃煝 涔板叆淇″彿锛佸績璺冲姞閫燂紝鍑嗗鎹曟崏甯傚満鐨勪笂娑ㄨ秼鍔?..")
鍦ㄨ繖閲屾坊鍔犳墽琛屼氦鏄撶殑瀹為檯浠g爜
else: 鍗栧嚭淇″彿锛屼繚鎸佸喎闈欙紝鍑嗗閿佸畾鍒╂鼎
print("馃煟 鍗栧嚭淇″彿锛佷繚鎸佸喎闈欙紝鏄椂鍊欓攣瀹氬埄娑︿簡...")
鍦ㄨ繖閲屾坊鍔犳墽琛屼氦鏄撶殑瀹為檯浠g爜
璋冪敤绛栫暐鎵ц鍑芥暟锛屼綋楠屽競鍦虹殑娉㈠姩
execute_strategy_with_emotion(95, df['SMA_20'].iloc[-1])
```
閫氳繃鐢熷姩鍖栫殑鎻忚堪鍜屾儏澧冨寲琛ㄨ揪锛岃繖娈垫枃鏈棬鍦ㄨ璇昏€呮劅鍙楀埌绛栫暐鎵ц鏃剁殑绱у紶鍒烘縺鍜屼氦鏄撶殑鍐崇瓥杩囩▼銆?/p>
绛栫暐浼樺寲
绛栫暐浼樺寲鏄氦鏄撹繃绋嬩腑涓嶆柇鎻愬崌鍜屽畬鍠勭殑鍏抽敭姝ラ銆傛兂璞′竴涓嬶紝濡備綍閫氳繃璋冩暣鍙傛暟鎴栦娇鐢ㄥ厛杩涚殑绠楁硶鏉ユ彁鍗囩瓥鐣ョ殑鏁堢巼鍜屽噯纭€э紵杩欏氨鏄瓥鐣ヤ紭鍖栫殑榄呭姏鎵€鍦ㄣ€?/p>
鍋囪鎴戜滑姝e湪浣跨敤SMA绛栫暐锛屽苟甯屾湜閫氳繃璋冩暣绐楀彛闀垮害鏉ヤ紭鍖栧叾鎬ц兘銆傛垜浠畾涔変簡涓€涓嚱鏁版潵瀵绘壘鏈€浣崇獥鍙i暱搴︺€傞€氳繃鍥炴祴鍜屾€ц兘娴嬭瘯锛屾垜浠兘澶熺‘瀹氬摢涓獥鍙i暱搴﹁兘澶熷甫鏉ユ渶浣充氦鏄撴晥鏋溿€備笅闈㈡槸绛栫暐浼樺寲鐨勭畝鍖栫増浠g爜绀轰緥锛?/p>
```python
def find_optimal_window(df, window_lengths):
best_window = None 鏈€浣崇獥鍙i暱搴﹀垵濮嬪寲涓篘one
for window in window_lengths: 寰幆娴嬭瘯涓嶅悓鐨勭獥鍙i暱搴﹁缃?/p>
sma = calculate_sma(df['Close'], window) 璁$畻SMA鍊硷紙杩欓噷鐪佺暐鍏蜂綋瀹炵幇锛?/p>
鍩轰簬SMA鐨勪氦鏄撻€昏緫鍜岀哗鏁堣瘎浼帮紙杩欓噷鐪佺暐鍏蜂綋瀹炵幇锛?..
performance = evaluate_performance() 鍋囪鏈変竴涓€ц兘璇勪及鍑芥暟鏉ュ疄鐜板叿浣撶殑缁╂晥璇勪及閫昏緫
if performance > best_performance: 瀵规瘮鎬ц兘锛屾洿鏂版渶浣冲弬鏁拌缃拰鎬ц兘璁板綍... |