写在前面

上一篇我们介绍了Qlib的整体架构和核心概念。这篇教程,我们将动手实践,从零开始构建一个完整的量化策略。

你将学到

  • ✅ 搭建Qlib开发环境
  • ✅ 获取和准备股票数据
  • ✅ 构建预测模型(LightGBM)
  • ✅ 设计交易策略
  • ✅ 执行回测并分析结果
  • ✅ 优化策略参数

最终目标:构建一个能够预测沪深300成分股收益率的量化策略,并通过回测验证其有效性。


第一部分:环境搭建

1.1 创建虚拟环境

1
2
3
4
5
6
7
8
# 使用conda创建Python环境
conda create -n qlib python=3.10
conda activate qlib

# 或使用venv
python -m venv qlib_env
source qlib_env/bin/activate # Linux/Mac
# qlib_env\Scripts\activate # Windows

1.2 安装Qlib

1
2
3
4
5
6
7
# 方式1:通过pip安装(推荐)
pip install pyqlib

# 方式2:从源码安装(获取最新功能)
git clone https://github.com/microsoft/qlib.git
cd qlib
pip install -e .

1.3 验证安装

1
2
import qlib
print(qlib.__version__) # 应输出类似 0.9.x

1.4 安装可选依赖

1
2
3
4
5
6
7
8
# 如果要使用LightGBM模型
pip install lightgbm

# 如果要使用深度学习模型
pip install torch

# 如果要使用强化学习
pip install tianshou

第二部分:数据准备

2.1 下载内置数据

Qlib提供了中国A股市场的内置数据,一键下载:

1
2
3
4
5
6
7
import qlib
from qlib.data import D

# 下载并初始化数据
qlib.init(provider_uri='~/.qlib/qlib_data/cn_data')

# 如果数据不存在,会自动下载(约1分钟)

或者使用命令行:

1
2
# 下载沪深300数据
python -m qlib.run.get_data --target_dir ~/.qlib/qlib_data/cn_data --region cn

2.2 探索数据结构

1
2
3
4
5
6
7
8
9
10
11
12
13
from qlib.data import D
import pandas as pd

# 查看可用的股票池
print("可用市场:", D.list_market())

# 查看沪深300成分股
instruments = D.instruments(market="csi300")
print(f"沪深300成分股数量: {len(instruments)}")
print("前10只股票:", instruments[:10])

# 查看可用字段
print("可用字段:", D.list_features())

2.3 获取股票数据

1
2
3
4
5
6
7
8
9
10
# 获取单只股票的历史数据
stock_data = D.features(
instruments=["SH600519"], # 贵州茅台
fields=["$close", "$open", "$high", "$low", "$volume"],
start_time="2020-01-01",
end_time="2023-12-31",
freq="day"
)

print(stock_data.head())

输出示例:

1
2
3
4
5
                     $close    $open    $high     $low     $volume
instrument datetime
SH600519 2020-01-02 1180.00 1150.00 1190.00 1145.00 3520000
2020-01-03 1165.00 1180.00 1185.00 1160.00 2890000
...

2.4 使用表达式构建因子

Qlib支持类似SQL的表达式语法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 构建常用技术因子
factors = D.features(
instruments=["SH600519"],
fields=[
"$close", # 收盘价
"($close - $open) / $open", # 日内收益率
"($close - Ref($close, 1)) / Ref($close, 1)", # 日收益率
"Mean($close, 5)", # 5日均线
"Mean($close, 20)", # 20日均线
"Std($close, 20)", # 20日波动率
"($close - Mean($close, 20)) / Std($close, 20)", # 布林带位置
"Max($high, 20) / Min($low, 20)", # 20日振幅
],
start_time="2020-01-01",
end_time="2023-12-31"
)

print(factors.head())

2.5 准备训练数据集

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from qlib.data.dataset import DatasetH
from qlib.contrib.data.handler import Alpha158

