tbdavid2019 commited on
Commit
ea4fe6a
1 Parent(s): 4ace3b5

美股清單更新

Browse files
Files changed (1) hide show
  1. app.py +44 -8
app.py CHANGED
@@ -77,21 +77,57 @@ def get_tw0051_stocks():
77
  "6526.TW", "1802.TW", "5522.TW", "6592.TW", "2204.TW", "2540.TW", "2539.TW", "3532.TW"
78
  ]
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  # Function to get top 10 potential stocks
81
  def get_top_10_potential_stocks(period, selected_indices):
82
  stock_list = []
83
- if "tw0050台灣50" in selected_indices:
84
  stock_list += get_tw0050_stocks()
85
- if "tw0051中型100" in selected_indices:
86
  stock_list += get_tw0051_stocks()
87
  if "S&P" in selected_indices:
88
- stock_list.append("^GSPC")
89
  if "NASDAQ" in selected_indices:
90
- stock_list.append("^IXIC")
91
  if "費城半導體" in selected_indices:
92
- stock_list.append("^SOX")
93
  if "道瓊" in selected_indices:
94
- stock_list.append("^DJI")
95
 
96
  stock_predictions = []
97
  time_step = 60
@@ -136,9 +172,9 @@ def stock_prediction_app(period, selected_indices):
136
  # Define Gradio interface
137
  inputs = [
138
  gr.Dropdown(choices=["3mo", "6mo", "9mo", "1yr"], label="時間範圍"),
139
- gr.CheckboxGroup(choices=["tw0050台灣50", "tw0051中型100", "S&P", "NASDAQ", "費城半導體", "道瓊"], label="指數選擇")
140
  ]
141
  outputs = gr.Dataframe(label="潛力股推薦結果")
142
 
143
- gr.Interface(fn=stock_prediction_app, inputs=inputs, outputs=outputs, title="潛力股推薦系統 - LSTM模型")\
144
  .launch()
 
77
  "6526.TW", "1802.TW", "5522.TW", "6592.TW", "2204.TW", "2540.TW", "2539.TW", "3532.TW"
78
  ]
79
 
80
+ # Function to fetch S&P 500 component stocks
81
+ def get_sp500_stocks():
82
+ return [
83
+ "AAPL", "MSFT", "GOOGL", "AMZN", "FB", "TSLA", "BRK-B", "JNJ", "V", "WMT",
84
+ "JPM", "MA", "PG", "NVDA", "UNH", "DIS", "HD", "PYPL", "VZ", "ADBE",
85
+ "NFLX", "CMCSA", "PEP", "KO", "MRK", "INTC", "T", "CRM", "CSCO", "PFE",
86
+ "XOM", "COST", "NKE", "CVX", "WFC", "MCD", "AMGN", "MDT", "IBM", "DHR",
87
+ "LLY", "HON", "BA", "MMM", "NEE", "ACN", "UPS", "TMO", "AVGO", "PM"
88
+ ]
89
+
90
+ # Function to fetch NASDAQ component stocks
91
+ def get_nasdaq_stocks():
92
+ return [
93
+ "AAPL", "MSFT", "AMZN", "TSLA", "GOOGL", "GOOG", "FB", "NVDA", "PYPL", "ADBE",
94
+ "CMCSA", "NFLX", "COST", "PEP", "CSCO", "INTC", "TXN", "AVGO", "AMGN", "QCOM",
95
+ "CHTR", "TMUS", "SBUX", "MDLZ", "ISRG", "BKNG", "MRNA", "FISV", "CSX", "ADI",
96
+ "VRTX", "ATVI", "GILD", "ILMN", "ADP", "MU", "KLAC", "LRCX", "EA", "KHC",
97
+ "JD", "MAR", "BIDU", "MELI", "ROST", "NXPI", "SPLK", "ALGN", "DOCU", "PDD"
98
+ ]
99
+
100
+ # Function to fetch Philadelphia Semiconductor Index component stocks
101
+ def get_sox_stocks():
102
+ return [
103
+ "AMD", "AVGO", "TXN", "INTC", "MU", "NVDA", "QCOM", "ASML", "LRCX", "TSM",
104
+ "AMAT", "ON", "NXPI", "ADI", "KLAC", "SWKS", "QRVO", "MCHP", "SLAB", "ENTG",
105
+ "TER", "COHU", "UCTT", "ACLS", "LSCC", "MRVL", "SYNA", "MPWR", "FORM", "UCTT"
106
+ ]
107
+
108
+ # Function to fetch Dow Jones Industrial Average component stocks
109
+ def get_dji_stocks():
110
+ return [
111
+ "AAPL", "MSFT", "JPM", "V", "UNH", "PG", "JNJ", "WMT", "DIS", "VZ",
112
+ "INTC", "KO", "MRK", "GS", "TRV", "IBM", "MMM", "CAT", "RTX", "CVX",
113
+ "MCD", "HON", "AXP", "WBA", "NKE", "DOW", "BA", "HD", "CRM", "AMGN"
114
+ ]
115
+
116
  # Function to get top 10 potential stocks
117
  def get_top_10_potential_stocks(period, selected_indices):
118
  stock_list = []
119
+ if "台灣50" in selected_indices:
120
  stock_list += get_tw0050_stocks()
121
+ if "台灣中型100" in selected_indices:
122
  stock_list += get_tw0051_stocks()
123
  if "S&P" in selected_indices:
124
+ stock_list += get_sp500_stocks()
125
  if "NASDAQ" in selected_indices:
126
+ stock_list += get_nasdaq_stocks()
127
  if "費城半導體" in selected_indices:
128
+ stock_list += get_sox_stocks()
129
  if "道瓊" in selected_indices:
130
+ stock_list += get_dji_stocks()
131
 
132
  stock_predictions = []
133
  time_step = 60
 
172
  # Define Gradio interface
173
  inputs = [
174
  gr.Dropdown(choices=["3mo", "6mo", "9mo", "1yr"], label="時間範圍"),
175
+ gr.CheckboxGroup(choices=["台灣50", "台灣中型100", "S&P", "NASDAQ", "費城半導體", "道瓊"], label="指數選擇", value=["台灣50", "台灣中型100"])
176
  ]
177
  outputs = gr.Dataframe(label="潛力股推薦結果")
178
 
179
+ gr.Interface(fn=stock_prediction_app, inputs=inputs, outputs=outputs, title="台股美股潛力股推薦系統 - LSTM模型")\
180
  .launch()