Update app.py

This commit is contained in:
jackyu66git
2025-09-11 18:40:55 +08:00
parent c6d02d7802
commit eaaa57915c
+6 -6
View File
@@ -274,9 +274,9 @@ def get_a_stock_kl_data(symbol, timeframe, limit=1000, start_time=None, end_time
return None return None
def add_indicators(df): def add_indicators(df):
fast = 8 fast = 24
slow = 16 slow = 52
period = 6 period = 18
macd = ta.MACD(df, fastperiod=fast, slowperiod=slow, signalperiod=period) macd = ta.MACD(df, fastperiod=fast, slowperiod=slow, signalperiod=period)
df['macd'] = macd['macd'] df['macd'] = macd['macd']
@@ -325,10 +325,10 @@ def add_indicators(df):
def calculate_macd(df): def calculate_macd(df):
"""计算MACD指标""" """计算MACD指标"""
exp1 = df['close'].ewm(span=10, adjust=False).mean() exp1 = df['close'].ewm(span=24, adjust=False).mean()
exp2 = df['close'].ewm(span=26, adjust=False).mean() exp2 = df['close'].ewm(span=52, adjust=False).mean()
macd = exp1 - exp2 macd = exp1 - exp2
signal = macd.ewm(span=9, adjust=False).mean() signal = macd.ewm(span=18, adjust=False).mean()
histogram = macd - signal histogram = macd - signal
return { return {