NYCU-Software-Testing-Final-project
-
收集即時的股票資訊
-
分析股票過去的資料
-
產生短、中、長期的均線圖
-
計算夏普及威廉指標
-
TDD: Python unittest + Coverage
-
Fuzz testing: Google Atheris
Will be uploaded AfterWard
-
股票機器人API:
- Python 3.6:
Stockbot\stockapi.py
- Python 3.10:
Stockbot\stockapi_310.py
- Python 3.6:
-
股票機器人Linebot:
Stockbot\stockbot.py
-
股票機器人Test Case:
Stockbot\test\*
-
股票機器人API FuzzTesting:
Stockbot\fuzz_test\*
-
開發環境:
Develop Environment:Python3.6 / 3.10
Windows:11
Linux WSL:22.04 (Atheris Fuzzing)
-
安裝環境需求:
Line App (Better Visual effect on phone)
git clone https://github.com/Jim890227/NYCU-Software-Testing-Final-project.git
cd Stockbot
pip install pandas matplotlib twstock mplfinance pyimgur beautifulsoup4 requests
pip install coverage
For Python3.10 or above:
Please alter
stockapi_310.py
tostockapi.py
Because some functions are different between 3.6 and 3.10
- Run the whole functions in stockapi
coverage run -m --source=. unittest discover test -v
You will see the screen Like:
- Get report in html type (Better View)
coverage html
- Get report on terminal
coverage report
pip3 install atheris
- Locate to fuzz_test Folder and copy stockapi.py into this Folder
cd fuzz_test
cp ./../stockapi.py .
- Directly execute the testfile with test_*_fuzzz.py
For example:
coverage run -m unittest test_calculate_daily_return_rate_fuzz.py
You will see the screen Like:
There are some Known Errors because of third party APIs or Database request:
-
imgur ⇒ Upload limit of 50 images per hour
-
台灣證券交易所資料庫(TWSE) ⇒ Request limit of 3 requests every 5 seconds, will be banned if exceeded
Reached 100% coverage on every function in StockAPI
You can also watch the details on the Stockbot\htmlcov\index.html
from your Browser!
https://docs.python.org/zh-tw/3.10/library/unittest.html
https://coverage.readthedocs.io/en/7.5.3/
https://github.com/google/atheris
https://bandit.readthedocs.io/en/latest/
https://twstock.readthedocs.io/zh-tw/latest/index.html
https://steam.oxxostudio.tw/category/python/example/line-bot.html