From 02166225b34a7ec2c41dc8eda77c431465b8d9dd Mon Sep 17 00:00:00 2001 From: admin <admin@example.com> Date: 星期一, 24 三月 2025 13:55:50 +0800 Subject: [PATCH] bug修改 --- strategy/basic_methods.py | 40 ++++++++++++++++++++-------------------- 1 files changed, 20 insertions(+), 20 deletions(-) diff --git a/strategy/basic_methods.py b/strategy/basic_methods.py index cc6f97c..f3b50d3 100644 --- a/strategy/basic_methods.py +++ b/strategy/basic_methods.py @@ -53,28 +53,28 @@ # print(f"open_growth=={open_growth}") -# 璁$畻鐬椂娑ㄥ箙鍏紡 -# 鍒濆鍖栧巻鍙蹭环鏍� -price_history = {} +# # 璁$畻鐬椂娑ㄥ箙鍏紡 +# # 鍒濆鍖栧巻鍙蹭环鏍� +# price_history = {} +# +# +# def calculate_growth(symbol, price): +# try: +# if symbol not in price_history: +# return 0 # 涓嶈冻涓や釜鍘嗗彶浠锋牸锛屾棤娉曡绠楁定骞� +# last_price = price_history[symbol] +# # print(f"price_history[symbol]~~~~~~~~~{price_history[symbol]}") +# if last_price != 0: +# growth = (price - last_price) / last_price * 100 # 璁$畻娑ㄥ箙鐧惧垎姣� +# return growth +# finally: +# price_history[symbol] = price +# # print(f"price======={price}") +# # print(f"price_history=={price_history}") +# # print(f"price_history[symbol]=={price_history[symbol]}") -def calculate_growth(symbol, price): - try: - if symbol not in price_history: - return 0 # 涓嶈冻涓や釜鍘嗗彶浠锋牸锛屾棤娉曡绠楁定骞� - last_price = price_history[symbol] - # print(f"price_history[symbol]~~~~~~~~~{price_history[symbol]}") - if last_price != 0: - growth = (price - last_price) / last_price * 100 # 璁$畻娑ㄥ箙鐧惧垎姣� - return growth - finally: - price_history[symbol] = price - # print(f"price======={price}") - # print(f"price_history=={price_history}") - # print(f"price_history[symbol]=={price_history[symbol]}") - - -# 璁$畻tick娑ㄥ箙鍏紡銆愪负鍗栧嚭绛栫暐鍗曠嫭鍒涘缓鍑芥暟銆� +# # 璁$畻鐬椂闂撮殧娑ㄥ箙鍏紡銆愪负鍗栧嚭绛栫暐鍗曠嫭鍒涘缓鍑芥暟銆� # 鍒濆鍖栧巻鍙蹭环鏍� history_price = {} -- Gitblit v1.8.0