Python for Quant Trading
【Python程式交易入門】學用python投資 | 從0開始安裝 | 制定不同投資交易策略 | 嘗試各類回測 | 量化交易增加利潤省氣省力
Estimated read time: 1:20
Summary
This video introduces Python as a powerful, low-cost way to get started with quantitative trading and investing. The creator explains why traditional platforms like MultiCharts, MT4, and XQ can be expensive, limited, or hard to customize, especially for machine learning and multi-strategy workflows. Python stands out because it is free, beginner-friendly, and flexible enough to handle backtesting, data analysis, automation, web scraping, and machine learning. The video also highlights how computer-based backtesting can reduce hesitation and help investors test ideas objectively across many stocks and different parameter settings. It then walks through installing Python using Anaconda, choosing a stable version, and opening Jupyter Notebook to verify everything works with simple commands. The overall message is to learn by doing: build practical projects first, then understand the theory later.
Highlights
- The video explains why Python is a great choice for modern investing and trading 🚀
- Traditional trading platforms may be useful, but they can be costly and difficult to customize 🧱
- Python can automate repetitive tasks like downloading stock data or collecting information online 🤖
- Backtesting lets you compare different strategy rules instead of guessing what works 📈
- Anaconda is introduced as an easy way to install Python and essential libraries all at once 📦
- Jupyter Notebook is used to test Python with simple examples like 1+1 and print('hi') 💻
- The creator encourages viewers to learn by building practical projects first, not by memorizing theory 📚
Key Takeaways
- Python gives traders a free, flexible, and powerful way to build custom strategies without being locked into expensive software 💸
- Backtesting helps you test ideas objectively, reduce fear, and compare strategy performance across many stocks and settings 📊
- Simple changes like moving averages or overbought/oversold thresholds can dramatically affect results, so testing matters a lot 🧪
- Anaconda makes Python setup easier by bundling useful tools and libraries into one beginner-friendly package 🧰
- Jupyter Notebook is a great place to start because you can run small Python commands immediately and confirm your installation works ✅
- The creator recommends learning in a practical, hands-on way: try real tasks first, then study the theory afterward 🛠️
Overview
The video opens by asking why investors should learn computer-based trading and what advantages it brings in today’s information-heavy market. It compares common platforms such as MultiCharts, MT4, and XQ, noting that while they are useful, they can be expensive, less flexible, or not well suited for newer approaches like machine learning. Python is presented as the answer because it is free, simple to learn, and powerful enough to handle many modern investing tasks.
A big focus of the video is backtesting. The creator explains that investors often hesitate before placing trades, but testing a strategy on historical data can build confidence and reveal whether an idea actually works. The video gives examples like golden cross strategies and stochastic overbought/oversold rules, showing how different parameters can lead to very different outcomes. It also highlights how Python can process huge amounts of stock data far more efficiently than doing everything by hand.
The latter part of the video shifts into setup and learning strategy. It demonstrates how to install Python through Anaconda, choose a stable version, and open Jupyter Notebook to run basic commands. It also introduces useful libraries for data analysis, visualization, web scraping, and machine learning. The final advice is to learn in reverse: start with practical coding tasks, use them to get results quickly, and only then dig into the theory behind the code.
Chapters
- 00:00 - 02:30: Why Learn Python for Quantitative Trading This chapter explains why learning Python is valuable for quantitative trading. It contrasts Python with existing trading platforms such as Multicharts, MT4, and XQ, noting that while these systems are useful, they are often costly, less flexible, and harder to adapt to newer approaches like machine learning. Python is presented as a free, simple, and powerful language that can do in a few lines what may take hundreds elsewhere, helping traders save time and money while gaining access to a wide range of free machine learning and data analysis tools.
- 02:30 - 05:00: Limits of Traditional Trading Platforms and the Power of Python This chapter contrasts traditional trading ideas with the reality of testing strategies in practice. It questions whether signals like golden cross or overbought/oversold levels actually work, and emphasizes that without backtesting, traders cannot know if a strategy is effective. It also argues that changing common thresholds, such as from 80/20 to 70/30, could lead to very different outcomes, showing why understanding the results of a strategy matters before using it.
- 05:00 - 07:30: Testing Trading Ideas with Backtests This segment explains how to choose a stable Anaconda installation, recommending an older archive version instead of the newest release to avoid bugs, and warning users not to accidentally download Anaconda2 when the course uses Anaconda3. It then walks through the Anaconda Navigator and its environments, introducing common libraries as prebuilt code for specific tasks such as BeautifulSoup for web scraping, NumPy and Pandas for data analysis, Matplotlib for visualization, and TensorFlow for machine learning. The speaker shows how to install missing libraries through the environment manager, then moves into Jupyter Notebook, creating a new Python 3 notebook and running simple commands like 1+1 and print('hi') to confirm that the installation works. Finally, the speaker criticizes theory-heavy learning for beginners and argues for reverse learning, where students start with practical applications to stay motivated and understand why the tools matter.
- 07:30 - 09:00: Installing Anaconda and Setting Up the Python Environment This segment encourages a practical, hands-on approach: copy the code, run it on your own computer, and complete the task first, then come back to understand why the code works that way. The speaker says this method is more realistic and easier to remember. The segment ends with a channel promotion, inviting viewers interested in finance, investing, and self-improvement to subscribe and enable all notifications so they do not miss future videos.
- 09:00 - 10:00: Jupyter Notebook, Libraries, and a Practical Learning Approach The speaker recommends a practical, hands-on learning style: copy some code, run it on your own computer, and complete something useful first, even if you do not fully understand the code yet. After it works, go back and learn why it works, because this approach is more concrete, easier to remember, and more effective for learning. The segment ends with a brief channel promotion encouraging viewers interested in finance, investing, and self-improvement to subscribe and enable all notifications.
【Python程式交易入門】學用python投資 | 從0開始安裝 | 制定不同投資交易策略 | 嘗試各類回測 | 量化交易增加利潤省氣省力 Transcription
- Segment 1: 00:00 - 02:30 這裡是一必學 今天的話題是量化交易 你為什麼要學用電腦投資呢 學了有什麼好處 在這個資訊發達的年代 怎樣不被市場淘汰呢 現在市面上有很多的回測 或量化交易的系統 比如股票和期貨為主的Multicharts 外匯為主的MT4 台股為主的XQ 雖然這些系統都有優點 不過大部分是要付費的 有人可能會說 MT4 不用錢呀 是的 不過程式碼很複雜 只是寫一個簡單的策略 可能需要半天 還有就是商用軟體自由度不夠 如果你想要利用機器學習策略 那使用這些付費軟體是非常難的 因為程式都已經包裝好了 可以用的都是現成的 沒辦法跟上最新的功能 還有 因為這些軟體都是針對不同的東西 要將多個策略整合 是有難度的 那究竟怎樣可以不用花錢 擁有最新的功能 有最高的自由度呢 由於機器學習 資料分析的崛起 Python 是其中一個最大的受惠者 那什麼是Python呢 Python 就是跟電腦溝通的語言 例如你跟人溝通 可以學英語 中文 日語等等 電腦語言也有很多種 那為什麼要選python呢 原因是簡單易學 功能強大 可以短短幾行代碼 就完成其他需要數百行 可以節省很多時間 而且每個月可以省錢 累積起來也不少 除了程式語言是免費 還有非常多機器學習演算法 都是免費的 我相信很多有投資或交易過的朋友都遇到過一個問題 就是快要下單的時候想東想西
- Segment 2: 00:00 - 02:30 猶豫 害怕 跟本不肯定要不要買 如果你懂得用電腦回測 不但可以為你增加信心 而且可以分析幾百 什至幾千隻股票 用人手是做不到的 例如經常有人說黃金交叉 如果每次有黃金交叉 我就入市 結果是怎樣呢? 為什麼麼一定要50和200天線呢 如果我把50和200天線改為60和180
- Segment 3: 02:30 - 05:00 結果會是怎樣呢? 在指數的黃金交叉 跟個別股票的黃金交叉有沒有區別呢 如果有學過技術分析的朋友 應該會知道隨機指標 超買超賣 這些聽起來好像很管用 但理論歸理論 實際是不一樣的 如果每次超買就賣 超賣我就買 結果是怎樣呢? 傳統用 80/20 超買賣區 如果改為70/30 又會是怎樣呢? 我相信很多人是不知道的 如果你跟本不了解你的策略 不知道什麼方法是不行的 怎樣找到可行的方法呢 怎樣可以在市場賺到錢 最後 Python除了拿來投資 還有非常多的功能 例如如果你想在ig 下載別人的照片 可能只能下載幾張 如果這個人有很多 而你想下載所有的 肯定花幾天也不行 用電腦的好處就是幫你重複做大量工作 另一個例子是如果你想下載一些股票的過去價格 如果你沒有付費 就只能在類似yahoo的網頁下載 不過有一個很大的問題就是 如果你只下載一兩隻就可以 如果你追蹤指數 例如恆生指數 就有三十幾隻股票 如果你人手下載 你就重複這個動作幾十次 肯定會 煩死 但是如果懂得用python 其實只需要寫幾句代碼 就可以幫你下載幾十 什至幾千股票的股價 好了 如果你現在還在看 應該對學習python有興趣的 我們現在就下載相關的軟體吧 現在會示範怎樣從零開始安裝Python 我們可以在 google 輸入Anaconda 然後頭幾個就是 進入它的網頁 這個Anaconda 就像一個懶人包 預設了很多有用的工具 可以方便我們不用分開安裝
- Segment 4: 02:30 - 05:00 你可以按 download 然後選擇windows Mac 或linux 你可以看到這裡是3.8 是最新的版本 但是我個人不用最新的 因為個人經驗
- Segment 5: 05:00 - 07:30 最新版本經常有bug 我會直接去它的archive 下載沒有那麼新 但是又不是很舊的版本 我現在是用2019 03 這個版本 如果你是在這裡下載就要小心 別下載了 anaconda2 我們是用anaconda3 安裝完以後可以打開 anaconda navigator 可以看到這幾個已經安裝 這幾個就沒有 在軟體方面 最主要會用這幾個 如果去 environment 你會看到有一大堆東西 這些叫library 就像你在 windows 要畫畫就會用paint 打字就用 word 這些library 就是一些很會編程的人 預先針對性寫好一些代碼給我們用 例如爬蟲 把你在網上看到的任何數字 文字 或者照片下自動下載出來 就用 beautifulsoup 資料分析 例如股票分析 市場營銷數據分析 就用 numpy pandas 資料視覺化就會用matplotlib 機器學習 預測股價 或者如果一個人去超市買牛奶 再會買糖果的機率有多高 就會用 tensorflow 如果遇到一些沒有的 可以直接選取或尋找 然後 apply 就可以在這裡直接下載 現在我們回去 home 然後打開 jupyter notebook 這裡是你自己電腦裡的 folder 你可以按 new 然後按python3 然後就會到達這個板面 在這裡你可以做一些簡單的算術 例如我打 1+1 按這裡 或者 shift+enter
- Segment 6: 05:00 - 07:30 你就會看到output 是2 print(‘hi’) 它會顯示hi 就代表你安裝成功 很多人剛開始學 都會學很多理論方面的基本東西 但是有一個題問就是很無聊 不知道用來干嘛 很快就會失去興趣 所以我會主張反向學習
- Segment 7: 07:30 - 10:00 就是先做一些務實 實用的東西 首先複制一些代碼 然後在你自己的電腦跑 去完成一些東西 不用解理是那些代碼 然後跑完了 再去理解為什麼要這樣做 這樣可能會比較實在 容易記得 最後 如果你對金融投資 自我提升的內容有興趣 記得訂閱這個頻道 然後按小鈴鐺選所有 就不會錯過任何影片