# 数据处理器配置
handler_config = {
"start_time": "2010-01-01",
"end_time": "2023-12-31",
"fit_start_time": "2010-01-01",
"fit_end_time": "2018-12-31",
"instruments": "csi300", # 沪深300
}

# 创建数据集
dataset = DatasetH(
handler={
"class": "Alpha158",
"module_path": "qlib.contrib.data.handler",
"kwargs": handler_config,
},
segments={
"train": ("2010-01-01", "2018-12-31"),
"valid": ("2019-01-01", "2020-12-31"),
"test": ("2021-01-01", "2023-12-31"),
},
)

# 查看数据集信息
train_data = dataset.prepare("train")
print(f"训练集形状: {train_data[0].shape}") # 特征
print(f"标签形状: {train_data[1].shape}") # 标签

第三部分:模型训练

3.1 配置LightGBM模型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from qlib.contrib.model.gbdt import LGBModel

# 模型配置
model = LGBModel(
loss="mse", # 均方误差损失
colsample_bytree=0.8, # 特征采样比例
learning_rate=0.05, # 学习率
subsample=0.8, # 样本采样比例
lambda_l1=0.0, # L1正则化
lambda_l2=0.0, # L2正则化
max_depth=6, # 树的最大深度
num_leaves=50, # 叶子节点数
num_threads=4, # 并行线程数
early_stopping_rounds=50,
num_boost_round=1000,
)

3.2 训练模型

1
2
3
4
5
6
7
8
9
10
11
12
13
from qlib.workflow import R

# 开始实验
with R.start(experiment_name="lgb_csi300"):
# 训练模型
model.fit(dataset)

# 保存模型
R.save_objects(trained_model=model)

# 记录实验ID
recorder = R.get_recorder()
print(f"实验ID: {recorder.id}")

训练过程输出:

1
2
3
4
5
[LightGBM] [Info] Start training...
[LightGBM] [Info] Iteration: 100, loss: 0.001234
[LightGBM] [Info] Iteration: 200, loss: 0.000987
...
[LightGBM] [Info] Training finished

3.3 模型预测

1
2
3
4
5
# 在测试集上预测
predictions = model.predict(dataset)

# 查看预测结果
print(predictions.head())

输出示例:

1
2
3
4
5
6
instrument  datetime
SH000001 2021-01-04 0.002345
2021-01-05 0.001234
SH000002 2021-01-04 -0.000567
...
Name: score, dtype: float64

3.4 查看特征重要性

1
2
3
4
5
6
7
8
9
10
11
12
13
import matplotlib.pyplot as plt

# 获取特征重要性
importance = model.get_feature_importance()

# 绘制Top 20特征
top_20 = importance.sort_values(ascending=False).head(20)
top_20.plot(kind='barh', figsize=(10, 8))
plt.title('Top 20 Feature Importance')
plt.xlabel('Importance')
plt.tight_layout()
plt.savefig('feature_importance.png')
plt.show()

第四部分:策略设计

4.1 理解预测分数

Qlib的预测分数代表股票的预期收益率排序

  • 正分数:预期上涨
  • 负分数:预期下跌
  • 分数越高:预期涨幅越大

4.2 TopkDropout策略原理

我们使用经典的TopkDropout策略

1
2
3
4
5
6
每个交易日:
1. 根据预测分数对所有股票排序
2. 选择分数最高的topk只股票
3. 卖出不在topk中的持仓
4. 买入新进入topk的股票
5. 每期替换n_drop只表现最差的股票

4.3 策略配置

1
2
3
4
5
6
7
8
from qlib.contrib.strategy import TopkDropoutStrategy

# 策略配置
strategy = TopkDropoutStrategy(
topk=30, # 持仓30只股票
n_drop=3, # 每期替换3只
signal=predictions, # 预测信号
)

4.4 自定义策略(进阶)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from qlib.strategy.base import BaseStrategy
from qlib.backtest.decision import Order, OrderDir

class MyCustomStrategy(BaseStrategy):
"""自定义策略:结合预测分数和动量因子"""

