Coder Social home page Coder Social logo

stock_review_dashboard's Introduction

股票觀測儀表板

本功能技術主要分為三個,
一、資料獲取
二、股市 K 線儀表板建立
接下來會依序介紹,並分享程式碼
三、Flask RESTful API 後端串接

IMAGE ALT TEXT HERE

一、資料獲取

  1. 建立資料庫、資料表:setting_db_and_table.py
    由於之前不斷的測試資料表的格式,所以有放一個以註解的刪除資料表程式碼,如果有需要使用,可以解開。

  2. 更新資料:update_db.py
    資料獲取是使用 TWSE API 進行提取,
    而設定方面,可以看到下面的 stock_list,如果有需要加入其他監測的股票,就可以透過這一段加入,
    而我的 API 也有設定可以設定區間,但只會依據月份,所以只需要填寫每個月的 1 號就好,舉例:20230201,就會直接抓取 2023 年 2 月份所有的資料
    比較需要注意的是,API 呼叫的限制,所以使用 time.sleep() 的方式限制取用資料的速度,經過測試如果時間低於 15 秒就會被 block,所以建議設定 20 秒。

  3. 資料更新完成後,就可以使用:visualize.py
    這個程式內只要調整你要查閱的股票代號,然後執行這個程式。
    就會直接產出一個名為「{stock_id}_kline_chart.html」的網頁,在裡面可以直接觀看每一個股票內容。了

二、資料串接

  1. 透過 Flask 進行前後端的資料整合,並透過 Jinja2 將自動產出的網頁,掛載進去每個股票的頁面框架中。
  2. 以上資料獲取、更新,可以透過 Linux crontab 的方式進行自動化每日資料更新,並只需要啟動 run.py,產生出一組網頁伺服器,就可以在前台使用了。

三、待更新事項

  1. 之後會建立可以查閱多個股票的篩選器,只需要篩選對應的股票 ID 就可以查閱,以此提升使用者便捷。
  2. 預計使用基礎的程式邏輯,並串接到 LINEBOT 中,系統會依循 MACD 指標提出判斷式,提醒是否買進、賣出。
  3. 使用「反饋強化學習(RLHF)」進行股市預測,提供投資者對低購買金額,並一樣會有相關通知功能。

本儀表板主要是參考外部開源程式進行數據來源調整,參考文件如下: pyecharts/pyecharts#1844

stock_review_dashboard's People

Contributors

samhuang95 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.