隨著資料科學與人工智慧的迅速發展,量化交易逐漸成為主流的投資方式。然而,現有的量化交易系統在應對多變的金融市場時存在一定的局限性。本研究旨在結合Python與Cython開發一個自動化股票回測平台,結合分位數迴歸模型,比較不同因子在不同回報分位數的影響效果,從而優化因子選擇的過程。透過分位數迴歸,可以對每個因子在不同回報分位數下的表現進行評估,並確定最適合的分位數,從而提高選擇因子的準確性和穩健性。 系統架構由資料存取層、邏輯運算層和應用層組成,藉由資料存取層與資料庫串接存取資料,並交付給邏輯運算層中的回測模組進行運算,其中核心的backtest_core子模組負責核心回測運算,包括資金分配、手續費計算以及最終績效等等,此子模組由Python與Cython所開發,有效降低運算時間成本,最終將投資組合績效傳遞給應用層產出視覺化工具展示回測結果。 本研究實驗結果顯示,該系統能夠有效評估不同因子在台灣股票市場中的表現,並自動生成投資組合的收益與風險分布圖。實驗還驗證藉由分位數迴歸建構單因子選股模型的有效性,藉由選取影響係數絕對值越大之分位數能夠增加投資組合之CAGR並有效降低MDD。本實驗於分位數迴歸模型中引入時間與群數的交互項,以此觀察因子在不同時間窗格中的穩健性,最終得出若是交互項不顯著(p值大於0.05)則較不受時間之影響。 ;With the rapid advancement of data science and artificial intelligence, quantitative trading has gradually become a mainstream investment method. However, existing quantitative trading systems have certain limitations when coping with the volatile financial markets. This study aims to develop an automated stock backtesting platform using Python and Cython, integrating quantile regression models to compare the effects of different factors across various return quantiles, thereby optimizing the factor selection process. Through quantile regression, the performance of each factor can be evaluated at different return quantiles to determine the most appropriate quantile, thereby enhancing the accuracy and robustness of factor selection. The system architecture consists of three layers: data access layer, logic processing layer, and application layer. The data access layer interfaces with the database to retrieve data, which is then processed by the backtesting module in the logic processing layer. The core backtest_core submodule is responsible for the primary backtesting computations, including fund allocation, fee calculation, and final performance evaluation. This submodule is developed using Python and Cython, effectively reducing computational time costs. The performance results of the investment portfolio are then passed to the application layer to produce visual tools that display the backtesting results. The experimental results of this study indicate that the system can effectively evaluate the performance of different factors in the Taiwan stock market and automatically generate the return and risk distribution charts of the investment portfolio. The experiments also validate the effectiveness of constructing single-factor stock selection models using quantile regression. Selecting the quantile with the highest absolute value of the impact coefficient can increase the CAGR and effectively reduce the MDD of the investment portfolio. The experiments introduce an interaction term between time and group number into the quantile regression model to observe the robustness of factors across different time windows. The results show that if the interaction term is not significant (p-value greater than 0.05), the factor is less affected by time.