def __init__(self, topk=30, n_drop=3, signal=None):
self.topk = topk
self.n_drop = n_drop
self.signal = signal

def generate_trade_decision(self, execute_result=None):
"""
生成交易决策
"""
# 获取当前预测分数
pred_score = self.signal

# 获取动量因子
momentum = D.features(
instruments=D.instruments(market="csi300"),
fields=["($close - Ref($close, 20)) / Ref($close, 20)"],
start_time=self.trade_calendar.get_trade_step(),
end_time=self.trade_calendar.get_trade_step(),
)

# 综合打分
combined_score = pred_score * 0.7 + momentum * 0.3

# 选股逻辑
top_stocks = combined_score.nlargest(self.topk)

# 生成订单
orders = []
for stock in top_stocks.index:
orders.append(Order(
stock_id=stock,
amount=100, # 买入100股
direction=OrderDir.BUY
))

return orders

第五部分:回测验证

5.1 配置回测环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from qlib.backtest import backtest, executor

# 回测配置
backtest_config = {
"start_time": "2021-01-01",
"end_time": "2023-12-31",
"account": 10000000, # 初始资金1000万
"benchmark": "SH000300", # 基准:沪深300
"exchange_kwargs": {
"freq": "day",
"limit_threshold": 0.095, # 涨跌停限制
"deal_price": "vwap", # 成交价格
"open_cost": 0.0003, # 开仓成本0.03%
"close_cost": 0.0013, # 平仓成本0.13%
"min_cost": 5, # 最小手续费5元
},
}

# 执行器配置
executor_obj = executor.SimulatorExecutor(
time_per_step="day",
generate_portfolio_metrics=True,
)

5.2 执行回测

1
2
3
4
5
6
7
8
9
# 执行回测
portfolio_metric_dict, indicator_dict = backtest(
executor=executor_obj,
strategy=strategy,
**backtest_config
)

# 获取回测结果
report, positions = portfolio_metric_dict.get("day")

5.3 分析回测结果

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from qlib.contrib.evaluate import risk_analysis
import pandas as pd

# 计算各项指标
def analyze_results(report):
"""分析回测结果"""

# 策略收益
strategy_return = report["return"]
# 基准收益
bench_return = report["bench"]
# 交易成本
cost = report["cost"]

# 超额收益(不含成本)
excess_return_no_cost = strategy_return - bench_return

# 超额收益(含成本)
excess_return_with_cost = strategy_return - bench_return - cost

# 风险分析
analysis = {
"策略收益": risk_analysis(strategy_return, freq="day"),
"基准收益": risk_analysis(bench_return, freq="day"),
"超额收益(不含成本)": risk_analysis(excess_return_no_cost, freq="day"),
"超额收益(含成本)": risk_analysis(excess_return_with_cost, freq="day"),
}

return pd.DataFrame(analysis).T

# 执行分析
analysis_df = analyze_results(report)
print(analysis_df)

5.4 关键指标解读

1
2
3
4
5
6
7
8
9
10
11
12
13
# 提取关键指标
metrics = {
"年化收益率": analysis_df.loc["超额收益(含成本)", "annualized_return"],
"夏普比率": analysis_df.loc["超额收益(含成本)", "sharpe_ratio"],
"最大回撤": analysis_df.loc["超额收益(含成本)", "max_drawdown"],
"信息比率": analysis_df.loc["超额收益(含成本)", "information_ratio"],
}

print("=" * 50)
print("策略表现总结")
print("=" * 50)
for key, value in metrics.items():
print(f"{key}: {value:.4f}")

5.5 可视化分析

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import matplotlib.pyplot as plt

# 创建图表
fig, axes = plt.subplots(3, 1, figsize=(14, 12))

# 1. 累计收益曲线
ax1 = axes[0]
cum_return = (1 + report["return"]).cumprod()
cum_bench = (1 + report["bench"]).cumprod()
ax1.plot(cum_return.index, cum_return, label="策略", linewidth=2)
ax1.plot(cum_bench.index, cum_bench, label="基准(沪深300)", linewidth=2)
ax1.set_title("累计收益曲线", fontsize=14)
ax1.legend()
ax1.grid(True, alpha=0.3)

# 2. 超额收益曲线
ax2 = axes[1]
excess_cum = (1 + (report["return"] - report["bench"] - report["cost"])).cumprod()
ax2.fill_between(excess_cum.index, 1, excess_cum, alpha=0.3)
ax2.plot(excess_cum.index, excess_cum, linewidth=2)
ax2.axhline(y=1, color='red', linestyle='--', alpha=0.5)
ax2.set_title("累计超额收益曲线", fontsize=14)
ax2.grid(True, alpha=0.3)

# 3. 回撤曲线
ax3 = axes[2]
cummax = cum_return.cummax()
drawdown = (cum_return - cummax) / cummax
ax3.fill_between(drawdown.index, 0, drawdown, alpha=0.3, color='red')
ax3.plot(drawdown.index, drawdown, linewidth=2, color='red')
ax3.set_title("策略回撤曲线", fontsize=14)
ax3.grid(True, alpha=0.3)

plt.tight_layout()
plt.savefig('backtest_analysis.png', dpi=150)
plt.show()

第六部分:参数优化

6.1 网格搜索优化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from itertools import product

# 定义参数搜索空间
param_grid = {
"topk": [20, 30, 40, 50],
"n_drop": [2, 3, 5],
"learning_rate": [0.01, 0.05, 0.1],
}

# 网格搜索
results = []
for topk, n_drop, lr in product(
param_grid["topk"],
param_grid["n_drop"],
param_grid["learning_rate"]
):
# 训练模型
model = LGBModel(learning_rate=lr, max_depth=6, num_leaves=50)
model.fit(dataset)

# 预测
predictions = model.predict(dataset)

# 回测
strategy = TopkDropoutStrategy(topk=topk, n_drop=n_drop, signal=predictions)
portfolio_dict, _ = backtest(executor=executor_obj, strategy=strategy, **backtest_config)
report, _ = portfolio_dict.get("day")

# 计算夏普比率
sharpe = risk_analysis(report["return"], freq="day")["sharpe_ratio"]

results.append({
"topk": topk,
"n_drop": n_drop,
"learning_rate": lr,
"sharpe_ratio": sharpe,
})

# 找到最佳参数
results_df = pd.DataFrame(results)
best_params = results_df.loc[results_df["sharpe_ratio"].idxmax()]
print("最佳参数:")
print(best_params)

6.2 使用Qlib内置调参

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from qlib.model.trainer import task_train

# 定义调参配置
tune_config = {
"model": {
"class": "LGBModel",
"module_path": "qlib.contrib.model.gbdt",
"kwargs": {
"learning_rate": {"_type": "choice", "_value": [0.01, 0.05, 0.1]},
"max_depth": {"_type": "choice", "_value": [4, 6, 8]},
"num_leaves": {"_type": "choice", "_value": [30, 50, 70]},
},
},
"dataset": {...},
}

# 执行调参
best_trial = task_train(tune_config)

第七部分:完整代码

7.1 一键运行脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
"""
Qlib量化策略完整实战脚本
运行方式: python qlib_strategy.py
"""

import qlib
from qlib.data import D
from qlib.data.dataset import DatasetH
from qlib.contrib.model.gbdt import LGBModel
from qlib.contrib.strategy import TopkDropoutStrategy
from qlib.backtest import backtest, executor
from qlib.contrib.evaluate import risk_analysis
from qlib.workflow import R
import pandas as pd
import matplotlib.pyplot as plt

# ==================== 配置区 ====================
CONFIG = {
"market": "csi300",
"benchmark": "SH000300",
"train_period": ("2010-01-01", "2018-12-31"),
"valid_period": ("2019-01-01", "2020-12-31"),
"test_period": ("2021-01-01", "2023-12-31"),
"initial_capital": 10000000,
"topk": 30,
"n_drop": 3,
}

