廖述銘
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 期末報告主題:利用S&P500預測QQQ股價 ## 1. **ETF 簡介** ETF全名 :Invesco QQQ Trust 成立時間 : 1999/03/10 發行公司 : 由美國Invesco Power Shares(景順投信公司)發行 配息頻率 : 季配 追蹤指數 : 那斯達克100指數 那斯達克指數中的股票是在那斯達克證券上市的100家最大公司,指數每年會重建一次,其主要成分股為美國科技股 主要成分股包含微軟、蘋果、Amazon 持股數量 : 102檔 優點 : 以科技股為主 成長性強 缺點 : 持股產業集中 波動風險大 ## 2. **ETF 股價資料爬取與分析** ### - 爬取Yahoo Finance上的ETF股價資料 https://colab.research.google.com/drive/13h4MA_JKWGvL2bvGnsUsvWyD5c6aUshb?usp=sharing ### - 爬取期間:至少五年 QQQ: https://drive.google.com/file/d/1isDOzdsAmfusDPZeGmQ_n1z7xF3iGLHv/view?usp=sharing S&P500: https://docs.google.com/spreadsheets/d/1hTAjYZwJUrLvU705l3BnqZtE0RSGF5kfviRMba5rNCU/edit?usp=sharing ### - 劃出均線圖 ![截圖 2023-12-21 下午4.50.01](https://hackmd.io/_uploads/rJ1vgqWDT.png) ### - 設定投資策略 ### - 分析不同的投資策略 ## 3. **機器學習與AI預測股價** ### - 描述使用的機器學習模型 我們使用了遞歸神經網絡(Recurrent Neural Network, RNN)來分析和預測股市走勢。RNN是一種專門處理序列數據的神經網絡,非常適合於時間序列數據,如股票價格。在此案例中,我們選擇了S&P 500指數的歷史數據作為訓練集,目的是訓練出一個能夠捕捉股市波動趨勢的模型,並用此模型去預測NASDAQ-100指數追踪基金(QQQ)的股價走勢。 ### - 模型訓練和驗證過程 #### S&P500的RNN模型訓練過程: S&P500的RNN模型訓練過程: https://colab.research.google.com/drive/1tPmBEDwDINUUi8EO9mB6c5YZ4eq_om3P?usp=sharing 整體流程: ![image](https://hackmd.io/_uploads/S1OCeJjvp.png) 1. 數據準備 * 數據收集: 獲取 S&P 500 指數的歷史價格數據。 * 數據預處理: 標準化/歸一化:將數據轉換為一個共同的範圍,以便更好地進行訓練。 創建序列數據:將數據轉換為可以供 RNN 處理的時間序列格式。 ![image](https://hackmd.io/_uploads/B1LW-1oDp.png) 2. 建立 RNN 模型 S&P500的RNN模型: https://drive.google.com/file/d/1-49T393PpmMO4sOZuf7BtKT3_VAdNRQc/view?usp=sharing * 選擇模型類型: 選擇適合的 RNN 結構,如 LSTM。 * 模型架構: 輸入層:根據您的數據維度設置。 隱藏層:添加一個或多個 LSTM 層。 輸出層:預測未來價格的單元。 * 編譯模型: 選擇適當的損失函數和優化器,例如使用 MSE 損失和 Adam 優化器。 ![image](https://hackmd.io/_uploads/ryRzW1swp.png) 3. 訓練模型 * 切分數據:將數據分為訓練集和測試集。 * 模型訓練:使用訓練數據訓練模型,並通過設置合適的 epoch 數和 batch 大小來控制訓練過程。 * 模型驗證:在測試集上評估模型的性能。 ![image](https://hackmd.io/_uploads/ByLSbyova.png) 4. 模型評估與調整 * 性能評估:使用如 MAE等指標來評估模型的預測能力。 * 參數調整:根據模型的表現調整參數,如學習率、層數、神經元數量等。 ![image](https://hackmd.io/_uploads/HyHUb1sD6.png) 5. 預測與應用 用S&P500的RNN預測模型預測QQQ股價: https://colab.research.google.com/drive/1nWnxnYOgCqahhUTCMo_2fRj-bxtSSwqw?usp=sharing 預測結果: (https://hackmd.io/_uploads/rJqGbqbwT.png) github: https://github.com/louis-5407/QQQ/blob/main/S%26P500_RNN%E9%A0%90%E6%B8%AC%E6%A8%A1%E5%9E%8B.ipynb * 預測未來價格:使用訓練好的模型對 QQQ ETF 的未來價格進行預測。 * 結果分析:分析和解釋模型的預測結果,並根據需要進行進一步的調整或優化。 ![image](https://hackmd.io/_uploads/r1zP-koDT.png) ##### **參數調整**: 通過調整學習率、層數、神經元數目等超參數,優化模型的預測能力。 優化神經網絡模型,特別是像RNN這樣的模型,通常需要進行一系列實驗,以找到最佳的超參數設置。 > model.fit: batch_size: *batch_size從100減至10* 這是在更新模型權重之前網絡處理的樣本數量。較小的batch size通常可以提供更穩定和精確的權重更新,但訓練速度會較慢。 epochs: *epochs從10增加至50* 這是整個訓練數據集被遍歷的次數。增加epochs數量可以讓模型有更多的機會學習數據。 > model.compile: metrics: *我把準確率(accuracy)換成了平均絕對誤差(MAE)* 在回歸問題中,通常不會使用準確度(accuracy)作為評估指標,因為準確度是用於分類問題的。 ##### 參數設置前後對比 參數設置前: ![截圖 2023-12-28 下午4.55.39](https://hackmd.io/_uploads/rkQru2cDT.png) 參數設置後: ![截圖 2023-12-28 晚上7.12.01](https://hackmd.io/_uploads/By3G_RqDa.png) ### - 預測結果和分析 使用訓練好的RNN模型對QQQ的未來股價進行預測。預測結果顯示,模型能夠在一定程度上捕捉到股價的波動趨勢。然而,由於股市受多種因素影響,包括宏觀經濟、政策調整、市場情緒等,單一模型的預測結果存在一定的不確定性。因此,我們分析了模型預測的準確性、波動範圍和預測失誤的可能原因,並探討了如何進一步改善模型的預測能力。 ![截圖 2023-12-28 晚上7.37.09](https://hackmd.io/_uploads/SkQx00qDa.png) ## 4. **現場展示程式並簡易講解(Demo)** ### - 展示預測結果 https://youtu.be/L4H1uKEKMYc https://github.com/louis-5407/QQQ/blob/main/S%26P500_RNN%E9%A0%90%E6%B8%AC%E6%A8%A1%E5%9E%8B.ipynb ## 5. **ETF成分股,進行分組,並檢測動能策略(JT, 1993)** ### - 基於過去6個月的表現進行分組 **QQQ指數6個月平均報酬** * 在樣本期間內(49個月),QQQ的未來6個月平均報酬率為5.74%。 * 運算結果:QQQ指數未來六個月平均報酬率 ![DBAD56C5-8367-4E68-AF7A-C13B1AB43217](https://hackmd.io/_uploads/B10yroZOa.jpg)![DBAD56C5-8367-4E68-AF7A-C13B1AB43217](https://hackmd.io/_uploads/B10yroZOa.jpg) ### - 持有贏家股票並賣出輸家股票 **套利機會** * 結論指出,那投資者能買進報酬率21.16%的Winner組合,並借券賣出報酬率16.33%的Loser組合,便可無風險套利賺取中間的4.83%。 * 這強調了動能策略的潛在有效性,特別是在捕捉市場中相對強勢和弱勢股票方面。 ### - 分析策略效能 **平均報酬率比較** * 在樣本期間內,Winner組合的平均報酬率為21.16%,高於Loser組合的16.33%。 * 這顯示了動能策略在過去的表現中,贏家組合的未來6個月平均報酬率確實優於輸家組合。 **組合間報酬率差異** * Winner組合的平均報酬率相對於Loser組合高出約4.83個百分點,即-16.33%與21.16%之間的差距。 * 這顯示動能策略在樣本期間內實現了一種套利機會,可以透過長持贏家組合並短持輸家組合,從中獲得超額報酬。 ![S__4775939](https://hackmd.io/_uploads/B1EBnk1up.jpg) https://colab.research.google.com/drive/16D8yoeH-ctSjCefDwb1hu3dgFzZCs5YG?usp=sharing 爬取網站:https://en.wikipedia.org/wiki/Nasdaq-100 ## 6. 額外延伸 https://chat.openai.com/share/3ed8bd3c-31c8-4ad2-a814-abbe173b2bcf

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully