├── qt-admin
└── src
│ ├── main
│ ├── docker
│ │ └── DockerFile
│ ├── resources
│ │ ├── application.yml
│ │ ├── banner.txt
│ │ ├── mapper
│ │ │ ├── BalanceMapper.xml
│ │ │ ├── SymbolMapper.xml
│ │ │ ├── UserMapper.xml
│ │ │ ├── AccountMapper.xml
│ │ │ ├── OrdersMapper.xml
│ │ │ ├── OrderProfitMapper.xml
│ │ │ ├── RobotMapper.xml
│ │ │ └── StrategyMapper.xml
│ │ ├── application-prod.yml
│ │ └── application-dev.yml
│ └── java
│ │ └── com
│ │ └── quant
│ │ └── admin
│ │ ├── dao
│ │ ├── UserMapper.java
│ │ ├── OrdersMapper.java
│ │ ├── SymbolMapper.java
│ │ ├── AccountMapper.java
│ │ ├── BalanceMapper.java
│ │ ├── StrategyMapper.java
│ │ ├── OrderProfitMapper.java
│ │ └── RobotMapper.java
│ │ ├── service
│ │ ├── SymbolService.java
│ │ ├── BalanceService.java
│ │ ├── OrdersService.java
│ │ ├── OrderProfitService.java
│ │ ├── AccountService.java
│ │ ├── UserService.java
│ │ ├── RobotService.java
│ │ ├── impl
│ │ │ ├── SymbolServiceImpl.java
│ │ │ ├── BalanceServiceImpl.java
│ │ │ ├── OrdersServiceImpl.java
│ │ │ ├── OrderProfitServiceImpl.java
│ │ │ └── UserServiceImpl.java
│ │ ├── StrategyService.java
│ │ └── IMailService.java
│ │ ├── rest
│ │ ├── RobotClientService.java
│ │ └── impl
│ │ │ └── RobotClientServiceImpl.java
│ │ ├── AppAdmin.java
│ │ ├── controller
│ │ ├── BaseController.java
│ │ ├── SymbolController.java
│ │ ├── BalanceController.java
│ │ ├── OrderController.java
│ │ ├── OrderProfitController.java
│ │ ├── AccountController.java
│ │ ├── UserController.java
│ │ ├── NodeController.java
│ │ └── RobotController.java
│ │ ├── config
│ │ ├── MybatisPlusConfig.java
│ │ ├── GlobalCorsConfig.java
│ │ ├── AsyncConfig.java
│ │ └── WebSocketConfig.java
│ │ ├── component
│ │ ├── RobotMsgReceiver.java
│ │ └── ProfitReceiver.java
│ │ └── task
│ │ ├── RobotStatusTask.java
│ │ └── SymbolTask.java
│ └── test
│ └── java
│ └── com
│ └── quant
│ └── admin
│ └── QtParentApplicationTests.java
├── qt-client
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── application.yml
│ │ │ ├── banner.txt
│ │ │ ├── application-prod.yml
│ │ │ └── application-dev.yml
│ │ └── java
│ │ │ └── com
│ │ │ └── quant
│ │ │ └── client
│ │ │ ├── service
│ │ │ ├── RobotService.java
│ │ │ └── impl
│ │ │ │ └── RobotServiceImpl.java
│ │ │ ├── config
│ │ │ └── ThreadPool.java
│ │ │ ├── AppClient.java
│ │ │ ├── controller
│ │ │ └── BotController.java
│ │ │ └── task
│ │ │ ├── SimpleNumRobotOperate.java
│ │ │ └── IndicatorRobotOperate.java
│ └── test
│ │ └── java
│ │ └── Test.java
└── pom.xml
├── qt-register
├── src
│ └── main
│ │ ├── resources
│ │ ├── application.yml
│ │ ├── application-dev.yml
│ │ ├── application-prod.yml
│ │ └── banner.txt
│ │ └── java
│ │ └── com
│ │ └── quant
│ │ └── center
│ │ ├── te.java
│ │ └── AppRegister.java
└── pom.xml
├── qt-common
└── src
│ └── main
│ ├── resources
│ └── libs
│ │ └── opslabJutil-2.0.3.jar
│ └── java
│ └── com
│ └── quant
│ └── common
│ ├── domain
│ ├── response
│ │ ├── Place.java
│ │ ├── Currencys.java
│ │ ├── Account.java
│ │ ├── Symbol.java
│ │ ├── Kline.java
│ │ ├── Trade.java
│ │ ├── ApiResponse.java
│ │ ├── Batchcancel.java
│ │ ├── TradeBean.java
│ │ ├── Details.java
│ │ ├── HistoryTradess.java
│ │ ├── BalanceBean.java
│ │ ├── BatchcancelBean.java
│ │ ├── TimestampResponse.java
│ │ ├── Accounts.java
│ │ ├── SubmitcancelResponse.java
│ │ ├── KlineResponse.java
│ │ ├── CurrencysResponse.java
│ │ ├── BatchcancelResponse.java
│ │ ├── BalanceResponse.java
│ │ ├── Depth.java
│ │ ├── MatchresultsOrdersDetailResponse.java
│ │ ├── HistoryTrade.java
│ │ ├── OrdersDetail.java
│ │ ├── Balance.java
│ │ ├── AccountsResponse.java
│ │ ├── IntrustDetailResponse.java
│ │ ├── OrdersDetailResponse.java
│ │ ├── TradeResponse.java
│ │ ├── DetailResponse.java
│ │ ├── SymbolsResponse.java
│ │ ├── HistoryTradeResponse.java
│ │ ├── DepthResponse.java
│ │ ├── MergedResponse.java
│ │ ├── Symbols.java
│ │ └── Merged.java
│ ├── vo
│ │ ├── Market.java
│ │ ├── Account.java
│ │ ├── IndicatorCalParam.java
│ │ ├── OrderTaskMessage.java
│ │ ├── RobotVo.java
│ │ ├── AccountVo.java
│ │ ├── IndicatorStrategyVo.java
│ │ ├── ProfitMessage.java
│ │ ├── RobotStrategyVo.java
│ │ └── BaseInfoEntity.java
│ ├── to
│ │ ├── RobotRunMessage.java
│ │ ├── RuleBean.java
│ │ ├── IndicatorBean.java
│ │ └── llIndicatorTo.java
│ ├── entity
│ │ ├── MarketOrder.java
│ │ └── Symbol.java
│ ├── bo
│ │ └── RobotBo.java
│ └── request
│ │ ├── DepthRequest.java
│ │ ├── CreateOrderRequest.java
│ │ └── IntrustOrdersDetailRequest.java
│ ├── enums
│ ├── TraceType.java
│ ├── PirceType.java
│ ├── SellType.java
│ ├── RobotState.java
│ ├── AType.java
│ ├── StrategyType.java
│ ├── HBOrderType.java
│ ├── Status.java
│ └── OrderType.java
│ ├── config
│ ├── VpnProxyConfig.java
│ ├── JsonConfig.java
│ └── RedisConfig.java
│ ├── exception
│ ├── ApiException.java
│ ├── IndicatorException.java
│ ├── TradingApiException.java
│ └── ExchangeNetworkException.java
│ ├── utils
│ ├── DateUtils.java
│ ├── JsonFormate.java
│ └── ComputeUtil.java
│ └── constans
│ ├── RobotRedisKeyConfig.java
│ └── IndicatorCons.java
├── qt-core
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── quant
│ │ └── core
│ │ ├── redisMq
│ │ ├── RedisMqService.java
│ │ ├── OrderProfitRedisMqServiceImpl.java
│ │ ├── OrderIdRedisMqServiceImpl.java
│ │ └── RobotLogsRedisMqServiceImpl.java
│ │ ├── config
│ │ ├── MarketConfig.java
│ │ ├── AccountConfig.java
│ │ ├── KlineConfig.java
│ │ ├── imp
│ │ │ ├── HuoBiMarketConfigImpl.java
│ │ │ ├── HuoBiKlineConfigImpl.java
│ │ │ ├── HuoboSimpleStragegyConfig.java
│ │ │ ├── HuoboIndicatorStragegyConfig.java
│ │ │ └── HuoBiAccountConfigImpl.java
│ │ └── StrategyConfig.java
│ │ ├── exchangeAdapter
│ │ └── BaseExchangeAdapter.java
│ │ ├── indicatorAdapter
│ │ ├── StochasticKiIndicatorAdapter.java
│ │ ├── CciIndicatorAdapter.java
│ │ ├── ADXIndicatorAdapter.java
│ │ ├── RsiIndicatorAdapter.java
│ │ ├── SmaIndicatorAdapter.java
│ │ ├── EmaIndicatorAdapter.java
│ │ ├── StochasticDIndicatorAdapter.java
│ │ ├── StochasticRsiiIndicatorAdapter.java
│ │ ├── AoIndicatorAdapter.java
│ │ └── MacdIndicatorAdapter.java
│ │ ├── api
│ │ └── ApiResult.java
│ │ ├── strategy
│ │ ├── impl
│ │ │ └── StrategyDelegate.java
│ │ ├── handle
│ │ │ ├── StrategyHandle.java
│ │ │ └── HuobiNotLimitBuyPriceHandle.java
│ │ ├── TradingStrategy.java
│ │ └── StrategyException.java
│ │ ├── factory
│ │ └── AbsIndicatorFactory.java
│ │ └── trading
│ │ ├── BalanceInfo.java
│ │ └── impl
│ │ └── HuoBiOpenOrderImpl.java
└── pom.xml
├── .gitignore
└── README.md
/qt-admin/src/main/docker/DockerFile:
--------------------------------------------------------------------------------
1 | FROM
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | profiles:
3 | active: dev
4 |
--------------------------------------------------------------------------------
/qt-client/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | profiles:
3 | active: dev
4 |
--------------------------------------------------------------------------------
/qt-register/src/main/resources/application.yml:
--------------------------------------------------------------------------------
1 | spring:
2 | profiles:
3 | active: dev
4 |
--------------------------------------------------------------------------------
/qt-register/src/main/java/com/quant/center/te.java:
--------------------------------------------------------------------------------
1 | package com.quant.center;
2 |
3 | public class te {
4 | }
5 |
--------------------------------------------------------------------------------
/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/resources/libs/opslabJutil-2.0.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IndexOutOfBounds998/quant4j/HEAD/qt-common/src/main/resources/libs/opslabJutil-2.0.3.jar
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/redisMq/RedisMqService.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.redisMq;
2 |
3 | public interface RedisMqService {
4 |
5 |
6 | void sendMsg(Object msg);
7 |
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/Place.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 17:10
7 | */
8 |
9 | public class Place {
10 | }
11 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/Currencys.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 15:47
7 | */
8 |
9 | public class Currencys {
10 | }
11 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/vo/Market.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 |
6 | @Data
7 | @AllArgsConstructor
8 | public class Market {
9 |
10 | String marketName;
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/config/MarketConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.config;
2 |
3 | /**
4 | * @author yang
5 | * @desc 市场扩展
6 | * @date 2019/7/9
7 | */
8 | public interface MarketConfig {
9 | /**
10 | * 市场交易对名称
11 | */
12 | String markName();
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/vo/Account.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.vo;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class Account {
7 |
8 | String id;
9 | String type;
10 | String state;
11 |
12 | String accessKey;
13 |
14 | String secretKey;
15 |
16 | String userId;
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/Account.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import lombok.Data;
4 |
5 | /**
6 | * @Author ISME
7 | * @Date 2018/1/14
8 | * @Time 16:02
9 | */
10 | @Data
11 | public class Account {
12 | public long id;
13 | public String type;
14 | public String state;
15 | }
16 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/enums/TraceType.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.enums;
2 |
3 | public enum TraceType {
4 | up("1"),
5 | down("2");
6 |
7 |
8 | String str;
9 |
10 | TraceType(String str) {
11 | this.str = str;
12 | }
13 |
14 | public String getStr() {
15 | return str;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/enums/PirceType.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.enums;
2 |
3 | public enum PirceType {
4 | isLimit(1),
5 | notLimit(0);
6 |
7 |
8 | Integer type;
9 |
10 | PirceType(Integer type) {
11 | this.type = type;
12 | }
13 |
14 | public Integer getType() {
15 | return type;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/enums/SellType.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.enums;
2 |
3 | public enum SellType {
4 | sellAll(1),
5 | sellCustom(0);
6 |
7 |
8 | Integer type;
9 |
10 | SellType(Integer type) {
11 | this.type = type;
12 | }
13 |
14 | public Integer getType() {
15 | return type;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/qt-register/src/main/resources/application-dev.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: ${EUREKA_PORT:8761}
3 |
4 | eureka:
5 | client:
6 | registerWithEureka: false
7 | fetchRegistry: false
8 | serviceUrl:
9 | defaultZone: http://${EUREKA_ZONE_HOST:localhost}:${EUREKA_ZONE_PORT:8761}/eureka/
10 |
11 | spring:
12 | application:
13 | name: eureka-server
14 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/to/RobotRunMessage.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.to;
2 |
3 | import lombok.Data;
4 |
5 | /**
6 | * @author yang
7 | * @desc 机器人实时日志
8 | * @date 2019/5/26
9 | */
10 | @Data
11 | public class RobotRunMessage {
12 |
13 | int userId;
14 | int robotId;
15 | String msg;
16 | String date;
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/to/RuleBean.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.to;
2 |
3 | /**
4 | * Created by yang on 2019/5/28.
5 | */
6 | public interface RuleBean {
7 |
8 | public String getName();
9 |
10 | public String getValue();
11 |
12 | public String getParams();
13 |
14 | BuyAndSellIndicatorTo.SourceBean getSource();
15 | }
16 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/config/AccountConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.config;
2 |
3 |
4 | /**
5 | * @author yang
6 | * @desc 账号扩展
7 | * @date 2019/7/9
8 | */
9 | public interface AccountConfig {
10 |
11 |
12 | String accountId();
13 |
14 | String getAccessKey();
15 |
16 | String getSecretKey();
17 |
18 | String getUserId();
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/qt-register/src/main/resources/application-prod.yml:
--------------------------------------------------------------------------------
1 | server:
2 | port: ${EUREKA_PORT:8762}
3 | address: 0.0.0.0
4 | eureka:
5 | client:
6 | registerWithEureka: false
7 | fetchRegistry: false
8 | serviceUrl:
9 | defaultZone: http://${EUREKA_ZONE_HOST:0.0.0.0}:${EUREKA_ZONE_PORT:8762}/eureka/
10 |
11 | spring:
12 | application:
13 | name: eureka-server
14 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/response/Symbol.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class Symbol {
7 |
8 | private String baseCurrency;
9 | private String quoteCurrency;
10 | private String symbol;
11 | private Integer pricePrecision;
12 | private Integer amountPrecision;
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/enums/RobotState.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.enums;
2 |
3 | /**
4 | * 机器人启动状态
5 | */
6 | public enum RobotState {
7 |
8 | start(1),
9 | stop(0);
10 |
11 |
12 | int str;
13 |
14 | RobotState(int str) {
15 | this.str = str;
16 | }
17 |
18 | public int getStr() {
19 | return str;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/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/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/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/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/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-core/src/main/java/com/quant/core/exchangeAdapter/BaseExchangeAdapter.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.exchangeAdapter;
2 |
3 | /**
4 | * @author yang
5 |
6 | * @desc 交换器基类
7 | * @date 2019/7/9
8 | */
9 | public abstract class BaseExchangeAdapter {
10 |
11 | protected static final String status = "ok";
12 | protected static final String buySign = "buy";
13 | protected static final String sellSign = "sell";
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/entity/MarketOrder.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.entity;
2 |
3 | import com.quant.common.domain.response.TradeBean;
4 | import lombok.Data;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * @author yang
10 |
11 | * @desc MarketOrder
12 | * @date 2019/7/9
13 | */
14 | @Data
15 | public class MarketOrder {
16 |
17 | List buy;
18 | List sell;
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/to/IndicatorBean.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.to;
2 |
3 | /**
4 | * Created by yang on 2019/5/28.
5 | */
6 | public interface IndicatorBean {
7 |
8 | String getCondition();
9 |
10 | BuyAndSellIndicatorTo.CompareBean getCompare();
11 |
12 | BuyAndSellIndicatorTo.RuleFirstBean getRuleFirst();
13 |
14 | BuyAndSellIndicatorTo.RuleSecondBean getRuleSecond();
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/vo/IndicatorCalParam.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.vo;
2 |
3 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
4 | import lombok.Data;
5 |
6 | /**
7 | * Created by yang on 2019/5/26.
8 | */
9 | @Data
10 | public class IndicatorCalParam {
11 | private String indicatorName;
12 | private String[] params;
13 | private BuyAndSellIndicatorTo.SourceBean sourceBean;
14 | }
15 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/vo/OrderTaskMessage.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.vo;
2 |
3 | import lombok.AllArgsConstructor;
4 | import lombok.Data;
5 |
6 | @AllArgsConstructor
7 | @Data
8 | public class OrderTaskMessage {
9 |
10 | private Long orderId;
11 |
12 | private String accessKey;
13 |
14 | private String secretKey;
15 |
16 | private int robotId;
17 |
18 | private String userId;
19 |
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/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/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-client/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | __ _ _ _ _ __
2 | / / | | | (_) | | \ \
3 | / / __ _ _ _ __ _ _ __ | |_ ______ ___| |_ ___ _ __ | |_ \ \
4 | < < / _` | | | |/ _` | '_ \| __|______/ __| | |/ _ | '_ \| __| > >
5 | \ | (_| | |_| | (_| | | | | |_ | (__| | | __| | | | |_ / /
6 | \_\__, |\__,_|\__,_|_| |_|\__| \___|_|_|\___|_| |_|\__/_/
7 | | |
8 | |_|
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/config/KlineConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.config;
2 |
3 | /**
4 | * @author yang
5 | * @desc k线扩展
6 | * @date 2019/7/9
7 | */
8 | public interface KlineConfig {
9 | /**
10 | * 每次获取数据的大小
11 | * @return
12 | */
13 | String size();
14 |
15 | /**
16 | * 返回数据时间粒度,也就是每根蜡烛的时间区间 1min, 5min, 15min, 30min, 60min, 1day, 1mon, 1week, 1year
17 | * @return
18 | */
19 | String period();
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/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/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-common/src/main/java/com/quant/common/enums/AType.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.enums;
2 |
3 |
4 | /**
5 | * spot:现货账户, margin:杠杆账户,otc:OTC 账户,point:点卡账户
6 | */
7 |
8 | public enum AType {
9 |
10 |
11 | SPOT("spot"),
12 | MARGIN("margin"),
13 | OTC("otc"),
14 | POINT("point");
15 |
16 |
17 | String str;
18 |
19 | AType(String str) {
20 | this.str = str;
21 | }
22 |
23 | public String getStr() {
24 | return str;
25 | }
26 | }
27 |
28 |
29 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/vo/RobotVo.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.vo;
2 |
3 | import lombok.Data;
4 |
5 | import javax.validation.constraints.NotNull;
6 |
7 | @Data
8 | public class RobotVo {
9 | Integer id;
10 | @NotNull
11 | String robotName;
12 | @NotNull
13 | String symbol;
14 | @NotNull
15 | int strategyId;
16 | @NotNull
17 | String nodeAddress;
18 | @NotNull
19 | String userId;
20 | @NotNull
21 | int accountId;
22 | }
23 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/to/llIndicatorTo.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.to;
2 |
3 | import com.quant.common.domain.vo.BaseInfoEntity;
4 | import lombok.Data;
5 | import lombok.NoArgsConstructor;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * Created by yang on 2019/5/28.
11 | */
12 | @NoArgsConstructor
13 | @Data
14 | public class llIndicatorTo {
15 | private Integer id;
16 | private BaseInfoEntity baseInfo;
17 | private BuyAndSellIndicatorTo baseData;
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/enums/StrategyType.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.enums;
2 |
3 | /**
4 | * Created by yang on 2019/8/24.
5 | */
6 | public enum StrategyType {
7 | /**
8 | * 简单数值
9 | */
10 | simple(0),
11 | /**
12 | * 指标
13 | */
14 | indicator(1);
15 |
16 |
17 | Integer type;
18 |
19 | StrategyType(Integer type) {
20 | this.type = type;
21 | }
22 |
23 | public Integer getType() {
24 | return type;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/response/Kline.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import lombok.Data;
4 |
5 | /**
6 | * @Author yang
7 | * @Date 2018/1/14
8 | * @Time 11:35
9 | * kline
10 | */
11 | @Data
12 | public class Kline {
13 | private long id;
14 | private Double amount;
15 | private int count;
16 | private Double open;
17 | private Double close;
18 | private Double low;
19 | private Double high;
20 | private Double vol;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/config/imp/HuoBiMarketConfigImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.config.imp;
2 |
3 | import com.quant.core.config.MarketConfig;
4 | import com.quant.common.domain.vo.Market;
5 |
6 | public class HuoBiMarketConfigImpl implements MarketConfig {
7 | private Market market;
8 |
9 | public HuoBiMarketConfigImpl(Market market) {
10 | this.market = market;
11 | }
12 |
13 |
14 | @Override
15 | public String markName() {
16 | return market.getMarketName();
17 | }
18 |
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/config/VpnProxyConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.config;
2 |
3 | import lombok.Data;
4 | import org.springframework.boot.context.properties.ConfigurationProperties;
5 | import org.springframework.stereotype.Component;
6 |
7 | /**
8 | * Created by yang on 2019/5/16.
9 | */
10 | @Data
11 | @Component
12 | @ConfigurationProperties(prefix = "vpnproxy")
13 | public class VpnProxyConfig {
14 |
15 | private Boolean enable;
16 |
17 | private String ip;
18 |
19 | private int port;
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/Trade.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import lombok.Data;
4 |
5 | /**
6 | * @Author ISME
7 | * @Date 2018/1/14
8 | * @Time 14:52
9 | */
10 | @Data
11 | public class Trade {
12 |
13 | /**
14 | * id : 600848670
15 | * ts : 1489464451000
16 | * data : [{"id":600848670,"price":7962.62,"amount":0.0122,"direction":"buy","ts":1489464451000}]
17 | */
18 |
19 | private String id;
20 | private long ts;
21 | private T data;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/ApiResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import com.quant.common.exception.ApiException;
4 | import lombok.Data;
5 |
6 | @Data
7 | public class ApiResponse {
8 |
9 | public String status;
10 | public String errCode;
11 | public String errMsg;
12 | public T data;
13 |
14 | public T checkAndReturn() {
15 | if ("ok".equals(status)) {
16 | return data;
17 | }
18 | throw new ApiException(errCode, errMsg);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/qt-register/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | __ _ _ _ __
2 | / / | | (_) | | \ \
3 | / / __ _ _ _ __ _ _ __ | |_ ______ _ __ ___ __ _ _ ___| |_ ___ _ _\ \
4 | < < / _` | | | |/ _` | '_ \| __|______| '__/ _ \/ _` | / __| __/ _ | '__> >
5 | \ | (_| | |_| | (_| | | | | |_ | | | __| (_| | \__ | || __| | / /
6 | \_\__, |\__,_|\__,_|_| |_|\__| |_| \___|\__, |_|___/\__\___|_|/_/
7 | | | __/ |
8 | |_| |___/
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/vo/AccountVo.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.vo;
2 |
3 | import lombok.Data;
4 |
5 | import javax.validation.constraints.NotBlank;
6 |
7 | @Data
8 | public class AccountVo {
9 | Integer id;
10 | @NotBlank(message = "名称 不能为空")
11 | String name;
12 |
13 | @NotBlank(message = "accessKey 不能为空")
14 | String accessKey;
15 |
16 | @NotBlank(message = "secretKey 不能为空")
17 | String secretKey;
18 |
19 | @NotBlank(message = "用户id 不能为空")
20 | int userId;
21 |
22 | String info;
23 | String type;
24 | String state;
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/vo/IndicatorStrategyVo.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.vo;
2 |
3 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
4 | import com.quant.common.domain.to.llIndicatorTo;
5 | import lombok.Data;
6 |
7 | import java.math.BigDecimal;
8 |
9 | @Data
10 | public class IndicatorStrategyVo {
11 |
12 | //机器人id
13 | int robotId;
14 |
15 | //机器人托管地址
16 | String address;
17 |
18 | String appKey;
19 |
20 | String appSecret;
21 |
22 | String symbol;
23 |
24 | llIndicatorTo indicatorTo;
25 |
26 | Account accountConfig;
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/config/imp/HuoBiKlineConfigImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.config.imp;
2 |
3 | import com.quant.core.config.KlineConfig;
4 |
5 |
6 | public class HuoBiKlineConfigImpl implements KlineConfig {
7 |
8 | String size;
9 | String period;
10 |
11 | public HuoBiKlineConfigImpl(String size, String period) {
12 | this.size = size;
13 | this.period = period;
14 | }
15 |
16 | @Override
17 | public String size() {
18 | return size;
19 | }
20 |
21 | @Override
22 | public String period() {
23 | return period;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/vo/ProfitMessage.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.vo;
2 |
3 | import lombok.Data;
4 |
5 | import java.math.BigDecimal;
6 |
7 | @Data
8 | public class ProfitMessage {
9 |
10 |
11 | long sellOrderId;
12 | long buyOrderId;
13 | int robot_id;
14 |
15 | BigDecimal buyPrice;
16 | BigDecimal sellPrice;
17 |
18 | BigDecimal buyAmount;
19 | BigDecimal sellAmount;
20 |
21 | BigDecimal buyCashAmount;
22 | BigDecimal sellCashAmount;
23 | //是否盈利
24 | int isProfit;
25 |
26 | BigDecimal diff;
27 |
28 | BigDecimal divide;
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/enums/HBOrderType.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.enums;
2 |
3 | public enum HBOrderType {
4 | /**
5 | * 限价买入
6 | */
7 | BUY_LIMIT("buy-limit"),
8 | /**
9 | * 限价卖出
10 | */
11 | SELL_LIMIT("sell-limit"),
12 |
13 | /**
14 | * 市价买入
15 | */
16 | BUY_MARKET("buy-market"),
17 | /**
18 | * 市价卖出
19 | */
20 | SELL_MARKET("sell-market");
21 |
22 | String tyoe;
23 |
24 | HBOrderType(String tyoe) {
25 | this.tyoe = tyoe;
26 | }
27 |
28 | public String getTyoe() {
29 | return tyoe;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/qt-admin/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 | __ _ _ _ __
2 | / / | | | | (_) \ \
3 | / / __ _ _ _ __ _ _ __ | |_ ______ __ _ __| |_ __ ___ _ _ __ \ \
4 | < < / _` | | | |/ _` | '_ \| __|______/ _` |/ _` | '_ ` _ \| | '_ \ > >
5 | \ | (_| | |_| | (_| | | | | |_ | (_| | (_| | | | | | | | | | |/ /
6 | \_\__, |\__,_|\__,_|_| |_|\__| \__,_|\__,_|_| |_| |_|_|_| |_/_/
7 | | |
8 | |_|
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/Batchcancel.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 17:52
7 | */
8 |
9 | public class Batchcancel {
10 | private T1 success;
11 | private T2 failed;
12 |
13 | public T1 getSuccess() {
14 | return success;
15 | }
16 |
17 | public void setSuccess(T1 success) {
18 | this.success = success;
19 | }
20 |
21 | public T2 getFailed() {
22 | return failed;
23 | }
24 |
25 | public void setFailed(T2 failed) {
26 | this.failed = failed;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/qt-register/src/main/java/com/quant/center/AppRegister.java:
--------------------------------------------------------------------------------
1 | package com.quant.center;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
6 |
7 | @SpringBootApplication
8 | @EnableEurekaServer
9 | public class AppRegister {
10 |
11 |
12 | /**
13 | * 注册中心 可以移至 admin 为了方便管理 还是单独使用、
14 | * 注册中心只是为了注册节点 获取节点的ip 无其他意义
15 | * @param args
16 | */
17 | public static void main(String[] args) {
18 | SpringApplication.run(AppRegister.class, args);
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/TradeBean.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import lombok.Data;
4 |
5 | import java.math.BigDecimal;
6 |
7 | /**
8 | * @Author ISME
9 | * @Date 2018/1/14
10 | * @Time 14:57
11 | */
12 | @Data
13 | public class TradeBean {
14 |
15 | /**
16 | * id : 600848670
17 | * price : 7962.62
18 | * amount : 0.0122
19 | * direction : buy
20 | * ts : 1489464451000
21 | */
22 |
23 | private String id;
24 | private BigDecimal price;
25 | private BigDecimal amount;
26 | private String direction;
27 | private long ts;
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/bo/RobotBo.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.bo;
2 |
3 | import lombok.Data;
4 |
5 | import java.util.Date;
6 |
7 | @Data
8 | public class RobotBo {
9 | private static final long serialVersionUID = 1L;
10 |
11 |
12 | private Integer id;
13 |
14 | private String robotName;
15 |
16 | private String symbol;
17 |
18 | private String userId;
19 |
20 | private Integer strategyId;
21 |
22 | private String clientAddress;
23 |
24 | private Date createTime;
25 |
26 | private Integer isDelete;
27 |
28 | private Integer isRun;
29 |
30 | private String strategyName;
31 |
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.exception;
2 |
3 | /**
4 | * ApiException if api returns error.
5 | *
6 | * @Date 2018/1/14
7 | * @Time 16:02
8 | */
9 |
10 | public class ApiException extends RuntimeException {
11 |
12 | final String errCode;
13 |
14 | public ApiException(String errCode, String errMsg) {
15 | super(errMsg);
16 | this.errCode = errCode;
17 | }
18 |
19 | public ApiException(Exception e) {
20 | super(e);
21 | this.errCode = e.getClass().getName();
22 | }
23 |
24 | public String getErrCode() {
25 | return this.errCode;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/exception/IndicatorException.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.exception;
2 |
3 | /**
4 | * @author yang
5 | * @desc IndicatorException
6 | * @date 2019/5/28
7 | */
8 |
9 | public class IndicatorException extends RuntimeException {
10 |
11 | final String errCode;
12 |
13 | public IndicatorException(String errCode, String errMsg) {
14 | super(errMsg);
15 | this.errCode = errCode;
16 | }
17 |
18 | public IndicatorException(Exception e) {
19 | super(e);
20 | this.errCode = e.getClass().getName();
21 | }
22 |
23 | public String getErrCode() {
24 | return this.errCode;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/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-core/src/main/java/com/quant/core/indicatorAdapter/StochasticKiIndicatorAdapter.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.indicatorAdapter;
2 |
3 | import org.ta4j.core.Indicator;
4 | import org.ta4j.core.TimeSeries;
5 | import org.ta4j.core.indicators.StochasticOscillatorKIndicator;
6 |
7 | /**
8 | * Created by yang on 2019/5/30.
9 | */
10 | public class StochasticKiIndicatorAdapter extends IndicatorAdapter {
11 |
12 |
13 | public StochasticKiIndicatorAdapter(TimeSeries timeSeries, int barCount) {
14 | super(timeSeries, barCount);
15 | }
16 |
17 |
18 | @Override
19 | public Indicator indicatorCalculation() {
20 | return new StochasticOscillatorKIndicator(timeSeries, barCount);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/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/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-core/src/main/java/com/quant/core/indicatorAdapter/CciIndicatorAdapter.java:
--------------------------------------------------------------------------------
1 |
2 | package com.quant.core.indicatorAdapter;
3 |
4 |
5 | import org.ta4j.core.Indicator;
6 | import org.ta4j.core.TimeSeries;
7 | import org.ta4j.core.indicators.CCIIndicator;
8 |
9 |
10 | /**
11 | * cci指标计算
12 | */
13 | public class CciIndicatorAdapter extends IndicatorAdapter {
14 |
15 |
16 | public CciIndicatorAdapter(TimeSeries timeSeries, int barCount) {
17 | super(timeSeries, barCount);
18 | }
19 |
20 | /**
21 | * 计算并返回Indicator
22 | *
23 | * @return
24 | */
25 | @Override
26 | public Indicator indicatorCalculation() {
27 | return new CCIIndicator(timeSeries, barCount);
28 | }
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/request/DepthRequest.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.request;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 14:39
7 | */
8 |
9 | public class DepthRequest {
10 |
11 | //交易对
12 | public String symbol;
13 |
14 | //Depth 类型 step0, step1, step2, step3, step4, step5(合并深度0-5);step0时,不合并深度
15 | public String type;
16 |
17 | public String getSymbol() {
18 | return symbol;
19 | }
20 |
21 | public void setSymbol(String symbol) {
22 | this.symbol = symbol;
23 | }
24 |
25 | public String getType() {
26 | return type;
27 | }
28 |
29 | public void setType(String type) {
30 | this.type = type;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/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-core/src/main/java/com/quant/core/indicatorAdapter/ADXIndicatorAdapter.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.indicatorAdapter;
2 |
3 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
4 | import org.ta4j.core.Indicator;
5 | import org.ta4j.core.TimeSeries;
6 | import org.ta4j.core.indicators.adx.ADXIndicator;
7 |
8 | /**
9 | * 计算adx指标
10 | * Created by yang on 2019/5/26.
11 | */
12 | public class ADXIndicatorAdapter extends IndicatorAdapter {
13 |
14 | public ADXIndicatorAdapter(TimeSeries timeSeries, int barCount, BuyAndSellIndicatorTo.SourceBean sourceBean) {
15 | super(timeSeries, barCount,sourceBean);
16 | }
17 |
18 | @Override
19 | public Indicator indicatorCalculation() {
20 | return new ADXIndicator(timeSeries, barCount);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/vo/RobotStrategyVo.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.vo;
2 |
3 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
4 | import lombok.Data;
5 |
6 | @Data
7 | public class RobotStrategyVo {
8 |
9 | //机器人id
10 | int robotId;
11 |
12 | //机器人托管地址
13 | String address;
14 |
15 | String appKey;
16 |
17 | String appSecret;
18 |
19 | String symbol;
20 | //策略信息
21 | StrategyVo strategyVo;
22 |
23 | Account accountConfig;
24 |
25 | @Override
26 | public String toString() {
27 | return "RobotStrategyVo{" +
28 | "robotId=" + robotId +
29 | ", address='" + address + '\'' +
30 | ", strategyVo=" + strategyVo +
31 | '}';
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/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-core/src/main/java/com/quant/core/api/ApiResult.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.api;
2 |
3 | import com.quant.common.enums.Status;
4 | import lombok.AllArgsConstructor;
5 | import lombok.Data;
6 |
7 |
8 | /**
9 | * @author yang
10 | * @desc 返回的数据结构
11 | * @date 2019/7/9
12 | */
13 | @Data
14 | @AllArgsConstructor
15 | public class ApiResult {
16 |
17 | int code;
18 |
19 | String message;
20 |
21 | Object data;
22 |
23 | public ApiResult() {
24 | }
25 |
26 | public ApiResult(Status status, Object res) {
27 | this.data = res;
28 | this.message = status.getMsg();
29 | this.code = status.getCode();
30 | }
31 |
32 | public ApiResult(Status status) {
33 | this.message = status.getMsg();
34 | this.code = status.getCode();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/strategy/impl/StrategyDelegate.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.strategy.impl;
2 |
3 | import com.quant.common.enums.HBOrderType;
4 | import com.quant.common.enums.OrderType;
5 | import com.quant.core.trading.TradingApi;
6 |
7 | import java.math.BigDecimal;
8 |
9 | /**
10 | * StrategyDelegate
11 | * Created by yang on 2019/8/23.
12 | */
13 | public interface StrategyDelegate {
14 |
15 | /**
16 | * 计算盈利
17 | */
18 | void CalculateProfit();
19 |
20 | /**
21 | * 下单
22 | *
23 | * @param tradingApi
24 | * @param sellAmount
25 | * @param sellPrice
26 | * @param HBOrderType
27 | * @param type
28 | */
29 | void orderPlace(TradingApi tradingApi, BigDecimal sellAmount, BigDecimal sellPrice, HBOrderType HBOrderType, OrderType type);
30 | }
31 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/request/CreateOrderRequest.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.request;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class CreateOrderRequest {
7 |
8 | /**
9 | * 交易对,必填,例如:"ethcny",
10 | */
11 | String symbol;
12 |
13 | /**
14 | * 账户ID,必填,例如:"12345"
15 | */
16 | String accountId;
17 |
18 | /**
19 | * 当订单类型为buy-limit,sell-limit时,表示订单数量, 当订单类型为buy-market时,表示订单总金额, 当订单类型为sell-market时,表示订单总数量
20 | */
21 | String amount;
22 |
23 | /**
24 | * 订单价格,仅针对限价单有效,例如:"1234.56"
25 | */
26 | String price = "0.0";
27 |
28 | /**
29 | * 订单类型,取值范围"buy-market,sell-market,buy-limit,sell-limit"
30 | */
31 | String type;
32 |
33 | /**
34 | * 订单来源,例如:"api"
35 | */
36 | String source = "com/qklx/qt/core/api";
37 | }
38 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/config/imp/HuoboSimpleStragegyConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.config.imp;
2 |
3 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
4 | import com.quant.common.domain.to.llIndicatorTo;
5 | import com.quant.common.domain.vo.StrategyVo;
6 | import com.quant.core.config.StrategyConfig;
7 |
8 | /**
9 | * Created by yang on 2019/5/31.
10 | */
11 | public class HuoboSimpleStragegyConfig implements StrategyConfig {
12 |
13 |
14 | public HuoboSimpleStragegyConfig(StrategyVo strategyVo) {
15 | this.strategyVo = strategyVo;
16 | }
17 |
18 | private StrategyVo strategyVo;
19 |
20 | @Override
21 | public StrategyVo getStrategyVo() {
22 | return strategyVo;
23 | }
24 |
25 | @Override
26 | public llIndicatorTo getIndicatorStrategy() {
27 | return null;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/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-core/src/main/java/com/quant/core/config/imp/HuoboIndicatorStragegyConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.config.imp;
2 |
3 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
4 | import com.quant.common.domain.to.llIndicatorTo;
5 | import com.quant.common.domain.vo.StrategyVo;
6 | import com.quant.core.config.StrategyConfig;
7 |
8 | /**
9 | * Created by yang on 2019/5/31.
10 | */
11 | public class HuoboIndicatorStragegyConfig implements StrategyConfig {
12 |
13 |
14 | public HuoboIndicatorStragegyConfig(llIndicatorTo strategyVo) {
15 | this.strategyVo = strategyVo;
16 | }
17 |
18 | private llIndicatorTo strategyVo;
19 |
20 | @Override
21 | public StrategyVo getStrategyVo() {
22 | return null;
23 | }
24 |
25 | @Override
26 | public llIndicatorTo getIndicatorStrategy() {
27 | return strategyVo;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/Details.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import lombok.Data;
4 |
5 | import java.math.BigDecimal;
6 |
7 | /**
8 | * @Author ISME
9 | * @Date 2018/1/14
10 | * @Time 15:33
11 | */
12 | @Data
13 | public class Details {
14 |
15 | /**
16 | * amount : 4316.4346
17 | * open : 8090.54
18 | * close : 7962.62
19 | * high : 8119
20 | * ts : 1489464451000
21 | * id : 1489464451
22 | * count : 9595
23 | * low : 7875
24 | * vol : 3.449727690576E7
25 | */
26 |
27 | private BigDecimal amount;
28 | private BigDecimal open;
29 | private BigDecimal close;
30 | private BigDecimal high;
31 | private String ts;
32 | private String id;
33 | private String count;
34 | private BigDecimal low;
35 | private BigDecimal vol;
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/factory/AbsIndicatorFactory.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.factory;
2 |
3 |
4 | import com.quant.common.domain.vo.IndicatorCalParam;
5 | import org.ta4j.core.Indicator;
6 | import org.ta4j.core.TimeSeries;
7 |
8 | /**
9 | * 指标工厂基类
10 | * Created by yang on 2019/5/26.
11 | */
12 | public abstract class AbsIndicatorFactory {
13 |
14 | protected volatile TimeSeries timeSeries;
15 |
16 | AbsIndicatorFactory(TimeSeries timeSeries) {
17 | this.timeSeries = timeSeries;
18 | }
19 |
20 | /**
21 | * 通过指标名称获取指标
22 | *
23 | * @param indicatorName
24 | * @return
25 | */
26 | public abstract Indicator getIndicator(String indicatorName);
27 |
28 | public abstract Indicator getIndicator(IndicatorCalParam simpleIndicatorVo);
29 |
30 | public abstract void updateTimeSeries(TimeSeries timeSeries);
31 | }
32 |
--------------------------------------------------------------------------------
/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-core/src/main/java/com/quant/core/redisMq/OrderProfitRedisMqServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.redisMq;
2 |
3 | import com.alibaba.fastjson.JSON;
4 | import com.quant.common.config.RedisUtil;
5 | import com.quant.common.constans.RobotRedisKeyConfig;
6 | import lombok.extern.slf4j.Slf4j;
7 |
8 | /**
9 | * @author yang
10 |
11 | * @desc 订单盈利推送到admin
12 | * @date 2019/7/9
13 | */
14 | @Slf4j
15 | public class OrderProfitRedisMqServiceImpl implements RedisMqService {
16 |
17 | private RedisUtil redisUtil;
18 |
19 |
20 | public OrderProfitRedisMqServiceImpl(RedisUtil redisUtil) {
21 | this.redisUtil = redisUtil;
22 |
23 | }
24 |
25 | @Override
26 | public void sendMsg(Object msg) {
27 | redisUtil.convertAndSend(RobotRedisKeyConfig.getOrder_profit(), JSON.toJSONString(msg));
28 | log.info("机器人盈利信息日志:" + JSON.toJSONString(msg));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/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-core/src/main/java/com/quant/core/config/imp/HuoBiAccountConfigImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.config.imp;
2 |
3 | import com.quant.common.domain.vo.Account;
4 | import com.quant.core.config.AccountConfig;
5 | import lombok.Data;
6 |
7 | @Data
8 | public class HuoBiAccountConfigImpl implements AccountConfig {
9 |
10 | private Account account;
11 |
12 | public HuoBiAccountConfigImpl(Account account) {
13 | this.account = account;
14 | }
15 |
16 | @Override
17 | public String accountId() {
18 | return account.getId();
19 | }
20 |
21 | @Override
22 | public String getAccessKey() {
23 | return account.getAccessKey();
24 | }
25 |
26 | @Override
27 | public String getSecretKey() {
28 | return account.getSecretKey();
29 | }
30 |
31 | @Override
32 | public String getUserId() {
33 | return account.getUserId();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/indicatorAdapter/RsiIndicatorAdapter.java:
--------------------------------------------------------------------------------
1 |
2 | package com.quant.core.indicatorAdapter;
3 |
4 |
5 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
6 | import org.ta4j.core.Indicator;
7 | import org.ta4j.core.TimeSeries;
8 | import org.ta4j.core.indicators.RSIIndicator;
9 |
10 |
11 | /**
12 | * Rsi指标计算
13 | */
14 | public class RsiIndicatorAdapter extends IndicatorAdapter {
15 |
16 |
17 | public RsiIndicatorAdapter(TimeSeries timeSeries, int barCount, BuyAndSellIndicatorTo.SourceBean sourceBean) {
18 | super(timeSeries, barCount, sourceBean);
19 | }
20 |
21 | /**
22 | * 计算并返回Indicator
23 | *
24 | * @return
25 | */
26 | @Override
27 | public Indicator indicatorCalculation() {
28 | final Indicator indicator =defaultIndicatorFromSource();
29 | return new RSIIndicator(indicator, barCount);
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/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/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/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-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-core/src/main/java/com/quant/core/indicatorAdapter/SmaIndicatorAdapter.java:
--------------------------------------------------------------------------------
1 |
2 | package com.quant.core.indicatorAdapter;
3 |
4 |
5 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
6 | import org.ta4j.core.Indicator;
7 | import org.ta4j.core.TimeSeries;
8 | import org.ta4j.core.indicators.SMAIndicator;
9 | import org.ta4j.core.indicators.helpers.ClosePriceIndicator;
10 |
11 |
12 | /**
13 | * sma指标计算
14 | */
15 | public class SmaIndicatorAdapter extends IndicatorAdapter {
16 |
17 |
18 | public SmaIndicatorAdapter(TimeSeries timeSeries, int barCount, BuyAndSellIndicatorTo.SourceBean sourceBean) {
19 | super(timeSeries, barCount,sourceBean);
20 | }
21 |
22 | /**
23 | * 计算并返回Indicator
24 | *
25 | * @return
26 | */
27 | @Override
28 | public Indicator indicatorCalculation() {
29 | final Indicator indicator =defaultIndicatorFromSource();
30 | return new SMAIndicator(indicator, barCount);
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/enums/Status.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.enums;
2 |
3 |
4 | /**
5 | * 返回骂
6 | */
7 | public enum Status {
8 |
9 | SUCCESS(20000, "请求成功"),
10 | USER_NOT_EXIST(1001, "用户不存在"),
11 | KEYS_NOT_Available(1002, "accesskey和秘钥 不可用"),
12 | Account_maybe_exist(1003, "该api已经存在或者数据服务器异常"),
13 | getRobotListError(1004, "获取机器人列表发生错误"),
14 | startRobotError(1005, "启动client端机器人失败"),
15 | Login_out(50014, "登录过期"),
16 | ERROR(1000, "请求参数异常");
17 |
18 | int code;
19 | String msg;
20 |
21 | Status(int code, String msg) {
22 | this.code = code;
23 | this.msg = msg;
24 | }
25 |
26 | public int getCode() {
27 | return code;
28 | }
29 |
30 | public void setCode(int code) {
31 | this.code = code;
32 | }
33 |
34 | public String getMsg() {
35 | return msg;
36 | }
37 |
38 | public void setMsg(String msg) {
39 | this.msg = msg;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/indicatorAdapter/EmaIndicatorAdapter.java:
--------------------------------------------------------------------------------
1 |
2 | package com.quant.core.indicatorAdapter;
3 |
4 |
5 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
6 | import org.ta4j.core.Indicator;
7 | import org.ta4j.core.TimeSeries;
8 | import org.ta4j.core.indicators.EMAIndicator;
9 | import org.ta4j.core.indicators.helpers.ClosePriceIndicator;
10 |
11 |
12 | /**
13 | * ema指标计算
14 | */
15 | public class EmaIndicatorAdapter extends IndicatorAdapter {
16 |
17 |
18 | public EmaIndicatorAdapter(TimeSeries timeSeries, int barCount, BuyAndSellIndicatorTo.SourceBean sourceBean) {
19 | super(timeSeries, barCount, sourceBean);
20 | }
21 |
22 | /**
23 | * 计算并返回Indicator
24 | *
25 | * @return
26 | */
27 | @Override
28 | public Indicator indicatorCalculation() {
29 | final Indicator indicator = defaultIndicatorFromSource();
30 | return new EMAIndicator(indicator, barCount);
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/indicatorAdapter/StochasticDIndicatorAdapter.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.indicatorAdapter;
2 |
3 | import org.ta4j.core.Indicator;
4 | import org.ta4j.core.TimeSeries;
5 | import org.ta4j.core.indicators.SMAIndicator;
6 | import org.ta4j.core.indicators.StochasticOscillatorDIndicator;
7 | import org.ta4j.core.indicators.StochasticOscillatorKIndicator;
8 | import org.ta4j.core.indicators.StochasticRSIIndicator;
9 | import org.ta4j.core.num.Num;
10 |
11 | /**
12 | * Created by yang on 2019/5/30.
13 | */
14 | public class StochasticDIndicatorAdapter extends IndicatorAdapter {
15 |
16 |
17 | public StochasticDIndicatorAdapter(TimeSeries timeSeries, int barCount) {
18 | super(timeSeries, barCount);
19 | }
20 |
21 |
22 | @Override
23 | public Indicator indicatorCalculation() {
24 | Indicator stochRSI = new StochasticRSIIndicator(timeSeries, 14);
25 | return new SMAIndicator(stochRSI, barCount);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/HistoryTradess.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 15:25
7 | */
8 |
9 | public class HistoryTradess {
10 | /**
11 | * id : 31459998
12 | * ts : 1502448920106
13 | * data : [{"id":17592256642623,"amount":0.04,"price":1997,"direction":"buy","ts":1502448920106}]
14 | */
15 |
16 | private int id;
17 | private long ts;
18 | private HistoryTrade data;
19 |
20 | public int getId() {
21 | return id;
22 | }
23 |
24 | public void setId(int id) {
25 | this.id = id;
26 | }
27 |
28 | public long getTs() {
29 | return ts;
30 | }
31 |
32 | public void setTs(long ts) {
33 | this.ts = ts;
34 | }
35 |
36 | public HistoryTrade getData() {
37 | return data;
38 | }
39 |
40 | public void setData(HistoryTrade data) {
41 | this.data = data;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/BalanceBean.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 16:23
7 | */
8 |
9 | public class BalanceBean {
10 | /**
11 | * currency : usdt
12 | * type : trade
13 | * balance : 500009195917.4362872650
14 | */
15 |
16 | private String currency;
17 | private String type;
18 | private String balance;
19 |
20 | public String getCurrency() {
21 | return currency;
22 | }
23 |
24 | public void setCurrency(String currency) {
25 | this.currency = currency;
26 | }
27 |
28 | public String getType() {
29 | return type;
30 | }
31 |
32 | public void setType(String type) {
33 | this.type = type;
34 | }
35 |
36 | public String getBalance() {
37 | return balance;
38 | }
39 |
40 | public void setBalance(String balance) {
41 | this.balance = balance;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/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/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-common/src/main/java/com/quant/common/domain/response/BatchcancelBean.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 17:53
7 | */
8 |
9 | public class BatchcancelBean {
10 | /**
11 | * err-msg : 记录无效
12 | * order-id : 2
13 | * err-code : base-record-invalid
14 | */
15 |
16 | private String errmsg;
17 | private String orderid;
18 | private String errcode;
19 |
20 | public String getErrmsg() {
21 | return errmsg;
22 | }
23 |
24 | public void setErrmsg(String errmsg) {
25 | this.errmsg = errmsg;
26 | }
27 |
28 | public String getOrderid() {
29 | return orderid;
30 | }
31 |
32 | public void setOrderid(String orderid) {
33 | this.orderid = orderid;
34 | }
35 |
36 | public String getErrcode() {
37 | return errcode;
38 | }
39 |
40 | public void setErrcode(String errcode) {
41 | this.errcode = errcode;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/vo/BaseInfoEntity.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.vo;
2 |
3 | import lombok.Data;
4 |
5 | import java.math.BigDecimal;
6 |
7 | @Data
8 | public class BaseInfoEntity {
9 | /**
10 | * buyPrice : 1.0E-8
11 | * sleep : 3
12 | * strategyName :
13 | * buyAmount :
14 | * buyAllWeights : 1
15 | * sellAmount :
16 | * isAllBuy : true
17 | * sellPrice : 1.0E-8
18 | * isAllSell : true
19 | * isLimitPrice : true
20 | * sellAllWeights : 1
21 | */
22 | private BigDecimal buyPrice;
23 | private double sleep;
24 | private String strategyName;
25 | private BigDecimal buyAmount;
26 | private int buyAllWeights;
27 | private BigDecimal sellAmount;
28 | private int isAllBuy;
29 | private BigDecimal sellPrice;
30 | private BigDecimal buyQuotaPrice;
31 | private int isAllSell;
32 | private int isLimitPrice;
33 | private int sellAllWeights;
34 | private int profit;
35 |
36 | }
--------------------------------------------------------------------------------
/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/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-common/src/main/java/com/quant/common/domain/response/TimestampResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import java.text.SimpleDateFormat;
4 | import java.util.Date;
5 |
6 | /**
7 | * @Author ISME
8 | * @Date 2018/1/14
9 | * @Time 15:53
10 | */
11 |
12 | public class TimestampResponse {
13 |
14 | /**
15 | * status : ok
16 | * data : 1494900087029
17 | */
18 |
19 | private String status;
20 | private long data;
21 | private String dateTime;
22 |
23 | public String getStatus() {
24 | return status;
25 | }
26 |
27 | public void setStatus(String status) {
28 | this.status = status;
29 | }
30 |
31 | public long getData() {
32 | return data;
33 | }
34 |
35 | public void setData(long data) {
36 | this.data = data;
37 | }
38 |
39 | public String getDateTime() {
40 | SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd hh:mm:ss");
41 | Date date = new Date(data);
42 | return sdf.format(date);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/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-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-common/src/main/java/com/quant/common/domain/response/Accounts.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 16:02
7 | */
8 |
9 | public class Accounts {
10 | /**
11 | * id : 100009
12 | * type : spot
13 | * state : working
14 | * user-id : 1000
15 | */
16 |
17 | private int id;
18 | private String type;
19 | private String state;
20 | private int userid;
21 |
22 | public int getId() {
23 | return id;
24 | }
25 |
26 | public void setId(int id) {
27 | this.id = id;
28 | }
29 |
30 | public String getType() {
31 | return type;
32 | }
33 |
34 | public void setType(String type) {
35 | this.type = type;
36 | }
37 |
38 | public String getState() {
39 | return state;
40 | }
41 |
42 | public void setState(String state) {
43 | this.state = state;
44 | }
45 |
46 | public int getUserid() {
47 | return userid;
48 | }
49 |
50 | public void setUserid(int userid) {
51 | this.userid = userid;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/SubmitcancelResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 17:15
7 | */
8 |
9 | public class SubmitcancelResponse {
10 |
11 |
12 | /**
13 | * status : ok
14 | * data : 59378
15 | */
16 |
17 | private String status;
18 | public String errCode;
19 | public String errMsg;
20 | private String data;
21 |
22 | public String getStatus() {
23 | return status;
24 | }
25 |
26 | public void setStatus(String status) {
27 | this.status = status;
28 | }
29 |
30 | public String getData() {
31 | return data;
32 | }
33 |
34 | public void setData(String data) {
35 | this.data = data;
36 | }
37 |
38 | public String getErrCode() {
39 | return errCode;
40 | }
41 |
42 | public void setErrCode(String errCode) {
43 | this.errCode = errCode;
44 | }
45 |
46 | public String getErrMsg() {
47 | return errMsg;
48 | }
49 |
50 | public void setErrMsg(String errMsg) {
51 | this.errMsg = errMsg;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/response/KlineResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import com.quant.common.exception.ApiException;
4 | import lombok.Data;
5 |
6 | /**
7 | * @Author ISME
8 | * @Date 2018/1/14
9 | * @Time 11:56
10 | */
11 | @Data
12 | public class KlineResponse {
13 |
14 | private String status;
15 | private String ch;
16 | private String ts;
17 | public String errCode;
18 | public String errMsg;
19 | public T data;
20 |
21 | public T checkAndReturn() {
22 | if ("ok".equals(status)) {
23 | return data;
24 | }
25 | throw new ApiException(errCode, errMsg);
26 | }
27 |
28 |
29 | public String getStatus() {
30 | return status;
31 | }
32 |
33 | public void setStatus(String status) {
34 | this.status = status;
35 | }
36 |
37 | public String getCh() {
38 | return ch;
39 | }
40 |
41 | public void setCh(String ch) {
42 | this.ch = ch;
43 | }
44 |
45 | public String getTs() {
46 | return ts;
47 | }
48 |
49 | public void setTs(String ts) {
50 | this.ts = ts;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/indicatorAdapter/StochasticRsiiIndicatorAdapter.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.indicatorAdapter;
2 |
3 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
4 | import org.ta4j.core.Indicator;
5 | import org.ta4j.core.TimeSeries;
6 | import org.ta4j.core.indicators.RSIIndicator;
7 | import org.ta4j.core.indicators.SMAIndicator;
8 | import org.ta4j.core.indicators.StochasticOscillatorKIndicator;
9 | import org.ta4j.core.indicators.StochasticRSIIndicator;
10 | import org.ta4j.core.indicators.helpers.ClosePriceIndicator;
11 |
12 | /**
13 | * Created by yang on 2019/5/30.
14 | */
15 | public class StochasticRsiiIndicatorAdapter extends IndicatorAdapter {
16 |
17 |
18 | public StochasticRsiiIndicatorAdapter(TimeSeries timeSeries, int barCount, int barCount2, BuyAndSellIndicatorTo.SourceBean sourceBean) {
19 | super(timeSeries, barCount, barCount2,sourceBean);
20 | }
21 |
22 |
23 | @Override
24 | public Indicator indicatorCalculation() {
25 | final Indicator indicator =defaultIndicatorFromSource();
26 | RSIIndicator r = new RSIIndicator(indicator, barCount);
27 | return new StochasticRSIIndicator(r, barCount2);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/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-core/src/main/java/com/quant/core/indicatorAdapter/AoIndicatorAdapter.java:
--------------------------------------------------------------------------------
1 |
2 | package com.quant.core.indicatorAdapter;
3 |
4 |
5 | import org.ta4j.core.Indicator;
6 | import org.ta4j.core.TimeSeries;
7 | import org.ta4j.core.indicators.AwesomeOscillatorIndicator;
8 | import org.ta4j.core.indicators.helpers.MedianPriceIndicator;
9 |
10 |
11 | /**
12 | * cci指标计算
13 | */
14 | public class AoIndicatorAdapter extends IndicatorAdapter {
15 |
16 |
17 | public AoIndicatorAdapter(TimeSeries timeSeries, Integer barCount, Integer barCount2) {
18 | super(timeSeries, barCount, barCount2);
19 | }
20 |
21 | /**
22 | * 计算并返回Indicator
23 | *
24 | * @return
25 | */
26 | @Override
27 | public Indicator indicatorCalculation() {
28 |
29 | if (barCount != null && barCount2 == null) {
30 | return new AwesomeOscillatorIndicator(new MedianPriceIndicator(timeSeries), barCount, 34);
31 | } else if (barCount != null) {
32 | return new AwesomeOscillatorIndicator(new MedianPriceIndicator(timeSeries), barCount, barCount2);
33 | } else {
34 | return new AwesomeOscillatorIndicator(timeSeries);
35 | }
36 |
37 | }
38 | }
39 |
40 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/response/CurrencysResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * @Author ISME
7 | * @Date 2018/1/14
8 | * @Time 15:46
9 | */
10 |
11 | public class CurrencysResponse {
12 |
13 |
14 | /**
15 | * status : ok
16 | * data : ["usdt","eth","etc"]
17 | */
18 |
19 | private String status;
20 | public String errCode;
21 | public String errMsg;
22 | private List data;
23 |
24 | public String getStatus() {
25 | return status;
26 | }
27 |
28 | public void setStatus(String status) {
29 | this.status = status;
30 | }
31 |
32 | public List getData() {
33 | return data;
34 | }
35 |
36 | public void setData(List data) {
37 | this.data = data;
38 | }
39 |
40 | public String getErrCode() {
41 | return errCode;
42 | }
43 |
44 | public void setErrCode(String errCode) {
45 | this.errCode = errCode;
46 | }
47 |
48 | public String getErrMsg() {
49 | return errMsg;
50 | }
51 |
52 | public void setErrMsg(String errMsg) {
53 | this.errMsg = errMsg;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/utils/DateUtils.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.utils;
2 |
3 | import java.text.SimpleDateFormat;
4 | import java.util.Date;
5 |
6 | public class DateUtils {
7 |
8 | /**
9 | * @author yang
10 | * @desc 使用ThreadLocal保证线程安全
11 | * @date 2019/5/26
12 | */
13 | private static final ThreadLocal local = new ThreadLocal<>();
14 |
15 | public static void main(String[] args) {
16 | long time = System.currentTimeMillis();
17 | Date date = parseTimeMillisToDate(time);
18 | System.out.println(date);
19 | }
20 |
21 | public static Date parseTimeMillisToDate(Long timeStamp) {
22 | return new Date(Long.parseLong(String.valueOf(timeStamp)));
23 | }
24 |
25 | public static String formateDate(Date date, String format) {
26 | if (local.get() != null) {
27 | return local.get().format(date);
28 | }
29 | if (format == null) {
30 | format = "yyyy-MM-dd HH:mm:ss";
31 | }
32 | final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
33 | local.set(simpleDateFormat);
34 | return simpleDateFormat.format(date);
35 | }
36 |
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/BatchcancelResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 17:51
7 | */
8 |
9 | public class BatchcancelResponse {
10 |
11 |
12 | /**
13 | * status : ok
14 | * data : {"success":["1","3"],"failed":[{"err-msg":"记录无效","order-id":"2","err-code":"base-record-invalid"}]}
15 | */
16 |
17 | private String status;
18 | public String errCode;
19 | public String errMsg;
20 | private T data;
21 |
22 | public String getStatus() {
23 | return status;
24 | }
25 |
26 | public void setStatus(String status) {
27 | this.status = status;
28 | }
29 |
30 | public String getErrCode() {
31 | return errCode;
32 | }
33 |
34 | public void setErrCode(String errCode) {
35 | this.errCode = errCode;
36 | }
37 |
38 | public String getErrMsg() {
39 | return errMsg;
40 | }
41 |
42 | public void setErrMsg(String errMsg) {
43 | this.errMsg = errMsg;
44 | }
45 |
46 | public T getData() {
47 | return data;
48 | }
49 |
50 | public void setData(T data) {
51 | this.data = data;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/utils/JsonFormate.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.utils;
2 |
3 | import java.lang.reflect.Field;
4 | import java.util.HashMap;
5 |
6 | public class JsonFormate {
7 |
8 | public static String parseJsonToString(String message) {
9 | message = message.replaceAll("\\\\", "");
10 | message = message.substring(1, message.length() - 1);
11 | return message;
12 | }
13 |
14 | /**
15 | *
16 | * 使用java.lang.reflect进行转换
17 | * @param object
18 | * @return map
19 | */
20 | public static HashMap objToHashMap(Object object){
21 | HashMap map = new HashMap<>();
22 | try{
23 | Field[] declaredFields = object.getClass().getDeclaredFields();
24 | for (Field field : declaredFields) {
25 | field.setAccessible(true);
26 | try {
27 | map.put(field.getName(), field.get(object));
28 | } catch (IllegalArgumentException | IllegalAccessException e) {
29 | e.printStackTrace();
30 | }
31 | }
32 | }catch(SecurityException e){
33 | e.printStackTrace();
34 | }
35 | return map;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/response/BalanceResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 16:11
7 | */
8 |
9 | public class BalanceResponse {
10 |
11 |
12 | /**
13 | * status : ok
14 | * data : {"id":"100009","type":"spot","state":"working","list":[{"currency":"usdt","type":"trade","balance":"500009195917.4362872650"}],"user-id":"1000"}
15 | */
16 |
17 | private String status;
18 | public String errCode;
19 | public String errMsg;
20 | private T data;
21 |
22 | public String getStatus() {
23 | return status;
24 | }
25 |
26 | public void setStatus(String status) {
27 | this.status = status;
28 | }
29 |
30 | public T getData() {
31 | return data;
32 | }
33 |
34 | public void setData(T data) {
35 | this.data = data;
36 | }
37 |
38 | public String getErrCode() {
39 | return errCode;
40 | }
41 |
42 | public void setErrCode(String errCode) {
43 | this.errCode = errCode;
44 | }
45 |
46 | public String getErrMsg() {
47 | return errMsg;
48 | }
49 |
50 | public void setErrMsg(String errMsg) {
51 | this.errMsg = errMsg;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/indicatorAdapter/MacdIndicatorAdapter.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.indicatorAdapter;
2 |
3 | import com.quant.common.domain.to.BuyAndSellIndicatorTo;
4 | import org.ta4j.core.Indicator;
5 | import org.ta4j.core.TimeSeries;
6 | import org.ta4j.core.indicators.MACDIndicator;
7 | import org.ta4j.core.indicators.adx.ADXIndicator;
8 | import org.ta4j.core.indicators.helpers.ClosePriceIndicator;
9 |
10 | /**
11 | * 计算madc指标
12 | * Created by yang on 2019/5/26.
13 | */
14 | public class MacdIndicatorAdapter extends IndicatorAdapter {
15 |
16 | public MacdIndicatorAdapter(TimeSeries timeSeries, Integer barCount, Integer barCount2, BuyAndSellIndicatorTo.SourceBean sourceBean) {
17 | super(timeSeries, barCount, barCount2, sourceBean);
18 | }
19 |
20 | @Override
21 | public Indicator indicatorCalculation() {
22 | final Indicator indicator = defaultIndicatorFromSource();
23 | if (barCount != null && barCount2 == null) {
24 | return new MACDIndicator(indicator, barCount, 26);
25 | }
26 | if (barCount != null && barCount2 != null) {
27 | return new MACDIndicator(indicator, barCount, barCount2);
28 | } else {
29 | return new MACDIndicator(indicator);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/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-register/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-register
14 |
15 |
16 |
17 |
18 | org.springframework.cloud
19 | spring-cloud-starter-netflix-eureka-server
20 |
21 |
22 |
23 | org.springframework.boot
24 | spring-boot-starter-web
25 |
26 |
27 |
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-maven-plugin
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/Depth.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import java.math.BigDecimal;
4 | import java.util.List;
5 |
6 | /**
7 | * @Author ISME
8 | * @Date 2018/1/14
9 | * @Time 14:39
10 | */
11 |
12 | public class Depth {
13 |
14 | /**
15 | * id : 1489464585407
16 | * ts : 1489464585407
17 | * bids : [[7964,0.0678],[7963,0.9162]]
18 | * asks : [[7979,0.0736],[8020,13.6584]]
19 | */
20 |
21 | private String id;
22 | private String ts;
23 | private List> bids;
24 | private List> asks;
25 |
26 | public String getId() {
27 | return id;
28 | }
29 |
30 | public void setId(String id) {
31 | this.id = id;
32 | }
33 |
34 | public String getTs() {
35 | return ts;
36 | }
37 |
38 | public void setTs(String ts) {
39 | this.ts = ts;
40 | }
41 |
42 | public List> getBids() {
43 | return bids;
44 | }
45 |
46 | public void setBids(List> bids) {
47 | this.bids = bids;
48 | }
49 |
50 | public List> getAsks() {
51 | return asks;
52 | }
53 |
54 | public void setAsks(List> asks) {
55 | this.asks = asks;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/response/MatchresultsOrdersDetailResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 18:48
7 | */
8 |
9 | public class MatchresultsOrdersDetailResponse {
10 |
11 |
12 | /**
13 | * status : ok
14 | * data : [{"id":29553,"order-id":59378,"match-id":59335,"symbol":"ethusdt","type":"buy-limit","source":"api","price":"100.1000000000","filled-amount":"9.1155000000","filled-fees":"0.0182310000","created-at":1494901400435}]
15 | */
16 |
17 | private String status;
18 | public String errCode;
19 | public String errMsg;
20 | private T data;
21 |
22 | public String getStatus() {
23 | return status;
24 | }
25 |
26 | public void setStatus(String status) {
27 | this.status = status;
28 | }
29 |
30 | public T getData() {
31 | return data;
32 | }
33 |
34 | public void setData(T data) {
35 | this.data = data;
36 | }
37 |
38 | public String getErrCode() {
39 | return errCode;
40 | }
41 |
42 | public void setErrCode(String errCode) {
43 | this.errCode = errCode;
44 | }
45 |
46 | public String getErrMsg() {
47 | return errMsg;
48 | }
49 |
50 | public void setErrMsg(String errMsg) {
51 | this.errMsg = errMsg;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/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/domain/response/HistoryTrade.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 15:24
7 | */
8 |
9 | public class HistoryTrade {
10 | /**
11 | * id : 17592256642623
12 | * amount : 0.04
13 | * price : 1997
14 | * direction : buy
15 | * ts : 1502448920106
16 | */
17 |
18 | private long id;
19 | private double amount;
20 | private int price;
21 | private String direction;
22 | private long ts;
23 |
24 | public long getId() {
25 | return id;
26 | }
27 |
28 | public void setId(long id) {
29 | this.id = id;
30 | }
31 |
32 | public double getAmount() {
33 | return amount;
34 | }
35 |
36 | public void setAmount(double amount) {
37 | this.amount = amount;
38 | }
39 |
40 | public int getPrice() {
41 | return price;
42 | }
43 |
44 | public void setPrice(int price) {
45 | this.price = price;
46 | }
47 |
48 | public String getDirection() {
49 | return direction;
50 | }
51 |
52 | public void setDirection(String direction) {
53 | this.direction = direction;
54 | }
55 |
56 | public long getTs() {
57 | return ts;
58 | }
59 |
60 | public void setTs(long ts) {
61 | this.ts = ts;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/OrdersDetail.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | import lombok.Data;
4 |
5 | /**
6 | * @Author cyy
7 | * @Date 2018/1/14
8 | * @Time 18:22
9 | */
10 | @Data
11 | public class OrdersDetail {
12 |
13 | /**
14 | * id : 59378
15 | * symbol : ethusdt
16 | * account-id : 100009
17 | * amount : 10.1000000000
18 | * price : 100.1000000000
19 | * created-at : 1494901162595
20 | * type : buy-limit
21 | * field-amount : 10.1000000000
22 | * field-cash-amount : 1011.0100000000
23 | * field-fees : 0.0202000000
24 | * finished-at : 1494901400468
25 | * user-id : 1000
26 | * source : api
27 | * state : filled
28 | * canceled-at : 0
29 | * exchange : huobi
30 | * batch :
31 | */
32 |
33 | private String id;
34 | private String symbol;
35 | private String accountId;
36 | private String amount;
37 | private String price;
38 | private long createdAt;
39 | private String type;
40 | private String fieldAmount;
41 | private String fieldCashAmount;
42 | private String fieldFees;
43 | private long finishedAt;
44 | private String userId;
45 | private String source;
46 | private String state;
47 | private long canceleAt;
48 | private String exchange;
49 | private String batch;
50 | }
51 |
--------------------------------------------------------------------------------
/qt-core/src/main/java/com/quant/core/redisMq/OrderIdRedisMqServiceImpl.java:
--------------------------------------------------------------------------------
1 | package com.quant.core.redisMq;
2 |
3 | import com.alibaba.fastjson.JSON;
4 | import com.quant.common.config.RedisUtil;
5 | import com.quant.common.constans.RobotRedisKeyConfig;
6 | import com.quant.core.config.AccountConfig;
7 | import com.quant.common.domain.vo.OrderTaskMessage;
8 | import lombok.extern.slf4j.Slf4j;
9 |
10 | /**
11 | * @author yang
12 |
13 | * @desc 订单推送到admin 处理
14 | * @date 2019/7/9
15 | */
16 | @Slf4j
17 | public class OrderIdRedisMqServiceImpl implements RedisMqService {
18 |
19 | private RedisUtil redisUtil;
20 |
21 | private AccountConfig accountConfig;
22 |
23 | private int robotId;
24 |
25 | public OrderIdRedisMqServiceImpl(RedisUtil redisUtil, AccountConfig accountConfig, int robotId) {
26 | this.redisUtil = redisUtil;
27 | this.accountConfig = accountConfig;
28 | this.robotId = robotId;
29 | }
30 |
31 | @Override
32 | public void sendMsg(Object orderId) {
33 | OrderTaskMessage message = new OrderTaskMessage(Long.parseLong(orderId.toString()), this.accountConfig.getAccessKey(), this.accountConfig.getSecretKey(), this.robotId, this.accountConfig.getUserId());
34 | redisUtil.convertAndSend(RobotRedisKeyConfig.getQueue(), JSON.toJSONString(message));
35 | log.info("机器人订单信息日志:" + JSON.toJSONString(message));
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/response/Balance.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 16:15
7 | */
8 |
9 | public class Balance {
10 | /**
11 | * id : 100009
12 | * type : spot
13 | * state : working
14 | * list : [{"currency":"usdt","type":"trade","balance":"500009195917.4362872650"}]
15 | * user-id : 1000
16 | */
17 |
18 | private String id;
19 | private String type;
20 | private String state;
21 | private String userid;
22 | private T list;
23 |
24 | public String getId() {
25 | return id;
26 | }
27 |
28 | public void setId(String id) {
29 | this.id = id;
30 | }
31 |
32 | public String getType() {
33 | return type;
34 | }
35 |
36 | public void setType(String type) {
37 | this.type = type;
38 | }
39 |
40 | public String getState() {
41 | return state;
42 | }
43 |
44 | public void setState(String state) {
45 | this.state = state;
46 | }
47 |
48 | public String getUserid() {
49 | return userid;
50 | }
51 |
52 | public void setUserid(String userid) {
53 | this.userid = userid;
54 | }
55 |
56 | public T getList() {
57 | return list;
58 | }
59 |
60 | public void setList(T list) {
61 | this.list = list;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/response/AccountsResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 |
4 | import com.quant.common.exception.ApiException;
5 |
6 | /**
7 | * @Author ISME
8 | * @Date 2018/1/14
9 | * @Time 16:01
10 | */
11 |
12 | public class AccountsResponse {
13 |
14 | /**
15 | * status : ok
16 | * data : [{"id":100009,"type":"spot","state":"working","user-id":1000}]
17 | */
18 |
19 | private String status;
20 | public String errCode;
21 | public String errMsg;
22 | private T data;
23 |
24 | public T checkAndReturn() {
25 | if ("ok".equals(status)) {
26 | return data;
27 | }
28 | throw new ApiException(errCode, errMsg);
29 | }
30 |
31 | public String getStatus() {
32 | return status;
33 | }
34 |
35 | public void setStatus(String status) {
36 | this.status = status;
37 | }
38 |
39 | public T getData() {
40 | return data;
41 | }
42 |
43 | public void setData(T data) {
44 | this.data = data;
45 | }
46 |
47 | public String getErrCode() {
48 | return errCode;
49 | }
50 |
51 | public void setErrCode(String errCode) {
52 | this.errCode = errCode;
53 | }
54 |
55 | public String getErrMsg() {
56 | return errMsg;
57 | }
58 |
59 | public void setErrMsg(String errMsg) {
60 | this.errMsg = errMsg;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/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/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-common/src/main/java/com/quant/common/domain/response/IntrustDetailResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 19:08
7 | */
8 |
9 | public class IntrustDetailResponse {
10 |
11 |
12 | /**
13 | * status : ok
14 | * data : [{"id":59378,"symbol":"ethusdt","account-id":100009,"amount":"10.1000000000","price":"100.1000000000","created-at":1494901162595,"type":"buy-limit","field-amount":"10.1000000000","field-cash-amount":"1011.0100000000","field-fees":"0.0202000000","finished-at":1494901400468,"user-id":1000,"source":"api","state":"filled","canceled-at":0,"exchange":"huobi","batch":""}]
15 | */
16 |
17 | private String status;
18 | public String errCode;
19 | public String errMsg;
20 | private T data;
21 |
22 | public String getStatus() {
23 | return status;
24 | }
25 |
26 | public void setStatus(String status) {
27 | this.status = status;
28 | }
29 |
30 | public T getData() {
31 | return data;
32 | }
33 |
34 | public void setData(T data) {
35 | this.data = data;
36 | }
37 |
38 | public String getErrCode() {
39 | return errCode;
40 | }
41 |
42 | public void setErrCode(String errCode) {
43 | this.errCode = errCode;
44 | }
45 |
46 | public String getErrMsg() {
47 | return errMsg;
48 | }
49 |
50 | public void setErrMsg(String errMsg) {
51 | this.errMsg = errMsg;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/OrdersDetailResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 18:21
7 | */
8 |
9 | public class OrdersDetailResponse {
10 |
11 | /**
12 | * status : ok
13 | * data : {"id":59378,"symbol":"ethusdt","account-id":100009,"amount":"10.1000000000","price":"100.1000000000","created-at":1494901162595,"type":"buy-limit","field-amount":"10.1000000000","field-cash-amount":"1011.0100000000","field-fees":"0.0202000000","finished-at":1494901400468,"user-id":1000,"source":"api","state":"filled","canceled-at":0,"exchange":"huobi","batch":""}
14 | */
15 |
16 | private String status;
17 | public String errCode;
18 | public String errMsg;
19 | private T data;
20 |
21 | public String getStatus() {
22 | return status;
23 | }
24 |
25 | public void setStatus(String status) {
26 | this.status = status;
27 | }
28 |
29 | public T getData() {
30 | return data;
31 | }
32 |
33 | public void setData(T data) {
34 | this.data = data;
35 | }
36 |
37 | public static class DataBean {
38 |
39 | }
40 |
41 | public String getErrCode() {
42 | return errCode;
43 | }
44 |
45 | public void setErrCode(String errCode) {
46 | this.errCode = errCode;
47 | }
48 |
49 | public String getErrMsg() {
50 | return errMsg;
51 | }
52 |
53 | public void setErrMsg(String errMsg) {
54 | this.errMsg = errMsg;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/constans/RobotRedisKeyConfig.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.constans;
2 |
3 |
4 | public class RobotRedisKeyConfig {
5 |
6 | /**
7 | * 机器人是否启动的标志
8 | */
9 | private final static String robotIsStartStateKey = "robot_start_id_";
10 |
11 | /**
12 | * 机器人是否还在运行的标志
13 | *
14 | * @return
15 | */
16 | private final static String robotIsRunStateKey = "robot_run_id_";
17 |
18 | /**
19 | * 订单成功后的id存储在queue这个队列中
20 | */
21 | private final static String queue = "order_id";
22 |
23 | /**
24 | * 订单成功后的id存储在queue这个队列中
25 | */
26 | private final static String robot_msg_queue = "robot_msg";
27 |
28 | /**
29 | *
30 | */
31 | private final static String order_profit = "order_profit";
32 |
33 | /**
34 | * 每个交易对对应的 和 quote 标志
35 | */
36 | private final static String symbol = "symbol_base_quote_price_amount_";
37 |
38 | public final static String ok = "ok";
39 |
40 |
41 | public static String getOrder_profit() {
42 | return order_profit;
43 | }
44 |
45 | public static String getRobot_msg_queue() {
46 | return robot_msg_queue;
47 | }
48 |
49 | public static String getQueue() {
50 | return queue;
51 | }
52 |
53 | public static String getSymbol() {
54 | return symbol;
55 | }
56 |
57 | public static String getRobotIsStartStateKey() {
58 | return robotIsStartStateKey;
59 | }
60 |
61 | public static String getRobotIsRunStateKey() {
62 | return robotIsRunStateKey;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/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-core/src/main/java/com/quant/core/config/StrategyConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2015 Gareth Jon Lynch
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy of
7 | * this software and associated documentation files (the "Software"), to deal in
8 | * the Software without restriction, including without limitation the rights to
9 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10 | * the Software, and to permit persons to whom the Software is furnished to do so,
11 | * subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in all
14 | * copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 | */
23 |
24 | package com.quant.core.config;
25 |
26 | import com.quant.common.domain.to.llIndicatorTo;
27 | import com.quant.common.domain.vo.StrategyVo;
28 |
29 | /**
30 | * @author yang
31 | * @desc 策略配置扩展
32 | * @date 2019/7/9
33 | */
34 | public interface StrategyConfig {
35 |
36 | StrategyVo getStrategyVo();
37 |
38 | llIndicatorTo getIndicatorStrategy();
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/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/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/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/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-common/src/main/java/com/quant/common/domain/response/TradeResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 14:52
7 | */
8 |
9 | public class TradeResponse {
10 |
11 |
12 | /**
13 | * status : ok
14 | * ch : market.btcusdt.trade.detail
15 | * ts : 1489473346905
16 | * tick : {"id":600848670,"ts":1489464451000,"data":[{"id":600848670,"price":7962.62,"amount":0.0122,"direction":"buy","ts":1489464451000}]}
17 | */
18 |
19 | private String status;
20 | private String ch;
21 | private long ts;
22 | public String errCode;
23 | public String errMsg;
24 | private Trade tick;
25 |
26 | public String getStatus() {
27 | return status;
28 | }
29 |
30 | public void setStatus(String status) {
31 | this.status = status;
32 | }
33 |
34 | public String getCh() {
35 | return ch;
36 | }
37 |
38 | public void setCh(String ch) {
39 | this.ch = ch;
40 | }
41 |
42 | public long getTs() {
43 | return ts;
44 | }
45 |
46 | public void setTs(long ts) {
47 | this.ts = ts;
48 | }
49 |
50 | public String getErrCode() {
51 | return errCode;
52 | }
53 |
54 | public void setErrCode(String errCode) {
55 | this.errCode = errCode;
56 | }
57 |
58 | public String getErrMsg() {
59 | return errMsg;
60 | }
61 |
62 | public void setErrMsg(String errMsg) {
63 | this.errMsg = errMsg;
64 | }
65 |
66 | public Trade getTick() {
67 | return tick;
68 | }
69 |
70 | public void setTick(Trade tick) {
71 | this.tick = tick;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/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-common/src/main/java/com/quant/common/domain/response/DetailResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 15:31
7 | */
8 |
9 | public class DetailResponse {
10 |
11 |
12 | /**
13 | * status : ok
14 | * ch : market.btcusdt.detail
15 | * ts : 1489473538996
16 | * tick : {"amount":4316.4346,"open":8090.54,"close":7962.62,"high":8119,"ts":1489464451000,"id":1489464451,"count":9595,"low":7875,"vol":3.449727690576E7}
17 | */
18 |
19 | private String status;
20 | private String ch;
21 | private long ts;
22 | public String errCode;
23 | public String errMsg;
24 | private T tick;
25 |
26 | public String getStatus() {
27 | return status;
28 | }
29 |
30 | public void setStatus(String status) {
31 | this.status = status;
32 | }
33 |
34 | public String getCh() {
35 | return ch;
36 | }
37 |
38 | public void setCh(String ch) {
39 | this.ch = ch;
40 | }
41 |
42 | public long getTs() {
43 | return ts;
44 | }
45 |
46 | public void setTs(long ts) {
47 | this.ts = ts;
48 | }
49 |
50 | public String getErrCode() {
51 | return errCode;
52 | }
53 |
54 | public void setErrCode(String errCode) {
55 | this.errCode = errCode;
56 | }
57 |
58 | public String getErrMsg() {
59 | return errMsg;
60 | }
61 |
62 | public void setErrMsg(String errMsg) {
63 | this.errMsg = errMsg;
64 | }
65 |
66 | public T getTick() {
67 | return tick;
68 | }
69 |
70 | public void setTick(T tick) {
71 | this.tick = tick;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/qt-common/src/main/java/com/quant/common/domain/response/SymbolsResponse.java:
--------------------------------------------------------------------------------
1 | package com.quant.common.domain.response;
2 |
3 | /**
4 | * @Author ISME
5 | * @Date 2018/1/14
6 | * @Time 15:39
7 | */
8 |
9 | public class SymbolsResponse {
10 |
11 |
12 | /**
13 | * status : ok
14 | * ch : market.btcusdt.detail
15 | * ts : 1489473538996
16 | * tick : {"amount":4316.4346,"open":8090.54,"close":7962.62,"high":8119,"ts":1489464451000,"id":1489464451,"count":9595,"low":7875,"vol":3.449727690576E7}
17 | */
18 |
19 | private String status;
20 | private String ch;
21 | private long ts;
22 | public String errCode;
23 | public String errMsg;
24 | private T tick;
25 |
26 | public String getStatus() {
27 | return status;
28 | }
29 |
30 | public void setStatus(String status) {
31 | this.status = status;
32 | }
33 |
34 | public String getCh() {
35 | return ch;
36 | }
37 |
38 | public void setCh(String ch) {
39 | this.ch = ch;
40 | }
41 |
42 | public long getTs() {
43 | return ts;
44 | }
45 |
46 | public void setTs(long ts) {
47 | this.ts = ts;
48 | }
49 |
50 | public String getErrCode() {
51 | return errCode;
52 | }
53 |
54 | public void setErrCode(String errCode) {
55 | this.errCode = errCode;
56 | }
57 |
58 | public String getErrMsg() {
59 | return errMsg;
60 | }
61 |
62 | public void setErrMsg(String errMsg) {
63 | this.errMsg = errMsg;
64 | }
65 |
66 | public T getTick() {
67 | return tick;
68 | }
69 |
70 | public void setTick(T tick) {
71 | this.tick = tick;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/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-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