diff --git a/__pycache__/strategy_lifecycle.cpython-312.pyc b/__pycache__/strategy_lifecycle.cpython-312.pyc index ca22d5f..0555d22 100644 Binary files a/__pycache__/strategy_lifecycle.cpython-312.pyc and b/__pycache__/strategy_lifecycle.cpython-312.pyc differ diff --git a/data/chip_cache/000657.json b/data/chip_cache/000657.json index 7afe047..59cbe33 100644 --- a/data/chip_cache/000657.json +++ b/data/chip_cache/000657.json @@ -1 +1 @@ -{"winner_pct": 0.8905253861016628, "loser_pct": 0.10947461389833724, "bias": 0.0021894922779667446, "updated_at": "2026-07-02T00:35:07.027353"} \ No newline at end of file +{"winner_pct": 0.9806336040435885, "loser_pct": 0.01936639595641151, "bias": 0.0003873279191282302, "updated_at": "2026-07-02T00:44:45.975293"} \ No newline at end of file diff --git a/data/chip_cache/000700.json b/data/chip_cache/000700.json index 86809ab..651c3b2 100644 --- a/data/chip_cache/000700.json +++ b/data/chip_cache/000700.json @@ -1 +1 @@ -{"winner_pct": 0.7051650439382611, "loser_pct": 0.29483495606173893, "bias": 0.005896699121234778, "updated_at": "2026-07-02T00:35:08.872295"} \ No newline at end of file +{"winner_pct": 0.9366643901055676, "loser_pct": 0.06333560989443245, "bias": 0.001266712197888649, "updated_at": "2026-07-02T00:44:48.085198"} \ No newline at end of file diff --git a/data/chip_cache/000711.json b/data/chip_cache/000711.json index 3bf52b4..801cfc8 100644 --- a/data/chip_cache/000711.json +++ b/data/chip_cache/000711.json @@ -1 +1 @@ -{"winner_pct": 0.4599205028102528, "loser_pct": 0.5400794971897471, "bias": 0.010801589943794944, "updated_at": "2026-07-02T00:35:10.904477"} \ No newline at end of file +{"winner_pct": 0.8576946920402719, "loser_pct": 0.14230530795972807, "bias": 0.0028461061591945613, "updated_at": "2026-07-02T00:44:50.155122"} \ No newline at end of file diff --git a/data/chip_cache/001309.json b/data/chip_cache/001309.json index f5235aa..12e0aa5 100644 --- a/data/chip_cache/001309.json +++ b/data/chip_cache/001309.json @@ -1 +1 @@ -{"winner_pct": 0.9384281148873177, "loser_pct": 0.061571885112682245, "bias": 0.001231437702253645, "updated_at": "2026-07-02T00:35:13.007896"} \ No newline at end of file +{"winner_pct": 0.9896105603070028, "loser_pct": 0.010389439692997248, "bias": 0.0007439340403273239, "updated_at": "2026-07-02T00:44:52.287382"} \ No newline at end of file diff --git a/data/chip_cache/002594.json b/data/chip_cache/002594.json index 965d101..f587ced 100644 --- a/data/chip_cache/002594.json +++ b/data/chip_cache/002594.json @@ -1 +1 @@ -{"winner_pct": 0.06109805218679897, "loser_pct": 0.938901947813201, "bias": 0.01877803895626402, "updated_at": "2026-07-02T00:35:15.121583"} \ No newline at end of file +{"winner_pct": 0.1347851485695232, "loser_pct": 0.8652148514304768, "bias": 0.017304297028609538, "updated_at": "2026-07-02T00:44:54.433552"} \ No newline at end of file diff --git a/data/chip_cache/01070.json b/data/chip_cache/01070.json index 896cfd5..8a9d528 100644 --- a/data/chip_cache/01070.json +++ b/data/chip_cache/01070.json @@ -1 +1 @@ -{"winner_pct": 0.11515632261891377, "loser_pct": 0.8848436773810862, "bias": 0.017696873547621724, "updated_at": "2026-07-02T00:35:21.588604"} \ No newline at end of file +{"winner_pct": 0.9048415259336623, "loser_pct": 0.0951584740663377, "bias": 0.0019031694813267542, "updated_at": "2026-07-02T00:45:01.123204"} \ No newline at end of file diff --git a/data/chip_cache/01088.json b/data/chip_cache/01088.json index 89c6f9e..b0b5b42 100644 --- a/data/chip_cache/01088.json +++ b/data/chip_cache/01088.json @@ -1 +1 @@ -{"winner_pct": 0.01442763129876452, "loser_pct": 0.9855723687012354, "bias": 0.01971144737402471, "updated_at": "2026-07-02T00:35:23.448927"} \ No newline at end of file +{"winner_pct": 0.8241215447247867, "loser_pct": 0.17587845527521323, "bias": 0.0035175691055042645, "updated_at": "2026-07-02T00:45:03.212196"} \ No newline at end of file diff --git a/data/chip_cache/01211.json b/data/chip_cache/01211.json index e8d406b..18ce67e 100644 --- a/data/chip_cache/01211.json +++ b/data/chip_cache/01211.json @@ -1 +1 @@ -{"winner_pct": 0.012654394366315136, "loser_pct": 0.9873456056336849, "bias": 0.0197469121126737, "updated_at": "2026-07-02T00:35:25.515177"} \ No newline at end of file +{"winner_pct": 0.0019470276458546261, "loser_pct": 0.9980529723541453, "bias": 0.019961059447082905, "updated_at": "2026-07-02T00:45:05.297271"} \ No newline at end of file diff --git a/data/chip_cache/01478.json b/data/chip_cache/01478.json index dc03f53..6500080 100644 --- a/data/chip_cache/01478.json +++ b/data/chip_cache/01478.json @@ -1 +1 @@ -{"winner_pct": 0.02378383161135486, "loser_pct": 0.9762161683886451, "bias": 0.019524323367772902, "updated_at": "2026-07-02T00:35:27.617318"} \ No newline at end of file +{"winner_pct": 0.44137334122971467, "loser_pct": 0.5586266587702853, "bias": 0.011172533175405706, "updated_at": "2026-07-02T00:45:07.463245"} \ No newline at end of file diff --git a/data/chip_cache/01888.json b/data/chip_cache/01888.json index 01e03e7..385c2a9 100644 --- a/data/chip_cache/01888.json +++ b/data/chip_cache/01888.json @@ -1 +1 @@ -{"winner_pct": 0.9605101031912507, "loser_pct": 0.039489896808749314, "bias": 0.0007897979361749863, "updated_at": "2026-07-02T00:35:29.720189"} \ No newline at end of file +{"winner_pct": 0.9866163993464405, "loser_pct": 0.013383600653559464, "bias": 0.0006651935425033301, "updated_at": "2026-07-02T00:45:09.546450"} \ No newline at end of file diff --git a/data/chip_cache/02202.json b/data/chip_cache/02202.json index e5816e1..1d2d844 100644 --- a/data/chip_cache/02202.json +++ b/data/chip_cache/02202.json @@ -1 +1 @@ -{"winner_pct": 0.0054820390352224024, "loser_pct": 0.9945179609647776, "bias": 0.019890359219295554, "updated_at": "2026-07-02T00:35:31.579501"} \ No newline at end of file +{"winner_pct": 0.00024203244508924288, "loser_pct": 0.9997579675549108, "bias": 0.039564098261682626, "updated_at": "2026-07-02T00:45:11.637672"} \ No newline at end of file diff --git a/data/chip_cache/02318.json b/data/chip_cache/02318.json index c7b97bb..12a6ea6 100644 --- a/data/chip_cache/02318.json +++ b/data/chip_cache/02318.json @@ -1 +1 @@ -{"winner_pct": 0.02266099339387972, "loser_pct": 0.9773390066061202, "bias": 0.019546780132122403, "updated_at": "2026-07-02T00:35:33.432173"} \ No newline at end of file +{"winner_pct": 0.6241393442090698, "loser_pct": 0.3758606557909302, "bias": 0.007517213115818604, "updated_at": "2026-07-02T00:45:13.738933"} \ No newline at end of file diff --git a/data/chip_cache/02359.json b/data/chip_cache/02359.json index 12a7108..90a6218 100644 --- a/data/chip_cache/02359.json +++ b/data/chip_cache/02359.json @@ -1 +1 @@ -{"winner_pct": 0.9788099282869067, "loser_pct": 0.02119007171309323, "bias": 0.00042380143426186466, "updated_at": "2026-07-02T00:35:35.527231"} \ No newline at end of file +{"winner_pct": 0.9983363743718657, "loser_pct": 0.0016636256281342872, "bias": 3.3272512562685745e-05, "updated_at": "2026-07-02T00:45:15.860775"} \ No newline at end of file diff --git a/data/chip_cache/02388.json b/data/chip_cache/02388.json index 70952e5..4adbacc 100644 --- a/data/chip_cache/02388.json +++ b/data/chip_cache/02388.json @@ -1 +1 @@ -{"winner_pct": 0.03250983201120672, "loser_pct": 0.9674901679887933, "bias": 0.019349803359775868, "updated_at": "2026-07-02T00:35:37.394766"} \ No newline at end of file +{"winner_pct": 0.8901293359594721, "loser_pct": 0.10987066404052795, "bias": 0.002197413280810559, "updated_at": "2026-07-02T00:45:17.975256"} \ No newline at end of file diff --git a/data/chip_cache/02628.json b/data/chip_cache/02628.json index 07ae320..ef37ad3 100644 --- a/data/chip_cache/02628.json +++ b/data/chip_cache/02628.json @@ -1 +1 @@ -{"winner_pct": 0.16852330162051746, "loser_pct": 0.8314766983794825, "bias": 0.01662953396758965, "updated_at": "2026-07-02T00:35:39.254760"} \ No newline at end of file +{"winner_pct": 0.7900078948017442, "loser_pct": 0.20999210519825579, "bias": 0.004199842103965116, "updated_at": "2026-07-02T00:45:20.091419"} \ No newline at end of file diff --git a/data/chip_cache/06160.json b/data/chip_cache/06160.json index de1da33..6085b05 100644 --- a/data/chip_cache/06160.json +++ b/data/chip_cache/06160.json @@ -1 +1 @@ -{"winner_pct": 0.36653309165872255, "loser_pct": 0.6334669083412774, "bias": 0.012669338166825549, "updated_at": "2026-07-02T00:35:41.322663"} \ No newline at end of file +{"winner_pct": 0.5722888851123522, "loser_pct": 0.42771111488764785, "bias": 0.008554222297752958, "updated_at": "2026-07-02T00:45:22.179638"} \ No newline at end of file diff --git a/data/chip_cache/06869.json b/data/chip_cache/06869.json index 7d5c43c..2056a2b 100644 --- a/data/chip_cache/06869.json +++ b/data/chip_cache/06869.json @@ -1 +1 @@ -{"winner_pct": 0.8235950164623566, "loser_pct": 0.17640498353764347, "bias": 0.0035280996707528697, "updated_at": "2026-07-02T00:35:43.401261"} \ No newline at end of file +{"winner_pct": 0.9729771285366041, "loser_pct": 0.027022871463395843, "bias": 0.0005404574292679168, "updated_at": "2026-07-02T00:45:24.286446"} \ No newline at end of file diff --git a/data/chip_cache/09868.json b/data/chip_cache/09868.json index 8434511..cb708b8 100644 --- a/data/chip_cache/09868.json +++ b/data/chip_cache/09868.json @@ -1 +1 @@ -{"winner_pct": 0.10325476172315214, "loser_pct": 0.8967452382768478, "bias": 0.017934904765536958, "updated_at": "2026-07-02T00:35:45.448103"} \ No newline at end of file +{"winner_pct": 0.3252340331221118, "loser_pct": 0.6747659668778883, "bias": 0.013495319337557765, "updated_at": "2026-07-02T00:45:26.369838"} \ No newline at end of file diff --git a/data/chip_cache/09988.json b/data/chip_cache/09988.json index fb91a09..5e5c8d1 100644 --- a/data/chip_cache/09988.json +++ b/data/chip_cache/09988.json @@ -1 +1 @@ -{"winner_pct": 0.053119794705996114, "loser_pct": 0.9468802052940039, "bias": 0.018937604105880076, "updated_at": "2026-07-02T00:35:47.336553"} \ No newline at end of file +{"winner_pct": 0.2719839509092063, "loser_pct": 0.7280160490907936, "bias": 0.014560320981815873, "updated_at": "2026-07-02T00:45:28.476701"} \ No newline at end of file diff --git a/data/chip_cache/300035.json b/data/chip_cache/300035.json index 597103a..f0be859 100644 --- a/data/chip_cache/300035.json +++ b/data/chip_cache/300035.json @@ -1 +1 @@ -{"winner_pct": 0.028368192935391008, "loser_pct": 0.971631807064609, "bias": 0.019432636141292182, "updated_at": "2026-07-02T00:35:49.222809"} \ No newline at end of file +{"winner_pct": 0.24517735256570908, "loser_pct": 0.7548226474342911, "bias": 0.015096452948685822, "updated_at": "2026-07-02T00:45:30.594484"} \ No newline at end of file diff --git a/data/chip_cache/300124.json b/data/chip_cache/300124.json index 24877cf..da1706a 100644 --- a/data/chip_cache/300124.json +++ b/data/chip_cache/300124.json @@ -1 +1 @@ -{"winner_pct": 0.36417545165724186, "loser_pct": 0.6358245483427581, "bias": 0.012716490966855162, "updated_at": "2026-07-02T00:35:51.342524"} \ No newline at end of file +{"winner_pct": 0.5085832238108319, "loser_pct": 0.4914167761891682, "bias": 0.009828335523783364, "updated_at": "2026-07-02T00:45:32.751358"} \ No newline at end of file diff --git a/data/chip_cache/300308.json b/data/chip_cache/300308.json index 2c86c49..925d824 100644 --- a/data/chip_cache/300308.json +++ b/data/chip_cache/300308.json @@ -1 +1 @@ -{"winner_pct": 0.792023910513367, "loser_pct": 0.20797608948663301, "bias": 0.004159521789732661, "updated_at": "2026-07-02T00:35:53.208843"} \ No newline at end of file +{"winner_pct": 0.9836595299961747, "loser_pct": 0.016340470003825366, "bias": 0.00032680940007650736, "updated_at": "2026-07-02T00:45:34.879675"} \ No newline at end of file diff --git a/data/chip_cache/300548.json b/data/chip_cache/300548.json index c20f674..6423d77 100644 --- a/data/chip_cache/300548.json +++ b/data/chip_cache/300548.json @@ -1 +1 @@ -{"winner_pct": 0.5896316941534578, "loser_pct": 0.41036830584654216, "bias": 0.008207366116930844, "updated_at": "2026-07-02T00:35:55.349248"} \ No newline at end of file +{"winner_pct": 0.9643635376930005, "loser_pct": 0.03563646230699947, "bias": 0.0007127292461399894, "updated_at": "2026-07-02T00:45:36.995336"} \ No newline at end of file diff --git a/data/chip_cache/300750.json b/data/chip_cache/300750.json index 1489225..4777d43 100644 --- a/data/chip_cache/300750.json +++ b/data/chip_cache/300750.json @@ -1 +1 @@ -{"winner_pct": 0.051381452378474426, "loser_pct": 0.9486185476215256, "bias": 0.018972370952430512, "updated_at": "2026-07-02T00:35:57.452499"} \ No newline at end of file +{"winner_pct": 0.8250221210073526, "loser_pct": 0.17497787899264738, "bias": 0.0034995575798529477, "updated_at": "2026-07-02T00:45:39.111567"} \ No newline at end of file diff --git a/data/chip_cache/301308.json b/data/chip_cache/301308.json index b961054..c2cf4b2 100644 --- a/data/chip_cache/301308.json +++ b/data/chip_cache/301308.json @@ -1 +1 @@ -{"winner_pct": 0.9278175418685898, "loser_pct": 0.07218245813141022, "bias": 0.0014436491626282045, "updated_at": "2026-07-02T00:35:59.312573"} \ No newline at end of file +{"winner_pct": 0.9874395067179887, "loser_pct": 0.012560493282011215, "bias": 0.00025120986564022434, "updated_at": "2026-07-02T00:45:41.239585"} \ No newline at end of file diff --git a/data/chip_cache/518880.json b/data/chip_cache/518880.json index 91bbd6a..8d0ced0 100644 --- a/data/chip_cache/518880.json +++ b/data/chip_cache/518880.json @@ -1 +1 @@ -{"winner_pct": 0.015377013137657148, "loser_pct": 0.9846229868623428, "bias": 0.019692459737246856, "updated_at": "2026-07-02T00:36:01.402360"} \ No newline at end of file +{"winner_pct": 0.5509915567863326, "loser_pct": 0.4490084432136674, "bias": 0.008980168864273348, "updated_at": "2026-07-02T00:45:43.410106"} \ No newline at end of file diff --git a/data/chip_cache/600519.json b/data/chip_cache/600519.json index 9a8774e..c1cc968 100644 --- a/data/chip_cache/600519.json +++ b/data/chip_cache/600519.json @@ -1 +1 @@ -{"winner_pct": 0.10535744228960574, "loser_pct": 0.8946425577103942, "bias": 0.035427845285331605, "updated_at": "2026-07-02T00:36:03.265204"} \ No newline at end of file +{"winner_pct": 0.022019682466754367, "loser_pct": 0.9779803175332457, "bias": 0.03872802057431653, "updated_at": "2026-07-02T00:45:45.564306"} \ No newline at end of file diff --git a/data/chip_cache/600563.json b/data/chip_cache/600563.json index 453171b..e7e1c8f 100644 --- a/data/chip_cache/600563.json +++ b/data/chip_cache/600563.json @@ -1 +1 @@ -{"winner_pct": 0.901115667682602, "loser_pct": 0.09888433231739803, "bias": 0.0019776866463479606, "updated_at": "2026-07-02T00:36:05.897221"} \ No newline at end of file +{"winner_pct": 0.9736309318514315, "loser_pct": 0.026369068148568535, "bias": 0.0005273813629713707, "updated_at": "2026-07-02T00:45:47.673568"} \ No newline at end of file diff --git a/data/chip_cache/601318.json b/data/chip_cache/601318.json index edb5240..5fd1c51 100644 --- a/data/chip_cache/601318.json +++ b/data/chip_cache/601318.json @@ -1 +1 @@ -{"winner_pct": 0.12629635051048638, "loser_pct": 0.8737036494895137, "bias": 0.017474072989790274, "updated_at": "2026-07-02T00:36:07.760371"} \ No newline at end of file +{"winner_pct": 0.4249266733297725, "loser_pct": 0.5750733266702275, "bias": 0.01150146653340455, "updated_at": "2026-07-02T00:45:49.780753"} \ No newline at end of file diff --git a/data/chip_cache/601899.json b/data/chip_cache/601899.json index eab1aa9..472f5a6 100644 --- a/data/chip_cache/601899.json +++ b/data/chip_cache/601899.json @@ -1 +1 @@ -{"winner_pct": 0.03603420474156716, "loser_pct": 0.9639657952584328, "bias": 0.019279315905168657, "updated_at": "2026-07-02T00:36:09.643701"} \ No newline at end of file +{"winner_pct": 0.5877933411419987, "loser_pct": 0.41220665885800134, "bias": 0.008244133177160027, "updated_at": "2026-07-02T00:45:51.892513"} \ No newline at end of file diff --git a/data/chip_cache/688411.json b/data/chip_cache/688411.json index 627f947..af761ad 100644 --- a/data/chip_cache/688411.json +++ b/data/chip_cache/688411.json @@ -1 +1 @@ -{"winner_pct": 0.5745885997936249, "loser_pct": 0.42541140020637513, "bias": 0.008508228004127504, "updated_at": "2026-07-02T00:36:11.528137"} \ No newline at end of file +{"winner_pct": 0.6831599702559918, "loser_pct": 0.31684002974400816, "bias": 0.006336800594880163, "updated_at": "2026-07-02T00:45:54.018131"} \ No newline at end of file diff --git a/data/chip_cache/688630.json b/data/chip_cache/688630.json index 777cd60..f038f37 100644 --- a/data/chip_cache/688630.json +++ b/data/chip_cache/688630.json @@ -1 +1 @@ -{"winner_pct": 0.9180078278115366, "loser_pct": 0.08199217218846348, "bias": 0.0016398434437692698, "updated_at": "2026-07-02T00:36:13.369248"} \ No newline at end of file +{"winner_pct": 0.986690766691903, "loser_pct": 0.013309233308096953, "bias": 0.00026618466616193907, "updated_at": "2026-07-02T00:45:56.137095"} \ No newline at end of file diff --git a/data/chip_cache/688639.json b/data/chip_cache/688639.json index 42ce1af..2ca8a3c 100644 --- a/data/chip_cache/688639.json +++ b/data/chip_cache/688639.json @@ -1 +1 @@ -{"winner_pct": 0.19133053163048952, "loser_pct": 0.8086694683695105, "bias": 0.01617338936739021, "updated_at": "2026-07-02T00:36:15.460650"} \ No newline at end of file +{"winner_pct": 0.025566719946732226, "loser_pct": 0.9744332800532678, "bias": 0.019488665601065356, "updated_at": "2026-07-02T00:45:58.254879"} \ No newline at end of file diff --git a/data/price_history.json b/data/price_history.json index 0eb5798..6eefbf9 100644 --- a/data/price_history.json +++ b/data/price_history.json @@ -49,6 +49,12 @@ "high": 101.33, "low": 92.52, "close": 95.94 + }, + { + "date": "2026-07-02", + "high": 101.33, + "low": 94.41, + "close": 95.94 } ], "000700": [ @@ -101,6 +107,12 @@ "high": 4.77, "low": 4.1, "close": 4.77 + }, + { + "date": "2026-07-02", + "high": 4.77, + "low": 4.77, + "close": 4.77 } ], "001309": [ @@ -127,6 +139,12 @@ "high": 976.0, "low": 880.0, "close": 893.22 + }, + { + "date": "2026-07-02", + "high": 976.0, + "low": 880.0, + "close": 893.22 } ], "002594": [ @@ -153,6 +171,12 @@ "high": 81.65, "low": 78.55, "close": 80.66 + }, + { + "date": "2026-07-02", + "high": 81.65, + "low": 78.55, + "close": 80.66 } ], "00700": [ @@ -205,6 +229,12 @@ "high": 2.08, "low": 2.01, "close": 2.06 + }, + { + "date": "2026-07-02", + "high": 2.08, + "low": 2.01, + "close": 2.06 } ], "00981": [ @@ -257,6 +287,12 @@ "high": 13.22, "low": 12.59, "close": 12.89 + }, + { + "date": "2026-07-02", + "high": 13.22, + "low": 12.59, + "close": 12.89 } ], "01088": [ @@ -413,6 +449,12 @@ "high": 52.6, "low": 50.75, "close": 51.05 + }, + { + "date": "2026-07-02", + "high": 52.6, + "low": 50.75, + "close": 51.05 } ], "02359": [ @@ -439,6 +481,12 @@ "high": 158.4, "low": 151.7, "close": 153.7 + }, + { + "date": "2026-07-02", + "high": 158.4, + "low": 151.7, + "close": 153.7 } ], "02388": [ @@ -465,6 +513,12 @@ "high": 43.6, "low": 41.82, "close": 42.38 + }, + { + "date": "2026-07-02", + "high": 43.6, + "low": 41.82, + "close": 42.38 } ], "02628": [ @@ -491,6 +545,12 @@ "high": 27.18, "low": 26.32, "close": 26.66 + }, + { + "date": "2026-07-02", + "high": 27.18, + "low": 26.32, + "close": 26.66 } ], "06160": [ @@ -777,6 +837,12 @@ "high": 1196.8, "low": 1166.33, "close": 1193.01 + }, + { + "date": "2026-07-02", + "high": 1196.8, + "low": 1166.33, + "close": 1193.01 } ], "600563": [ diff --git a/scripts/chip_factors.py b/scripts/chip_factors.py index 035522b..5ecdfd4 100644 --- a/scripts/chip_factors.py +++ b/scripts/chip_factors.py @@ -100,7 +100,7 @@ class ChipFactors: os.environ.pop(k) # 从腾讯API取60日K线 prefix = "sh" if code.startswith(('60','68','51')) else "sz" if code.startswith(('00','30','15')) else "hk" - url = f"http://ifzq.gtimg.cn/appstock/app/fqkline/get?param={prefix}{code},day,,,60,qfq" + url = f"http://ifzq.gtimg.cn/appstock/app/fqkline/get?param={prefix}{code},day,,,640,qfq" try: opener = urllib.request.build_opener(urllib.request.ProxyHandler({})) req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"}) diff --git a/strategy_lifecycle.py b/strategy_lifecycle.py index b1e2114..78d3eaf 100644 --- a/strategy_lifecycle.py +++ b/strategy_lifecycle.py @@ -51,6 +51,55 @@ def calc_atr(code, period=14): except Exception: return None + +def calc_chip_sr(code, price): + """从筹码分布计算支撑/阻力位。 + + 返回: {"chip_ss": 筹码强支撑, "chip_sr": 筹码强阻力} 或 None + 筹码强支撑 = 当前价下方成交量最大的价格区间 + 筹码强阻力 = 当前价上方成交量最大的价格区间 + + 用法: + sr = calc_chip_sr("600519", 1193) + if sr: + print(f"筹码支撑{sr['chip_ss']} 筹码阻力{sr['chip_sr']}") + """ + if not price or price <= 0: + return None + try: + # 复用chip_factors的筹码分布构建 + import sys as _sys + _sys.path.insert(0, "/home/hmo/MoFin/scripts") + from chip_factors import ChipFactors + cf = ChipFactors() + chip = cf._build_chip_distribution(code) + if not chip: + return None + total = sum(chip.values()) + if total <= 0: + return None + # 2%区间聚合 + step = max(round(price * 0.02, 2), 1.0) + bins = {} + for p, v in chip.items(): + k = round(p / step) * step + bins[k] = bins.get(k, 0) + v + sb = sorted(bins.items()) + below = [(p, v) for p, v in sb if p < price] + above = [(p, v) for p, v in sb if p >= price] + if not below or not above: + return None + + # 支撑 = 下方成交量最大的密集区 + chip_ss = max(below, key=lambda x: x[1])[0] + # 阻力 = 上方成交量最大的密集区 + chip_sr = max(above, key=lambda x: x[1])[0] + + return {"chip_ss": chip_ss, "chip_sr": chip_sr} + except Exception as e: + print(f" ⚠️ 筹码S/R计算失败: {e}", file=sys.stderr) + return None + # 提示词版本追踪 try: from prompt_manager.tracking import record_strategy_generation @@ -542,6 +591,25 @@ def reassess_strategy(code, name, price, cost, shares, current_action, except Exception as e: print(f" 多周期分析失败: {e}", file=sys.stderr) + # ----- 筹码分布支撑/阻力(中长线参考) ----- + chip_sr = None + try: + chip_sr = calc_chip_sr(code, price) + if chip_sr: + print(f" 筹码: 强撑={chip_sr['chip_ss']} 强压={chip_sr['chip_sr']}") + # 与枢轴点对比,判断共振/分歧 + if ss and ws and pivot: + chip_ss_pct = (price - chip_sr['chip_ss']) / price * 100 if chip_sr['chip_ss'] > 0 else 0 + chip_sr_pct = (chip_sr['chip_sr'] - price) / price * 100 if chip_sr['chip_sr'] > 0 else 0 + pivot_ss_pct = (price - ss) / price * 100 if ss > 0 else 0 + pivot_sr_pct = (sr_resist - price) / price * 100 if sr_resist > 0 else 0 + if abs(chip_ss_pct - pivot_ss_pct) < 3: + print(f" ⚡ 支撑共振: 筹码+枢轴均指向{chip_sr['chip_ss']:.0f}附近") + if abs(chip_sr_pct - pivot_sr_pct) < 3: + print(f" ⚡ 阻力共振: 筹码+枢轴均指向{chip_sr['chip_sr']:.0f}附近") + except Exception: + pass + profit_pct = (price - cost) / cost * 100 if cost else 0 is_new_entry = (cost == 0) or (shares == 0) is_deep_loss = profit_pct < -20