本测试旨在重现一套比较简单且完备的量化框架,该框架基于现代投资组合理论,并应用主流的机器学习算法(SVM)进行分析。 旨在初步形成一个量化投资的思路,辅助构建科学合理的投资策略。
- SQL Queries
- Initial Capital of Loopback Test (optional, default = 1 M)
- Stock Pool
- Base Stock Index
- Interval of Loopback Test
- Windows of Preproession (optional, default = 365)
- Windows of Loopback Trainning Test (optional, default = 90)
- Windows of Loopack Portfolio (optional, default = year)
- Change Frequency of Portfolio (optional, default =5)
$ python Init_StockALL_Sp.py
$ python stock_index_pro.py
$ python main_pro.py
- Daily Trading Data in Stock Pool and Base Index
- Result of SVM Model Evaluation
- The Capital Situation during Loopback Test
- The Stocks Holding in Last Loopback Test Day
- Effect Index of Quantization
- Visualization of Return and Withdrawal
测试使用的Python版本:3.6.8
测试使用的Anaconda版本:1.9.6
$ pip install tushare
$ pip install tushare --upgrade
import tushare as ts
tushare版本需大于1.2.10
ts.set_token('your token')
完成调取tushare数据凭证的设置,通常只需要设置一次
pro = ts.pro_api()
# 或者在初始化中直接设置token
pro = ts.pro_api('your token')
pro.daily() # 获取日K数据(未赋权)
pro.index_daily() # 获取指数行情
pro.trade_cal() # 获取交易日历
import datetime
import pymysql.cursors
import sqlalchemy
import numpy as np
import pandas as pd
from sklearn import svm
import pylab as *
import math