# ==================== 主流程 ====================
def main():
print("=" * 60)
print("Qlib量化策略实战")
print("=" * 60)

# 1. 初始化
print("\n[1/6] 初始化Qlib...")
qlib.init(provider_uri="~/.qlib/qlib_data/cn_data")

# 2. 准备数据
print("\n[2/6] 准备数据集...")
dataset = DatasetH(
handler={
"class": "Alpha158",
"module_path": "qlib.contrib.data.handler",
"kwargs": {
"start_time": CONFIG["train_period"][0],
"end_time": CONFIG["test_period"][1],
"fit_start_time": CONFIG["train_period"][0],
"fit_end_time": CONFIG["train_period"][1],
"instruments": CONFIG["market"],
},
},
segments={
"train": CONFIG["train_period"],
"valid": CONFIG["valid_period"],
"test": CONFIG["test_period"],
},
)

# 3. 训练模型
print("\n[3/6] 训练LightGBM模型...")
model = LGBModel(
loss="mse",
colsample_bytree=0.8,
learning_rate=0.05,
subsample=0.8,
max_depth=6,
num_leaves=50,
)

with R.start(experiment_name="qlib_strategy"):
model.fit(dataset)
R.save_objects(trained_model=model)
recorder_id = R.get_recorder().id

# 4. 预测
print("\n[4/6] 生成预测信号...")
predictions = model.predict(dataset)
print(f"预测样本数: {len(predictions)}")

# 5. 回测
print("\n[5/6] 执行回测...")
strategy = TopkDropoutStrategy(
topk=CONFIG["topk"],
n_drop=CONFIG["n_drop"],
signal=predictions,
)

executor_obj = executor.SimulatorExecutor(
time_per_step="day",
generate_portfolio_metrics=True,
)

portfolio_dict, _ = backtest(
executor=executor_obj,
strategy=strategy,
start_time=CONFIG["test_period"][0],
end_time=CONFIG["test_period"][1],
account=CONFIG["initial_capital"],
benchmark=CONFIG["benchmark"],
exchange_kwargs={
"freq": "day",
"limit_threshold": 0.095,
"deal_price": "vwap",
"open_cost": 0.0003,
"close_cost": 0.0013,
"min_cost": 5,
},
)

report, positions = portfolio_dict.get("day")

# 6. 分析结果
print("\n[6/6] 分析回测结果...")
print_results(report)

# 可视化
plot_results(report)

print("\n" + "=" * 60)
print("策略运行完成!")
print("=" * 60)


def print_results(report):
"""打印关键指标"""
strategy_analysis = risk_analysis(report["return"], freq="day")
bench_analysis = risk_analysis(report["bench"], freq="day")
excess_analysis = risk_analysis(
report["return"] - report["bench"] - report["cost"],
freq="day"
)

print("\n" + "-" * 50)
print(f"{'指标':<20} {'策略':<15} {'基准':<15} {'超额':<15}")
print("-" * 50)
print(f"{'年化收益率':<20} {strategy_analysis['annualized_return']:<15.4f} "
f"{bench_analysis['annualized_return']:<15.4f} "
f"{excess_analysis['annualized_return']:<15.4f}")
print(f"{'夏普比率':<20} {strategy_analysis['sharpe_ratio']:<15.4f} "
f"{bench_analysis['sharpe_ratio']:<15.4f} "
f"{excess_analysis['sharpe_ratio']:<15.4f}")
print(f"{'最大回撤':<20} {strategy_analysis['max_drawdown']:<15.4f} "
f"{bench_analysis['max_drawdown']:<15.4f} "
f"{excess_analysis['max_drawdown']:<15.4f}")
print("-" * 50)


def plot_results(report):
"""可视化回测结果"""
fig, axes = plt.subplots(2, 1, figsize=(14, 8))

