33 lines
614 B
Python
33 lines
614 B
Python
import pandas as pd
|
|
|
|
|
|
def calc_score(df):
|
|
|
|
df["MA5"] = df["收盘"].rolling(5).mean()
|
|
df["MA10"] = df["收盘"].rolling(10).mean()
|
|
df["MA20"] = df["收盘"].rolling(20).mean()
|
|
|
|
df["VOL5"] = df["成交量"].rolling(5).mean()
|
|
|
|
latest = df.iloc[-1]
|
|
|
|
score = 0
|
|
|
|
# 趋势评分
|
|
if latest["MA5"] > latest["MA10"]:
|
|
score += 20
|
|
|
|
if latest["MA10"] > latest["MA20"]:
|
|
score += 20
|
|
|
|
# 量能评分
|
|
if latest["成交量"] > latest["VOL5"] * 1.5:
|
|
score += 30
|
|
|
|
# 动量
|
|
pct = latest["涨跌幅"]
|
|
|
|
if 0 < pct < 5:
|
|
score += 30
|
|
|
|
return score |