SlideShare a Scribd company logo
1 of 17
Hikaru Mizuno, Intern at Smart Trade Inc.
May 2019
Python for Finance
2
Pythonとは ? (6 mins)
 Pythonの趨勢
 特徴と主な活用領域
 何がエクセルより優れているか ?
 金融機関におけるPythonの活用
Black-Litterman Model を実装してみよう! (10 mins)
 Black-Litterman Model とは
 BL Model のアルゴリズム
 QuantX上での実装結果
 演習
付録
 Details of BL Model
Table of Contents
3
Pythonとは ?
Popularity of Python: Growth of major programming languages
Sorce: https://stackoverflow.blog/2017/09/06/incredible-growth-python/
4
機械学習
科学計算・数値計算
Web開発
ソフトウェア開発
業務効率化
教育
Pythonとは ?
×
平易な文法
豊富な外部ツール
Features Common Uses
多くのユーザー
5
Pythonとは ?
ExcelPython
• 初期参入の心理的コストが高い
– プログラミングというと腰がひける(?)
• 操作が(相対的に)直感的でない
– Excelのように常にデータを目で確認し
ながら個別に処理を行うことは少ない
• 複雑な処理が面倒
– 大量のデータを処理するには、通常の
Excelの他に、 VBAやPower Quality、
Power Pivot など add-in の操作方法を
個別に習得する必要あり
長所
短所
• 複雑な処理が簡単に行える
– 大量なデータ処理を統一的な操作で
Excel (VBA)より高速に実行可能
• システム開発において中心的な存在
– 金融分野におけるアルゴリズム構築な
どでもメインで用いられている
• 簡単な計算の実行や視覚化に優れる
– 組み込み関数やグラフの描画法が豊富
• 何より慣れている
– Excel関連の技術を時間をかけて磨かれ
た方も多いはず
6
Pythonとは ?
Technology has become a major asset for almost any financial institution
around the globe, having the potential to lead to competitive advantages as
well as disadvantages. -Finance for Python-
• Data processing: It does not suffice to consider and process end-of-day quotes;
“too much” happens during the day for some instruments during 24/7 (Big data)
• Analytics speed: Decisions often have to be made in milliseconds, making it
necessary to build the respective analytics capabilities and to analyze large
amounts of data in real time.
• Theoretical foundations: For the millisecond scales important as of today,
consistent concepts and theories that have proven to be somewhat robust over
time are still missing.
• Cf. https://www.ft.com/content/4c17d6ce-c8b2-11e8-ba8f-ee390057b8c9
• Cf. Indeed: https://www.indeed.com/q-Python-Financial-jobs.html
7
■ Black-Litterman Model とは (1)
• 平均分散法 (Modern Portfolio Theory, MPT) ポートフォリオ理論における数理的
モデルで、所与のリスクの下で期待リターンを最大化する最適化問題に帰着
• BLモデルは平均分散法における困難、すなわち個別銘柄の期待値とリスクの推
定にかかる問題を克服することに成功
• 導出された最適なウェイトtはマーケット・ポートフォリオに投資家のviewを混
合したものになっている
• BLモデルは、より多様な資産を含み、それらの資産に対してマーケットポート
フ ォリオに準じた配分(=投資家の直感にあう配分)が行われる
Black-Litterman Model を実装してみよう!
8
■ Black-Litterman Model とは (2)
Black-Litterman Model を実装してみよう!
最適資産配分
Market Portfolio 資産配分
期待分散
期待均衡リターン
期待リターン
(期待分散)
過去のデータ
平
均
分
散
法
投資家Viewをブレンド
Market Portfolio 資産配分が
最適資産配分だと仮定
通常の平均分散法
BL モデル
*数字はBLモデルの実行手順
③
②
①
9
Black-Litterman Model を実装してみよう!
後ろ向き最適化
• 各銘柄の時価総額に応じたweightと、過去のデータから各銘柄の分
散を計算 (今回は終値に応じて毎日算出)
投資家のviewを織り込んだ均衡リターンを計算
• Step1の結果と投資家のviewを表すパラメータを用いて均衡リターン
を計算
新しい最適化問題を解く(平均分散法)
• ここからは通常の平均分散方法
取引戦略の実装
• 算出された最適なweightが保持されるような売買戦略を実装
Step 1
Step 2
Step 3
Step 4
■ BL Model のアルゴリズム
10
■ QuantX上の実装結果: Core30
• 実際にアルゴリズムを見てみよう!
URL: https://factory.quantx.io/developer/1939fbe747c94440a9cb1cfa8ea88129
• 投資家のViewについて補足
• 詳しい導出式は Appendix 、あるいは参考文献の [7] か [8] を参照のこと
Black-Litterman Model を実装してみよう!
11
Reference
12
[1] Fischer Black and Robert Litterman. (1992) “Global Portfolio Optimization”, Financial Analysts
Journal, Vol. 48, No. 5, pp. 28-43.
[2] Guangliang He and Robert Litterman. (1999) “The Intuition Behind Black-Litterman Model
Portfolios", Goldman Sachs Investment Management Research.
[3] Harry Markowitz. (1952) "Portfolio Selection", The Journal of Finance, Vol. 7, No. 1, pp. 77-91,
[4] William F. Sharpe, “Capital Asset Prices: A Theory of Market Equilibrium under Conditions of Risk”,
The Journal of Finance, Vol. 19, No. 3, pp. 425-442, 1964.
[5] Benninga, Simon (2008): Financial modeling, 3rd ed. MIT Press.
[6] @nokomitch (2016) 「ブラック・リッターマンモデルによる資産配分を解説してみる」
(URL: https://qiita.com/nokomitch/items/0d1812763114e6266bf3)
[7] @ropomopo (2019) 「QuantXでBlack-Litterman Modelを実装してみた」*弊社インターン生
(URL: https://qiita.com/ropomopo/private/0e250697d91b3b74cbf9 )
Reference
13
Appendix
14
■ Details of Black-Litterman Model (1)
Appendix 1
15
■ Details of Black-Litterman Model (2)
Appendix 1
16
■ Details of Black-Litterman Model (3)
Appendix 1
17
■ Details of Black-Litterman Model (4)
Appendix 1

More Related Content

Similar to Presen 190517

すくすくスクラム要求開発入門(公開用).Key
すくすくスクラム要求開発入門(公開用).Keyすくすくスクラム要求開発入門(公開用).Key
すくすくスクラム要求開発入門(公開用).KeyEiichi Hayashi
 
SIにおけるプロジェクトとプロマネ
SIにおけるプロジェクトとプロマネSIにおけるプロジェクトとプロマネ
SIにおけるプロジェクトとプロマネTakesato Nigorikawa
 
S06 t1 python学習奮闘記#4
S06 t1 python学習奮闘記#4S06 t1 python学習奮闘記#4
S06 t1 python学習奮闘記#4Takeshi Akutsu
 
動的最適化の今までとこれから
動的最適化の今までとこれから動的最適化の今までとこれから
動的最適化の今までとこれからKazuki Baba
 
Machine Learning Bootstrap
Machine Learning BootstrapMachine Learning Bootstrap
Machine Learning BootstrapTakahiro Kubo
 
「概念モデリング自動化に向けた第一歩」 ~ ChatGPT・Open AI 活用による開発対象のモデル化
「概念モデリング自動化に向けた第一歩」 ~ ChatGPT・Open AI 活用による開発対象のモデル化「概念モデリング自動化に向けた第一歩」 ~ ChatGPT・Open AI 活用による開発対象のモデル化
「概念モデリング自動化に向けた第一歩」 ~ ChatGPT・Open AI 活用による開発対象のモデル化Knowledge & Experience
 
Pythonで機械学習をやってみる(bizpy 1/19 2022)
Pythonで機械学習をやってみる(bizpy 1/19 2022)Pythonで機械学習をやってみる(bizpy 1/19 2022)
Pythonで機械学習をやってみる(bizpy 1/19 2022)Hirofumi Watanabe
 
第15回ピク活IT勉強会 ピクト図解入門(01 ピクト図解入門 20140328_公開用)
第15回ピク活IT勉強会 ピクト図解入門(01 ピクト図解入門 20140328_公開用)第15回ピク活IT勉強会 ピクト図解入門(01 ピクト図解入門 20140328_公開用)
第15回ピク活IT勉強会 ピクト図解入門(01 ピクト図解入門 20140328_公開用)Hidehiko Akasaka
 
140928 競争優位を築くため「ビジネスモデル」
140928 競争優位を築くため「ビジネスモデル」140928 競争優位を築くため「ビジネスモデル」
140928 競争優位を築くため「ビジネスモデル」Kenichi Takara
 
[DLゼミ] Learning agile and dynamic motor skills for legged robots
[DLゼミ] Learning agile and dynamic motor skills for legged robots[DLゼミ] Learning agile and dynamic motor skills for legged robots
[DLゼミ] Learning agile and dynamic motor skills for legged robotsharmonylab
 
Mirai carved out by innovations
Mirai carved out by innovationsMirai carved out by innovations
Mirai carved out by innovationsOsaka University
 
ChatGPTの驚くべき対話能力 20230414APR.pdf
ChatGPTの驚くべき対話能力 20230414APR.pdfChatGPTの驚くべき対話能力 20230414APR.pdf
ChatGPTの驚くべき対話能力 20230414APR.pdfYamashitaKatsushi
 
Sano tokyowebmining 36_20140526
Sano tokyowebmining 36_20140526Sano tokyowebmining 36_20140526
Sano tokyowebmining 36_20140526Masakazu Sano
 
機械学習ゴリゴリ派のための数学とPython
機械学習ゴリゴリ派のための数学とPython機械学習ゴリゴリ派のための数学とPython
機械学習ゴリゴリ派のための数学とPythonKimikazu Kato
 
Machine learning microservice_management
Machine learning microservice_managementMachine learning microservice_management
Machine learning microservice_managementyusuke shibui
 
Machine learning 15min TensorFlow hub
Machine learning 15min TensorFlow hubMachine learning 15min TensorFlow hub
Machine learning 15min TensorFlow hubJunya Kamura
 
20171015 mosa machine learning
20171015 mosa machine learning20171015 mosa machine learning
20171015 mosa machine learningMuneyoshi Benzaki
 

Similar to Presen 190517 (20)

すくすくスクラム要求開発入門(公開用).Key
すくすくスクラム要求開発入門(公開用).Keyすくすくスクラム要求開発入門(公開用).Key
すくすくスクラム要求開発入門(公開用).Key
 
SIにおけるプロジェクトとプロマネ
SIにおけるプロジェクトとプロマネSIにおけるプロジェクトとプロマネ
SIにおけるプロジェクトとプロマネ
 
Why python
Why pythonWhy python
Why python
 
S06 t1 python学習奮闘記#4
S06 t1 python学習奮闘記#4S06 t1 python学習奮闘記#4
S06 t1 python学習奮闘記#4
 
動的最適化の今までとこれから
動的最適化の今までとこれから動的最適化の今までとこれから
動的最適化の今までとこれから
 
Machine Learning Bootstrap
Machine Learning BootstrapMachine Learning Bootstrap
Machine Learning Bootstrap
 
「概念モデリング自動化に向けた第一歩」 ~ ChatGPT・Open AI 活用による開発対象のモデル化
「概念モデリング自動化に向けた第一歩」 ~ ChatGPT・Open AI 活用による開発対象のモデル化「概念モデリング自動化に向けた第一歩」 ~ ChatGPT・Open AI 活用による開発対象のモデル化
「概念モデリング自動化に向けた第一歩」 ~ ChatGPT・Open AI 活用による開発対象のモデル化
 
Pythonで機械学習をやってみる(bizpy 1/19 2022)
Pythonで機械学習をやってみる(bizpy 1/19 2022)Pythonで機械学習をやってみる(bizpy 1/19 2022)
Pythonで機械学習をやってみる(bizpy 1/19 2022)
 
第15回ピク活IT勉強会 ピクト図解入門(01 ピクト図解入門 20140328_公開用)
第15回ピク活IT勉強会 ピクト図解入門(01 ピクト図解入門 20140328_公開用)第15回ピク活IT勉強会 ピクト図解入門(01 ピクト図解入門 20140328_公開用)
第15回ピク活IT勉強会 ピクト図解入門(01 ピクト図解入門 20140328_公開用)
 
140928 競争優位を築くため「ビジネスモデル」
140928 競争優位を築くため「ビジネスモデル」140928 競争優位を築くため「ビジネスモデル」
140928 競争優位を築くため「ビジネスモデル」
 
smarttrade勉強会
smarttrade勉強会smarttrade勉強会
smarttrade勉強会
 
[DLゼミ] Learning agile and dynamic motor skills for legged robots
[DLゼミ] Learning agile and dynamic motor skills for legged robots[DLゼミ] Learning agile and dynamic motor skills for legged robots
[DLゼミ] Learning agile and dynamic motor skills for legged robots
 
Mirai carved out by innovations
Mirai carved out by innovationsMirai carved out by innovations
Mirai carved out by innovations
 
ChatGPTの驚くべき対話能力 20230414APR.pdf
ChatGPTの驚くべき対話能力 20230414APR.pdfChatGPTの驚くべき対話能力 20230414APR.pdf
ChatGPTの驚くべき対話能力 20230414APR.pdf
 
Why python
Why pythonWhy python
Why python
 
Sano tokyowebmining 36_20140526
Sano tokyowebmining 36_20140526Sano tokyowebmining 36_20140526
Sano tokyowebmining 36_20140526
 
機械学習ゴリゴリ派のための数学とPython
機械学習ゴリゴリ派のための数学とPython機械学習ゴリゴリ派のための数学とPython
機械学習ゴリゴリ派のための数学とPython
 
Machine learning microservice_management
Machine learning microservice_managementMachine learning microservice_management
Machine learning microservice_management
 
Machine learning 15min TensorFlow hub
Machine learning 15min TensorFlow hubMachine learning 15min TensorFlow hub
Machine learning 15min TensorFlow hub
 
20171015 mosa machine learning
20171015 mosa machine learning20171015 mosa machine learning
20171015 mosa machine learning
 

Presen 190517

  • 1. Hikaru Mizuno, Intern at Smart Trade Inc. May 2019 Python for Finance
  • 2. 2 Pythonとは ? (6 mins)  Pythonの趨勢  特徴と主な活用領域  何がエクセルより優れているか ?  金融機関におけるPythonの活用 Black-Litterman Model を実装してみよう! (10 mins)  Black-Litterman Model とは  BL Model のアルゴリズム  QuantX上での実装結果  演習 付録  Details of BL Model Table of Contents
  • 3. 3 Pythonとは ? Popularity of Python: Growth of major programming languages Sorce: https://stackoverflow.blog/2017/09/06/incredible-growth-python/
  • 5. 5 Pythonとは ? ExcelPython • 初期参入の心理的コストが高い – プログラミングというと腰がひける(?) • 操作が(相対的に)直感的でない – Excelのように常にデータを目で確認し ながら個別に処理を行うことは少ない • 複雑な処理が面倒 – 大量のデータを処理するには、通常の Excelの他に、 VBAやPower Quality、 Power Pivot など add-in の操作方法を 個別に習得する必要あり 長所 短所 • 複雑な処理が簡単に行える – 大量なデータ処理を統一的な操作で Excel (VBA)より高速に実行可能 • システム開発において中心的な存在 – 金融分野におけるアルゴリズム構築な どでもメインで用いられている • 簡単な計算の実行や視覚化に優れる – 組み込み関数やグラフの描画法が豊富 • 何より慣れている – Excel関連の技術を時間をかけて磨かれ た方も多いはず
  • 6. 6 Pythonとは ? Technology has become a major asset for almost any financial institution around the globe, having the potential to lead to competitive advantages as well as disadvantages. -Finance for Python- • Data processing: It does not suffice to consider and process end-of-day quotes; “too much” happens during the day for some instruments during 24/7 (Big data) • Analytics speed: Decisions often have to be made in milliseconds, making it necessary to build the respective analytics capabilities and to analyze large amounts of data in real time. • Theoretical foundations: For the millisecond scales important as of today, consistent concepts and theories that have proven to be somewhat robust over time are still missing. • Cf. https://www.ft.com/content/4c17d6ce-c8b2-11e8-ba8f-ee390057b8c9 • Cf. Indeed: https://www.indeed.com/q-Python-Financial-jobs.html
  • 7. 7 ■ Black-Litterman Model とは (1) • 平均分散法 (Modern Portfolio Theory, MPT) ポートフォリオ理論における数理的 モデルで、所与のリスクの下で期待リターンを最大化する最適化問題に帰着 • BLモデルは平均分散法における困難、すなわち個別銘柄の期待値とリスクの推 定にかかる問題を克服することに成功 • 導出された最適なウェイトtはマーケット・ポートフォリオに投資家のviewを混 合したものになっている • BLモデルは、より多様な資産を含み、それらの資産に対してマーケットポート フ ォリオに準じた配分(=投資家の直感にあう配分)が行われる Black-Litterman Model を実装してみよう!
  • 8. 8 ■ Black-Litterman Model とは (2) Black-Litterman Model を実装してみよう! 最適資産配分 Market Portfolio 資産配分 期待分散 期待均衡リターン 期待リターン (期待分散) 過去のデータ 平 均 分 散 法 投資家Viewをブレンド Market Portfolio 資産配分が 最適資産配分だと仮定 通常の平均分散法 BL モデル *数字はBLモデルの実行手順 ③ ② ①
  • 9. 9 Black-Litterman Model を実装してみよう! 後ろ向き最適化 • 各銘柄の時価総額に応じたweightと、過去のデータから各銘柄の分 散を計算 (今回は終値に応じて毎日算出) 投資家のviewを織り込んだ均衡リターンを計算 • Step1の結果と投資家のviewを表すパラメータを用いて均衡リターン を計算 新しい最適化問題を解く(平均分散法) • ここからは通常の平均分散方法 取引戦略の実装 • 算出された最適なweightが保持されるような売買戦略を実装 Step 1 Step 2 Step 3 Step 4 ■ BL Model のアルゴリズム
  • 10. 10 ■ QuantX上の実装結果: Core30 • 実際にアルゴリズムを見てみよう! URL: https://factory.quantx.io/developer/1939fbe747c94440a9cb1cfa8ea88129 • 投資家のViewについて補足 • 詳しい導出式は Appendix 、あるいは参考文献の [7] か [8] を参照のこと Black-Litterman Model を実装してみよう!
  • 12. 12 [1] Fischer Black and Robert Litterman. (1992) “Global Portfolio Optimization”, Financial Analysts Journal, Vol. 48, No. 5, pp. 28-43. [2] Guangliang He and Robert Litterman. (1999) “The Intuition Behind Black-Litterman Model Portfolios", Goldman Sachs Investment Management Research. [3] Harry Markowitz. (1952) "Portfolio Selection", The Journal of Finance, Vol. 7, No. 1, pp. 77-91, [4] William F. Sharpe, “Capital Asset Prices: A Theory of Market Equilibrium under Conditions of Risk”, The Journal of Finance, Vol. 19, No. 3, pp. 425-442, 1964. [5] Benninga, Simon (2008): Financial modeling, 3rd ed. MIT Press. [6] @nokomitch (2016) 「ブラック・リッターマンモデルによる資産配分を解説してみる」 (URL: https://qiita.com/nokomitch/items/0d1812763114e6266bf3) [7] @ropomopo (2019) 「QuantXでBlack-Litterman Modelを実装してみた」*弊社インターン生 (URL: https://qiita.com/ropomopo/private/0e250697d91b3b74cbf9 ) Reference
  • 14. 14 ■ Details of Black-Litterman Model (1) Appendix 1
  • 15. 15 ■ Details of Black-Litterman Model (2) Appendix 1
  • 16. 16 ■ Details of Black-Litterman Model (3) Appendix 1
  • 17. 17 ■ Details of Black-Litterman Model (4) Appendix 1