# xlib-quant
* 一个简单的量化研究框架,具备基本的数据获取、因子分析、机器学习、回测及结果分析功能。
* 框架具体思路与内容请参考公众号FinHack炼金术《从零开始卷量化(25)-脱离Qlib,手撸一个属于自己的量化投资框架! 》
* **当且该框架并不稳定**,预计本系列文章全部更新完(预计65篇,5月底前更新完)后会出一个稳定版的分支。
# 公众号
![扫码_搜索联合传播样式-标准色版](https://user-images.githubusercontent.com/6196607/162598983-b11b756a-f4fd-4062-9d77-e414e2f072e1.jpg)
# 框架整体思路
<img width="300" alt="image" src="https://user-images.githubusercontent.com/6196607/162599136-2a8286c8-b205-4f43-a894-61c771356920.png">
# 一把梭代码
import pandas as pd
from xlib import data
from xlib import factors
from xlib import model
from xlib.strategies import Top10Strategy
from xlib import backtest
df=data.get_all_index_data()
bench=data.get_index_data(index="000300",start_date="20200101",end_date="20220330",renew=False)
df=factors.getTA(df)
df['label']=df.groupby('symbol')['close'].shift(10)
df['label']=df['close']/df['label']
df_train,df_valid,df_pred=model.datasplit(df,train_end='2019-01-01',valid_end='2020-01-01')
model.lgbtrain(df_train,df_valid,label='label')
preds=model.lgbpred(df_pred,label='label')
preds['score']=preds['pred']
preds['rank']=preds.groupby('date')['pred'].rank()
preds['signal']=preds.apply(lambda x: 1 if x['rank']<=10 else 0 ,axis=1)
returns=backtest.test(preds,Top10Strategy)
backtest.analysis(returns,bench)
# 结果演示
<img width="600" alt="image" src="https://user-images.githubusercontent.com/6196607/162584205-8bb34525-4ff0-47c2-8b29-5674af881f29.png">
<img width="600" alt="image" src="https://user-images.githubusercontent.com/6196607/162584222-3ff3f10e-5a07-4621-a9c3-c903a0e8b34f.png">
![image](https://user-images.githubusercontent.com/6196607/162584080-840c668f-524b-4729-9942-cc546456155f.png)
![image](https://user-images.githubusercontent.com/6196607/162584099-dbd51d9a-8e2e-4d5e-abc4-867964d279bc.png)
![image](https://user-images.githubusercontent.com/6196607/162584104-4687f9d6-98a7-4298-abfe-349865ecdd3e.png)
![image](https://user-images.githubusercontent.com/6196607/162584110-ace4df23-ff76-445d-9361-354730f30a89.png)
![image](https://user-images.githubusercontent.com/6196607/162584104-4687f9d6-98a7-4298-abfe-349865ecdd3e.png)
![image](https://user-images.githubusercontent.com/6196607/162584113-f948f488-fb78-4eb7-9bff-8e669c169c7e.png)
![image](https://user-images.githubusercontent.com/6196607/162584140-a63a8134-a432-469b-939f-083dcac43f3c.png)
![image](https://user-images.githubusercontent.com/6196607/162584155-528b7ece-8f97-4b74-bc7e-045d60c7338e.png)
![image](https://user-images.githubusercontent.com/6196607/162584146-f023ec48-6168-4ad5-9f0d-3e36b3fa241f.png)
![image](https://user-images.githubusercontent.com/6196607/162584131-7bf6e0b0-9fc9-40c2-81e1-94ca51a934ff.png)
![image](https://user-images.githubusercontent.com/6196607/162584067-90f96c9c-42b0-43e1-aba6-f81347303866.png)
![image](https://user-images.githubusercontent.com/6196607/162584119-1cdead27-64ae-4ca4-9aab-d154c19a6fbe.png)
![image](https://user-images.githubusercontent.com/6196607/162584127-0294e2c1-cf8c-40a9-a866-0ecad3d2c6ad.png)
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
一个简单的量化研究框架,具备基本的数据获取、因子分析、机器学习、回测及结果分析功能.zip (302个子文件)
i_all_000300_20150101_20220330.csv 45.16MB
000858_20150101_20220330.csv 162KB
600030_20150101_20220330.csv 161KB
300033_20150101_20220330.csv 161KB
601166_20150101_20220330.csv 161KB
600436_20150101_20220330.csv 160KB
600036_20150101_20220330.csv 160KB
000568_20150101_20220330.csv 160KB
002594_20150101_20220330.csv 160KB
002460_20150101_20220330.csv 160KB
i_000300_20150101_20220330.csv 160KB
600887_20150101_20220330.csv 160KB
000661_20150101_20220330.csv 160KB
600837_20150101_20220330.csv 160KB
600570_20150101_20220330.csv 160KB
000768_20150101_20220330.csv 159KB
600276_20150101_20220330.csv 159KB
601788_20150101_20220330.csv 159KB
002236_20150101_20220330.csv 159KB
300122_20150101_20220330.csv 159KB
002466_20150101_20220330.csv 159KB
600809_20150101_20220330.csv 159KB
600999_20150101_20220330.csv 159KB
002371_20150101_20220330.csv 159KB
603019_20150101_20220330.csv 159KB
601888_20150101_20220330.csv 159KB
601336_20150101_20220330.csv 159KB
603799_20150101_20220330.csv 159KB
600547_20150101_20220330.csv 159KB
000063_20150101_20220330.csv 159KB
002008_20150101_20220330.csv 159KB
002241_20150101_20220330.csv 159KB
002007_20150101_20220330.csv 158KB
002142_20150101_20220330.csv 158KB
300124_20150101_20220330.csv 158KB
002230_20150101_20220330.csv 158KB
600893_20150101_20220330.csv 158KB
000895_20150101_20220330.csv 158KB
000333_20150101_20220330.csv 158KB
002202_20150101_20220330.csv 158KB
002415_20150101_20220330.csv 158KB
300274_20150101_20220330.csv 158KB
300003_20150101_20220330.csv 158KB
000963_20150101_20220330.csv 158KB
300408_20150101_20220330.csv 158KB
600588_20150101_20220330.csv 158KB
002736_20150101_20220330.csv 158KB
600048_20150101_20220330.csv 158KB
300347_20150101_20220330.csv 158KB
600741_20150101_20220330.csv 157KB
600109_20150101_20220330.csv 157KB
603369_20150101_20220330.csv 157KB
002024_20150101_20220330.csv 157KB
601799_20150101_20220330.csv 157KB
600332_20150101_20220330.csv 157KB
300059_20150101_20220330.csv 157KB
601211_20150101_20220330.csv 157KB
600352_20150101_20220330.csv 157KB
000002_20150101_20220330.csv 157KB
002410_20150101_20220330.csv 157KB
300144_20150101_20220330.csv 157KB
601012_20150101_20220330.csv 157KB
002709_20150101_20220330.csv 157KB
300014_20150101_20220330.csv 157KB
600031_20150101_20220330.csv 157KB
603806_20150101_20220330.csv 157KB
601231_20150101_20220330.csv 156KB
601088_20150101_20220330.csv 156KB
300433_20150101_20220330.csv 156KB
600406_20150101_20220330.csv 156KB
600958_20150101_20220330.csv 156KB
601238_20150101_20220330.csv 156KB
002032_20150101_20220330.csv 156KB
600150_20150101_20220330.csv 156KB
002475_20150101_20220330.csv 156KB
600872_20150101_20220330.csv 156KB
002049_20150101_20220330.csv 156KB
601021_20150101_20220330.csv 156KB
600845_20150101_20220330.csv 156KB
000651_20150101_20220330.csv 156KB
600760_20150101_20220330.csv 156KB
603899_20150101_20220330.csv 156KB
000725_20150101_20220330.csv 156KB
600426_20150101_20220330.csv 156KB
600584_20150101_20220330.csv 156KB
600383_20150101_20220330.csv 156KB
300015_20150101_20220330.csv 155KB
600763_20150101_20220330.csv 155KB
002714_20150101_20220330.csv 155KB
603338_20150101_20220330.csv 155KB
000938_20150101_20220330.csv 155KB
601360_20150101_20220330.csv 155KB
600161_20150101_20220330.csv 155KB
601633_20150101_20220330.csv 155KB
002120_20150101_20220330.csv 155KB
002568_20150101_20220330.csv 155KB
002459_20150101_20220330.csv 155KB
601899_20150101_20220330.csv 155KB
002601_20150101_20220330.csv 155KB
601318_20150101_20220330.csv 155KB
共 302 条
- 1
- 2
- 3
- 4
资源评论
- V09582024-07-06资源内容详细全面,与描述一致,对我很有用,有一定的使用价值。
生瓜蛋子
- 粉丝: 3919
- 资源: 7441
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- RangeError.md
- ClosedChannelError.md
- InvalidArgumentError.md
- KeyError.md
- InvalidValueError.md
- InvalidFormatError.md
- MissingValueError.md
- UnknownError.md
- UnsupportedTypeError.md
- InvalidJSONError.md
- ActionPack 的 Redis 存储.zip
- c语言指针实验报告-c语言指针心得PDF
- ActiveSupport 的 Redis 存储.zip
- angularjs+mongodb+redis.zip
- Apache Kvrocks 是一个分布式键值 NoSQL 数据库,使用 RocksDB 作为存储引擎,并兼容 Redis 协议 .zip
- 543876fd05734ccdfcf755f80f748c31.gif
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功