以下是Python代碼實現:
``` import requests from datetime import datetime, timedelta
# 設置股票代碼和查詢日期 stock_code = "600100" query_date = "2022-08-01"
# 股票漲停的漲幅閾值 limit_up_percent = 10
# 構造查詢股票信息的URL url = f"http://hq.sinajs.cn/list={stock_code.lower()}"
# 發送HTTP請求并獲取響應內容 response = requests.get(url)
# 解析響應內容 result = response.text.split(",")[3]
# 獲取查詢日期的股票價格信息 query_date_price_info = result.split(";")[-2]
# 拆分股票價格信息,獲取開盤價、最高價、最低價、收盤價等信息 open_price, _, high_price, low_price, close_price, _, _ = query_date_price_info.split(",")
# 判斷當日漲幅是否達到漲停閾值 if float(high_price) / float(close_price) >= 1 + limit_up_percent / 100: print(f"{query_date} {stock_code} 股票曾經漲停") else: print(f"{query_date} {stock_code} 股票沒有漲停") ```
說明:
1. 通過requests庫發送HTTP請求,獲取新浪財經股票信息接口的響應內容。 2. 解析響應內容,獲取查詢日期的股票價格信息。 3. 拆分股票價格信息,獲取當日的開盤價、最高價、最低價、收盤價等信息。 4. 判斷當日漲幅是否達到漲停閾值,如果是則輸出“股票曾經漲停”,否則輸出“股票沒有漲停”。