├── .gitignore
├── README.md
├── pom.xml
├── qt-admin
├── pom.xml
└── src
│ ├── main
│ ├── docker
│ │ └── DockerFile
│ ├── java
│ │ └── com
│ │ │ └── quant
│ │ │ └── admin
│ │ │ ├── AppAdmin.java
│ │ │ ├── component
│ │ │ ├── IMailServiceImpl.java
│ │ │ ├── OrderIdReceiver.java
│ │ │ ├── ProfitReceiver.java
│ │ │ └── RobotMsgReceiver.java
│ │ │ ├── config
│ │ │ ├── AsyncConfig.java
│ │ │ ├── GlobalCorsConfig.java
│ │ │ ├── MybatisPlusConfig.java
│ │ │ ├── SubscriberConfig.java
│ │ │ └── WebSocketConfig.java
│ │ │ ├── controller
│ │ │ ├── AccountController.java
│ │ │ ├── BalanceController.java
│ │ │ ├── BaseController.java
│ │ │ ├── IndicatorController.java
│ │ │ ├── NodeController.java
│ │ │ ├── OrderController.java
│ │ │ ├── OrderProfitController.java
│ │ │ ├── RobotController.java
│ │ │ ├── StrategyController.java
│ │ │ ├── SymbolController.java
│ │ │ └── UserController.java
│ │ │ ├── dao
│ │ │ ├── AccountMapper.java
│ │ │ ├── BalanceMapper.java
│ │ │ ├── OrderProfitMapper.java
│ │ │ ├── OrdersMapper.java
│ │ │ ├── RobotMapper.java
│ │ │ ├── StrategyMapper.java
│ │ │ ├── SymbolMapper.java
│ │ │ └── UserMapper.java
│ │ │ ├── rest
│ │ │ ├── RobotClientService.java
│ │ │ └── impl
│ │ │ │ └── RobotClientServiceImpl.java
│ │ │ ├── service
│ │ │ ├── AccountService.java
│ │ │ ├── BalanceService.java
│ │ │ ├── IMailService.java
│ │ │ ├── OrderProfitService.java
│ │ │ ├── OrdersService.java
│ │ │ ├── RobotService.java
│ │ │ ├── StrategyService.java
│ │ │ ├── SymbolService.java
│ │ │ ├── UserService.java
│ │ │ └── impl
│ │ │ │ ├── AccountServiceImpl.java
│ │ │ │ ├── BalanceServiceImpl.java
│ │ │ │ ├── OrderProfitServiceImpl.java
│ │ │ │ ├── OrdersServiceImpl.java
│ │ │ │ ├── RobotServiceImpl.java
│ │ │ │ ├── StrategyServiceImpl.java
│ │ │ │ ├── SymbolServiceImpl.java
│ │ │ │ └── UserServiceImpl.java
│ │ │ ├── task
│ │ │ ├── RobotStatusTask.java
│ │ │ └── SymbolTask.java
│ │ │ └── utils
│ │ │ └── MysqlGenerator.java
│ └── resources
│ │ ├── application-dev.yml
│ │ ├── application-prod.yml
│ │ ├── application.yml
│ │ ├── banner.txt
│ │ ├── logback-spring.xml
│ │ └── mapper
│ │ ├── AccountMapper.xml
│ │ ├── BalanceMapper.xml
│ │ ├── OrderProfitMapper.xml
│ │ ├── OrdersMapper.xml
│ │ ├── RobotMapper.xml
│ │ ├── StrategyMapper.xml
│ │ ├── SymbolMapper.xml
│ │ └── UserMapper.xml
│ └── test
│ └── java
│ └── com
│ └── quant
│ └── admin
│ └── QtParentApplicationTests.java
├── qt-client
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── com
│ │ │ └── quant
│ │ │ └── client
│ │ │ ├── AppClient.java
│ │ │ ├── config
│ │ │ └── ThreadPool.java
│ │ │ ├── controller
│ │ │ └── BotController.java
│ │ │ ├── service
│ │ │ ├── RobotService.java
│ │ │ └── impl
│ │ │ │ └── RobotServiceImpl.java
│ │ │ └── task
│ │ │ ├── IndicatorRobotOperate.java
│ │ │ └── SimpleNumRobotOperate.java
│ └── resources
│ │ ├── application-dev.yml
│ │ ├── application-prod.yml
│ │ ├── application.yml
│ │ ├── banner.txt
│ │ └── logback-spring.xml
│ └── test
│ └── java
│ └── Test.java
├── qt-common
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── quant
│ │ └── common
│ │ ├── config
│ │ ├── JsonConfig.java
│ │ ├── RedisConfig.java
│ │ ├── RedisUtil.java
│ │ ├── RestTemplateConfig.java
│ │ └── VpnProxyConfig.java
│ │ ├── constans
│ │ ├── IndicatorCons.java
│ │ └── RobotRedisKeyConfig.java
│ │ ├── domain
│ │ ├── bo
│ │ │ └── RobotBo.java
│ │ ├── entity
│ │ │ ├── Account.java
│ │ │ ├── Balance.java
│ │ │ ├── MarketOrder.java
│ │ │ ├── OrderProfit.java
│ │ │ ├── Orders.java
│ │ │ ├── Robot.java
│ │ │ ├── Strategy.java
│ │ │ ├── Symbol.java
│ │ │ └── User.java
│ │ ├── request
│ │ │ ├── CreateOrderRequest.java
│ │ │ ├── DepthRequest.java
│ │ │ └── IntrustOrdersDetailRequest.java
│ │ ├── response
│ │ │ ├── Account.java
│ │ │ ├── Accounts.java
│ │ │ ├── AccountsResponse.java
│ │ │ ├── ApiResponse.java
│ │ │ ├── Balance.java
│ │ │ ├── BalanceBean.java
│ │ │ ├── BalanceResponse.java
│ │ │ ├── Batchcancel.java
│ │ │ ├── BatchcancelBean.java
│ │ │ ├── BatchcancelResponse.java
│ │ │ ├── Currencys.java
│ │ │ ├── CurrencysResponse.java
│ │ │ ├── Depth.java
│ │ │ ├── DepthResponse.java
│ │ │ ├── DetailResponse.java
│ │ │ ├── Details.java
│ │ │ ├── HistoryTrade.java
│ │ │ ├── HistoryTradeResponse.java
│ │ │ ├── HistoryTradess.java
│ │ │ ├── IntrustDetail.java
│ │ │ ├── IntrustDetailResponse.java
│ │ │ ├── Kline.java
│ │ │ ├── KlineResponse.java
│ │ │ ├── MatchresultsOrdersDetail.java
│ │ │ ├── MatchresultsOrdersDetailResponse.java
│ │ │ ├── Merged.java
│ │ │ ├── MergedResponse.java
│ │ │ ├── OrdersDetail.java
│ │ │ ├── OrdersDetailResponse.java
│ │ │ ├── Place.java
│ │ │ ├── SubmitcancelResponse.java
│ │ │ ├── Symbol.java
│ │ │ ├── Symbols.java
│ │ │ ├── SymbolsResponse.java
│ │ │ ├── TimestampResponse.java
│ │ │ ├── Trade.java
│ │ │ ├── TradeBean.java
│ │ │ └── TradeResponse.java
│ │ ├── to
│ │ │ ├── BuyAndSellIndicatorTo.java
│ │ │ ├── IndicatorBean.java
│ │ │ ├── RobotRunMessage.java
│ │ │ ├── RuleBean.java
│ │ │ └── llIndicatorTo.java
│ │ └── vo
│ │ │ ├── Account.java
│ │ │ ├── AccountVo.java
│ │ │ ├── BaseInfoEntity.java
│ │ │ ├── IndicatorCalParam.java
│ │ │ ├── IndicatorStrategyVo.java
│ │ │ ├── Market.java
│ │ │ ├── OrderTaskMessage.java
│ │ │ ├── ProfitMessage.java
│ │ │ ├── RobotStrategyVo.java
│ │ │ ├── RobotVo.java
│ │ │ └── StrategyVo.java
│ │ ├── enums
│ │ ├── AType.java
│ │ ├── HBOrderType.java
│ │ ├── OrderType.java
│ │ ├── PirceType.java
│ │ ├── RobotState.java
│ │ ├── SellType.java
│ │ ├── Status.java
│ │ ├── StrategyType.java
│ │ └── TraceType.java
│ │ ├── exception
│ │ ├── ApiException.java
│ │ ├── ExchangeNetworkException.java
│ │ ├── IndicatorException.java
│ │ └── TradingApiException.java
│ │ └── utils
│ │ ├── ComputeUtil.java
│ │ ├── DateUtils.java
│ │ ├── JsonFormate.java
│ │ └── SpringUtils.java
│ └── resources
│ └── libs
│ └── opslabJutil-2.0.3.jar
├── qt-core
├── pom.xml
└── src
│ ├── main
│ └── java
│ │ └── com
│ │ └── quant
│ │ └── core
│ │ ├── Main.java
│ │ ├── api
│ │ ├── ApiClient.java
│ │ └── ApiResult.java
│ │ ├── builder
│ │ └── StrategyBuilder.java
│ │ ├── config
│ │ ├── AccountConfig.java
│ │ ├── KlineConfig.java
│ │ ├── MarketConfig.java
│ │ ├── StrategyConfig.java
│ │ └── imp
│ │ │ ├── HuoBiAccountConfigImpl.java
│ │ │ ├── HuoBiKlineConfigImpl.java
│ │ │ ├── HuoBiMarketConfigImpl.java
│ │ │ ├── HuoboIndicatorStragegyConfig.java
│ │ │ └── HuoboSimpleStragegyConfig.java
│ │ ├── exchangeAdapter
│ │ ├── BaseExchangeAdapter.java
│ │ └── HuobiExchangeAdapter.java
│ │ ├── factory
│ │ ├── AbsIndicatorFactory.java
│ │ └── IndicatorFactory.java
│ │ ├── helpers
│ │ └── IndicatorHelper.java
│ │ ├── indicatorAdapter
│ │ ├── ADXIndicatorAdapter.java
│ │ ├── AoIndicatorAdapter.java
│ │ ├── CciIndicatorAdapter.java
│ │ ├── EmaIndicatorAdapter.java
│ │ ├── IndicatorAdapter.java
│ │ ├── MacdIndicatorAdapter.java
│ │ ├── RsiIndicatorAdapter.java
│ │ ├── SmaIndicatorAdapter.java
│ │ ├── StochasticDIndicatorAdapter.java
│ │ ├── StochasticKiIndicatorAdapter.java
│ │ └── StochasticRsiiIndicatorAdapter.java
│ │ ├── redisMq
│ │ ├── OrderIdRedisMqServiceImpl.java
│ │ ├── OrderProfitRedisMqServiceImpl.java
│ │ ├── RedisMqService.java
│ │ └── RobotLogsRedisMqServiceImpl.java
│ │ ├── strategy
│ │ ├── AbstractStrategy.java
│ │ ├── StrategyException.java
│ │ ├── TradingStrategy.java
│ │ ├── handle
│ │ │ ├── HuobiLimitBuyPriceHandle.java
│ │ │ ├── HuobiLimitSellPriceHandle.java
│ │ │ ├── HuobiNotLimitBuyPriceHandle.java
│ │ │ ├── HuobiNotLimitSellPriceHandle.java
│ │ │ └── StrategyHandle.java
│ │ └── impl
│ │ │ ├── HuoBIndicatoryStrategyImpl.java
│ │ │ ├── HuoBiSimpleStrategyImpl.java
│ │ │ └── StrategyDelegate.java
│ │ └── trading
│ │ ├── BalanceInfo.java
│ │ ├── OpenOrder.java
│ │ ├── TradingApi.java
│ │ └── impl
│ │ └── HuoBiOpenOrderImpl.java
│ └── test
│ └── java
│ ├── StrategyTest.java
│ └── TradingBotOnMovingTimeSeries.java
└── qt-register
├── pom.xml
└── src
└── main
├── java
└── com
│ └── quant
│ └── center
│ ├── AppRegister.java
│ └── te.java
└── resources
├── application-dev.yml
├── application-prod.yml
├── application.yml
├── banner.txt
└── logback-spring.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | /target/
3 | !.mvn/wrapper/maven-wrapper.jar
4 |
5 | ### STS ###
6 | .apt_generated
7 | .classpath
8 | .factorypath
9 | .project
10 | .settings
11 | .springBeans
12 | .sts4-cache
13 |
14 | ### IntelliJ IDEA ###
15 | .idea
16 | *.iws
17 | *.iml
18 | *.ipr
19 |
20 | ### NetBeans ###
21 | /nbproject/private/
22 | /nbbuild/
23 | /dist/
24 | /nbdist/
25 | /.nb-gradle/
26 | /build/
27 |
28 | ### VS Code ###
29 | .vscode/
30 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
quant4j
3 |
诚接区块链应用开发,有团队,联系:13693094831
4 |
Quantitative trading platform.
5 |
6 | ta4j包的目录 [0.13-SNAPSHOT.zip](https://github.com/yangyangchu1992/quant4j/files/5718998/0.13-SNAPSHOT.zip)
7 | 查看附件
8 |
9 |
10 | ## 功能
11 | 主要用于创建和管理自己的机器人,后台动态查看运行状态和收益信息。
12 | # 一: 简单策略 基于配置条件达到自己的条件计算总体权重触发买入卖出
13 | # 二: 指标策略 组装指标(RSI MACD ......等等 可以自由组合) 基于指标的值 触发买入卖出
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 | - 火币api设置
41 | - 邮件提醒设置 下单后将推送邮件
42 |
43 |
44 | ```
45 |
46 | ## 开发
47 |
48 | ```bash
49 | #后端
50 | springboot
51 |
52 | - [sql脚本](https://github.com/tokenIsme/images/blob/master/quant.sql)
53 | - [前端ui](https://github.com/tokenIsme/quant-admin)
54 |
55 | # 进入前端项目目录
56 | cd quant-admin
57 |
58 | # 安装依赖
59 | npm install
60 |
61 | # 建议不要直接使用 cnpm 安装依赖,会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题
62 | npm install --registry=https://registry.npm.taobao.org
63 |
64 | # 启动服务
65 | npm run dev
66 | 浏览器访问 http://localhost:9527
67 |
68 |
69 | #后端
70 | - 后台由一个admin 控制中心 client 机器人运行节点 和一个注册中心管理 节点信息组成
71 | - 启动机器人由admin分发信息给相应的机器人节点,redis作为消息中间件,在client和admin之间传递信息。
72 | - 项目由springboot构建 运行admin,client,register三个项目 动态扩展的是client节点。
73 | - 进入admin模块配置好配置文件,run AdminApplication
74 | - 进入client模块配置好配置文件,这里主要配置的是redis和节点的外网ip和端口,以便让admin获取到节点的信息。 执行run ClientApplication
75 | - 进入register模块配置好配置文件,run RegisterApplication
76 | ```
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/qt-admin/src/main/docker/DockerFile:
--------------------------------------------------------------------------------
1 | FROM
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/AppAdmin.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6 | import org.springframework.context.annotation.ComponentScan;
7 | import org.springframework.scheduling.annotation.EnableScheduling;
8 |
9 |
10 | @SpringBootApplication
11 | @EnableEurekaClient
12 | @EnableScheduling
13 | @ComponentScan({"com.quant.common", "com.quant.admin"})
14 | public class AppAdmin {
15 | public static void main(String[] args) {
16 | SpringApplication.run(AppAdmin.class, args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/component/ProfitReceiver.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.component;
2 |
3 | import com.alibaba.fastjson.JSON;
4 | import com.baomidou.mybatisplus.mapper.EntityWrapper;
5 | import com.baomidou.mybatisplus.mapper.Wrapper;
6 | import com.quant.common.domain.entity.OrderProfit;
7 | import com.quant.common.domain.vo.ProfitMessage;
8 | import lombok.extern.slf4j.Slf4j;
9 |
10 | import static com.quant.common.utils.JsonFormate.parseJsonToString;
11 |
12 | /***
13 | * 消息接收者(订阅者) 需要注入到springboot中 @Value(value = "${landen.ip}")
14 | * private String ip;
15 | * @Value(value = "${landen.port}")
16 | * private int port;
17 | */
18 | @Slf4j
19 | public class ProfitReceiver {
20 | /**
21 | * 收到通道的消息之后执行的方法
22 | *
23 | * @param message
24 | */
25 | public void receiveMessage(String message) {
26 | ProfitMessage msg = JSON.parseObject(parseJsonToString(message), ProfitMessage.class);
27 | OrderProfit isExist = new OrderProfit();
28 | Wrapper wrapper = new EntityWrapper<>();
29 | wrapper.eq("sell_order_id", msg.getSellOrderId());
30 | wrapper.eq("buy_order_id", msg.getBuyOrderId());
31 | OrderProfit one = isExist.selectOne(wrapper);
32 | log.info("sell_order_id》{},buy_order_id {}, one{}", msg.getSellOrderId(), msg.getBuyOrderId(), one);
33 | if (one == null) {
34 | log.info("插入盈利信息,购买订单id{},卖出订单id{}", msg.getBuyOrderId(), msg.getSellOrderId());
35 | OrderProfit orderProfit = new OrderProfit();
36 | orderProfit.setSellOrderId(msg.getSellOrderId());
37 | orderProfit.setBuyOrderId(msg.getBuyOrderId());
38 | orderProfit.setRobotId(msg.getRobot_id());
39 | orderProfit.setBuyAmount(msg.getBuyAmount());
40 | orderProfit.setBuyPrice(msg.getBuyPrice());
41 | orderProfit.setSellAmount(msg.getSellAmount());
42 | orderProfit.setSellPrice(msg.getSellPrice());
43 | orderProfit.setBuyCashAmount(msg.getBuyCashAmount());
44 | orderProfit.setSellCashAmount(msg.getSellCashAmount());
45 | orderProfit.setDiff(msg.getDiff());
46 | orderProfit.setDivide(msg.getDivide());
47 | if (orderProfit.insert()) {
48 | log.info("插入盈利数据成功!!!");
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/component/RobotMsgReceiver.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.component;
2 |
3 | import com.alibaba.fastjson.JSON;
4 | import com.quant.common.domain.to.RobotRunMessage;
5 | import com.quant.common.utils.JsonFormate;
6 | import lombok.extern.slf4j.Slf4j;
7 | import org.springframework.messaging.simp.SimpMessagingTemplate;
8 |
9 | /***
10 | * 消息接收者(订阅者) 需要注入到springboot中
11 | */
12 | @Slf4j
13 | public class RobotMsgReceiver {
14 |
15 | private SimpMessagingTemplate simpMessageSendingOperations;//消息发送模板
16 |
17 | public RobotMsgReceiver(SimpMessagingTemplate simpMessageSendingOperations) {
18 | this.simpMessageSendingOperations = simpMessageSendingOperations;
19 | }
20 |
21 | /**
22 | * 收到通道的消息之后执行的方法
23 | *
24 | * @param message
25 | */
26 | public void receiveMessage(String message) {
27 | try {
28 | //这里是收到通道的消息之后执行的方法??
29 | RobotRunMessage msg = JSON.parseObject(JsonFormate.parseJsonToString(message), RobotRunMessage.class);
30 | simpMessageSendingOperations.convertAndSend("/topic/" + msg.getRobotId(), JsonFormate.parseJsonToString(message));
31 | } catch (NumberFormatException e) {
32 | e.printStackTrace();
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/config/AsyncConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.scheduling.annotation.EnableAsync;
6 | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
7 |
8 | import java.util.concurrent.Executor;
9 |
10 | @Configuration
11 | @EnableAsync
12 | public class AsyncConfig {
13 |
14 | private final static int corePoolSize = 2;
15 | private final static int maxPoolSize = 4;
16 | private final static int queueCapacity = 6;
17 |
18 | @Bean
19 | public Executor taskExecutor() {
20 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
21 | executor.setCorePoolSize(corePoolSize);
22 | executor.setMaxPoolSize(maxPoolSize);
23 | executor.setQueueCapacity(queueCapacity);
24 | executor.initialize();
25 | return executor;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/config/GlobalCorsConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.config;
2 |
3 | import org.springframework.context.annotation.Bean;
4 | import org.springframework.context.annotation.Configuration;
5 | import org.springframework.web.servlet.config.annotation.CorsRegistry;
6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
7 |
8 | @Configuration
9 | public class GlobalCorsConfig {
10 |
11 |
12 | @Bean
13 | public WebMvcConfigurer addCorsMappings() {
14 |
15 | return new WebMvcConfigurer() {
16 | @Override
17 | public void addCorsMappings(CorsRegistry registry) {
18 |
19 | registry.addMapping("/**")
20 | .allowCredentials(true)
21 | .allowedHeaders("*")
22 | .allowedOrigins("*")
23 | .allowedMethods("*");
24 | }
25 | };
26 |
27 | }
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/config/MybatisPlusConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.config;
2 |
3 | import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
4 | import org.mybatis.spring.annotation.MapperScan;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.context.annotation.Configuration;
7 | import org.springframework.transaction.annotation.EnableTransactionManagement;
8 |
9 | //Spring boot方式
10 | @EnableTransactionManagement
11 | @Configuration
12 | @MapperScan("com.quant.admin.dao")
13 | public class MybatisPlusConfig {
14 |
15 | /**
16 | * 分页插件
17 | */
18 | @Bean
19 | public PaginationInterceptor paginationInterceptor() {
20 | return new PaginationInterceptor();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/config/WebSocketConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.config;
2 |
3 | import org.springframework.context.annotation.Configuration;
4 | import org.springframework.messaging.simp.config.MessageBrokerRegistry;
5 | import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
6 | import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
7 | import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
8 |
9 |
10 | @Configuration
11 | @EnableWebSocketMessageBroker
12 | public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
13 | @Override
14 | public void registerStompEndpoints(StompEndpointRegistry registry) {
15 | //注册一个Stomp 协议的endpoint指定URL为myWebSocket,并用.withSockJS()指定 SockJS协议。.setAllowedOrigins("*")设置跨域
16 | registry.addEndpoint("/robotLog").setAllowedOrigins("*").withSockJS();
17 | }
18 |
19 | @Override
20 | public void configureMessageBroker(MessageBrokerRegistry config) {
21 | //配置消息代理(message broker)
22 | //将消息传回给以‘/topic’开头的客户端
23 | config.enableSimpleBroker("/topic");
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/controller/AccountController.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.controller;
2 |
3 |
4 | import com.quant.admin.service.AccountService;
5 | import com.quant.common.domain.vo.AccountVo;
6 | import com.quant.core.api.ApiResult;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.web.bind.annotation.*;
9 | import org.springframework.web.servlet.ModelAndView;
10 |
11 | import javax.servlet.http.HttpServletRequest;
12 | import javax.servlet.http.HttpServletResponse;
13 |
14 |
15 | /**
16 | *
17 | * 前端控制器
18 | *
19 | *
20 | * @author yang
21 | * @since 2019-04-08
22 | */
23 | @RestController
24 | @RequestMapping("/account")
25 | public class AccountController extends BaseController {
26 |
27 | @Autowired
28 | AccountService accountService;
29 |
30 | @GetMapping("/accountsByUid")
31 | public ApiResult getAccountsByUid(int uid, int page, int limit) {
32 | return accountService.selectListByUid(uid, page, limit);
33 | }
34 |
35 | @GetMapping("/accounts")
36 | public ApiResult getAccountsByUid(int uid) {
37 | return accountService.accounts(uid);
38 | }
39 |
40 | /**
41 | * 添加或者更新一个账户
42 | *
43 | * @return
44 | */
45 | @PostMapping("/addOrUpdate")
46 | public ApiResult addAccount(@RequestBody AccountVo account) {
47 | return accountService.addOrUpdate(account);
48 | }
49 |
50 |
51 | @Override
52 | protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
53 | return null;
54 | }
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/controller/BalanceController.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.controller;
2 |
3 | import com.quant.admin.service.BalanceService;
4 | import com.quant.core.api.ApiResult;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.GetMapping;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 | import org.springframework.web.servlet.ModelAndView;
10 |
11 | import javax.servlet.http.HttpServletRequest;
12 | import javax.servlet.http.HttpServletResponse;
13 |
14 | /**
15 | *
16 | * 前端控制器
17 | *
18 | *
19 | * @author yang
20 | * @since 2019-04-15
21 | */
22 | @RestController
23 | @RequestMapping("/balance")
24 | public class BalanceController extends BaseController {
25 |
26 | @Autowired
27 | BalanceService balanceService;
28 |
29 |
30 | @GetMapping("/getBalanceList")
31 | public ApiResult getBalanceList(String accountId) {
32 | return balanceService.getBalanceListByAccountId(accountId);
33 | }
34 |
35 |
36 | @Override
37 | protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
38 | return null;
39 | }
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/controller/BaseController.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.controller;
2 |
3 | import org.springframework.web.servlet.ModelAndView;
4 | import org.springframework.web.servlet.mvc.AbstractController;
5 |
6 | import javax.servlet.http.HttpServletRequest;
7 | import javax.servlet.http.HttpServletResponse;
8 |
9 | public class BaseController extends AbstractController {
10 |
11 |
12 | public String getUid(HttpServletRequest httpRequest) {
13 | return httpRequest.getHeader("X-Token");
14 | }
15 |
16 | @Override
17 | protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
18 | return null;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/controller/NodeController.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.controller;
2 |
3 | import com.alibaba.fastjson.JSONObject;
4 | import com.netflix.appinfo.InstanceInfo;
5 | import com.netflix.discovery.EurekaClient;
6 | import com.netflix.discovery.shared.Application;
7 | import com.netflix.discovery.shared.Applications;
8 | import com.quant.common.enums.Status;
9 | import com.quant.core.api.ApiResult;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.beans.factory.annotation.Qualifier;
12 | import org.springframework.web.bind.annotation.GetMapping;
13 | import org.springframework.web.bind.annotation.RequestMapping;
14 | import org.springframework.web.bind.annotation.RestController;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 | import java.util.concurrent.CopyOnWriteArrayList;
19 |
20 | @RestController
21 | @RequestMapping("/node")
22 | public class NodeController extends BaseController {
23 | private static final String clientStr = "qt-client";
24 | @Qualifier("eurekaClient")
25 | @Autowired
26 | EurekaClient eurekaClient;
27 |
28 | @GetMapping("/nodes")
29 | public ApiResult nodes() {
30 |
31 | Applications applications = eurekaClient.getApplications();
32 | List apps = applications.getRegisteredApplications();
33 | List list = new ArrayList<>();
34 | int i = 0;
35 | for (Application application : apps) {
36 | if (application.getName().toLowerCase().equals(clientStr)) {
37 | try {
38 | List instanceInfos = new CopyOnWriteArrayList<>(application.getInstances());
39 | for (InstanceInfo instanceInfo : instanceInfos) {
40 | JSONObject obj = new JSONObject();
41 | obj.put("ipo", instanceInfo.getIPAddr() + ":" + instanceInfo.getPort());
42 | obj.put("id", i);
43 | list.add(obj);
44 | i++;
45 | }
46 | } catch (Exception ex) {
47 | ex.printStackTrace();
48 | return new ApiResult(Status.ERROR);
49 | }
50 | }
51 |
52 | }
53 | return new ApiResult(Status.SUCCESS, list);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/controller/OrderController.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.controller;
2 |
3 |
4 | import com.quant.admin.service.OrdersService;
5 | import com.quant.core.api.ApiResult;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.web.bind.annotation.GetMapping;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 | import org.springframework.web.servlet.ModelAndView;
11 | import org.springframework.web.servlet.mvc.AbstractController;
12 |
13 | import javax.servlet.http.HttpServletRequest;
14 | import javax.servlet.http.HttpServletResponse;
15 |
16 | /**
17 | *
18 | * 前端控制器
19 | *
20 | *
21 | * @author yang
22 | * @since 2019-04-22
23 | */
24 | @RestController
25 | @RequestMapping("/order")
26 | public class OrderController extends AbstractController {
27 |
28 | @Autowired
29 | private OrdersService ordersService;
30 |
31 | /**
32 | * 订单列表
33 | *
34 | * @return
35 | */
36 | @GetMapping("/list")
37 | public ApiResult list(int rid, int page, int limit) {
38 | return ordersService.getOrderByRobotId(rid,page,limit);
39 | }
40 |
41 | @Override
42 | protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
43 | return null;
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/controller/OrderProfitController.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.controller;
2 |
3 |
4 | import com.quant.admin.service.OrderProfitService;
5 | import com.quant.core.api.ApiResult;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.web.bind.annotation.GetMapping;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RestController;
10 | import org.springframework.web.servlet.ModelAndView;
11 | import org.springframework.web.servlet.mvc.AbstractController;
12 |
13 | import javax.servlet.http.HttpServletRequest;
14 | import javax.servlet.http.HttpServletResponse;
15 |
16 | /**
17 | *
18 | * 前端控制器
19 | *
20 | *
21 | * @author yang
22 | * @since 2019-04-26
23 | */
24 | @RestController
25 | @RequestMapping("/orderProfit")
26 | public class OrderProfitController extends AbstractController {
27 |
28 | @Autowired
29 | OrderProfitService orderProfitService;
30 | /**
31 | * 订单列表
32 | *
33 | * @return
34 | */
35 | @GetMapping("/list")
36 | public ApiResult list(int rid, int page, int limit) {
37 | return orderProfitService.getProfitList(rid,page,limit);
38 | }
39 |
40 |
41 | @Override
42 | protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
43 | return null;
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/controller/RobotController.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.controller;
2 |
3 |
4 | import com.quant.admin.service.RobotService;
5 | import com.quant.core.api.ApiResult;
6 | import com.quant.common.domain.vo.RobotVo;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.web.bind.annotation.*;
9 | import org.springframework.web.servlet.ModelAndView;
10 |
11 | import javax.servlet.http.HttpServletRequest;
12 | import javax.servlet.http.HttpServletResponse;
13 | import javax.validation.constraints.NotBlank;
14 | import javax.validation.constraints.NotNull;
15 |
16 | /**
17 | *
18 | * 前端控制器
19 | *
20 | *
21 | * @author yang
22 | * @since 2019-04-17
23 | */
24 | @RestController
25 | @RequestMapping("/robot")
26 | public class RobotController extends BaseController {
27 | @Autowired
28 | RobotService robotService;
29 |
30 | @PostMapping("/addOrUpdateRobot")
31 | public ApiResult addOrUpdateRobot(@RequestBody RobotVo vo, HttpServletRequest request) {
32 | @NotBlank
33 | String uid = getUid(request);
34 | vo.setUserId(uid);
35 | return robotService.addOrUpdateRobot(vo);
36 | }
37 |
38 |
39 | @GetMapping("/getRobotById")
40 | public ApiResult getRobotById(int id) {
41 | return robotService.getRobotById(id);
42 | }
43 |
44 | /**
45 | * 获取我的机器人
46 | *
47 | * @return
48 | */
49 | @GetMapping("/list")
50 | public ApiResult list(HttpServletRequest request) {
51 | @NotBlank
52 | String uid = getUid(request);
53 | return robotService.list(uid);
54 | }
55 |
56 | /**
57 | * 删除我的机器人
58 | *
59 | * @return
60 | */
61 | @GetMapping("/deleteRobot")
62 | public ApiResult deleteRobot(HttpServletRequest request, int id) {
63 | @NotBlank
64 | String uid = getUid(request);
65 | return robotService.deleteRobot(uid, id);
66 | }
67 |
68 |
69 | /**
70 | * 启动或者关闭机器人
71 | *
72 | * @param id 机器人编号
73 | * @return
74 | */
75 | @GetMapping("/operatingRobot")
76 | public ApiResult operatingRobot(@NotNull Integer id, @NotBlank Integer state, HttpServletRequest request) {
77 | @NotBlank
78 | String uid = getUid(request);
79 | return robotService.operatingRobot(id, state, uid);
80 | }
81 |
82 | @Override
83 | protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
84 | return null;
85 | }
86 | }
87 |
88 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/controller/SymbolController.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.controller;
2 |
3 | import com.quant.admin.service.SymbolService;
4 | import com.quant.core.api.ApiResult;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.GetMapping;
7 | import org.springframework.web.bind.annotation.RequestMapping;
8 | import org.springframework.web.bind.annotation.RestController;
9 |
10 | @RequestMapping("symbol")
11 | @RestController
12 | public class SymbolController extends BaseController {
13 |
14 | @Autowired
15 | SymbolService symbolService;
16 |
17 |
18 | @GetMapping("/symbols")
19 | public ApiResult getSymbols() {
20 | return symbolService.getSymbols();
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.controller;
2 |
3 |
4 | import com.quant.common.domain.entity.User;
5 | import com.quant.admin.service.UserService;
6 | import com.quant.core.api.ApiResult;
7 | import org.slf4j.Logger;
8 | import org.slf4j.LoggerFactory;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.web.bind.annotation.*;
11 | import org.springframework.web.servlet.ModelAndView;
12 |
13 | import javax.servlet.http.HttpServletRequest;
14 | import javax.servlet.http.HttpServletResponse;
15 | import javax.validation.constraints.NotNull;
16 |
17 | /**
18 | *
19 | * 前端控制器
20 | *
21 | *
22 | * @author yang
23 | * @since 2019-04-08
24 | */
25 | @RestController
26 | @RequestMapping("/user")
27 | public class UserController extends BaseController {
28 |
29 | private static Logger logger = LoggerFactory.getLogger(UserController.class);
30 |
31 |
32 | @Autowired
33 | UserService userService;
34 |
35 | /**
36 | * 登录
37 | *
38 | * @param user
39 | * @return
40 | */
41 | @PostMapping(value = "/login")
42 | public ApiResult login(@RequestBody User user) {
43 | return userService.login(user);
44 | }
45 |
46 | /**
47 | * 退出登录
48 | *
49 | * @return
50 | */
51 | @PostMapping(value = "/logout")
52 | public ApiResult logout() {
53 | return userService.logout();
54 | }
55 |
56 |
57 |
58 |
59 | @GetMapping(value = "/info")
60 | public ApiResult info(@NotNull String token) {
61 | return userService.info(token);
62 | }
63 |
64 | @GetMapping(value = "/getUserEmail")
65 | public ApiResult getUserEmail(@NotNull Integer id) {
66 | return userService.getUserEmail(id);
67 | }
68 |
69 |
70 | @PostMapping(value = "/emailEditer")
71 | public ApiResult emailEditer(@NotNull @RequestBody User user) {
72 | return userService.emailEditer(user);
73 | }
74 |
75 |
76 |
77 | @Override
78 | protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
79 | logger.info("method====" + httpServletRequest.getMethod());
80 | return null;
81 | }
82 | }
83 |
84 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/dao/AccountMapper.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.dao;
2 |
3 | import com.quant.common.domain.entity.Account;
4 | import com.baomidou.mybatisplus.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author yang
12 | * @since 2019-04-08
13 | */
14 | public interface AccountMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/dao/BalanceMapper.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.dao;
2 |
3 | import com.baomidou.mybatisplus.mapper.BaseMapper;
4 | import com.quant.common.domain.entity.Balance;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author yang
12 | * @since 2019-04-15
13 | */
14 | public interface BalanceMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/dao/OrderProfitMapper.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.dao;
2 |
3 | import com.baomidou.mybatisplus.mapper.BaseMapper;
4 | import com.quant.common.domain.entity.OrderProfit;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author yang
12 | * @since 2019-04-26
13 | */
14 | public interface OrderProfitMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/dao/OrdersMapper.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.dao;
2 |
3 | import com.baomidou.mybatisplus.mapper.BaseMapper;
4 | import com.quant.common.domain.entity.Orders;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author yang
12 | * @since 2019-04-22
13 | */
14 | public interface OrdersMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/dao/RobotMapper.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.dao;
2 |
3 | import com.baomidou.mybatisplus.mapper.BaseMapper;
4 | import com.quant.common.domain.bo.RobotBo;
5 | import com.quant.common.domain.entity.Robot;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | *
11 | * Mapper 接口
12 | *
13 | *
14 | * @author yang
15 | * @since 2019-04-17
16 | */
17 | public interface RobotMapper extends BaseMapper {
18 | List getRobotList(String uid);
19 | }
20 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/dao/StrategyMapper.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.dao;
2 |
3 | import com.baomidou.mybatisplus.mapper.BaseMapper;
4 | import com.quant.common.domain.entity.Strategy;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author yang
12 | * @since 2019-04-15
13 | */
14 | public interface StrategyMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/dao/SymbolMapper.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.dao;
2 |
3 | import com.baomidou.mybatisplus.mapper.BaseMapper;
4 | import com.quant.common.domain.entity.Symbol;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author yang
12 | * @since 2019-04-17
13 | */
14 | public interface SymbolMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/dao/UserMapper.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.dao;
2 |
3 | import com.quant.common.domain.entity.User;
4 | import com.baomidou.mybatisplus.mapper.BaseMapper;
5 |
6 | /**
7 | *
8 | * Mapper 接口
9 | *
10 | *
11 | * @author yang
12 | * @since 2019-04-08
13 | */
14 | public interface UserMapper extends BaseMapper {
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/rest/RobotClientService.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.rest;
2 |
3 | import com.quant.common.domain.vo.IndicatorStrategyVo;
4 | import com.quant.core.api.ApiResult;
5 | import com.quant.common.domain.vo.RobotStrategyVo;
6 |
7 | public interface RobotClientService {
8 |
9 | ApiResult operatingRobot(String url, RobotStrategyVo vo);
10 |
11 | ApiResult operatingIndicatorRobot(String url, IndicatorStrategyVo strategyVo);
12 | }
13 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/rest/impl/RobotClientServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.rest.impl;
2 |
3 | import com.quant.admin.rest.RobotClientService;
4 | import com.quant.common.domain.vo.IndicatorStrategyVo;
5 | import com.quant.core.api.ApiResult;
6 | import com.quant.common.domain.vo.RobotStrategyVo;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Service;
9 | import org.springframework.web.client.RestTemplate;
10 |
11 | /**
12 | * 调用机器人节点服务器 传递数据给机器人
13 | */
14 | @Service
15 | public class RobotClientServiceImpl implements RobotClientService {
16 |
17 | @Autowired
18 | RestTemplate restTemplate;
19 |
20 | /**
21 | * 发送信息到client端
22 | *
23 | * @param url
24 | * @param vo
25 | * @return
26 | */
27 | @Override
28 | public ApiResult operatingRobot(String url, RobotStrategyVo vo) {
29 | return restTemplate.postForEntity(url, vo, ApiResult.class).getBody();
30 | }
31 |
32 | @Override
33 | public ApiResult operatingIndicatorRobot(String url, IndicatorStrategyVo strategyVo) {
34 | return restTemplate.postForEntity(url, strategyVo, ApiResult.class).getBody();
35 | }
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/AccountService.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service;
2 |
3 | import com.quant.common.domain.entity.Account;
4 | import com.baomidou.mybatisplus.service.IService;
5 | import com.quant.common.domain.vo.AccountVo;
6 | import com.quant.core.api.ApiResult;
7 |
8 | /**
9 | *
10 | * 服务类
11 | *
12 | *
13 | * @author yang
14 | * @since 2019-04-08
15 | */
16 | public interface AccountService extends IService {
17 |
18 | /**
19 | * 添加一个账户
20 | *
21 | * @param account
22 | */
23 | ApiResult addOrUpdate(AccountVo account);
24 |
25 | ApiResult selectListByUid(int uid, int page, int limit);
26 |
27 | ApiResult accounts(int uid);
28 | }
29 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/BalanceService.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service;
2 |
3 | import com.baomidou.mybatisplus.service.IService;
4 | import com.quant.common.domain.entity.Balance;
5 | import com.quant.core.api.ApiResult;
6 |
7 | /**
8 | *
9 | * 服务类
10 | *
11 | *
12 | * @author yang
13 | * @since 2019-04-15
14 | */
15 | public interface BalanceService extends IService {
16 |
17 | ApiResult getBalanceListByAccountId(String accountId);
18 | }
19 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/IMailService.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service;
2 |
3 | import javax.mail.MessagingException;
4 |
5 | public interface IMailService {
6 | /**
7 | * 发送文本邮件
8 | *
9 | * @param to
10 | * @param subject
11 | * @param content
12 | */
13 | void sendSimpleMail(String to, String subject, String content);
14 |
15 |
16 | /**
17 | * 发送HTML邮件
18 | *
19 | * @param to
20 | * @param subject
21 | * @param content
22 | * @throws MessagingException
23 | */
24 | void sendHtmlMail(String to, String subject, String content) throws MessagingException;
25 |
26 | /**
27 | * 发送带附件的邮件
28 | *
29 | * @param to
30 | * @param subject
31 | * @param content
32 | * @param filePath
33 | * @throws MessagingException
34 | */
35 | void sendAttachmentsMail(String to, String subject, String content, String filePath) throws MessagingException;
36 |
37 | /**
38 | * 发送正文中有静态资源的邮件
39 | *
40 | * @param to
41 | * @param subject
42 | * @param content
43 | * @param rscPath
44 | * @param rscId
45 | * @throws MessagingException
46 | */
47 | void sendResourceMail(String to, String subject, String content, String rscPath, String rscId) throws MessagingException;
48 |
49 |
50 | }
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/OrderProfitService.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service;
2 |
3 | import com.baomidou.mybatisplus.service.IService;
4 | import com.quant.common.domain.entity.OrderProfit;
5 | import com.quant.core.api.ApiResult;
6 |
7 | /**
8 | *
9 | * 服务类
10 | *
11 | *
12 | * @author yang
13 | * @since 2019-04-26
14 | */
15 | public interface OrderProfitService extends IService {
16 |
17 | ApiResult getProfitList(int rid, int page, int limit);
18 | }
19 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/OrdersService.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service;
2 |
3 | import com.baomidou.mybatisplus.service.IService;
4 | import com.quant.common.domain.entity.Orders;
5 | import com.quant.core.api.ApiResult;
6 |
7 | /**
8 | *
9 | * 服务类
10 | *
11 | *
12 | * @author yang
13 | * @since 2019-04-22
14 | */
15 | public interface OrdersService extends IService {
16 |
17 | ApiResult getOrderByRobotId(int robotId, int page, int limit);
18 | }
19 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/RobotService.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service;
2 |
3 | import com.baomidou.mybatisplus.service.IService;
4 | import com.quant.common.domain.entity.Robot;
5 | import com.quant.core.api.ApiResult;
6 | import com.quant.common.domain.vo.RobotVo;
7 |
8 | import javax.validation.constraints.NotBlank;
9 |
10 | /**
11 | *
12 | * 服务类
13 | *
14 | *
15 | * @author yang
16 | * @since 2019-04-17
17 | */
18 | public interface RobotService extends IService {
19 |
20 | ApiResult addOrUpdateRobot(RobotVo vo);
21 |
22 | ApiResult list(String uid);
23 |
24 | ApiResult operatingRobot(Integer id,Integer state, String uid);
25 |
26 | ApiResult deleteRobot(String uid,int id);
27 |
28 | boolean editRobotRunState(int runState);
29 |
30 | ApiResult getRobotById(@NotBlank int uid);
31 | }
32 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/StrategyService.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service;
2 |
3 | import com.alibaba.fastjson.JSONObject;
4 | import com.baomidou.mybatisplus.service.IService;
5 | import com.quant.common.domain.entity.Strategy;
6 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
7 | import com.quant.common.domain.to.llIndicatorTo;
8 | import com.quant.core.api.ApiResult;
9 | import com.quant.common.domain.vo.StrategyVo;
10 |
11 | /**
12 | *
13 | * 服务类
14 | *
15 | *
16 | * @author yang
17 | * @since 2019-04-15
18 | */
19 | public interface StrategyService extends IService {
20 |
21 | ApiResult addOrUpdateStrategy(StrategyVo strategyVo, String uid);
22 |
23 | ApiResult strategyList(String uid);
24 |
25 | ApiResult simpleStrategyList(String uid);
26 |
27 | ApiResult getStrategyById(int id, String uid);
28 |
29 | ApiResult deleteStrategy(int id, String uid);
30 |
31 | ApiResult addOrUpdateIndicatorStrategy(llIndicatorTo strategyVo, String uid);
32 | }
33 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/SymbolService.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service;
2 |
3 | import com.baomidou.mybatisplus.service.IService;
4 | import com.quant.common.domain.entity.Symbol;
5 | import com.quant.core.api.ApiResult;
6 |
7 | /**
8 | *
9 | * 服务类
10 | *
11 | *
12 | * @author yang
13 | * @since 2019-04-17
14 | */
15 | public interface SymbolService extends IService {
16 |
17 | ApiResult getSymbols();
18 | }
19 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service;
2 |
3 | import com.baomidou.mybatisplus.service.IService;
4 | import com.quant.common.domain.entity.User;
5 | import com.quant.core.api.ApiResult;
6 |
7 | import javax.validation.constraints.NotNull;
8 |
9 | /**
10 | *
11 | * 服务类
12 | *
13 | *
14 | * @author yang
15 | * @since 2019-04-08
16 | */
17 | public interface UserService extends IService {
18 |
19 | /**
20 | * simple登录
21 | * @param params
22 | * @return
23 | */
24 | ApiResult login(User params);
25 |
26 |
27 | ApiResult info(String token);
28 |
29 | ApiResult logout();
30 |
31 | ApiResult getUserEmail(@NotNull Integer id);
32 |
33 | ApiResult emailEditer(@NotNull User user);
34 | }
35 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/impl/BalanceServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service.impl;
2 |
3 | import com.baomidou.mybatisplus.mapper.EntityWrapper;
4 | import com.baomidou.mybatisplus.mapper.Wrapper;
5 | import com.baomidou.mybatisplus.service.impl.ServiceImpl;
6 | import com.quant.admin.dao.BalanceMapper;
7 | import com.quant.common.domain.entity.Balance;
8 | import com.quant.admin.service.BalanceService;
9 | import com.quant.common.enums.Status;
10 | import com.quant.core.api.ApiResult;
11 | import org.springframework.stereotype.Service;
12 |
13 | import java.util.Collections;
14 | import java.util.List;
15 |
16 | /**
17 | *
18 | * 服务实现类
19 | *
20 | *
21 | * @author yang
22 | * @since 2019-04-15
23 | */
24 | @Service
25 | public class BalanceServiceImpl extends ServiceImpl implements BalanceService {
26 |
27 | @Override
28 | public ApiResult getBalanceListByAccountId(String accountId) {
29 | try {
30 | Wrapper balanceWrapper = new EntityWrapper<>();
31 | balanceWrapper.eq("account_id", accountId);
32 | balanceWrapper.orderDesc(Collections.singleton("trade_balance"));
33 | Balance balance = new Balance();
34 | List balances = balance.selectList(balanceWrapper);
35 | return new ApiResult(Status.SUCCESS, balances);
36 | } catch (Exception e) {
37 | return new ApiResult(Status.ERROR);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/impl/OrderProfitServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service.impl;
2 |
3 | import com.baomidou.mybatisplus.mapper.EntityWrapper;
4 | import com.baomidou.mybatisplus.mapper.Wrapper;
5 | import com.baomidou.mybatisplus.plugins.Page;
6 | import com.baomidou.mybatisplus.service.impl.ServiceImpl;
7 | import com.quant.admin.dao.OrderProfitMapper;
8 | import com.quant.common.domain.entity.OrderProfit;
9 | import com.quant.admin.service.OrderProfitService;
10 | import com.quant.core.api.ApiResult;
11 | import com.quant.common.enums.Status;
12 | import lombok.extern.slf4j.Slf4j;
13 | import org.springframework.stereotype.Service;
14 |
15 | import java.util.Collections;
16 |
17 | /**
18 | *
19 | * 服务实现类
20 | *
21 | *
22 | * @author yang
23 | * @since 2019-04-26
24 | */
25 | @Slf4j
26 | @Service
27 | public class OrderProfitServiceImpl extends ServiceImpl implements OrderProfitService {
28 |
29 | @Override
30 | public ApiResult getProfitList(int rid, int page, int limit) {
31 | try {
32 | Wrapper orderProfitEntityWrapper = new EntityWrapper<>();
33 | orderProfitEntityWrapper.eq("robot_id", rid);
34 | orderProfitEntityWrapper.orderDesc(Collections.singleton("create_time"));
35 | OrderProfit orders = new OrderProfit();
36 | Page ordersPage = orders.selectPage(new Page<>(page, limit), orderProfitEntityWrapper);
37 | return new ApiResult(Status.SUCCESS, ordersPage);
38 | } catch (Exception e) {
39 | e.printStackTrace();
40 | log.error("查询盈亏订单列表失败 {}", e.getMessage());
41 | }
42 | return new ApiResult(Status.ERROR);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/impl/OrdersServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service.impl;
2 |
3 | import com.baomidou.mybatisplus.mapper.EntityWrapper;
4 | import com.baomidou.mybatisplus.mapper.Wrapper;
5 | import com.baomidou.mybatisplus.plugins.Page;
6 | import com.baomidou.mybatisplus.service.impl.ServiceImpl;
7 | import com.quant.admin.dao.OrdersMapper;
8 | import com.quant.common.domain.entity.Orders;
9 | import com.quant.admin.service.OrdersService;
10 | import com.quant.core.api.ApiResult;
11 | import com.quant.common.enums.Status;
12 | import lombok.extern.slf4j.Slf4j;
13 | import org.springframework.stereotype.Service;
14 |
15 | import java.util.Collections;
16 |
17 | /**
18 | *
19 | * 服务实现类
20 | *
21 | *
22 | * @author yang
23 | * @since 2019-04-22
24 | */
25 | @Slf4j
26 | @Service
27 | public class OrdersServiceImpl extends ServiceImpl implements OrdersService {
28 |
29 | @Override
30 | public ApiResult getOrderByRobotId(int rid, int page, int limit) {
31 | try {
32 | Wrapper ordersWrapper = new EntityWrapper<>();
33 | ordersWrapper.eq("robot_id", rid);
34 | ordersWrapper.orderDesc(Collections.singleton("order_id"));
35 | Orders orders = new Orders();
36 | Page ordersPage = orders.selectPage(new Page<>(page, limit), ordersWrapper);
37 | return new ApiResult(Status.SUCCESS, ordersPage);
38 | } catch (Exception e) {
39 | e.printStackTrace();
40 | log.error("查询机器人订单列表失败 {}", e.getMessage());
41 | }
42 | return new ApiResult(Status.ERROR);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/impl/SymbolServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service.impl;
2 |
3 | import com.baomidou.mybatisplus.service.impl.ServiceImpl;
4 | import com.quant.admin.dao.SymbolMapper;
5 | import com.quant.common.domain.entity.Symbol;
6 | import com.quant.admin.service.SymbolService;
7 | import com.quant.common.enums.Status;
8 | import com.quant.core.api.ApiResult;
9 | import org.springframework.stereotype.Service;
10 |
11 | import java.util.List;
12 |
13 | /**
14 | *
15 | * 服务实现类
16 | *
17 | *
18 | * @author yang
19 | * @since 2019-04-17
20 | */
21 | @Service
22 | public class SymbolServiceImpl extends ServiceImpl implements SymbolService {
23 |
24 | @Override
25 | public ApiResult getSymbols() {
26 | Symbol symbol = new Symbol();
27 | List symbols = symbol.selectAll();
28 | return new ApiResult(Status.SUCCESS, symbols);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/service/impl/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.service.impl;
2 |
3 | import com.baomidou.mybatisplus.mapper.EntityWrapper;
4 | import com.baomidou.mybatisplus.service.impl.ServiceImpl;
5 | import com.quant.admin.dao.UserMapper;
6 | import com.quant.common.domain.entity.User;
7 | import com.quant.admin.service.UserService;
8 | import com.quant.common.enums.Status;
9 | import com.quant.core.api.ApiResult;
10 | import org.springframework.stereotype.Service;
11 |
12 | import javax.validation.constraints.NotNull;
13 |
14 | /**
15 | *
16 | * 服务实现类
17 | *
18 | *
19 | * @author yang
20 | * @since 2019-04-08
21 | */
22 | @Service
23 | public class UserServiceImpl extends ServiceImpl implements UserService {
24 |
25 | @Override
26 | public ApiResult login(User params) {
27 | EntityWrapper wrapper = new EntityWrapper<>();
28 | User user = new User();
29 | wrapper.eq("username", params.getUsername());
30 | wrapper.eq("password", params.getPassword());
31 | wrapper.eq("is_delete", 0);
32 | User u = user.selectOne(wrapper);
33 | if (u != null) {
34 | return new ApiResult(Status.SUCCESS, u.getId());
35 | } else {
36 | return new ApiResult(Status.USER_NOT_EXIST);
37 | }
38 |
39 | }
40 |
41 | @Override
42 | public ApiResult info(String token) {
43 | EntityWrapper wrapper = new EntityWrapper<>();
44 | User user = new User();
45 | wrapper.eq("id", token);
46 | wrapper.eq("is_delete", 0);
47 | User u = user.selectOne(wrapper);
48 | if (u != null) {
49 | u.setPassword(null);
50 | return new ApiResult(Status.SUCCESS, u);
51 | } else {
52 | return new ApiResult(Status.USER_NOT_EXIST);
53 | }
54 |
55 | }
56 |
57 | @Override
58 | public ApiResult logout() {
59 | return new ApiResult(Status.SUCCESS);
60 | }
61 |
62 | @Override
63 | public ApiResult getUserEmail(@NotNull Integer id) {
64 | User user = new User();
65 | User selectById = user.selectById(id);
66 | return new ApiResult(Status.SUCCESS, selectById);
67 | }
68 |
69 | @Override
70 | public ApiResult emailEditer(@NotNull User user) {
71 |
72 | boolean byId = user.updateById();
73 | if (byId) {
74 | return new ApiResult(Status.SUCCESS);
75 | }
76 | return new ApiResult(Status.ERROR);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/task/RobotStatusTask.java:
--------------------------------------------------------------------------------
1 | //package com.quant.admin.task;
2 | //
3 | //import com.quant.common.domain.entity.Robot;
4 | //import com.quant.common.config.RedisUtil;
5 | //import com.quant.common.constans.RobotRedisKeyConfig;
6 | //import lombok.extern.slf4j.Slf4j;
7 | //import org.springframework.beans.factory.annotation.Autowired;
8 | //import org.springframework.scheduling.annotation.Async;
9 | //import org.springframework.scheduling.annotation.Scheduled;
10 | //import org.springframework.stereotype.Component;
11 | //
12 | //import java.util.List;
13 | //
14 | //@Slf4j
15 | //@Component
16 | //public class RobotStatusTask {
17 | //
18 | // @Autowired
19 | // RedisUtil redisUtil;
20 | //
21 | // /**
22 | // * 更新机器人的运行状态
23 | // */
24 | // @Async
25 | // @Scheduled(fixedDelay = 5000, initialDelay = 1000)
26 | // public void updateRobotRunState() {
27 | // Robot robot = new Robot();
28 | // List robots = robot.selectAll();
29 | // for (Robot r : robots) {
30 | // String key = RobotRedisKeyConfig.getRobotIsRunStateKey() + r.getId();
31 | // Object o = redisUtil.get(key);
32 | // if (o == null) {
33 | // //已经取消了机器人的运行
34 | // r.setIsRun(0);
35 | // } else {
36 | // r.setIsRun(1);
37 | // }
38 | // try {
39 | // r.updateById();
40 | // } catch (Exception e) {
41 | // e.printStackTrace();
42 | // log.error("更新机器人状态失败");
43 | // }
44 | // }
45 | //
46 | //
47 | // }
48 | //}
49 |
--------------------------------------------------------------------------------
/qt-admin/src/main/java/com/quant/admin/task/SymbolTask.java:
--------------------------------------------------------------------------------
1 | package com.quant.admin.task;
2 |
3 | import com.quant.common.config.RedisUtil;
4 | import com.quant.common.config.VpnProxyConfig;
5 | import com.quant.common.constans.RobotRedisKeyConfig;
6 | import com.quant.core.api.ApiClient;
7 | import com.quant.common.domain.response.Symbol;
8 | import org.slf4j.Logger;
9 | import org.slf4j.LoggerFactory;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.scheduling.annotation.Async;
12 | import org.springframework.scheduling.annotation.Scheduled;
13 | import org.springframework.stereotype.Component;
14 |
15 | import java.util.Comparator;
16 | import java.util.List;
17 | import java.util.stream.Collectors;
18 |
19 | @Component
20 | public class SymbolTask {
21 |
22 | private static Logger logger = LoggerFactory.getLogger(SymbolTask.class);
23 | @Autowired
24 | VpnProxyConfig vpnProxyConfig;
25 | @Autowired
26 | RedisUtil redisUtil;
27 |
28 | /**
29 | * 收集交易对信息存到数据库 /v1/common/symbols
30 | */
31 | @Async
32 | @Scheduled(fixedDelay = 1000 * 60 * 60 * 24, initialDelay = 5000)
33 | public void symbolCollects() {
34 | logger.info("=========数据 redis 同步交易对信息开始=========");
35 | ApiClient apiClient = new ApiClient(vpnProxyConfig);
36 | List symbols = apiClient.getSymbols();
37 | //获取到交易对 进行排序操作 防止每次都插入不一致
38 | symbols = symbols.stream().sorted(Comparator.comparing(Symbol::getSymbol)).collect(Collectors.toList());
39 | int i = 0;
40 | for (Symbol s : symbols) {
41 | ++i;
42 | com.quant.common.domain.entity.Symbol symbol = new com.quant.common.domain.entity.Symbol();
43 | symbol.setId(i);
44 | symbol.setAmountPrecision(s.getAmountPrecision());
45 | symbol.setBaseCurrency(s.getBaseCurrency());
46 | symbol.setPricePrecision(s.getPricePrecision());
47 | symbol.setQuoteCurrency(s.getQuoteCurrency());
48 | symbol.setSymbol(s.getSymbol());
49 | if (symbol.insertOrUpdate()) {
50 | //将交易对的quote保存redis
51 | redisUtil.set(RobotRedisKeyConfig.getSymbol() + symbol.getSymbol(), symbol.getBaseCurrency() + "_" + symbol.getQuoteCurrency() + "_" + symbol.getPricePrecision() + "_" + symbol.getAmountPrecision());
52 | }
53 | }
54 |
55 | logger.info("=========同步交易对信息完毕=========");
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/application-dev.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8080
3 | connection-timeout: 10000
4 | #添加数据源
5 | spring:
6 | datasource:
7 | type: com.alibaba.druid.pool.DruidDataSource
8 | driver-class-name: com.mysql.jdbc.Driver
9 | url: jdbc:mysql://localhost:3306/quant?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
10 | username: root
11 | password: root
12 | druid:
13 | initial-size: 5
14 | min-idle: 10
15 | max-active: 20
16 | max-wait: 60000
17 | min-evictable-idle-time-millis: 6000
18 | time-between-eviction-runs-millis: 3000
19 | validation-query: SELECT 1 FROM DUAL
20 | test-while-idle: true
21 | test-on-borrow: false
22 | test-on-return: false
23 | filters: stat,wall
24 | use-global-data-source-stat: true
25 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
26 | jackson:
27 | date-format: yyyy-MM-dd HH:mm:ss
28 | time-zone: GMT+8
29 | application:
30 | name: qt-admin
31 | redis:
32 | database: 0
33 | host: 127.0.0.1
34 | port: 6379
35 | password:
36 | jedis:
37 | pool:
38 | max-active: 8
39 | max-wait: -1
40 | max-idle: 8
41 | min-idle: 0
42 | timeout: 15000
43 | mail:
44 | host: smtp.qq.com #发送邮件服务器
45 | username: yangge975965279@vip.qq.com #QQ邮箱 请换自己的邮箱谢谢
46 | password: sdncjthvgtwrbfgg #客户端授权码
47 | protocol: smtp #发送邮件协议
48 | properties.mail.smtp.auth: true
49 | properties.mail.smtp.port: 465 #端口号465或587
50 | properties.mail.display.sendmail: quant #可以任意
51 | properties.mail.display.sendname: quant Email #可以任意
52 | properties.mail.smtp.starttls.enable: true
53 | properties.mail.smtp.starttls.required: true
54 | properties.mail.smtp.ssl.enable: true
55 | default-encoding: utf-8
56 | from: yangge975965279@vip.qq.com #与上面的username保持一致
57 | # mapper-locations: classpath:/mapper/*
58 | eureka:
59 | client:
60 | serviceUrl:
61 | defaultZone: http://${EUREKA_ZONE_HOST:localhost}:${EUREKA_ZONE_PORT:8761}/eureka/
62 | mybatis-plus:
63 | mapper-locations: classpath*:mapper/*Mapper.xml
64 |
65 | vpnproxy:
66 | enable: false
67 | ip: 127.0.0.1
68 | port: 1088
69 |
70 |
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/application-prod.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8180
3 | address: 0.0.0.0
4 | #添加数据源
5 | spring:
6 | datasource:
7 | type: com.alibaba.druid.pool.DruidDataSource
8 | driver-class-name: com.mysql.jdbc.Driver
9 | url: jdbc:mysql://localhost:3306/quant?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
10 | username: root
11 | password: xxxx
12 | druid:
13 | initial-size: 5
14 | min-idle: 10
15 | max-active: 20
16 | max-wait: 60000
17 | min-evictable-idle-time-millis: 6000
18 | time-between-eviction-runs-millis: 3000
19 | validation-query: SELECT 1 FROM DUAL
20 | test-while-idle: true
21 | test-on-borrow: false
22 | test-on-return: false
23 | filters: stat,wall
24 | use-global-data-source-stat: true
25 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
26 | jackson:
27 | date-format: yyyy-MM-dd HH:mm:ss
28 | time-zone: GMT+8
29 | application:
30 | name: qt-admin
31 | redis:
32 | database: 0
33 | host: 127.0.0.1
34 | port: 6379
35 | password:
36 | jedis:
37 | pool:
38 | max-active: 8
39 | max-wait: -1
40 | max-idle: 8
41 | min-idle: 0
42 | timeout: 15000
43 | mail:
44 | host: smtp.qq.com #发送邮件服务器
45 | username: yangge975965279@vip.qq.com #QQ邮箱 请换自己的邮箱谢谢
46 | password: sdncjthvgtwrbfgg #客户端授权码
47 | protocol: smtp #发送邮件协议
48 | properties.mail.smtp.auth: true
49 | properties.mail.smtp.port: 465 #端口号465或587
50 | properties.mail.display.sendmail: quant #可以任意
51 | properties.mail.display.sendname: quant Email #可以任意
52 | properties.mail.smtp.starttls.enable: true
53 | properties.mail.smtp.starttls.required: true
54 | properties.mail.smtp.ssl.enable: true
55 | default-encoding: utf-8
56 | from: yangge975965279@vip.qq.com #与上面的username保持一致
57 | eureka:
58 | client:
59 | serviceUrl:
60 | defaultZone: http://${EUREKA_ZONE_HOST:0.0.0.0}:${EUREKA_ZONE_PORT:8762}/eureka/
61 | mybatis-plus:
62 | mapper-locations: classpath*:mapper/*Mapper.xml
63 |
64 | vpnproxy:
65 | enable: false
66 | ip: 127.0.0.1
67 | port: 1088
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | profiles:
3 | active: dev
4 |
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | __ _ _ _ __
2 | / / | | | | (_) \ \
3 | / / __ _ _ _ __ _ _ __ | |_ ______ __ _ __| |_ __ ___ _ _ __ \ \
4 | < < / _` | | | |/ _` | '_ \| __|______/ _` |/ _` | '_ ` _ \| | '_ \ > >
5 | \ | (_| | |_| | (_| | | | | |_ | (_| | (_| | | | | | | | | | |/ /
6 | \_\__, |\__,_|\__,_|_| |_|\__| \__,_|\__,_|_| |_| |_|_|_| |_/_/
7 | | |
8 | |_|
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/mapper/AccountMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | id, user_id AS userId,name as name , access_key AS accessKey, secret_key AS secretKey, type, state, info, create_time AS createTime, is_delete AS isDelete
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/mapper/BalanceMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | id, account_id AS accountId, type, currency, trade_balance AS tradeBalance, frozen_balance AS frozenBalance
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/mapper/OrderProfitMapper.xml:
--------------------------------------------------------------------------------
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 | id, robot_id AS robotId, sell_order_id AS sellOrderId, buy_order_id AS buyOrderId, buy_price AS buyPrice, sell_price AS sellPrice, buy_cash_amount AS buyCashAmount, sell_cash_amount AS sellCashAmount, buy_amount AS buyAmount, sell_amount AS sellAmount, is_profit AS isProfit, diff, divide, create_time AS createTime
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/mapper/OrdersMapper.xml:
--------------------------------------------------------------------------------
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 | id, order_id AS orderId, symbol, robot_id AS robotId, account_id AS accountId, amount, price, order_state AS orderState, order_type AS orderType, create_time AS createTime, finished_time AS finishedTime, field_fees AS fieldFees, field_amount AS fieldAmount, field_cash_amount AS fieldCashAmount
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/mapper/RobotMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | id, user_id AS userId, robot_name AS robotName, symbol, strategy_id AS strategyId, client_address AS clientAddress, create_time AS createTime, is_delete AS isDelete,is_run as isRun
22 |
23 |
24 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/mapper/StrategyMapper.xml:
--------------------------------------------------------------------------------
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 | id, user_id AS userId, strategy_name AS strategyName, buy_amount AS buyAmount, buy_quota_price AS buyQuotaPrice, sell_amount AS sellAmount, buy_price AS buyPrice, sell_price AS sellPrice, is_all_buy AS isAllBuy, is_all_sell AS isAllSell, is_limit_price AS isLimitPrice, sell_all_weights AS sellAllWeights, buy_all_weights AS buyAllWeights, profit, sleep, setting1, setting2, setting3, setting4, setting5, setting6
33 |
34 |
35 |
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/mapper/SymbolMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | id, base_currency AS baseCurrency, quote_currency AS quoteCurrency, price_precision AS pricePrecision, amount_precision AS amountPrecision, symbol
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/mapper/UserMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | id, username, password, create_time AS createTime, is_delete AS isDelete, avatar, introduction, roles
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/qt-admin/src/test/java/com/quant/admin/QtParentApplicationTests.java:
--------------------------------------------------------------------------------
1 | //package com.qklx.qt.admin;
2 | //
3 | //import User;
4 | //import RedisUtil;
5 | //import org.junit.Test;
6 | //import org.junit.runner.RunWith;
7 | //import org.springframework.beans.factory.annotation.Autowired;
8 | //import org.springframework.boot.test.context.SpringBootTest;
9 | //import org.springframework.test.context.junit4.SpringRunner;
10 | //
11 | //@RunWith(SpringRunner.class)
12 | //@SpringBootTest
13 | //public class QtParentApplicationTests {
14 | //
15 | // @Autowired
16 | // RedisUtil redisUtil;
17 | //
18 | //
19 | // @Test
20 | // public void test() throws Exception {
21 | //
22 | // redisUtil.sSet("testSet", 1, 2, 3);
23 | //
24 | // boolean testSet1 = redisUtil.sHasKey("testSet", 1);
25 | // boolean testSet2 = redisUtil.sHasKey("testSet", 4);
26 | // System.out.println("testSet1" + testSet1);
27 | // System.out.println("testSet2" + testSet2);
28 | // }
29 | //
30 | //
31 | //}
32 |
--------------------------------------------------------------------------------
/qt-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | qt-parent
7 | com.quant
8 | 0.0.1-SNAPSHOT
9 | ../pom.xml
10 |
11 | 4.0.0
12 |
13 | qt-client
14 |
15 |
16 | com.quant
17 | qt-core
18 | 0.0.1-SNAPSHOT
19 | compile
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 | org.yaml
28 | snakeyaml
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-starter-data-redis
33 |
34 |
35 |
36 | redis.clients
37 | jedis
38 | 2.7.3
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | org.springframework.boot
47 | spring-boot-maven-plugin
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/qt-client/src/main/java/com/quant/client/AppClient.java:
--------------------------------------------------------------------------------
1 | package com.quant.client;
2 |
3 |
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
7 | import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
8 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
9 | import org.springframework.context.annotation.ComponentScan;
10 | import org.springframework.scheduling.annotation.EnableScheduling;
11 |
12 | @EnableEurekaClient
13 | @EnableScheduling
14 | @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
15 | @ComponentScan({"com.quant.common","com.quant.client"})
16 | public class AppClient {
17 | public static void main(String[] args) {
18 |
19 | SpringApplication.run(AppClient.class, args);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/qt-client/src/main/java/com/quant/client/config/ThreadPool.java:
--------------------------------------------------------------------------------
1 | package com.quant.client.config;
2 |
3 | import com.google.common.util.concurrent.ThreadFactoryBuilder;
4 | import org.springframework.context.annotation.Bean;
5 | import org.springframework.context.annotation.Configuration;
6 |
7 | import java.util.concurrent.*;
8 |
9 | @Configuration
10 | public class ThreadPool {
11 |
12 | @Bean
13 | public ExecutorService initPool() {
14 | ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
15 | .setNameFormat("-----机器人后台程序-----pool--%d").build();
16 | return new ThreadPoolExecutor(10,
17 | 20,
18 | 1000L,
19 | TimeUnit.MILLISECONDS,
20 | new LinkedBlockingQueue<>(1000),
21 | namedThreadFactory,
22 | new ThreadPoolExecutor.AbortPolicy());
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/qt-client/src/main/java/com/quant/client/controller/BotController.java:
--------------------------------------------------------------------------------
1 | package com.quant.client.controller;
2 |
3 | import com.quant.client.service.RobotService;
4 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
5 | import com.quant.common.domain.vo.IndicatorStrategyVo;
6 | import com.quant.core.api.ApiResult;
7 | import com.quant.common.domain.vo.RobotStrategyVo;
8 | import lombok.extern.slf4j.Slf4j;
9 | import org.springframework.beans.factory.annotation.Autowired;
10 | import org.springframework.web.bind.annotation.PostMapping;
11 | import org.springframework.web.bind.annotation.RequestBody;
12 | import org.springframework.web.bind.annotation.RequestMapping;
13 | import org.springframework.web.bind.annotation.RestController;
14 |
15 | @Slf4j
16 | @RestController
17 | @RequestMapping("/robot")
18 | public class BotController {
19 |
20 | @Autowired
21 | RobotService robotService;
22 |
23 | @PostMapping("/operatingRobot")
24 | public ApiResult operatingRobot(@RequestBody RobotStrategyVo vo) {
25 | log.info("获取到机器人的配置信息:{}", vo.toString());
26 | return robotService.operatingRobot(vo);
27 | }
28 |
29 | @PostMapping("/operatingIndicatorRobot")
30 | public ApiResult operatingIndicatorRobot(@RequestBody IndicatorStrategyVo vo) {
31 | log.info("获取到机器人的配置信息:{}", vo.toString());
32 | return robotService.operatingIndicatorRobot(vo);
33 | }
34 |
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/qt-client/src/main/java/com/quant/client/service/RobotService.java:
--------------------------------------------------------------------------------
1 | package com.quant.client.service;
2 |
3 | import com.quant.common.domain.vo.IndicatorStrategyVo;
4 | import com.quant.common.domain.vo.RobotStrategyVo;
5 | import com.quant.core.api.ApiResult;
6 |
7 | public interface RobotService {
8 |
9 |
10 | ApiResult operatingRobot(RobotStrategyVo vo);
11 |
12 | ApiResult operatingIndicatorRobot(IndicatorStrategyVo vo);
13 | }
14 |
--------------------------------------------------------------------------------
/qt-client/src/main/java/com/quant/client/service/impl/RobotServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.client.service.impl;
2 |
3 | import com.quant.client.task.IndicatorRobotOperate;
4 | import com.quant.client.task.SimpleNumRobotOperate;
5 | import com.quant.client.service.RobotService;
6 | import com.quant.common.config.RedisUtil;
7 | import com.quant.common.config.VpnProxyConfig;
8 | import com.quant.common.domain.vo.IndicatorStrategyVo;
9 | import com.quant.core.api.ApiResult;
10 | import com.quant.common.enums.Status;
11 | import com.quant.common.domain.vo.RobotStrategyVo;
12 | import lombok.extern.slf4j.Slf4j;
13 | import org.springframework.beans.factory.annotation.Autowired;
14 | import org.springframework.stereotype.Service;
15 |
16 | import java.util.concurrent.ExecutorService;
17 |
18 | @Slf4j
19 | @Service
20 | public class RobotServiceImpl implements RobotService {
21 | @Autowired
22 | VpnProxyConfig vpnProxyConfig;
23 | @Autowired
24 | RedisUtil redisUtil;
25 | @Autowired
26 | ExecutorService executorService;
27 |
28 | @Override
29 | public ApiResult operatingRobot(RobotStrategyVo vo) {
30 | //启动机器人
31 | try {
32 | executorService.execute(() -> {
33 | SimpleNumRobotOperate robotOperate = new SimpleNumRobotOperate(redisUtil, vpnProxyConfig);
34 | robotOperate.doRobotTask(vo);
35 | });
36 | return new ApiResult(Status.SUCCESS);
37 | } catch (Exception e) {
38 | e.printStackTrace();
39 | log.error("client端启动机器人发生错误:机器人编号:{},client端地址:{}", vo.getRobotId(), vo.getAddress());
40 | log.error("错误信息:" + e.getMessage());
41 | return new ApiResult(Status.startRobotError);
42 | }
43 | }
44 |
45 | @Override
46 | public ApiResult operatingIndicatorRobot(IndicatorStrategyVo vo) {
47 | //启动机器人
48 | try {
49 | executorService.execute(() -> {
50 | IndicatorRobotOperate robotOperate = new IndicatorRobotOperate(redisUtil, vpnProxyConfig);
51 | robotOperate.doRobotTask(vo);
52 | });
53 | return new ApiResult(Status.SUCCESS);
54 | } catch (Exception e) {
55 | e.printStackTrace();
56 | log.error("client端启动机器人发生错误:机器人编号:{},client端地址:{}", vo.getRobotId(), vo.getAddress());
57 | log.error("错误信息:" + e.getMessage());
58 | return new ApiResult(Status.startRobotError);
59 | }
60 |
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/qt-client/src/main/java/com/quant/client/task/IndicatorRobotOperate.java:
--------------------------------------------------------------------------------
1 | package com.quant.client.task;
2 |
3 | import com.quant.common.config.RedisUtil;
4 | import com.quant.common.config.VpnProxyConfig;
5 | import com.quant.common.domain.vo.IndicatorStrategyVo;
6 | import com.quant.common.enums.StrategyType;
7 | import com.quant.core.builder.StrategyBuilder;
8 | import com.quant.core.strategy.StrategyException;
9 | import com.quant.core.strategy.TradingStrategy;
10 | import com.quant.core.strategy.impl.HuoBIndicatoryStrategyImpl;
11 | import lombok.extern.slf4j.Slf4j;
12 |
13 | /**
14 | * IndicatorRobotOperate 指标策略机器人启动
15 | * Created by yang on 2019/5/31.
16 | */
17 | @Slf4j
18 | public class IndicatorRobotOperate {
19 | private RedisUtil redisUtil;
20 |
21 |
22 | private VpnProxyConfig vpnProxyConfig;
23 |
24 | public IndicatorRobotOperate(RedisUtil redisUtil, VpnProxyConfig vpnProxyConfig) {
25 | this.redisUtil = redisUtil;
26 | this.vpnProxyConfig = vpnProxyConfig;
27 | }
28 |
29 | public void doRobotTask(IndicatorStrategyVo vo) {
30 | log.info("启动机器人{}>>>>>>", vo.getRobotId());
31 | TradingStrategy strategy = builderStrategy(vo);
32 | try {
33 | strategy.execute();
34 | } catch (StrategyException e) {
35 | e.printStackTrace();
36 | }
37 |
38 | }
39 |
40 | private TradingStrategy builderStrategy(IndicatorStrategyVo vo) {
41 |
42 | StrategyType indicator = StrategyType.indicator;
43 | StrategyBuilder builder = new StrategyBuilder().setRedisUtil(redisUtil)
44 | .setStratrgyType(indicator)
45 | .setIndicatorStrategyVo(vo).setVpnProxyConfig(vpnProxyConfig)
46 | .buildApiClient()
47 | .buildTradingApi().buildMarketConfig()
48 | .buildStrategyConfig().buildAccountConfig();
49 |
50 | TradingStrategy huoBIndicatoryStrategy = new HuoBIndicatoryStrategyImpl(redisUtil, vo.getRobotId());
51 |
52 | log.info("加载机器人{}>>>>>>", vo.getRobotId());
53 | huoBIndicatoryStrategy.init(builder);
54 | return huoBIndicatoryStrategy;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/qt-client/src/main/java/com/quant/client/task/SimpleNumRobotOperate.java:
--------------------------------------------------------------------------------
1 | package com.quant.client.task;
2 |
3 | import com.quant.common.config.RedisUtil;
4 | import com.quant.common.config.VpnProxyConfig;
5 | import com.quant.common.enums.StrategyType;
6 | import com.quant.core.builder.StrategyBuilder;
7 | import com.quant.core.strategy.StrategyException;
8 | import com.quant.core.strategy.TradingStrategy;
9 | import com.quant.core.strategy.impl.HuoBiSimpleStrategyImpl;
10 | import com.quant.common.domain.vo.RobotStrategyVo;
11 | import lombok.extern.slf4j.Slf4j;
12 |
13 | @Slf4j
14 | public class SimpleNumRobotOperate {
15 |
16 | private RedisUtil redisUtil;
17 |
18 |
19 | private VpnProxyConfig vpnProxyConfig;
20 |
21 | public SimpleNumRobotOperate(RedisUtil redisUtil, VpnProxyConfig vpnProxyConfig) {
22 | this.redisUtil = redisUtil;
23 | this.vpnProxyConfig = vpnProxyConfig;
24 | }
25 |
26 | public void doRobotTask(RobotStrategyVo vo) {
27 | log.info("启动机器人{}>>>>>>", vo.getRobotId());
28 | TradingStrategy strategy = builderStrategy(vo);
29 | try {
30 | strategy.execute();
31 | } catch (StrategyException e) {
32 | e.printStackTrace();
33 | }
34 |
35 | }
36 |
37 | private TradingStrategy builderStrategy(RobotStrategyVo vo) {
38 |
39 | StrategyType simple = StrategyType.simple;
40 | StrategyBuilder builder = new StrategyBuilder().setRedisUtil(redisUtil)
41 | .setStratrgyType(simple)
42 | .setRobotStrategyVo(vo)
43 | .setVpnProxyConfig(vpnProxyConfig)
44 | .buildApiClient()
45 | .buildTradingApi().buildMarketConfig()
46 | .buildStrategyConfig().buildAccountConfig();
47 |
48 | TradingStrategy huoBIndicatoryStrategy = new HuoBiSimpleStrategyImpl(redisUtil, vo.getRobotId());
49 |
50 | log.info("加载机器人{}>>>>>>", vo.getRobotId());
51 | huoBIndicatoryStrategy.init(builder);
52 | return huoBIndicatoryStrategy;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/qt-client/src/main/resources/application-dev.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8024
3 | address: 0.0.0.0
4 | eureka:
5 | client:
6 | serviceUrl:
7 | defaultZone: http://${EUREKA_ZONE_HOST:127.0.0.1}:${EUREKA_ZONE_PORT:8761}/eureka/
8 | instance:
9 | prefer-ip-address: true
10 | ip-address: ${server.address}
11 | spring:
12 | application:
13 | name: qt-client
14 | # rabbitmq:
15 | # host: ${RABBIT_MQ_HOST:localhost}
16 | # port: ${RABBIT_MQ_PORT:5672}
17 | # username: ${RABBIT_MQ_USERNAME:yang}
18 | # password: ${RABBIT_MQ_PASSWORD:yang}
19 | redis:
20 | database: 0
21 | host: 127.0.0.1
22 | port: 6379
23 | password:
24 | jedis:
25 | pool:
26 | max-active: 8
27 | max-wait: -1
28 | max-idle: 8
29 | min-idle: 0
30 | timeout: 15000
31 | feign:
32 | hystrix:
33 | enabled: true
34 |
35 | management:
36 | endpoints:
37 | web:
38 | exposure:
39 | include: '*'
40 | base-path: /
41 | vpnproxy:
42 | enable: true
43 | ip: 127.0.0.1
44 | port: 1088
45 |
46 |
--------------------------------------------------------------------------------
/qt-client/src/main/resources/application-prod.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: 8024
3 | address: 0.0.0.0
4 | eureka:
5 | client:
6 | serviceUrl:
7 | defaultZone: http://${EUREKA_ZONE_HOST:124.156.196.215}:${EUREKA_ZONE_PORT:8762}/eureka/
8 | instance:
9 | prefer-ip-address: true
10 | ip-address: 124.156.196.215
11 |
12 | spring:
13 | application:
14 | name: qt-client
15 | redis:
16 | database: 0
17 | host: 127.0.0.1
18 | port: 6379
19 | password:
20 | jedis:
21 | pool:
22 | max-active: 8
23 | max-wait: -1
24 | max-idle: 8
25 | min-idle: 0
26 | timeout: 15000
27 | feign:
28 | hystrix:
29 | enabled: true
30 |
31 | management:
32 | endpoints:
33 | web:
34 | exposure:
35 | include: '*'
36 | base-path: /
37 | vpnproxy:
38 | enable: false
39 | ip: 127.0.0.1
40 | port: 64035
41 |
42 |
--------------------------------------------------------------------------------
/qt-client/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | profiles:
3 | active: dev
4 |
--------------------------------------------------------------------------------
/qt-client/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | __ _ _ _ _ __
2 | / / | | | (_) | | \ \
3 | / / __ _ _ _ __ _ _ __ | |_ ______ ___| |_ ___ _ __ | |_ \ \
4 | < < / _` | | | |/ _` | '_ \| __|______/ __| | |/ _ | '_ \| __| > >
5 | \ | (_| | |_| | (_| | | | | |_ | (__| | | __| | | | |_ / /
6 | \_\__, |\__,_|\__,_|_| |_|\__| \___|_|_|\___|_| |_|\__/_/
7 | | |
8 | |_|
--------------------------------------------------------------------------------
/qt-client/src/test/java/Test.java:
--------------------------------------------------------------------------------
1 | public class Test {
2 |
3 | public static void main(String[] args) {
4 |
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/config/JsonConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.config;
2 |
3 | import com.alibaba.fastjson.serializer.SerializerFeature;
4 | import com.alibaba.fastjson.support.config.FastJsonConfig;
5 | import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
6 | import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
7 | import org.springframework.context.annotation.Bean;
8 | import org.springframework.context.annotation.Configuration;
9 | import org.springframework.http.converter.HttpMessageConverter;
10 |
11 | @Configuration
12 | public class JsonConfig {
13 |
14 | /**
15 | * 覆盖方法configureMessageConverters,使用fastJson
16 | *
17 | * @return
18 | */
19 | @Bean
20 | public HttpMessageConverters fastJsonHttpMessageConverters() {
21 | //1、定义一个convert转换消息的对象
22 | FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
23 | //2、添加fastjson的配置信息
24 | FastJsonConfig fastJsonConfig = new FastJsonConfig();
25 | fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
26 | //3、在convert中添加配置信息
27 | fastConverter.setFastJsonConfig(fastJsonConfig);
28 | //4、将convert添加到converters中
29 | HttpMessageConverter> converter = fastConverter;
30 | return new HttpMessageConverters(converter);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/config/RedisConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.config;
2 |
3 | import com.fasterxml.jackson.annotation.JsonAutoDetect;
4 | import com.fasterxml.jackson.annotation.PropertyAccessor;
5 | import com.fasterxml.jackson.databind.ObjectMapper;
6 | import org.springframework.context.annotation.Bean;
7 | import org.springframework.context.annotation.Configuration;
8 | import org.springframework.data.redis.connection.RedisConnectionFactory;
9 | import org.springframework.data.redis.core.RedisTemplate;
10 | import org.springframework.data.redis.core.StringRedisTemplate;
11 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
12 |
13 | /**
14 | * RedisConfig 重新 redis存储对象的键值对
15 | */
16 | @Configuration
17 | public class RedisConfig {
18 |
19 | /**
20 | * 定义 StringRedisTemplate ,指定序列化和反序列化的处理类
21 | *
22 | * @param factory
23 | * @return
24 | */
25 | @Bean
26 | public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
27 | StringRedisTemplate template = new StringRedisTemplate(factory);
28 | Jackson2JsonRedisSerializer