From 4212f32e8df7a955605096328e3d3a6e95cd0081 Mon Sep 17 00:00:00 2001 From: admin <admin@example.com> Date: 星期五, 01 八月 2025 14:28:10 +0800 Subject: [PATCH] 修复昨日涨停股票代码BUG --- strategy/basic_methods.py | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/strategy/basic_methods.py b/strategy/basic_methods.py index 1d88b88..6f1e685 100644 --- a/strategy/basic_methods.py +++ b/strategy/basic_methods.py @@ -97,20 +97,22 @@ # 璁$畻褰撴棩娑ㄥ仠浠峰嚱鏁� 褰㈠弬pre_close 瀹炲弬搴斾紶鍏� pre_close 銆恟eturn鐨勭粨鏋滈渶瑕佸皬鏁扮偣鍚庝袱浣�,鍦ㄧ涓変綅杩涜鍥涜垗浜斿叆銆� -def limit_up_price(pre_close): +def limit_up_price(pre_close, fixed=2): limit_up_price_data = decimal.Decimal(str(pre_close)) * decimal.Decimal("1.1") - limit_up_price_value = limit_up_price_data.quantize(decimal.Decimal("0.00"), decimal.ROUND_HALF_UP) + limit_up_price_value = limit_up_price_data.quantize(decimal.Decimal("0." + '0' * fixed), decimal.ROUND_HALF_UP) return float(limit_up_price_value) + # 娴嬭瘯璁$畻鐢� # limit_up = limit_up_price(15) # print(f"limit_up=={limit_up}") # 璁$畻褰撴棩璺屽仠浠峰嚱鏁� 褰㈠弬pre_close 瀹炲弬搴斾紶鍏� pre_close 銆恟eturn鐨勭粨鏋滈渶瑕佸皬鏁扮偣鍚庝袱浣峳ound鍙栨暣銆� -def limit_down_price(pre_close): +def limit_down_price(pre_close, fixed=2): limit_down_price_data = decimal.Decimal(str(pre_close)) * decimal.Decimal("0.9") - limit_down_price_value = limit_down_price_data.quantize(decimal.Decimal("0.00"), decimal.ROUND_HALF_UP) + limit_down_price_value = limit_down_price_data.quantize(decimal.Decimal("0." + '0' * fixed), decimal.ROUND_HALF_UP) return float(limit_down_price_value) + # 娴嬭瘯璁$畻鐢� # limit_down = limit_down_price(20) # print(f"limit_up=={limit_down}") @@ -210,8 +212,8 @@ # 鍏呭垎浜ゆ槗閲忓叕寮� 鐢ㄤ簬璁$畻鏃ュ唴娑ㄥ箙娈电悊璁虹殑瀹夊叏浜ゆ槗閲忓�� def sufficient_volume(current_volume, yesterday_volume, today_growth): - if today_growth > 0 and round(current_volume / yesterday_volume / 100, 2) >= 0.01: - if current_volume > yesterday_volume * 0.5 * (today_growth/100): + if today_growth > 0 and round(current_volume / yesterday_volume, 2) >= 0.01: + if current_volume > yesterday_volume * (today_growth/10) * 0.3: return True else: return False -- Gitblit v1.8.0