KKKMatthias commited on
Commit
e6816b6
·
verified ·
1 Parent(s): 9f7a5ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -7
app.py CHANGED
@@ -39,10 +39,7 @@ def get_stock(ticker: str):
39
 
40
  if est is not None and not est.empty:
41
  try:
42
- # 方法 A: 使用位置索引 iloc (更通用)
43
- # 假设数据按时间升序排列,第0行是当前年,第1行是明年
44
- # 注意:有时 yfinance 返回的顺序可能是反的,或者包含季度数据,
45
- # 但 earnings_estimate 通常是年度数据且按时间排序。
46
  eps_est_current = est.iloc[2]['avg'] # 当前财年
47
  eps_est_next = est.iloc[3]['avg'] # 下一财年
48
 
@@ -59,17 +56,15 @@ def get_stock(ticker: str):
59
  try:
60
  ept = stock.eps_trend
61
  except Exception:
62
- eps_current = 0
63
  ept = None
64
 
65
  eps_current = None
66
 
67
  if ept is not None and not ept.empty:
68
  try:
69
- eps_current = ept.iloc[2][0] # 当前财年
70
  except Exception as e:
71
  print(f"Error parsing dataframe: {e}")
72
- eps_current = 1
73
 
74
  return {
75
  "ticker": ticker.upper(),
 
39
 
40
  if est is not None and not est.empty:
41
  try:
42
+ # 方法 A: 使用位置索引 iloc
 
 
 
43
  eps_est_current = est.iloc[2]['avg'] # 当前财年
44
  eps_est_next = est.iloc[3]['avg'] # 下一财年
45
 
 
56
  try:
57
  ept = stock.eps_trend
58
  except Exception:
 
59
  ept = None
60
 
61
  eps_current = None
62
 
63
  if ept is not None and not ept.empty:
64
  try:
65
+ eps_current = ept.iloc[2]['current'] # 当前财年
66
  except Exception as e:
67
  print(f"Error parsing dataframe: {e}")
 
68
 
69
  return {
70
  "ticker": ticker.upper(),