MOPCON
      • 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
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners 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
    • 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 Help
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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners 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
    # 機器學習於量化交易的挑戰與解法 - 韓承佑 {%hackmd MNcuRlXoQDak0uCmtaJKwA %} :::info [講者簡報](https://www.finlab.tw/slide_mopcon.pdf) [議程影片](https://www.youtube.com/watch?v=v7MgZLIc-ds) ::: [TOC] ![](https://i.imgur.com/zsebL5I.png) > 投資:長期經營 > 錢換來的價值= 「時間」 ### 時間帶來的好處: - 為社會帶來更多的影響 一個人能不能好死取決於有沒有把資產的 70% 花在投資上。 - 有投資: 年老後資產繼續增長 - 沒投資: 年老後沒錢 ## Finlab https://www.finlab.tw/mopcon.html 講者投影片: https://www.finlab.tw/slide_mopcon.pdf ### Machine Learning - AI 的 papers 數量不斷提升,平均每天需讀10篇以上才可完全跟上最新技術 ### Supervised Machine Learning 兩步驟 - Training (訓練) - features - labels 預測種類 - Testing (確認) - 從 features 預測出 labels 不給答案(label),能做預測嗎? ### Financial Data(features) - Fundamental data Focusing in creating a portrait of a company - Trading Data 如何查看公司價值: 1. 財報:公司價值、獲利 2. 價量(股價) 機器學習可透過股價來判斷後續發展獲利 ### Creating Technical indicators 原始資料是"股價" Price historical data 利用原始資料計算出各種指標作為特徵,如: - RSI(是可看出 股價相對強弱 的指標,Relative Strength Index) - KD值 ...等 指標有什麼用?做預測股票上漲或下跌 [使用講者提供的程式碼:](https://colab.research.google.com/drive/1_l-7Cdx_xG0Fja-0L4H7Dgl0QAQzhmvs) ### Labeling > 探討時間和漲跌的關係 #### Challenging of Labeling the data fixed time horizon 標記方式:一段時間內(w): - 如果上升,標記為 +1 - 如果沒變動,標記為 0 - 如果下降,標記為 -1 問題: 必須持有一段時間(w),才能賣出股票(風險承擔性較大) #### Label Generation Methods - tripel barriers - 1, 0 ,-1(漲, 不漲, 跌) - Continuous trading signals (Dash 2016) - 連續的區間(利用內差公式來得到區間內的位置) - 愈接近1: 上漲 - 愈接近0: 下跌 - Trading Point decision - 看整個時間序列去做判斷 - 找出 local minimun 和 maximun 點 - 利用這些點,對原始股價訊號進行切割,以直線來趨近原始訊號 > 概念上透過機器學習達到,低價買入、高價賣出的近似訊號。 ### Demo #### 問題:講者提供的label對於股票預測有何影響? #### 講者:買賣股票的方式有很多種,可以產生很多種策略 * 例如「趨勢」跟「逆勢」,趨勢型的策略勝率低,但是單筆獲利較多,而逆勢型則是勝率高,但單筆虧損較嚴重,而不論是「趨勢」或「逆勢」交易,都是有機會可以獲利的 * 還有不同的交易頻率(每分鐘、每小時、每天、每月),也都可以產生出不同的訊號,頻率高採樣多,所以交易獲利比較穩定,但是手續費昂貴。交易頻率低則剛好相反,各有優劣 所以根據不同的 label ,就可以用同樣的模型 創造出各種不同的策略喔! 假如您有很多種不同的labeling方式,都可以產生獲利模型,分散風險,會是不錯的選擇! ## Neural Network (神經網路) - 用數學來模擬神經,突觸、軸突等構造 ## Deep Neural Network (深度神經網路) - 神經網路有很多層 - 透過多層的權重(Weight)將輸入訊號(input)映射到答案(label) - 利用 Cost Function 來計算誤差,用以調整Weight - Cost愈大,代表誤差愈大 - 調整 Weight,讓Cost盡可能降低(類似走在山坡上,盡量要往低處走) ![](https://i.imgur.com/NWmsVJe.png) ### Long Short Term Memory Neural Network ( LSTM ) - 有記憶的效應 (利用Forget Gate, Input Gate, Output Gate 等結構) - LSTM 可以解決梯度爆炸(Gradient Expoding)、梯度消失(Gradient Vanishing)的問題 - 有真正的記憶體 - 用額外的神經網路來達到記憶的效果 ### Convolutional Neural Network(CNN) - 經常用於電腦視覺 (Image) - 讓節點只處理不分區部分的分析不需要每一個像素都處理 - 優點: - 避免過度擬和 (Overfitting) ### 視覺網路 vs 交易 Time series to Image conversion Approach ## Backtest (回測) - 需注意的: - 生存者偏差,可能是很爛的策略意外剛好對了 - 可能會正確找到一張過去開獎過的樂透,但其實對未來預測幫助不大 - 解法: - Develop model for entire asset or classes - 使用 Bootstrap aggregating - 紀錄每次回測 - Resist the temptation of reusing a failed strategy ## 序列資料切 Validation 遇到的問題 由於是序列化資料,訓練資料很容易包含測試資料。 ||day1|day2|day3|day4|day5| |:-:|:-:|:-:|:-:|:-:|:-:| |training|x1|x2|<p style="color:red;">y||| |training||x1|<p style="color:red;">x2|<p style="color:red;">y|| |testing|||<p style="color:red;">x1|<p style="color:red;">x2|y| p.s 如果測試越多,可產生的預測將越準確 ###### tags: `MOPCON 2019`

    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