Spaces:
Sleeping
Sleeping
tbdavid2019
commited on
Commit
•
0c2507c
1
Parent(s):
924472b
股票代號更改
Browse files
README.md
CHANGED
@@ -11,3 +11,105 @@ short_description: 台灣上市股票 潛力股
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
14 |
+
|
15 |
+
---
|
16 |
+
|
17 |
+
# Taiwan Stock Short-Term Potential Stock Prediction System - LSTM Model
|
18 |
+
|
19 |
+
This project is a stock prediction system for short-term potential stocks in the Taiwan stock market. It uses LSTM (Long Short-Term Memory) models to predict future prices based on historical data from Taiwan listed stocks. The system is implemented using Python, and the web interface is created using Gradio. The project is designed for research and educational purposes only and should not be used for investment decision-making.
|
20 |
+
|
21 |
+
## Features
|
22 |
+
- Fetch historical stock data for Taiwan listed stocks using `yfinance`.
|
23 |
+
- Train LSTM models on stock data to predict future prices.
|
24 |
+
- Recommend the top 10 potential stocks based on prediction analysis.
|
25 |
+
- User-friendly web interface created with Gradio.
|
26 |
+
|
27 |
+
## Installation
|
28 |
+
To run the project locally or on a server like Hugging Face Space, you need to install the required dependencies.
|
29 |
+
|
30 |
+
1. Clone the repository:
|
31 |
+
```bash
|
32 |
+
git clone https://github.com/tbdavid2019/twStock-Underdogs.git
|
33 |
+
cd twStock-Underdogs
|
34 |
+
```
|
35 |
+
|
36 |
+
2. Install dependencies:
|
37 |
+
```bash
|
38 |
+
pip install -r requirements.txt
|
39 |
+
```
|
40 |
+
|
41 |
+
## Usage
|
42 |
+
You can run the application by executing the `app.py` file.
|
43 |
+
|
44 |
+
```bash
|
45 |
+
python app.py
|
46 |
+
```
|
47 |
+
The application will launch a Gradio interface where you can select a period (e.g., 1 month, 3 months) and receive predictions for the top 10 potential stocks.
|
48 |
+
|
49 |
+
## Requirements
|
50 |
+
The `requirements.txt` file includes the necessary libraries for the project:
|
51 |
+
- `yfinance`
|
52 |
+
- `numpy`
|
53 |
+
- `pandas`
|
54 |
+
- `scikit-learn`
|
55 |
+
- `tensorflow`
|
56 |
+
- `gradio`
|
57 |
+
- `keras`
|
58 |
+
|
59 |
+
## Note
|
60 |
+
This system is for research purposes only. Investing in stocks involves significant risk, and predictions made by this system should not be the sole basis for investment decisions.
|
61 |
+
|
62 |
+
## License
|
63 |
+
This project is licensed under the MIT License. See the LICENSE file for more details.
|
64 |
+
|
65 |
+
---
|
66 |
+
|
67 |
+
# 台股短線潛力股推薦系統 - LSTM 模型
|
68 |
+
|
69 |
+
此專案是一個針對台灣股票市場短線潛力股的預測系統,使用 LSTM(長短期記憶)模型根據台灣上市股票的歷史數據來預測未來股價。本系統使用 Python 實現,並透過 Gradio 建立網頁介面。本專案僅供學術研究用途,不應用於投資決策。
|
70 |
+
|
71 |
+
## 功能
|
72 |
+
- 使用 `yfinance` 抓取台灣上市股票的歷史數據。
|
73 |
+
- 使用 LSTM 模型進行股價預測。
|
74 |
+
- 根據預測分析推薦前 10 名潛力股。
|
75 |
+
- 透過 Gradio 建立簡單易用的網頁介面。
|
76 |
+
|
77 |
+
## 安裝
|
78 |
+
若要在本地或 Hugging Face Space 等伺服器上運行本專案,請先安裝必要的相依套件。
|
79 |
+
|
80 |
+
1. 複製此倉庫:
|
81 |
+
```bash
|
82 |
+
git clone https://github.com/tbdavid2019/twStock-Underdogs.git
|
83 |
+
cd twStock-Underdogs
|
84 |
+
```
|
85 |
+
|
86 |
+
2. 安裝相依套件:
|
87 |
+
```bash
|
88 |
+
pip install -r requirements.txt
|
89 |
+
```
|
90 |
+
|
91 |
+
## 使用方式
|
92 |
+
執行 `app.py` 來啟動應用程式:
|
93 |
+
|
94 |
+
```bash
|
95 |
+
python app.py
|
96 |
+
```
|
97 |
+
應用程式會啟動一個 Gradio 介面,您可以選擇時間範圍(例如:1 個月、3 個月),並查看系統推薦的前 10 名潛力股。
|
98 |
+
|
99 |
+
## 相依套件
|
100 |
+
`requirements.txt` 文件包含了本專案所需的套件:
|
101 |
+
- `yfinance`
|
102 |
+
- `numpy`
|
103 |
+
- `pandas`
|
104 |
+
- `scikit-learn`
|
105 |
+
- `tensorflow`
|
106 |
+
- `gradio`
|
107 |
+
- `keras`
|
108 |
+
|
109 |
+
## 注意事項
|
110 |
+
此系統僅供研究用途。投資股票具有高度風險,本系統的預測結果不應作為投資決策的唯一依據。
|
111 |
+
|
112 |
+
## 授權
|
113 |
+
本專案使用 MIT 授權條款。詳細請參見 LICENSE 文件。
|
114 |
+
|
115 |
+
|
app.py
CHANGED
@@ -55,15 +55,25 @@ def predict_stock(model, data, scaler, time_step=60):
|
|
55 |
|
56 |
return predicted_prices
|
57 |
|
58 |
-
|
59 |
-
# Function to fetch all Taiwan listed stocks (Taiwan 50)
|
60 |
def get_all_taiwan_stocks():
|
61 |
return [
|
62 |
-
"
|
63 |
-
"
|
64 |
-
"
|
65 |
-
"
|
66 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
]
|
68 |
|
69 |
# Function to get top 10 potential stocks
|
@@ -108,4 +118,5 @@ inputs = gr.Dropdown(choices=["1mo", "3mo", "6mo", "9mo", "1yr"], label="時間
|
|
108 |
outputs = gr.Dataframe(label="潛力股推薦結果")
|
109 |
|
110 |
gr.Interface(fn=stock_prediction_app, inputs=inputs, outputs=outputs, title="台股潛力股推薦系統 - LSTM模型")\
|
111 |
-
.launch()
|
|
|
|
55 |
|
56 |
return predicted_prices
|
57 |
|
58 |
+
# Function to fetch all Taiwan listed stocks (Taiwan 50 and Small 100)
|
|
|
59 |
def get_all_taiwan_stocks():
|
60 |
return [
|
61 |
+
"2345.TW", "3017.TW", "2454.TW", "2330.TW", "2395.TW", "2379.TW", "2890.TW", "2891.TW", "2882.TW", "3008.TW",
|
62 |
+
"5871.TW", "2303.TW", "2357.TW", "3661.TW", "2883.TW", "3711.TW", "2308.TW", "2885.TW", "2603.TW", "2881.TW",
|
63 |
+
"4904.TW", "2887.TW", "2880.TW", "2301.TW", "1216.TW", "2884.TW", "2327.TW", "6669.TW", "5880.TW", "1303.TW",
|
64 |
+
"3045.TW", "2382.TW", "2912.TW", "4938.TW", "3231.TW", "2892.TW", "2317.TW", "1590.TW", "3034.TW", "2002.TW",
|
65 |
+
"2412.TW", "2207.TW", "3037.TW", "1301.TW", "1326.TW", "1101.TW", "6446.TW", "2886.TW", "6505.TW", "5876.TW",
|
66 |
+
"3533.TW", "9904.TW", "2618.TW", "5522.TW", "2360.TW", "6005.TW", "3653.TW", "2368.TW", "2474.TW", "6285.TW",
|
67 |
+
"1519.TW", "9958.TW", "3044.TW", "1476.TW", "2324.TW", "2059.TW", "1402.TW", "6176.TW", "1102.TW", "2353.TW",
|
68 |
+
"3665.TW", "2049.TW", "2609.TW", "2478.TW", "9945.TW", "1216.TW", "8464.TW", "3702.TW", "2801.TW", "6526.TW",
|
69 |
+
"2845.TW", "2834.TW", "2610.TW", "4763.TW", "4958.TW", "9941.TW", "6239.TW", "2915.TW", "9917.TW", "2376.TW",
|
70 |
+
"1451.TW", "2313.TW", "3051.TW", "9914.TW", "1477.TW", "2377.TW", "2206.TW", "1504.TW", "2912.TW", "6409.TW",
|
71 |
+
"1560.TW", "1503.TW", "2615.TW", "3005.TW", "2204.TW", "3532.TW", "2888.TW", "2449.TW", "6789.TW", "3481.TW",
|
72 |
+
"2409.TW", "2385.TW", "3406.TW", "2352.TW", "2207.TW", "2347.TW", "6531.TW", "9910.TW", "2371.TW", "2356.TW",
|
73 |
+
"2492.TW", "1718.TW", "6890.TW", "8454.TW", "2633.TW", "1802.TW", "2006.TW", "2542.TW", "1513.TW", "1907.TW",
|
74 |
+
"1722.TW", "2809.TW", "1319.TW", "4137.TW", "2388.TW", "2812.TW", "2540.TW", "3035.TW", "2354.TW", "2027.TW",
|
75 |
+
"1229.TW", "2105.TW", "2408.TW", "5269.TW", "2344.TW", "3443.TW", "6415.TW", "9921.TW", "3036.TW", "6592.TW",
|
76 |
+
"6472.TW", "3023.TW", "6770.TW", "1795.TW", "2201.TW", "1605.TW", "8046.TW", "2312.TW", "2359.TW", "2337.TW"
|
77 |
]
|
78 |
|
79 |
# Function to get top 10 potential stocks
|
|
|
118 |
outputs = gr.Dataframe(label="潛力股推薦結果")
|
119 |
|
120 |
gr.Interface(fn=stock_prediction_app, inputs=inputs, outputs=outputs, title="台股潛力股推薦系統 - LSTM模型")\
|
121 |
+
.launch()
|
122 |
+
|