easy-quant是一个轻量级数字货币量化框架,目的是简化开发人员开发策略的成本,使开发人员专注于策略逻辑开发。 为什么不引用Spring框架?因为Spring引入了很多不需要的功能和代码,会导致jar包变大;在开发调试阶段,需要经常在ide上重启服务,Spring的启动流程会比较慢,导致浪费调试时间。
轻量级数字货币量化框架
- 开发工具:IntelliJ IDEA
- JDK1.8
- 框架入口:com.zyf.strategy.Main,通过给String[] args赋值,分别为策略包名和配置名,用于指定策略和策略使用的配置文件。
public class Main {
public static void main(String[] args) throws ClassNotFoundException {
EasyQuantyApplication.run(Class.forName(args[0]), args[1]);
}
}
- 框架启动原理借鉴Spring的启动流程,包含功能: 读取配置文件
// 预处理
this.prepareRefresh();
通过反射实例化策略,并将配置信息加载到策略实例中
// 将配置信息加载到策略实例
this.invokeProcessors();
通过反射实例化策略,并将配置信息加载到策略实例中
// 将配置信息加载到策略实例
this.invokeProcessors();
处理自定义注解
// 处理注解
this.handleAnnotation();
通过IOC容器调用策略函数
// 初始化策略
this.prepareStrategy();
启动策略
// 启动定时任务
this.startUpScheduler();
{
"configs" : [
{
// 策略实例id
"id" : "1",
// 目标交易所名
"exchangeName" : "deribit",
// 目标币对(合约)
"symbol" : "BTC-PERPETUAL",
// 行情接口实例
"mdE" : { "exchangeName" : "deribit", "securitiesType" : "future" },
// 私有接口实例
"tradeE" : { "exchangeName" : "deribit","securitiesType" : "future", "accessKey" : "accessKey/12312", "secretKey" : "secretKey" },
// 自定义行情接口实例
"huobiproE" : { "exchangeName" : "huobipro" }
}
]
}
- baseservice:业务公共模块
- common:通用公共模块
- framework:量化框架模块
- marketdata:交易所公共接口模块(盘口等)
- strategy:策略模块
- trade:交易所私有接口模块(下单等)
- 启动demo程序命令 java -jar 包名.jar 策略包名 --config-name:配置名
- 例子 java -jar strategy-1.0-jar-with-dependencies.jar com.zyf.strategy.Strategy --config-name:grid.json
- 程序会输出deribit交易所的BTC-PERPETUAL合约的Detph数据(为什么demo用deribit交易所,因为不需要翻墙)
eg:
filetree
├─.idea
│ └─inspectionProfiles
├─baseservice
│ └─src
│ ├─main
│ │ ├─java
│ │ │ └─com
│ │ │ └─zyf
│ │ │ └─baseservice
│ │ │ ├─baseexchange
│ │ │ │ ├─future
│ │ │ │ ├─option
│ │ │ │ └─stock
│ │ │ ├─model
│ │ │ │ └─enums
│ │ │ └─util
│ │ │ ├─deribit
│ │ │ ├─huobipro
│ │ │ └─okex
│ │ └─resources
│ └─test
│ └─java
├─common
│ └─src
│ ├─main
│ │ ├─java
│ │ │ └─com
│ │ │ └─zyf
│ │ │ └─common
│ │ │ ├─crypto
│ │ │ ├─exceptions
│ │ │ ├─http
│ │ │ ├─model
│ │ │ │ ├─enums
│ │ │ │ ├─future
│ │ │ │ └─http
│ │ │ ├─okhttp
│ │ │ └─util
│ │ └─resources
│ └─test
│ └─java
├─framework
│ └─src
│ ├─main
│ │ ├─java
│ │ │ └─com
│ │ │ └─zyf
│ │ │ └─framework
│ │ │ ├─boot
│ │ │ ├─scheduling
│ │ │ │ └─interfaces
│ │ │ ├─service
│ │ │ │ └─impl
│ │ │ └─util
│ │ └─resources
│ └─test
│ └─java
│ └─com
│ └─zyf
│ └─framework
├─logs
├─marketdata
│ └─src
│ ├─main
│ │ ├─java
│ │ │ └─com
│ │ │ └─zyf
│ │ │ └─marketdata
│ │ │ ├─factory
│ │ │ ├─http
│ │ │ │ ├─future
│ │ │ │ ├─option
│ │ │ │ │ └─deribit
│ │ │ │ └─stock
│ │ │ └─proxy
│ │ └─resources
│ └─test
│ └─java
├─strategy
│ └─src
│ ├─main
│ │ ├─java
│ │ │ └─com
│ │ │ └─zyf
│ │ │ └─strategy
│ │ └─resources
│ └─test
│ └─java
└─trade
└─src
├─main
│ ├─java
│ │ └─com
│ │ └─zyf
│ │ └─trade
│ │ ├─factory
│ │ ├─http
│ │ │ ├─future
│ │ │ └─stock
│ │ └─proxy
│ └─resources
└─test
└─java
贡献使开源社区成为一个学习、激励和创造的绝佳场所。你所作的任何贡献都是非常感谢的。
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
该项目使用Git进行版本管理。您可以在repository参看当前可用版本。
yuanfeng.z
邮箱:sourcez@foxmail.com qq:1004283115
您也可以在贡献者名单中参看所有参与该项目的开发者。
该项目签署了MIT 授权许可,详情请参阅 LICENSE.txt