# 累计收益
cum_return = (1 + report["return"]).cumprod()
cum_bench = (1 + report["bench"]).cumprod()

axes[0].plot(cum_return.index, cum_return, label="策略", linewidth=2)
axes[0].plot(cum_bench.index, cum_bench, label="沪深300", linewidth=2)
axes[0].set_title("累计收益对比", fontsize=14)
axes[0].legend()
axes[0].grid(True, alpha=0.3)

# 回撤
cummax = cum_return.cummax()
drawdown = (cum_return - cummax) / cummax
axes[1].fill_between(drawdown.index, 0, drawdown, alpha=0.3, color='red')
axes[1].plot(drawdown.index, drawdown, color='red', linewidth=2)
axes[1].set_title("策略回撤", fontsize=14)
axes[1].grid(True, alpha=0.3)

plt.tight_layout()
plt.savefig('qlib_backtest_result.png', dpi=150)
print("\n图表已保存: qlib_backtest_result.png")


if __name__ == "__main__":
main()

7.2 运行结果示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
============================================================
Qlib量化策略实战
============================================================

[1/6] 初始化Qlib...

[2/6] 准备数据集...

[3/6] 训练LightGBM模型...
[LightGBM] [Info] Training...

[4/6] 生成预测信号...
预测样本数: 180000

[5/6] 执行回测...
backtest loop: 100%|██████████| 730/730 [00:15<00:00]

[6/6] 分析回测结果...

--------------------------------------------------
指标 策略 基准 超额
--------------------------------------------------
年化收益率 0.1523 0.0234 0.1289
夏普比率 1.2345 0.3456 1.1234
最大回撤 -0.1234 -0.2345 -0.0891
--------------------------------------------------

图表已保存: qlib_backtest_result.png

============================================================
策略运行完成!
============================================================

第八部分:进阶方向

8.1 尝试其他模型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# LSTM模型
from qlib.contrib.model.pytorch_lstm import LSTMModel

lstm_model = LSTMModel(
d_feat=6, # 特征维度
hidden_size=64,
num_layers=2,
dropout=0.1,
)

# Transformer模型
from qlib.contrib.model.pytorch_transformer import TransformerModel

transformer_model = TransformerModel(
d_feat=6,
d_model=64,
nhead=4,
num_layers=2,
)

8.2 使用更多因子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Alpha360:360个技术因子
handler_config["class"] = "Alpha360"

# 自定义因子
from qlib.contrib.data.handler import Alpha158

class MyAlpha(Alpha158):
def get_feature_config(self):
# 继承Alpha158
features = super().get_feature_config()
# 添加自定义因子
features.extend([
"($close - $open) / $open * $volume", # 量价结合
"Corr($close, $volume, 10)", # 量价相关性
])
return features

8.3 组合多个模型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from qlib.model.ens import Ensemble

# 集成多个模型
ensemble = Ensemble(
models={
"lgb": lgb_model,
"lstm": lstm_model,
"transformer": transformer_model,
},
method="mean", # 平均融合
)

# 训练
ensemble.fit(dataset)

# 预测(自动融合)
predictions = ensemble.predict(dataset)

总结

通过本教程,你已经:

  1. ✅ 搭建了Qlib开发环境
  2. ✅ 学会了数据获取和特征构建
  3. ✅ 训练了LightGBM预测模型
  4. ✅ 设计并回测了TopkDropout策略
  5. ✅ 分析了回测结果
  6. ✅ 掌握了参数优化方法

下一步建议

方向 学习内容
模型进阶 LSTM、Transformer、图神经网络
因子研究 自定义因子、因子挖掘、因子正交化
策略优化 组合优化、风险控制、仓位管理
实盘部署 VnPy对接、风控系统、监控系统

推荐资源


💡 提示:量化投资是一个需要持续学习和实践的领域。建议从简单策略开始,逐步增加复杂度,同时注重风险控制。

⚠️ 免责声明:本教程仅供学习交流,不构成任何投资建议。历史回测表现不代表未来收益。