Compare commits
64 Commits
feature/kl
...
retifive
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8b5cb002a | ||
|
|
98d067d59a | ||
|
|
ee76d122e6 | ||
|
|
29ae06447e | ||
|
|
7ea8b2dc07 | ||
|
|
3e505bd05b | ||
|
|
451747dd24 | ||
|
|
25c4bae2d6 | ||
|
|
c60d28a367 | ||
|
|
15f5cf1c80 | ||
|
|
c3d15b13ec | ||
|
|
c9c60667f0 | ||
|
|
9313481ec5 | ||
|
|
db434d3db2 | ||
|
|
5a3de795b9 | ||
|
|
72a404d2d1 | ||
|
|
1c7a3bd95e | ||
|
|
14d19f1812 | ||
|
|
1e6b6adbe7 | ||
|
|
1789c3ea79 | ||
|
|
44ee0e1a60 | ||
|
|
5c726fa5fa | ||
|
|
2c2fcc0bab | ||
|
|
d799898bcc | ||
|
|
68e12d321f | ||
|
|
287157c276 | ||
|
|
6a4531803f | ||
|
|
e6a65ec416 | ||
|
|
ce619be376 | ||
|
|
d3c00ad426 | ||
|
|
807023a878 | ||
|
|
b73bd18289 | ||
|
|
83e518b3f7 | ||
|
|
3a5d3851d4 | ||
|
|
b5c0e7947e | ||
|
|
cb96479bce | ||
|
|
888ce2adeb | ||
|
|
0696f91ef8 | ||
|
|
3fb3e9918f | ||
|
|
6daf6e7150 | ||
|
|
f097fa89fb | ||
|
|
6595ac0d50 | ||
|
|
6815ab0c8b | ||
|
|
b32e90bb1f | ||
|
|
42b9d2917a | ||
|
|
662537bcbe | ||
|
|
658abd04e0 | ||
|
|
34d9c07038 | ||
|
|
d3155bce53 | ||
|
|
12c55d1d37 | ||
|
|
6289aab551 | ||
|
|
bf9da51048 | ||
|
|
c183e92cd7 | ||
|
|
9e9299e098 | ||
|
|
6eb98a07ec | ||
|
|
130849ddc0 | ||
|
|
d8c90d5136 | ||
|
|
60e8fa41d4 | ||
|
|
87202f2b91 | ||
|
|
c3b3259646 | ||
|
|
c48fec0397 | ||
|
|
d42e4981a1 | ||
|
|
1d317149b3 | ||
|
|
9d3bac8a9d |
@@ -1,8 +1,7 @@
|
||||
stages:
|
||||
# 构建
|
||||
- build
|
||||
- dockerize
|
||||
- deploy
|
||||
- webhook
|
||||
|
||||
build:
|
||||
image: maven:3.6.3-openjdk-8
|
||||
@@ -10,6 +9,7 @@ build:
|
||||
only:
|
||||
- main
|
||||
- develop
|
||||
- retifive
|
||||
before_script:
|
||||
- echo '<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
@@ -38,42 +38,17 @@ build:
|
||||
- mvn clean install -Dmaven.test.skip=true
|
||||
- ls
|
||||
- echo ">>>>>>Finish Building<<<<<<"
|
||||
dockerize:
|
||||
stage: dockerize
|
||||
tags:
|
||||
- hk2
|
||||
dependencies:
|
||||
- build
|
||||
only:
|
||||
- main
|
||||
- develop
|
||||
script:
|
||||
- echo ">>>>>>Start Building Image<<<<<<"
|
||||
- ls
|
||||
- ls target
|
||||
- echo $DOCKER_PASSWORD
|
||||
- echo $CI_PIPELINE_ID
|
||||
- docker build -t juyoutech/india_stock_market:latest .
|
||||
- docker tag juyoutech/india_stock_market:latest juyoutech/india_stock_market:$CI_PIPELINE_ID
|
||||
- docker tag juyoutech/india_stock_market:latest juyoutech/india_stock_market:$CI_COMMIT_BRANCH
|
||||
- docker login -u juyoutech -p dckr_pat_8rg23IBA2kZMOCX4IJKApb8m5l8
|
||||
- docker push juyoutech/india_stock_market:latest
|
||||
- docker push juyoutech/india_stock_market:$CI_PIPELINE_ID
|
||||
- docker push juyoutech/india_stock_market:$CI_COMMIT_BRANCH
|
||||
deploy-dev:
|
||||
stage: deploy
|
||||
webhook:
|
||||
stage: webhook
|
||||
only:
|
||||
- develop
|
||||
- retifive
|
||||
script:
|
||||
- echo "Deploying application..."
|
||||
- echo ">>>>>>Start Deploy<<<<<<"
|
||||
- ls
|
||||
- apt-get update
|
||||
- apt-get install -y curl
|
||||
- |
|
||||
curl -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"namespace":"yddev", "deployment_name":"india-stock-market"}' \
|
||||
https://updater-yddev.moneytj.com/restart-deployment
|
||||
- echo "Application successfully deployed."
|
||||
- curl --max-time 30 http://149.88.86.7:11113/api/webhook/justpull?project=india_market_java\&setenv_file=alpha.sh\&publish_env=alpha\&shell=retifive/deploy-test.sh
|
||||
- echo ">>>>>>Start Deploy Finish<<<<<<"
|
||||
|
||||
|
||||
|
||||
17
Dockerfile
17
Dockerfile
@@ -1,17 +0,0 @@
|
||||
FROM openjdk:8
|
||||
|
||||
RUN echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list \
|
||||
&& echo "deb-src http://archive.debian.org/debian/ stretch main contrib non-free" >> /etc/apt/sources.list \
|
||||
&& echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/10no-check-valid
|
||||
|
||||
RUN apt-get update
|
||||
#RUN apt-get install -y iputils-ping dnsutils vim net-tools --allow-unauthenticated
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY target/india_market_java.jar /app/app.jar
|
||||
|
||||
COPY docker-entrypoint.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
||||
|
||||
CMD ["docker-entrypoint.sh"]
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
export JAVA_OPTS="$JAVA_OPTS -XX:-OmitStackTraceInFastThrow \
|
||||
-Dspring.redis.host=$REDIS_HOST \
|
||||
-Dspring.redis.password=$REDIS_PASS \
|
||||
-Dmarket.domain=$MARKET_HOST \
|
||||
-Dspring.redis.port=$REDIS_PORT \
|
||||
-Dspring.datasource.stock-market.url=jdbc:mysql://$MYSQL_HOST:$MYSQL_PORT/$MYSQL_DB?useUnicode=true&autoReconnect=true&allowPublicKeyRetrieval=true&useSSL=true \
|
||||
-Dspring.datasource.stock-market.username=$MYSQL_USER \
|
||||
-Dspring.datasource.stock-market.password=$MYSQL_PASSWORD \
|
||||
-Dspring.datasource.stock.url=jdbc:mysql://$MYSQL_HOST:$MYSQL_PORT/$MYSQL_DB?useUnicode=true&autoReconnect=true&allowPublicKeyRetrieval=true&useSSL=true \
|
||||
-Dspring.datasource.stock.username=$MYSQL_USER \
|
||||
-Dspring.datasource.stock.password=$MYSQL_PASSWORD"
|
||||
|
||||
|
||||
echo 'param:'$@
|
||||
echo 'JAVA_OPTS:'$JAVA_OPTS
|
||||
|
||||
java $JAVA_OPTS -jar /app/app.jar $@
|
||||
|
||||
tail -f /dev/null
|
||||
21
pom.xml
21
pom.xml
@@ -14,6 +14,7 @@
|
||||
<maven.compile.source>1.8</maven.compile.source>
|
||||
<maven.compile.target>1.8</maven.compile.target>
|
||||
<maven.build.timestamp.format>MMdd-HHmm</maven.build.timestamp.format>
|
||||
<rtsdk.version>3.6.5.0</rtsdk.version>
|
||||
</properties>
|
||||
<groupId>cn.stock</groupId>
|
||||
<artifactId>market</artifactId>
|
||||
@@ -42,6 +43,11 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
@@ -77,11 +83,11 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||
<version>3.13.3</version>
|
||||
</dependency>-->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
@@ -185,6 +191,17 @@
|
||||
<version>30.1-jre</version>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>com.thomsonreuters.ema</groupId>
|
||||
<artifactId>ema</artifactId>
|
||||
<version>3.5.1.0</version>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>com.refinitiv.ema</groupId>
|
||||
<artifactId>ema</artifactId>
|
||||
<version>${rtsdk.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.stock.market.infrastructure.db.po;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
|
||||
|
||||
/**
|
||||
* QRetifiveStockPO is a Querydsl query type for RetifiveStockPO
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.EntitySerializer")
|
||||
public class QRetifiveStockPO extends EntityPathBase<RetifiveStockPO> {
|
||||
|
||||
private static final long serialVersionUID = -280817720L;
|
||||
|
||||
public static final QRetifiveStockPO retifiveStockPO = new QRetifiveStockPO("retifiveStockPO");
|
||||
|
||||
public final NumberPath<Integer> id = createNumber("id", Integer.class);
|
||||
|
||||
public final NumberPath<Integer> isLock = createNumber("isLock", Integer.class);
|
||||
|
||||
public final NumberPath<Integer> isShow = createNumber("isShow", Integer.class);
|
||||
|
||||
public final DateTimePath<java.util.Date> saveTime = createDateTime("saveTime", java.util.Date.class);
|
||||
|
||||
public final StringPath stockCode = createString("stockCode");
|
||||
|
||||
public final StringPath stockName = createString("stockName");
|
||||
|
||||
public final StringPath stockType = createString("stockType");
|
||||
|
||||
public final StringPath symbol = createString("symbol");
|
||||
|
||||
public QRetifiveStockPO(String variable) {
|
||||
super(RetifiveStockPO.class, forVariable(variable));
|
||||
}
|
||||
|
||||
public QRetifiveStockPO(Path<? extends RetifiveStockPO> path) {
|
||||
super(path.getType(), path.getMetadata());
|
||||
}
|
||||
|
||||
public QRetifiveStockPO(PathMetadata metadata) {
|
||||
super(RetifiveStockPO.class, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package cn.stock.market.infrastructure.db.po;
|
||||
|
||||
import static com.querydsl.core.types.PathMetadataFactory.*;
|
||||
|
||||
import com.querydsl.core.types.dsl.*;
|
||||
|
||||
import com.querydsl.core.types.PathMetadata;
|
||||
import javax.annotation.Generated;
|
||||
import com.querydsl.core.types.Path;
|
||||
|
||||
|
||||
/**
|
||||
* QTwelveStockPO is a Querydsl query type for TwelveStockPO
|
||||
*/
|
||||
@Generated("com.querydsl.codegen.EntitySerializer")
|
||||
public class QTwelveStockPO extends EntityPathBase<TwelveStockPO> {
|
||||
|
||||
private static final long serialVersionUID = -100071895L;
|
||||
|
||||
public static final QTwelveStockPO twelveStockPO = new QTwelveStockPO("twelveStockPO");
|
||||
|
||||
public final NumberPath<Integer> id = createNumber("id", Integer.class);
|
||||
|
||||
public final NumberPath<Integer> isLock = createNumber("isLock", Integer.class);
|
||||
|
||||
public final NumberPath<Integer> isShow = createNumber("isShow", Integer.class);
|
||||
|
||||
public final DateTimePath<java.util.Date> saveTime = createDateTime("saveTime", java.util.Date.class);
|
||||
|
||||
public final StringPath stockCode = createString("stockCode");
|
||||
|
||||
public final StringPath stockName = createString("stockName");
|
||||
|
||||
public final StringPath stockType = createString("stockType");
|
||||
|
||||
public QTwelveStockPO(String variable) {
|
||||
super(TwelveStockPO.class, forVariable(variable));
|
||||
}
|
||||
|
||||
public QTwelveStockPO(Path<? extends TwelveStockPO> path) {
|
||||
super(path.getType(), path.getMetadata());
|
||||
}
|
||||
|
||||
public QTwelveStockPO(PathMetadata metadata) {
|
||||
super(TwelveStockPO.class, metadata);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.stock.market.application.assembler;
|
||||
|
||||
import cn.qutaojing.common.utils.Beans;
|
||||
import cn.qutaojing.common.utils.SpringUtils;
|
||||
import cn.stock.market.domain.basic.entity.RetifiveStock;
|
||||
import cn.stock.market.dto.RetifiveStockDTO;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* RetifiveStockAssembler
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/04/10
|
||||
*/
|
||||
@Component
|
||||
@Lazy
|
||||
public class RetifiveStockAssembler {
|
||||
public RetifiveStockDTO toDTO(RetifiveStock e) {
|
||||
RetifiveStockDTO dto = Beans.mapper(e, RetifiveStockDTO.class);
|
||||
if(dto == null) return dto;
|
||||
fill(e, dto);
|
||||
return dto;
|
||||
}
|
||||
|
||||
protected void fill(RetifiveStock e, RetifiveStockDTO dto) {
|
||||
if(dto == null) return;
|
||||
return;
|
||||
}
|
||||
|
||||
public static RetifiveStockAssembler of() {
|
||||
return SpringUtils.getBean(RetifiveStockAssembler.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.stock.market.application.assembler;
|
||||
|
||||
import cn.qutaojing.common.utils.Beans;
|
||||
import cn.qutaojing.common.utils.SpringUtils;
|
||||
import cn.stock.market.domain.basic.entity.TwelveStock;
|
||||
import cn.stock.market.dto.TwelveStockDTO;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* TwelveStockAssembler
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/05/30
|
||||
*/
|
||||
@Component
|
||||
@Lazy
|
||||
public class TwelveStockAssembler {
|
||||
public TwelveStockDTO toDTO(TwelveStock e) {
|
||||
TwelveStockDTO dto = Beans.mapper(e, TwelveStockDTO.class);
|
||||
if(dto == null) return dto;
|
||||
fill(e, dto);
|
||||
return dto;
|
||||
}
|
||||
|
||||
protected void fill(TwelveStock e, TwelveStockDTO dto) {
|
||||
if(dto == null) return;
|
||||
return;
|
||||
}
|
||||
|
||||
public static TwelveStockAssembler of() {
|
||||
return SpringUtils.getBean(TwelveStockAssembler.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.stock.market.constant;
|
||||
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
|
||||
public enum InChangeDataTypeEnum {
|
||||
/**
|
||||
* InChangeDataTypeEnum
|
||||
*/
|
||||
DEL, ADD, WAS, NOW;
|
||||
}
|
||||
46
src/main/java/cn/stock/market/constant/InChangeType.java
Normal file
46
src/main/java/cn/stock/market/constant/InChangeType.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package cn.stock.market.constant;
|
||||
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
|
||||
public enum InChangeType {
|
||||
/**
|
||||
* InChangeType
|
||||
*/
|
||||
ALL(1, "所有数据"),
|
||||
TODAY(2, "今日数据"),
|
||||
;
|
||||
|
||||
int code;
|
||||
String remark;
|
||||
InChangeType(int code, String remark) {
|
||||
this.code = code;
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public int code() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String remark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public static String remark(int code) {
|
||||
InChangeType of = of(code);
|
||||
return of == null ? "" : of.remark;
|
||||
}
|
||||
|
||||
public static InChangeType of(int code) {
|
||||
InChangeType[] values = InChangeType.values();
|
||||
for (InChangeType e : values) {
|
||||
if (e.code == code) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
56
src/main/java/cn/stock/market/constant/MonthEnum.java
Normal file
56
src/main/java/cn/stock/market/constant/MonthEnum.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package cn.stock.market.constant;
|
||||
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
|
||||
public enum MonthEnum {
|
||||
/**
|
||||
* MonthEnum
|
||||
*/
|
||||
JAN("JAN", "01"),
|
||||
FEB("FEB", "02"),
|
||||
MAR("MAR", "03"),
|
||||
APR("APR", "04"),
|
||||
MAY("MAY", "05"),
|
||||
JUN("JUN", "06"),
|
||||
JUL("JUL", "07"),
|
||||
AUG("AUG", "08"),
|
||||
SEP("SEP", "09"),
|
||||
OCT("OCT", "10"),
|
||||
NOV("NOV", "11"),
|
||||
DEC("DEC", "12"),
|
||||
;
|
||||
|
||||
String code;
|
||||
String remark;
|
||||
MonthEnum(String code, String remark) {
|
||||
this.code = code;
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String code() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String remark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public static String remark(String code) {
|
||||
MonthEnum of = of(code);
|
||||
return of == null ? "" : of.remark;
|
||||
}
|
||||
|
||||
public static MonthEnum of(String code) {
|
||||
MonthEnum[] values = MonthEnum.values();
|
||||
for (MonthEnum e : values) {
|
||||
if (e.code.equalsIgnoreCase(code)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.stock.market.domain.basic.convert;
|
||||
|
||||
import cn.qutaojing.common.domain.convert.SimpleEntityPOConvert;
|
||||
import cn.qutaojing.common.utils.SpringUtils;
|
||||
import cn.stock.market.domain.basic.entity.RetifiveStock;
|
||||
import cn.stock.market.infrastructure.db.po.RetifiveStockPO;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* RetifiveStockConvert
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/04/10
|
||||
*/
|
||||
@Component
|
||||
@Lazy
|
||||
public class RetifiveStockConvert extends SimpleEntityPOConvert<RetifiveStock, RetifiveStockPO> {
|
||||
public static RetifiveStockConvert of() {
|
||||
return SpringUtils.getBean(RetifiveStockConvert.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package cn.stock.market.domain.basic.convert;
|
||||
|
||||
import cn.qutaojing.common.domain.convert.SimpleEntityPOConvert;
|
||||
import cn.qutaojing.common.utils.SpringUtils;
|
||||
import cn.stock.market.domain.basic.entity.TwelveStock;
|
||||
import cn.stock.market.infrastructure.db.po.TwelveStockPO;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* TwelveStockConvert
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/05/30
|
||||
*/
|
||||
@Component
|
||||
@Lazy
|
||||
public class TwelveStockConvert extends SimpleEntityPOConvert<TwelveStock, TwelveStockPO> {
|
||||
public static TwelveStockConvert of() {
|
||||
return SpringUtils.getBean(TwelveStockConvert.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.stock.market.domain.basic.entity;
|
||||
|
||||
import cn.qutaojing.common.utils.Beans;
|
||||
import cn.stock.market.dto.command.RetifiveStockCreateCommand;
|
||||
import cn.stock.market.infrastructure.db.po.RetifiveStockPO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* RetifiveStock
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/04/10
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(
|
||||
callSuper = false
|
||||
)
|
||||
public class RetifiveStock extends RetifiveStockPO {
|
||||
public void update(RetifiveStockCreateCommand cmd) {
|
||||
Beans.copyProperties(cmd, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.stock.market.domain.basic.entity;
|
||||
|
||||
import cn.qutaojing.common.utils.Beans;
|
||||
import cn.stock.market.dto.command.TwelveStockCreateCommand;
|
||||
import cn.stock.market.infrastructure.db.po.TwelveStockPO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* TwelveStock
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/05/30
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(
|
||||
callSuper = false
|
||||
)
|
||||
public class TwelveStock extends TwelveStockPO {
|
||||
public void update(TwelveStockCreateCommand cmd) {
|
||||
Beans.copyProperties(cmd, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.stock.market.domain.basic.factory;
|
||||
|
||||
import cn.qutaojing.common.utils.SpringUtils;
|
||||
import cn.stock.market.domain.basic.entity.RetifiveStock;
|
||||
import cn.stock.market.dto.command.RetifiveStockCreateCommand;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* RetifiveStockFactory
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/04/10
|
||||
*/
|
||||
@Component
|
||||
@Lazy
|
||||
public class RetifiveStockFactory {
|
||||
public static RetifiveStockFactory of() {
|
||||
return SpringUtils.getBean(RetifiveStockFactory.class);
|
||||
}
|
||||
|
||||
public RetifiveStock from(RetifiveStockCreateCommand cmd) {
|
||||
RetifiveStock e = RetifiveStock.builder().build();
|
||||
e.update(cmd);
|
||||
return e;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package cn.stock.market.domain.basic.factory;
|
||||
|
||||
import cn.qutaojing.common.utils.SpringUtils;
|
||||
import cn.stock.market.domain.basic.entity.TwelveStock;
|
||||
import cn.stock.market.dto.command.TwelveStockCreateCommand;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* TwelveStockFactory
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/05/30
|
||||
*/
|
||||
@Component
|
||||
@Lazy
|
||||
public class TwelveStockFactory {
|
||||
public static TwelveStockFactory of() {
|
||||
return SpringUtils.getBean(TwelveStockFactory.class);
|
||||
}
|
||||
|
||||
public TwelveStock from(TwelveStockCreateCommand cmd) {
|
||||
TwelveStock e = TwelveStock.builder().build();
|
||||
e.update(cmd);
|
||||
return e;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cn.stock.market.domain.basic.repository;
|
||||
|
||||
import cn.qutaojing.common.domain.convert.IEntityPOConvert;
|
||||
import cn.qutaojing.common.domain.respostory.SimplePoConvertEntityRepository;
|
||||
import cn.qutaojing.common.utils.SpringUtils;
|
||||
import cn.stock.market.domain.basic.convert.RetifiveStockConvert;
|
||||
import cn.stock.market.domain.basic.entity.RetifiveStock;
|
||||
import cn.stock.market.infrastructure.db.po.QRetifiveStockPO;
|
||||
import cn.stock.market.infrastructure.db.po.RetifiveStockPO;
|
||||
import cn.stock.market.infrastructure.db.repo.RetifiveStockRepo;
|
||||
import com.rp.spring.jpa.GenericJpaRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* RetifiveStockRepository
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/04/10
|
||||
*/
|
||||
@Repository
|
||||
@RequiredArgsConstructor(
|
||||
onConstructor = @__(@Autowired)
|
||||
)
|
||||
public class RetifiveStockRepository extends SimplePoConvertEntityRepository<RetifiveStock, RetifiveStockPO, Integer> {
|
||||
final RetifiveStockRepo repo;
|
||||
|
||||
final RetifiveStockConvert convert;
|
||||
|
||||
final QRetifiveStockPO p = QRetifiveStockPO.retifiveStockPO;
|
||||
|
||||
@Override
|
||||
public GenericJpaRepository<RetifiveStockPO, Integer> repo() {
|
||||
return repo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntityPOConvert<RetifiveStock, RetifiveStockPO> convert() {
|
||||
return convert;
|
||||
}
|
||||
|
||||
public static RetifiveStockRepository of() {
|
||||
return SpringUtils.getBean(RetifiveStockRepository.class);
|
||||
}
|
||||
|
||||
public RetifiveStock findBtStockByCoCode(String coCode) {
|
||||
return findOneIfMutil(p.symbol.eq(coCode));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.stock.market.domain.basic.repository;
|
||||
|
||||
import cn.qutaojing.common.domain.convert.IEntityPOConvert;
|
||||
import cn.qutaojing.common.domain.respostory.SimplePoConvertEntityRepository;
|
||||
import cn.qutaojing.common.utils.SpringUtils;
|
||||
import cn.stock.market.domain.basic.convert.TwelveStockConvert;
|
||||
import cn.stock.market.domain.basic.entity.TwelveStock;
|
||||
import cn.stock.market.infrastructure.db.po.TwelveStockPO;
|
||||
import cn.stock.market.infrastructure.db.repo.TwelveStockRepo;
|
||||
import com.rp.spring.jpa.GenericJpaRepository;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Override;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* TwelveStockRepository
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/05/30
|
||||
*/
|
||||
@Repository
|
||||
@RequiredArgsConstructor(
|
||||
onConstructor = @__(@Autowired)
|
||||
)
|
||||
public class TwelveStockRepository extends SimplePoConvertEntityRepository<TwelveStock, TwelveStockPO, Integer> {
|
||||
final TwelveStockRepo repo;
|
||||
|
||||
final TwelveStockConvert convert;
|
||||
|
||||
@Override
|
||||
public GenericJpaRepository<TwelveStockPO, Integer> repo() {
|
||||
return repo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IEntityPOConvert<TwelveStock, TwelveStockPO> convert() {
|
||||
return convert;
|
||||
}
|
||||
|
||||
public static TwelveStockRepository of() {
|
||||
return SpringUtils.getBean(TwelveStockRepository.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.stock.market.domain.basic.service;
|
||||
|
||||
import cn.qutaojing.common.utils.SpringUtils;
|
||||
import cn.stock.market.domain.basic.factory.RetifiveStockFactory;
|
||||
import cn.stock.market.domain.basic.repository.RetifiveStockRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* RetifiveStockService
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/04/10
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor(
|
||||
onConstructor = @__(@Autowired)
|
||||
)
|
||||
public class RetifiveStockService {
|
||||
final RetifiveStockRepository repository;
|
||||
|
||||
final RetifiveStockFactory factory;
|
||||
|
||||
public RetifiveStockRepository repository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public static RetifiveStockService of() {
|
||||
return SpringUtils.getBean(RetifiveStockService.class);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,23 @@
|
||||
package cn.stock.market.domain.basic.service;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import javax.persistence.EntityExistsException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sound.midi.Soundbank;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.stock.market.dto.model.*;
|
||||
import cn.stock.market.infrastructure.api.EttechchartsApis;
|
||||
import cn.stock.market.infrastructure.api.GrowwInApis;
|
||||
import cn.stock.market.infrastructure.api.TodayApis;
|
||||
import cn.stock.market.infrastructure.api.investing.IndiaIndexVo;
|
||||
import cn.stock.market.infrastructure.api.investing.IndiaStockVO;
|
||||
@@ -25,9 +30,18 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Protocol;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Request.Builder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import cn.stock.market.infrastructure.db.po.QStockPO;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.utils.HttpClientUtils;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
@@ -56,6 +70,11 @@ import cn.stock.market.infrastructure.api.sina.vo.MarketVO;
|
||||
import cn.stock.market.infrastructure.api.sina.vo.MarketVOResult;
|
||||
import cn.stock.market.infrastructure.api.sina.vo.k.MinDataVO;
|
||||
import cn.stock.market.infrastructure.api.sina.vo.k.echarts.EchartsDataVO;
|
||||
import cn.stock.market.utils.GetPyByChinese;
|
||||
import cn.stock.market.utils.HttpClientRequest;
|
||||
import cn.stock.market.utils.PropertiesUtil;
|
||||
import cn.stock.market.utils.ServerResponse;
|
||||
import cn.stock.market.utils.Utils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
@@ -254,13 +273,7 @@ public class StockService {
|
||||
.header("Referer", "https://www.business-standard.com/")
|
||||
.header("Accept-Language", "en-US,en;q=0.9")
|
||||
.get();
|
||||
// result = doc.html().substring(doc.html().indexOf("<div class=\"listingstyle_shortvideoimg__0TWuX shortvideoimg\">"),doc.html().lastIndexOf("<div class=\"listingstyle_shortvideoimg__0TWuX shortvideoimg\">")+500);
|
||||
Elements divElements = doc.select("div.listingstyle_cardlistlist__dfq57");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Element divElement : divElements) {
|
||||
sb.append(divElement.outerHtml()).append("\n");
|
||||
}
|
||||
result = sb.toString();
|
||||
result = doc.html().substring(doc.html().indexOf("<div class=\"short-video-img\">"),doc.html().lastIndexOf("<div class=\"short-video-img\">")+500);
|
||||
} catch (Exception e) {
|
||||
return e.toString();
|
||||
}
|
||||
@@ -982,7 +995,7 @@ public class StockService {
|
||||
String exchange = "bse";
|
||||
IndiaIndexVo vo1 = new IndiaIndexVo();
|
||||
String coCode = "20558";
|
||||
JSONObject object = TodayApis.getStockDetail("in%3BSEN", coCode);
|
||||
JSONObject object = TodayApis.getStockDetail(exchange, coCode);
|
||||
IndiaStockVO market = objToVo(object);
|
||||
market.setName("BSESENSEX指数");
|
||||
vo1.setIndexVo(market);
|
||||
@@ -995,24 +1008,14 @@ public class StockService {
|
||||
vo1.setKLine(kine);
|
||||
indexVoList.add(vo1);
|
||||
}catch (Exception e){
|
||||
log.error("BToday获取BSESENSEX指数数据异常,异常信息。。。。", e);
|
||||
try {
|
||||
GrowwInApis.requestSenSexData(indexVoList);
|
||||
} catch (Exception e1) {
|
||||
log.error("GrowwIn获取BSESENSEX指数数据异常,异常信息。。。。", e1);
|
||||
try{
|
||||
EttechchartsApis.requestSensexData(indexVoList);
|
||||
} catch (Exception e2) {
|
||||
log.error("Ettechcharts获取BSESENSEX指数数据异常,异常信息。。。。", e2);
|
||||
}
|
||||
}
|
||||
log.info("获取NIFTY50指数数据异常,异常信息{}。。。。",e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
String exchange = "nse";
|
||||
IndiaIndexVo vo1 = new IndiaIndexVo();
|
||||
String coCode = "20559";
|
||||
JSONObject object = TodayApis.getStockDetail("in%3BNSX", coCode);
|
||||
JSONObject object = TodayApis.getStockDetail(exchange, coCode);
|
||||
IndiaStockVO market = objToVo(object);
|
||||
market.setName("NIFTY50指数");
|
||||
vo1.setIndexVo(market);
|
||||
@@ -1025,40 +1028,30 @@ public class StockService {
|
||||
vo1.setKLine(kine);
|
||||
indexVoList.add(vo1);
|
||||
}catch (Exception e){
|
||||
log.error("BToday获取NIFTY50指数数据异常,异常信息。。。。", e);
|
||||
try {
|
||||
GrowwInApis.requestNifty50Data(indexVoList);
|
||||
} catch (Exception e1) {
|
||||
log.error("GrowwIn获取NIFTY50指数数据异常,异常信息。。。。", e1);
|
||||
try{
|
||||
EttechchartsApis.requestNifty50Data(indexVoList);
|
||||
} catch (Exception e2) {
|
||||
log.error("Ettechcharts获取NIFTY50指数数据异常,异常信息。。。。", e2);
|
||||
}
|
||||
}
|
||||
log.info("获取NIFTY50指数数据异常,异常信息{}。。。。",e.getMessage());
|
||||
}
|
||||
return ServerResponse.createBySuccess(indexVoList);
|
||||
|
||||
}
|
||||
private IndiaStockVO objToVo(JSONObject object){
|
||||
IndiaStockVO market = new IndiaStockVO();
|
||||
if(object.containsKey("priceprevclose")){
|
||||
market.setClose(object.getString("priceprevclose"));
|
||||
if(object.containsKey("prev_close")){
|
||||
market.setClose(object.getString("prev_close"));
|
||||
}
|
||||
if(object.containsKey("pricecurrent")){
|
||||
market.setNowPrice(object.getString("pricecurrent"));
|
||||
if(object.containsKey("price")){
|
||||
market.setNowPrice(object.getString("price"));
|
||||
}
|
||||
if(object.containsKey("pricepercentchange")){
|
||||
market.setRate(object.getString("pricepercentchange"));
|
||||
if(object.containsKey("perchg")){
|
||||
market.setRate(object.getString("perchg"));
|
||||
}
|
||||
if(object.containsKey("HIGH")){
|
||||
market.setHigh(object.getString("HIGH"));
|
||||
if(object.containsKey("high_price")){
|
||||
market.setHigh(object.getString("high_price"));
|
||||
}
|
||||
if(object.containsKey("LOW")){
|
||||
market.setLow(object.getString("LOW"));
|
||||
if(object.containsKey("low_price")){
|
||||
market.setLow(object.getString("low_price"));
|
||||
}
|
||||
if(object.containsKey("OPEN")){
|
||||
market.setOpen(object.getString("OPEN"));
|
||||
if(object.containsKey("open_price")){
|
||||
market.setOpen(object.getString("open_price"));
|
||||
}
|
||||
return market;
|
||||
// stockListVO.setName(jsonObject.getString("companyname"));
|
||||
@@ -1076,48 +1069,4 @@ public class StockService {
|
||||
|
||||
}
|
||||
|
||||
public ServerResponse getEttechcharts(){
|
||||
List<IndiaIndexVo> indexVoList = new ArrayList<>();
|
||||
try {
|
||||
//获取详情
|
||||
String indexid = "2365";
|
||||
String exchange = "47";
|
||||
String keyName = "sensex";
|
||||
IndiaIndexVo vo1 = new IndiaIndexVo();
|
||||
JSONObject object = EttechchartsApis.getStockDetail(indexid, exchange,keyName);
|
||||
IndiaStockVO market = EttechchartsApis.ettechchartsObjToVo(object);
|
||||
market.setName("BSESENSEX指数");
|
||||
vo1.setIndexVo(market);
|
||||
|
||||
//获取k线图 1min 当天的数据 分钟
|
||||
String scripcode = "SENSEX";
|
||||
List kine = EttechchartsApis.getStockKline(scripcode,exchange);
|
||||
vo1.setKLine(kine);
|
||||
indexVoList.add(vo1);
|
||||
}catch (Exception e){
|
||||
log.info("获取BSESENSEX指数数据异常,异常信息{}。。。。",e.getMessage());
|
||||
}
|
||||
try {
|
||||
//获取详情
|
||||
String indexid = "2369";
|
||||
String exchangeid = "50";
|
||||
String keyName = "nifty";
|
||||
IndiaIndexVo vo1 = new IndiaIndexVo();
|
||||
JSONObject object = EttechchartsApis.getStockDetail(indexid, exchangeid,keyName);
|
||||
IndiaStockVO market = EttechchartsApis.ettechchartsObjToVo(object);
|
||||
market.setName("NIFTY50指数");
|
||||
vo1.setIndexVo(market);
|
||||
|
||||
//获取k线图 1min 当天的数据 分钟
|
||||
String scripcode = "NSE+Index";
|
||||
List kine = EttechchartsApis.getStockKline(scripcode,exchangeid);
|
||||
vo1.setKLine(kine);
|
||||
indexVoList.add(vo1);
|
||||
}catch (Exception e){
|
||||
log.info("获取NIFTY50指数数据异常,异常信息{}。。。。",e.getMessage());
|
||||
}
|
||||
return ServerResponse.createBySuccess(indexVoList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.stock.market.domain.basic.service;
|
||||
|
||||
import cn.qutaojing.common.utils.SpringUtils;
|
||||
import cn.stock.market.domain.basic.factory.TwelveStockFactory;
|
||||
import cn.stock.market.domain.basic.repository.TwelveStockRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* TwelveStockService
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/05/30
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor(
|
||||
onConstructor = @__(@Autowired)
|
||||
)
|
||||
public class TwelveStockService {
|
||||
final TwelveStockRepository repository;
|
||||
|
||||
final TwelveStockFactory factory;
|
||||
|
||||
public TwelveStockRepository repository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
public static TwelveStockService of() {
|
||||
return SpringUtils.getBean(TwelveStockService.class);
|
||||
}
|
||||
}
|
||||
23
src/main/java/cn/stock/market/dto/RetifiveStockDTO.java
Normal file
23
src/main/java/cn/stock/market/dto/RetifiveStockDTO.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package cn.stock.market.dto;
|
||||
|
||||
import cn.stock.market.infrastructure.db.po.RetifiveStockPO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* RetifiveStockDTO
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/04/10
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(
|
||||
callSuper = false
|
||||
)
|
||||
public class RetifiveStockDTO extends RetifiveStockPO {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package cn.stock.market.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class RetifiveStockHistoryResponse {
|
||||
private String s;
|
||||
private List<Long> t;
|
||||
private List<Double> o;
|
||||
private List<Double> h;
|
||||
private List<Double> l;
|
||||
private List<Double> c;
|
||||
private List<Double> v;
|
||||
|
||||
}
|
||||
67
src/main/java/cn/stock/market/dto/RetifiveStockInfo.java
Normal file
67
src/main/java/cn/stock/market/dto/RetifiveStockInfo.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package cn.stock.market.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author gs
|
||||
* @date 2024/4/9 10:53
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
/**
|
||||
* RetifiveStockInfo类用于存储股票信息。
|
||||
* 该类包含了股票的基本信息和交易数据。
|
||||
*/
|
||||
@ApiModel("RefinitivStockInfo")
|
||||
public class RetifiveStockInfo {
|
||||
@ApiModelProperty("股票代码")
|
||||
private String stockCode;
|
||||
|
||||
@ApiModelProperty("交易代码")
|
||||
private String symbol;
|
||||
|
||||
@ApiModelProperty("股票名称")
|
||||
private String stockName;
|
||||
|
||||
@ApiModelProperty("股票类型")
|
||||
private String stockType;
|
||||
|
||||
@ApiModelProperty("当前价格")
|
||||
private String lastPrice;
|
||||
|
||||
@ApiModelProperty("变动百分比")
|
||||
private String perchg;
|
||||
@ApiModelProperty("变动值")
|
||||
private String change;
|
||||
|
||||
@ApiModelProperty("开盘价格")
|
||||
private String openPrice;
|
||||
|
||||
@ApiModelProperty("昨日收盘价格")
|
||||
private String previousPrice;
|
||||
|
||||
@ApiModelProperty("成交量")
|
||||
private String volume;
|
||||
|
||||
@ApiModelProperty("最高价格")
|
||||
private String highPrice;
|
||||
|
||||
@ApiModelProperty("最低价格")
|
||||
private String lowPrice;
|
||||
|
||||
@ApiModelProperty("52周最高价格")
|
||||
private String week52HighPrice;
|
||||
|
||||
@ApiModelProperty("52周最低价格")
|
||||
private String week52LowPrice;
|
||||
|
||||
@ApiModelProperty("股票当前的交易状态: 1-表示退市Closed, 2-Opening Auction, 3-Continuous Trading, 15-Intra-day Close (scheduled)")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("股票id")
|
||||
private Integer id;
|
||||
}
|
||||
|
||||
23
src/main/java/cn/stock/market/dto/TwelveStockDTO.java
Normal file
23
src/main/java/cn/stock/market/dto/TwelveStockDTO.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package cn.stock.market.dto;
|
||||
|
||||
import cn.stock.market.infrastructure.db.po.TwelveStockPO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* TwelveStockDTO
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/05/30
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@EqualsAndHashCode(
|
||||
callSuper = false
|
||||
)
|
||||
public class TwelveStockDTO extends TwelveStockPO {
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.stock.market.dto.command;
|
||||
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* RetifiveStockCreateCommand
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/04/10
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
public class RetifiveStockCreateCommand {
|
||||
/**
|
||||
* 主键 */
|
||||
Integer id;
|
||||
|
||||
/**
|
||||
* 股票名称 */
|
||||
String stockName;
|
||||
|
||||
/**
|
||||
* BSE or NSE */
|
||||
String stockType;
|
||||
|
||||
/**
|
||||
* symbol,查询Rics的id用 */
|
||||
String symbol;
|
||||
|
||||
/**
|
||||
* 股票code */
|
||||
String stockCode;
|
||||
|
||||
/**
|
||||
* 保存时间 */
|
||||
Date saveTime;
|
||||
|
||||
/**
|
||||
* 是否锁定 0否 1是 */
|
||||
Integer isLock;
|
||||
|
||||
/**
|
||||
* 是否展示 0是 1否 */
|
||||
Integer isShow;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.stock.market.dto.command;
|
||||
|
||||
import java.lang.Integer;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* RetifiveStockModifyCommand
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/04/10
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(
|
||||
callSuper = false
|
||||
)
|
||||
public class RetifiveStockModifyCommand extends RetifiveStockCreateCommand {
|
||||
Integer id;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.stock.market.dto.command;
|
||||
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* TwelveStockCreateCommand
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/05/30
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
public class TwelveStockCreateCommand {
|
||||
/**
|
||||
* 主键 */
|
||||
Integer id;
|
||||
|
||||
/**
|
||||
* 股票code */
|
||||
String stockCode;
|
||||
|
||||
/**
|
||||
* 股票名称 */
|
||||
String stockName;
|
||||
|
||||
/**
|
||||
* BSE or NSE */
|
||||
String stockType;
|
||||
|
||||
/**
|
||||
* 保存时间 */
|
||||
Date saveTime;
|
||||
|
||||
/**
|
||||
* 是否锁定 0否 1是 */
|
||||
Integer isLock;
|
||||
|
||||
/**
|
||||
* 是否展示 0是 1否 */
|
||||
Integer isShow;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.stock.market.dto.command;
|
||||
|
||||
import java.lang.Integer;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* TwelveStockModifyCommand
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/05/30
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(
|
||||
callSuper = false
|
||||
)
|
||||
public class TwelveStockModifyCommand extends TwelveStockCreateCommand {
|
||||
Integer id;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,233 +0,0 @@
|
||||
package cn.stock.market.infrastructure.api;
|
||||
|
||||
import cn.stock.market.dto.TodayStockDTO;
|
||||
import cn.stock.market.infrastructure.api.investing.IndiaIndexVo;
|
||||
import cn.stock.market.infrastructure.api.investing.IndiaStockVO;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 数据来源网站:<a href="https://groww.in/indices/nifty">...</a>, <a href="https://groww.in/indices/sp-bse-sensex">...</a>
|
||||
*
|
||||
* @auther jnerh
|
||||
*/
|
||||
public class GrowwInApis {
|
||||
|
||||
public static final String INDEX_DETAIL_URL = "https://groww.in/v1/api/stocks_data/v1/accord_points/exchange/%s/segment/CASH/latest_indices_ohlc/%s";
|
||||
public static final String INDEX_KLINE_URL = "https://groww.in/v1/api/charting_service/v2/chart/delayed/exchange/%s/segment/CASH/%s/daily?intervalInMinutes=%s&minimal=true";
|
||||
|
||||
|
||||
public static void requestSenSexData(List<IndiaIndexVo> indexVoList) {
|
||||
IndiaIndexVo vo1 = new IndiaIndexVo();
|
||||
JSONObject object = GrowwInApis.getSenSexDetail();
|
||||
IndiaStockVO market = GrowwInApis.objToVo(object);
|
||||
market.setName("BSESENSEX指数");
|
||||
vo1.setIndexVo(market);
|
||||
|
||||
List kine = GrowwInApis.getSenSexKline();
|
||||
vo1.setKLine(kine);
|
||||
indexVoList.add(vo1);
|
||||
}
|
||||
public static void requestNifty50Data(List<IndiaIndexVo> indexVoList) {
|
||||
IndiaIndexVo vo1 = new IndiaIndexVo();
|
||||
JSONObject object = GrowwInApis.getNifty50Detail();
|
||||
IndiaStockVO market = GrowwInApis.objToVo(object);
|
||||
market.setName("NIFTY50指数");
|
||||
vo1.setIndexVo(market);
|
||||
|
||||
List kine = GrowwInApis.getNifty50Kline();
|
||||
vo1.setKLine(kine);
|
||||
indexVoList.add(vo1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Nifty50指数详情
|
||||
*/
|
||||
public static JSONObject getIndexDetail(String exchange, String type) {
|
||||
String url = String.format(INDEX_DETAIL_URL, exchange, type);
|
||||
String str = get(url);
|
||||
return JSON.parseObject(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取k线图
|
||||
*/
|
||||
public static List getIndexKline(String exchange, String type, String intervalInMinutes) {
|
||||
String url = String.format(INDEX_KLINE_URL, exchange, type, intervalInMinutes);
|
||||
String str = get(url);
|
||||
JSONObject object = JSON.parseObject(str);
|
||||
return getList(object.getString("candles"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取Nifty50指数详情
|
||||
*/
|
||||
public static JSONObject getSenSexDetail() {
|
||||
return getIndexDetail("BSE", "1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取k线图
|
||||
*/
|
||||
public static List getSenSexKline() {
|
||||
return getIndexKline("BSE", "1", "1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Nifty50指数详情
|
||||
*/
|
||||
public static JSONObject getNifty50Detail() {
|
||||
return getIndexDetail("NSE", "NIFTY");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取k线图
|
||||
*/
|
||||
public static List getNifty50Kline() {
|
||||
return getIndexKline("NSE", "NIFTY", "5");
|
||||
}
|
||||
|
||||
static String get(String url) {
|
||||
CloseableHttpClient httpClient = null;
|
||||
CloseableHttpResponse response = null;
|
||||
String result = "";
|
||||
|
||||
try {
|
||||
httpClient = HttpClients.createDefault();
|
||||
HttpGet httpGet = new HttpGet(url);
|
||||
httpGet.setHeader("Referer", "https://groww.in/indices/nifty");
|
||||
httpGet.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0");
|
||||
httpGet.setHeader("X-App-Id", "growwWeb");
|
||||
httpGet.setHeader("X-Device-Id", "fd4815a2-49e4-570a-931a-0316d4d8a52d");
|
||||
httpGet.setHeader("X-Device-Type", "desktop");
|
||||
httpGet.setHeader("X-Platform", "web");
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000).setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
|
||||
httpGet.setConfig(requestConfig);
|
||||
response = httpClient.execute(httpGet);
|
||||
HttpEntity entity = response.getEntity();
|
||||
result = EntityUtils.toString(entity);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
if (null != response) {
|
||||
try {
|
||||
response.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != httpClient) {
|
||||
try {
|
||||
httpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static IndiaStockVO objToVo(JSONObject object) {
|
||||
IndiaStockVO market = new IndiaStockVO();
|
||||
if (object.containsKey("close")) {
|
||||
market.setClose(object.getString("close"));
|
||||
}
|
||||
if (object.containsKey("value")) {
|
||||
market.setNowPrice(object.getString("value"));
|
||||
}
|
||||
if (object.containsKey("dayChangePerc")) {
|
||||
market.setRate(object.getString("dayChangePerc"));
|
||||
}
|
||||
if (object.containsKey("high")) {
|
||||
market.setHigh(object.getString("high"));
|
||||
}
|
||||
if (object.containsKey("low")) {
|
||||
market.setLow(object.getString("low"));
|
||||
}
|
||||
if (object.containsKey("open")) {
|
||||
market.setOpen(object.getString("open"));
|
||||
}
|
||||
|
||||
return market;
|
||||
}
|
||||
|
||||
private static List getList(String json) {
|
||||
List<JSONObject> dataObject = new ArrayList<>();
|
||||
JSONArray jsonArray = JSON.parseArray(json);
|
||||
for (Object obj : jsonArray) {
|
||||
JSONObject entity = new JSONObject();
|
||||
JSONArray jsonArray1 = JSON.parseArray(obj.toString());
|
||||
entity.put("upd_date", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(JSON.parseArray(obj.toString()).getLong(0) * 1000)).replace(" ", "T"));
|
||||
entity.put("price", jsonArray1.getBigDecimal(1));
|
||||
dataObject.add(entity);
|
||||
}
|
||||
return dataObject;
|
||||
}
|
||||
|
||||
private static TodayStockDTO todayStockDTO(JSONObject jsonObject) {
|
||||
TodayStockDTO dto = new TodayStockDTO();
|
||||
if (jsonObject.containsKey("exchange")) {
|
||||
dto.setStockType(jsonObject.getString("exchange"));
|
||||
} else {
|
||||
dto.setStockType("");
|
||||
}
|
||||
if (jsonObject.containsKey("lname")) {
|
||||
dto.setStockName(jsonObject.getString("lname"));
|
||||
} else {
|
||||
dto.setStockName("");
|
||||
}
|
||||
if (jsonObject.containsKey("high_price")) {
|
||||
dto.setHighPrice(jsonObject.getString("highPrice"));
|
||||
} else {
|
||||
dto.setHighPrice("0.00");
|
||||
}
|
||||
if (jsonObject.containsKey("low_price")) {
|
||||
dto.setLowPrice(jsonObject.getString("low_price"));
|
||||
} else {
|
||||
dto.setLowPrice("0.00");
|
||||
}
|
||||
if (jsonObject.containsKey("price")) {
|
||||
dto.setLastPrice(jsonObject.getString("price"));
|
||||
} else {
|
||||
dto.setLastPrice("0.00");
|
||||
}
|
||||
if (jsonObject.containsKey("close_price")) {
|
||||
dto.setPrevClosePrice(jsonObject.getString("close_price"));
|
||||
} else {
|
||||
dto.setPrevClosePrice("0.00");
|
||||
}
|
||||
if (jsonObject.containsKey("netchg")) {
|
||||
dto.setChange(jsonObject.getString("netchg"));
|
||||
} else {
|
||||
dto.setChange("0.00");
|
||||
}
|
||||
if (jsonObject.containsKey("perchg")) {
|
||||
dto.setChangePercent(jsonObject.getString("perchg"));
|
||||
} else {
|
||||
dto.setChangePercent("0.00");
|
||||
}
|
||||
return dto;
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getNifty50Detail());
|
||||
System.out.println(getNifty50Kline());
|
||||
}
|
||||
}
|
||||
@@ -187,17 +187,18 @@ public class TodayApis {
|
||||
|
||||
//获取详情
|
||||
public static JSONObject getStockDetail(String exchange,String coCode){
|
||||
String url = String.format("https://priceapi.moneycontrol.com/pricefeed/notapplicable/inidicesindia/%s",exchange);
|
||||
String url = String.format("https://marketapi.intoday.in/widget/stockdetail/pullview?co_code=%s&exchange=%s",coCode,exchange);
|
||||
String str = get(url);
|
||||
JSONObject object = JSON.parseObject(str);
|
||||
boolean bool = false;
|
||||
if(object.containsKey("code")){
|
||||
bool = object.getInteger("code") == 200;
|
||||
if(object.containsKey("success")){
|
||||
bool = object.getBoolean("success");
|
||||
}
|
||||
if(!bool){
|
||||
return new JSONObject();
|
||||
}
|
||||
JSONObject entity = JSON.parseObject(object.getString("data"));
|
||||
JSONArray jsonArray = JSON.parseArray(object.getString("data"));
|
||||
JSONObject entity = JSON.parseObject(jsonArray.get(0).toString());
|
||||
return entity;
|
||||
|
||||
}
|
||||
|
||||
@@ -56,14 +56,6 @@ public class MoneyStockPO {
|
||||
* 展示表示 */
|
||||
String selfDispId;
|
||||
|
||||
/**
|
||||
* NSE India的id */
|
||||
String nseIndiaId;
|
||||
|
||||
/**
|
||||
* NSE India Chart的id */
|
||||
String nseIndiaChartId;
|
||||
|
||||
/**
|
||||
* 自有self_url */
|
||||
String selfUrl;
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package cn.stock.market.infrastructure.db.po;
|
||||
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
import java.util.Date;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
|
||||
/**
|
||||
* RetifiveStockPO
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/04/10
|
||||
*/
|
||||
@SuperBuilder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@DynamicInsert
|
||||
@DynamicUpdate
|
||||
@Table(
|
||||
name = "retifive_stock"
|
||||
)
|
||||
public class RetifiveStockPO {
|
||||
/**
|
||||
* 主键 */
|
||||
@Id
|
||||
@GeneratedValue(
|
||||
strategy = javax.persistence.GenerationType.IDENTITY
|
||||
)
|
||||
Integer id;
|
||||
|
||||
/**
|
||||
* 股票名称 */
|
||||
String stockName;
|
||||
|
||||
/**
|
||||
* BSE or NSE */
|
||||
String stockType;
|
||||
|
||||
/**
|
||||
* symbol,查询Rics的id用 */
|
||||
String symbol;
|
||||
|
||||
/**
|
||||
* 股票code */
|
||||
String stockCode;
|
||||
|
||||
/**
|
||||
* 保存时间 */
|
||||
Date saveTime;
|
||||
|
||||
/**
|
||||
* 更新时间:退市或有修改时会进行更新
|
||||
*/
|
||||
Date updateTime;
|
||||
|
||||
/**
|
||||
* 是否锁定 0否 1是 */
|
||||
Integer isLock;
|
||||
|
||||
/**
|
||||
* 是否展示 0是 1否 */
|
||||
Integer isShow;
|
||||
|
||||
/**
|
||||
* 是否退市:0-否,1-是
|
||||
*/
|
||||
Integer isDelisted;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.stock.market.infrastructure.db.po;
|
||||
|
||||
import java.lang.Integer;
|
||||
import java.lang.String;
|
||||
import java.util.Date;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
|
||||
/**
|
||||
* TwelveStockPO
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/05/30
|
||||
*/
|
||||
@SuperBuilder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@DynamicInsert
|
||||
@DynamicUpdate
|
||||
@Table(
|
||||
name = "twelve_stock"
|
||||
)
|
||||
public class TwelveStockPO {
|
||||
/**
|
||||
* 主键 */
|
||||
@Id
|
||||
@GeneratedValue(
|
||||
strategy = javax.persistence.GenerationType.IDENTITY
|
||||
)
|
||||
Integer id;
|
||||
|
||||
/**
|
||||
* 股票code */
|
||||
String stockCode;
|
||||
|
||||
/**
|
||||
* 股票名称 */
|
||||
String stockName;
|
||||
|
||||
/**
|
||||
* BSE or NSE */
|
||||
String stockType;
|
||||
|
||||
/**
|
||||
* 保存时间 */
|
||||
Date saveTime;
|
||||
|
||||
/**
|
||||
* 是否锁定 0否 1是 */
|
||||
Integer isLock;
|
||||
|
||||
/**
|
||||
* 是否展示 0是 1否 */
|
||||
Integer isShow;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.stock.market.infrastructure.db.repo;
|
||||
|
||||
import cn.stock.market.infrastructure.db.po.RetifiveStockPO;
|
||||
import com.rp.spring.jpa.GenericJpaRepository;
|
||||
import java.lang.Integer;
|
||||
|
||||
/**
|
||||
* RetifiveStockRepo
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/04/10
|
||||
*/
|
||||
public interface RetifiveStockRepo extends GenericJpaRepository<RetifiveStockPO, Integer> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.stock.market.infrastructure.db.repo;
|
||||
|
||||
import cn.stock.market.infrastructure.db.po.TwelveStockPO;
|
||||
import com.rp.spring.jpa.GenericJpaRepository;
|
||||
import java.lang.Integer;
|
||||
|
||||
/**
|
||||
* TwelveStockRepo
|
||||
*
|
||||
* @author rplees
|
||||
* @email rplees.i.ly@gmail.com
|
||||
* @created 2024/05/30
|
||||
*/
|
||||
public interface TwelveStockRepo extends GenericJpaRepository<TwelveStockPO, Integer> {
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import cn.stock.market.domain.basic.repository.StockRepository;
|
||||
import cn.stock.market.domain.basic.service.StockService;
|
||||
import cn.stock.market.infrastructure.api.investing.InvestingInvokerApis;
|
||||
import cn.stock.market.infrastructure.db.po.QSiteNewsPO;
|
||||
import cn.stock.market.utils.DateTimeUtil;
|
||||
import cn.stock.market.utils.Utils;
|
||||
import com.ag.utils.CollectionUtils;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -26,8 +25,6 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -121,16 +118,8 @@ public class InvestingTask {
|
||||
newsList.forEach( n -> {
|
||||
String contentUrl = n.substring(1, n.indexOf("class=\"img-smllnews\"") - 2);
|
||||
String id = contentUrl.substring(contentUrl.lastIndexOf("-") + 1, contentUrl.lastIndexOf("_"));
|
||||
// String imgUrl = n.substring(n.indexOf("img loading=\"lazy\" src=") + 24, n.indexOf("?"));
|
||||
String imgUrl = extractImgSrc(n);
|
||||
// String time = n.substring(n.indexOf("Last Updated") + 23, n.indexOf("IST") - 9);
|
||||
// Extract the date and time using regex
|
||||
Pattern pattern = Pattern.compile("Updated On :<!-- --> <!-- -->(.*?)<!-- -->");
|
||||
Matcher matcher = pattern.matcher(n);
|
||||
String time = "";
|
||||
if (matcher.find()) {
|
||||
time = DateTimeUtil.formatDateTimeFor24H(matcher.group(1).trim(),"dd MMM yyyy | hh:mm a");
|
||||
}
|
||||
String imgUrl = n.substring(n.indexOf("img loading=\"lazy\" src=") + 24, n.indexOf("?"));
|
||||
String time = n.substring(n.indexOf("Last Updated") + 23, n.indexOf("IST") - 9);
|
||||
|
||||
SiteNews siteNews = new SiteNews();
|
||||
siteNews.setAddTime(new Date());
|
||||
@@ -151,22 +140,4 @@ public class InvestingTask {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String extractImgSrc(String htmlData) {
|
||||
String searchString = "<noscript>";
|
||||
int startPos = htmlData.indexOf(searchString);
|
||||
|
||||
if (startPos != -1) {
|
||||
String startTag = "src=";
|
||||
startPos = htmlData.indexOf(startTag, startPos) + startTag.length() + 1;
|
||||
|
||||
int endPos = htmlData.indexOf("?", startPos);
|
||||
|
||||
if (endPos != -1) {
|
||||
return htmlData.substring(startPos, endPos);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
package cn.stock.market.infrastructure.job;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.stock.market.constant.InChangeDataTypeEnum;
|
||||
import cn.stock.market.constant.InChangeType;
|
||||
import cn.stock.market.domain.basic.entity.RetifiveStock;
|
||||
import cn.stock.market.domain.basic.service.RetifiveStockService;
|
||||
import cn.stock.market.lesg.InChangeEntity;
|
||||
import cn.stock.market.lesg.RefinitivConsumer;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
@RestController
|
||||
public class RefinitivTask {
|
||||
@Autowired
|
||||
private RefinitivConsumer refinitivConsumer;
|
||||
@Autowired
|
||||
private RetifiveStockService retifiveStockService;
|
||||
|
||||
@GetMapping("/task/syncStockData")
|
||||
@Scheduled(cron = "0 0 18 * * ?")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncStockData() {
|
||||
log.info("每天18点定时同步Refinitiv股票数据开始");
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
// 获取股票symbol列表
|
||||
List<String> symbolList = refinitivConsumer.getSymbolList();
|
||||
// 查询出数据库中所有股票
|
||||
List<RetifiveStock> allRetifiveStocks = retifiveStockService.repository().findAll();
|
||||
List<String> savedSymbols = allRetifiveStocks.stream().map(RetifiveStock::getSymbol).collect(Collectors.toList());
|
||||
// 去除数据库中已经存在的股票
|
||||
symbolList.removeAll(savedSymbols);
|
||||
if (CollUtil.isEmpty(symbolList)) {
|
||||
log.error("定时同步Refinitiv股票数据获取symbol为空");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
List<RetifiveStock> stockList = refinitivConsumer.getRefinitivStockList(String.join(",", symbolList));
|
||||
retifiveStockService.repository().saveAll(stockList);
|
||||
log.info("每天18点定时同步Refinitiv股票数据结束, 当前股票总数 {}, 新增数{}, 耗时:{}毫秒",
|
||||
allRetifiveStocks.size(), symbolList.size(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
} catch (Exception e) {
|
||||
log.error("每天18点定时同步Refinitiv股票数据异常, 错误:", e);
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/task/syncInChange")
|
||||
@Scheduled(cron = "0 10 0 * * ?")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void syncInChange() {
|
||||
log.info("每天6点定时同步Refinitiv股票数据IN/CHANGE开始");
|
||||
InChangeType inChangeType = InChangeType.TODAY;
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
// 获取股票symbol列表
|
||||
Map<InChangeDataTypeEnum, List<InChangeEntity>> inChangeSymbolList = refinitivConsumer.getInChangeSymbolList(inChangeType);
|
||||
// 过滤出要删除的数据
|
||||
List<InChangeEntity> delList = inChangeSymbolList.get(InChangeDataTypeEnum.DEL);
|
||||
List<String> delSymbols = delList.stream().map(InChangeEntity::getRic).collect(Collectors.toList());
|
||||
|
||||
// List<InChangeEntity> addList = inChangeSymbolList.get(InChangeDataTypeEnum.ADD);
|
||||
// List<String> addSymbols = addList.stream().map(InChangeEntity::getRic).collect(Collectors.toList());
|
||||
// 过滤出要更新的数据
|
||||
List<InChangeEntity> updateList = inChangeSymbolList.get(InChangeDataTypeEnum.WAS);
|
||||
List<String> wasSymbols = new ArrayList<>();
|
||||
for (int i = 0; i < updateList.size(); i++) {
|
||||
if (i % 2 == 0) {
|
||||
wasSymbols.add(updateList.get(i).getRic());
|
||||
}
|
||||
}
|
||||
|
||||
// 查询出数据库中所有股票
|
||||
List<RetifiveStock> allRetifiveStocks = retifiveStockService.repository().findAll();
|
||||
List<String> savedSymbols = allRetifiveStocks.stream().map(RetifiveStock::getSymbol).collect(Collectors.toList());
|
||||
// 取交集过滤出需要删除的股票
|
||||
delSymbols.retainAll(savedSymbols);
|
||||
// addSymbols.removeAll(savedSymbols);
|
||||
// 取交集过滤出需要更新的股票
|
||||
wasSymbols.retainAll(savedSymbols);
|
||||
|
||||
try {
|
||||
// 执行删除操作
|
||||
List<RetifiveStock> delStocks = allRetifiveStocks.stream()
|
||||
.filter(item -> delSymbols.contains(item.getSymbol()))
|
||||
.filter(item -> item.getIsDelisted() == 0)
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(delStocks)) {
|
||||
for (RetifiveStock delStock : delStocks) {
|
||||
// 将股票设为退市状态
|
||||
delStock.setIsDelisted(1);
|
||||
delStock.setUpdateTime(new Date());
|
||||
}
|
||||
retifiveStockService.repository().saveAll(delStocks);
|
||||
}
|
||||
log.info("每天6点定时同步Refinitiv股票数据IN/CHANGE结束, 受影响删除数{}, 耗时:{}毫秒", delStocks.size(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
|
||||
// 当类型为今日数据时才更新
|
||||
List<RetifiveStock> updateStocks = allRetifiveStocks.stream()
|
||||
.filter(item -> wasSymbols.contains(item.getSymbol()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(updateStocks)) {
|
||||
// 执行更新操作
|
||||
for (RetifiveStock updateStock : updateStocks) {
|
||||
// 定位到原来的股票数据
|
||||
InChangeEntity wasEntity = updateList.stream().filter(item -> item.getRic().equals(updateStock.getSymbol())).collect(Collectors.toList()).get(0);
|
||||
// 定位到要更新的股票数据
|
||||
InChangeEntity nowEntity = updateList.get(updateList.indexOf(wasEntity) + 1);
|
||||
// 进行更新赋值
|
||||
updateStock.setStockName(nowEntity.getDescription());
|
||||
updateStock.setStockCode(nowEntity.getCodeTicker());
|
||||
updateStock.setSymbol(nowEntity.getRic());
|
||||
updateStock.setUpdateTime(new Date());
|
||||
}
|
||||
retifiveStockService.repository().saveAll(updateStocks);
|
||||
}
|
||||
log.info("每天6点定时同步Refinitiv股票数据IN/CHANGE结束, 受影响更新数{}, 耗时:{}毫秒", updateStocks.size(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
} catch (Exception e) {
|
||||
log.error("每天6点定时同步Refinitiv股票数据IN/CHANGE异常, 错误:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,87 +1,87 @@
|
||||
//package cn.stock.market.infrastructure.redis;
|
||||
//
|
||||
//import java.time.LocalDateTime;
|
||||
//import java.time.format.DateTimeFormatter;
|
||||
//import java.util.Map;
|
||||
//import java.util.Map.Entry;
|
||||
//import java.util.concurrent.TimeUnit;
|
||||
//
|
||||
//import org.redisson.api.RLock;
|
||||
//import org.redisson.api.RedissonClient;
|
||||
//
|
||||
//import com.google.common.base.Stopwatch;
|
||||
//import com.google.common.collect.Maps;
|
||||
//
|
||||
//import cn.qutaojing.common.aop.distributedlock.DistributedLockCallback;
|
||||
//import cn.qutaojing.common.aop.distributedlock.DistributedLockInfo;
|
||||
//import cn.qutaojing.common.aop.distributedlock.DistributedLockTemplate;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// * title: SingleDistributedLockTemplate.java
|
||||
// *
|
||||
// * @author xlfd
|
||||
// * @email xlfd@gmail.com
|
||||
// * @version 1.0
|
||||
// * @created Sep 1, 2020 5:03:20 PM
|
||||
// */
|
||||
//@Slf4j
|
||||
//public class SingleDistributedLockTemplate implements DistributedLockTemplate {
|
||||
// private RedissonClient redisson;
|
||||
// DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
|
||||
//
|
||||
// public SingleDistributedLockTemplate() {
|
||||
// }
|
||||
//
|
||||
// public SingleDistributedLockTemplate(RedissonClient redisson) {
|
||||
// this.redisson = redisson;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public <T> T lock(DistributedLockCallback<T> callback, DistributedLockInfo... lockInfoList) throws Throwable {
|
||||
// Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
// Map<RLock, DistributedLockInfo> lockMap = Maps.newConcurrentMap();
|
||||
//
|
||||
// for (DistributedLockInfo info : lockInfoList) {
|
||||
// RLock lock = getLock(info.getLockName(), info.getFairLock());
|
||||
// lockMap.put(lock, info);
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// for (Entry<RLock, DistributedLockInfo> entry : lockMap.entrySet()) {
|
||||
// RLock lock = entry.getKey();
|
||||
// DistributedLockInfo info = entry.getValue();
|
||||
// log.info("{}-准备获取{}分布式锁:{}", dateTimeFormatter.format(LocalDateTime.now()), info.getMessage(), info.getLockName());
|
||||
// lock.lock(info.getLeaseTime(), info.getTimeUnit());
|
||||
// log.info("{}-{}分布式锁:{}获取成功, 耗时:{} ms", dateTimeFormatter.format(LocalDateTime.now()), info.getMessage(), info.getLockName(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
// }
|
||||
//
|
||||
// return callback.process();
|
||||
// } finally {
|
||||
// for (Entry<RLock, DistributedLockInfo> entry : lockMap.entrySet()) {
|
||||
// RLock lock = entry.getKey();
|
||||
// DistributedLockInfo info = entry.getValue();
|
||||
// if (lock != null && lock.isLocked() && lock.isHeldByCurrentThread()) {
|
||||
// lock.unlock();
|
||||
// log.info("{}-{}分布式锁:{}释放成功, 耗时:{} ms", dateTimeFormatter.format(LocalDateTime.now()), info.getMessage(), info.getLockName(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private RLock getLock(String lockName, boolean fairLock) {
|
||||
// RLock lock;
|
||||
// if (fairLock) {
|
||||
// lock = redisson.getFairLock(lockName);
|
||||
// } else {
|
||||
// lock = redisson.getLock(lockName);
|
||||
// }
|
||||
// return lock;
|
||||
// }
|
||||
//
|
||||
// public void setRedisson(RedissonClient redisson) {
|
||||
// this.redisson = redisson;
|
||||
// }
|
||||
//}
|
||||
package cn.stock.market.infrastructure.redis;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import cn.qutaojing.common.aop.distributedlock.DistributedLockCallback;
|
||||
import cn.qutaojing.common.aop.distributedlock.DistributedLockInfo;
|
||||
import cn.qutaojing.common.aop.distributedlock.DistributedLockTemplate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
*
|
||||
* title: SingleDistributedLockTemplate.java
|
||||
*
|
||||
* @author xlfd
|
||||
* @email xlfd@gmail.com
|
||||
* @version 1.0
|
||||
* @created Sep 1, 2020 5:03:20 PM
|
||||
*/
|
||||
@Slf4j
|
||||
public class SingleDistributedLockTemplate implements DistributedLockTemplate {
|
||||
private RedissonClient redisson;
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
|
||||
|
||||
public SingleDistributedLockTemplate() {
|
||||
}
|
||||
|
||||
public SingleDistributedLockTemplate(RedissonClient redisson) {
|
||||
this.redisson = redisson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T lock(DistributedLockCallback<T> callback, DistributedLockInfo... lockInfoList) throws Throwable {
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
Map<RLock, DistributedLockInfo> lockMap = Maps.newConcurrentMap();
|
||||
|
||||
for (DistributedLockInfo info : lockInfoList) {
|
||||
RLock lock = getLock(info.getLockName(), info.getFairLock());
|
||||
lockMap.put(lock, info);
|
||||
}
|
||||
|
||||
try {
|
||||
for (Entry<RLock, DistributedLockInfo> entry : lockMap.entrySet()) {
|
||||
RLock lock = entry.getKey();
|
||||
DistributedLockInfo info = entry.getValue();
|
||||
log.info("{}-准备获取{}分布式锁:{}", dateTimeFormatter.format(LocalDateTime.now()), info.getMessage(), info.getLockName());
|
||||
lock.lock(info.getLeaseTime(), info.getTimeUnit());
|
||||
log.info("{}-{}分布式锁:{}获取成功, 耗时:{} ms", dateTimeFormatter.format(LocalDateTime.now()), info.getMessage(), info.getLockName(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
||||
return callback.process();
|
||||
} finally {
|
||||
for (Entry<RLock, DistributedLockInfo> entry : lockMap.entrySet()) {
|
||||
RLock lock = entry.getKey();
|
||||
DistributedLockInfo info = entry.getValue();
|
||||
if (lock != null && lock.isLocked() && lock.isHeldByCurrentThread()) {
|
||||
lock.unlock();
|
||||
log.info("{}-{}分布式锁:{}释放成功, 耗时:{} ms", dateTimeFormatter.format(LocalDateTime.now()), info.getMessage(), info.getLockName(), stopwatch.elapsed(TimeUnit.MILLISECONDS));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private RLock getLock(String lockName, boolean fairLock) {
|
||||
RLock lock;
|
||||
if (fairLock) {
|
||||
lock = redisson.getFairLock(lockName);
|
||||
} else {
|
||||
lock = redisson.getLock(lockName);
|
||||
}
|
||||
return lock;
|
||||
}
|
||||
|
||||
public void setRedisson(RedissonClient redisson) {
|
||||
this.redisson = redisson;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,70 +1,71 @@
|
||||
//package cn.stock.market.infrastructure.redis.config;
|
||||
//
|
||||
//import java.time.Duration;
|
||||
//
|
||||
//import org.redisson.api.RedissonClient;
|
||||
//import org.springframework.cache.CacheManager;
|
||||
//import org.springframework.cache.annotation.EnableCaching;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
//import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
//import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
//import org.springframework.data.redis.core.RedisTemplate;
|
||||
//import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
//import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
//import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
//
|
||||
//import cn.qutaojing.common.aop.distributedlock.DistributedLockTemplate;
|
||||
//import cn.stock.market.infrastructure.redis.SingleDistributedLockTemplate;
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// * @author xlfd
|
||||
// * @email xlfd@gmail.com
|
||||
// * @version 1.0
|
||||
// * @created Jun 3, 2021 4:56:28 PM
|
||||
// */
|
||||
//@Configuration
|
||||
//@EnableCaching
|
||||
//public class RedisConfig {
|
||||
//
|
||||
// @Bean
|
||||
// public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
// RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
|
||||
// redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
// redisTemplate.setValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class));
|
||||
// redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
//
|
||||
// redisTemplate.setHashValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class));
|
||||
// redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||
//
|
||||
// return redisTemplate;
|
||||
// }
|
||||
//
|
||||
// @Bean
|
||||
// public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
|
||||
// // 配置序列化
|
||||
// RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
|
||||
// config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()));
|
||||
// config.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new Jackson2JsonRedisSerializer<>(Object.class)));
|
||||
//
|
||||
// // 设置缓存的默认过期时间 ,30分钟
|
||||
// config.entryTtl(Duration.ofMinutes(30));
|
||||
// // 不缓存空值
|
||||
// config.disableCachingNullValues();
|
||||
// RedisCacheManager cacheManager = RedisCacheManager.builder(redisConnectionFactory).cacheDefaults(config)
|
||||
// .build();
|
||||
// return cacheManager;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 分布式锁实现
|
||||
// * @param redissonClient
|
||||
// * @return
|
||||
// */
|
||||
// @Bean
|
||||
// public DistributedLockTemplate distributedLockTemplate(RedissonClient redissonClient) {
|
||||
// return new SingleDistributedLockTemplate(redissonClient);
|
||||
// }
|
||||
//}
|
||||
package cn.stock.market.infrastructure.redis.config;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import cn.qutaojing.common.aop.distributedlock.DistributedLockTemplate;
|
||||
import cn.stock.market.infrastructure.redis.SingleDistributedLockTemplate;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author xlfd
|
||||
* @email xlfd@gmail.com
|
||||
* @version 1.0
|
||||
* @created Jun 3, 2021 4:56:28 PM
|
||||
*/
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class RedisConfig {
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
redisTemplate.setValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class));
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
|
||||
redisTemplate.setHashValueSerializer(new Jackson2JsonRedisSerializer<>(Object.class));
|
||||
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
|
||||
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
|
||||
// 配置序列化
|
||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
|
||||
config.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new StringRedisSerializer()));
|
||||
config.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(new Jackson2JsonRedisSerializer<>(Object.class)));
|
||||
|
||||
// 设置缓存的默认过期时间 ,30分钟
|
||||
config.entryTtl(Duration.ofMinutes(30));
|
||||
// 不缓存空值
|
||||
config.disableCachingNullValues();
|
||||
RedisCacheManager cacheManager = RedisCacheManager.builder(redisConnectionFactory).cacheDefaults(config)
|
||||
.build();
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分布式锁实现
|
||||
* @param redissonClient
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public DistributedLockTemplate distributedLockTemplate(RedissonClient redissonClient) {
|
||||
return new SingleDistributedLockTemplate(redissonClient);
|
||||
}
|
||||
}
|
||||
|
||||
75
src/main/java/cn/stock/market/lesg/Batch.java
Normal file
75
src/main/java/cn/stock/market/lesg/Batch.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package cn.stock.market.lesg;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
public class Batch {
|
||||
private static int id = 0;
|
||||
|
||||
private int thisID = 0;
|
||||
private long _startTimeStamp = 0, _endTimeStamp = 0;
|
||||
private Map<String, InstrumentData> batchInstruments;
|
||||
private CountDownLatch countDownLatch;
|
||||
private long timeout = 0;
|
||||
|
||||
Batch(String[] rics, long timeout) {
|
||||
thisID = id++;
|
||||
this.timeout = timeout;
|
||||
batchInstruments = new HashMap<String, InstrumentData>(rics.length);
|
||||
for(String ric : rics) {
|
||||
batchInstruments.put(ric, new InstrumentData(ric));
|
||||
}
|
||||
|
||||
countDownLatch = new CountDownLatch(batchInstruments.size());
|
||||
}
|
||||
|
||||
|
||||
public String[] getAllRics() {
|
||||
return batchInstruments.keySet().toArray(new String[batchInstruments.size()]);
|
||||
}
|
||||
|
||||
public InstrumentData getInstrument(String ric) throws Exception {
|
||||
if(!batchInstruments.containsKey(ric)) {
|
||||
throw new Exception("RIC not found in batch: " + ric);
|
||||
}
|
||||
|
||||
return batchInstruments.get(ric);
|
||||
}
|
||||
|
||||
|
||||
public InstrumentData[] getAllInstruments() {
|
||||
return batchInstruments.values().toArray(new InstrumentData[0]);
|
||||
}
|
||||
|
||||
public void recordStartTime() {
|
||||
_startTimeStamp = System.currentTimeMillis();
|
||||
_endTimeStamp = 0;
|
||||
}
|
||||
|
||||
public void recordEndTime() {
|
||||
_endTimeStamp = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean await() throws Exception {
|
||||
return countDownLatch.await(timeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public void countDown() {
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
|
||||
public long batchFulfilmentTime() {
|
||||
return _endTimeStamp - _startTimeStamp;
|
||||
}
|
||||
|
||||
public int getBatchId() {
|
||||
return thisID;
|
||||
}
|
||||
|
||||
}
|
||||
22
src/main/java/cn/stock/market/lesg/InChangeEntity.java
Normal file
22
src/main/java/cn/stock/market/lesg/InChangeEntity.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package cn.stock.market.lesg;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* InChangeEntity
|
||||
*
|
||||
* @author jnerh
|
||||
* @since 2024/05/09 16:39
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class InChangeEntity {
|
||||
private String date;
|
||||
private String description;
|
||||
private String typ;
|
||||
private String ric;
|
||||
private String isin;
|
||||
private String codeTicker;
|
||||
private String cls;
|
||||
}
|
||||
34
src/main/java/cn/stock/market/lesg/InstrumentData.java
Normal file
34
src/main/java/cn/stock/market/lesg/InstrumentData.java
Normal file
@@ -0,0 +1,34 @@
|
||||
package cn.stock.market.lesg;
|
||||
|
||||
import com.refinitiv.ema.access.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@Data
|
||||
public class InstrumentData {
|
||||
|
||||
public String ric;
|
||||
public String dataState = "";
|
||||
public HashMap<String, String> dataMap = new HashMap<>();
|
||||
|
||||
|
||||
public InstrumentData(String ric) {
|
||||
this.ric = ric;
|
||||
}
|
||||
|
||||
|
||||
public void setState(OmmState state) {
|
||||
dataState = state.dataStateAsString() + "|" +
|
||||
state.statusCodeAsString() + "|" +
|
||||
state.statusText() + "|" +
|
||||
state.streamStateAsString();
|
||||
}
|
||||
|
||||
|
||||
public void decode(FieldList fieldList) {
|
||||
for(FieldEntry fieldEntry : fieldList)
|
||||
dataMap.put(fieldEntry.name(), fieldEntry.load().toString());
|
||||
}
|
||||
|
||||
}
|
||||
54
src/main/java/cn/stock/market/lesg/RefinitivAppClient.java
Normal file
54
src/main/java/cn/stock/market/lesg/RefinitivAppClient.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package cn.stock.market.lesg;
|
||||
|
||||
import com.refinitiv.ema.access.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
class RefinitivAppClient implements OmmConsumerClient {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RefinitivAppClient.class);
|
||||
|
||||
|
||||
public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event) {
|
||||
try {
|
||||
Batch bRequest = (Batch) event.closure();
|
||||
InstrumentData instr = bRequest.getInstrument(refreshMsg.name());
|
||||
instr.setState(refreshMsg.state());
|
||||
if(DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType()) {
|
||||
instr.decode(refreshMsg.payload().fieldList());
|
||||
}
|
||||
bRequest.countDown();
|
||||
}
|
||||
catch(Exception e) {
|
||||
LOG.error("Exception processing Refresh callback");
|
||||
LOG.error("Message: ", refreshMsg);
|
||||
LOG.error("Exception: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onStatusMsg(StatusMsg statusMsg, OmmConsumerEvent event) {
|
||||
if(statusMsg.hasName()) {
|
||||
try {
|
||||
Batch bRequest = (Batch) event.closure();
|
||||
InstrumentData instr = bRequest.getInstrument(statusMsg.name());
|
||||
instr.setState(statusMsg.state());
|
||||
bRequest.countDown();
|
||||
}
|
||||
catch(Exception e) {
|
||||
LOG.error("Exception processing Status callback");
|
||||
LOG.error("Message: ", statusMsg);
|
||||
LOG.error("Exception: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdateMsg(UpdateMsg updateMsg, OmmConsumerEvent event) {}
|
||||
|
||||
public void onGenericMsg(GenericMsg genericMsg, OmmConsumerEvent consumerEvent) {}
|
||||
|
||||
public void onAckMsg(AckMsg ackMsg, OmmConsumerEvent consumerEvent) {}
|
||||
|
||||
public void onAllMsg(Msg msg, OmmConsumerEvent consumerEvent) {}
|
||||
}
|
||||
670
src/main/java/cn/stock/market/lesg/RefinitivConsumer.java
Normal file
670
src/main/java/cn/stock/market/lesg/RefinitivConsumer.java
Normal file
@@ -0,0 +1,670 @@
|
||||
package cn.stock.market.lesg;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.stock.market.constant.InChangeDataTypeEnum;
|
||||
import cn.stock.market.constant.InChangeType;
|
||||
import cn.stock.market.domain.basic.entity.RetifiveStock;
|
||||
import cn.stock.market.dto.RetifiveStockHistoryResponse;
|
||||
import cn.stock.market.dto.RetifiveStockInfo;
|
||||
import cn.stock.market.utils.RefinitivUtil;
|
||||
import com.ag.exception.SysTipsException;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.refinitiv.ema.access.*;
|
||||
import com.refinitiv.ema.rdm.EmaRdm;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* RefinitivConsumer
|
||||
*
|
||||
* @author jnerh
|
||||
* @since 2024/04/29 10:37
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class RefinitivConsumer implements ApplicationRunner {
|
||||
|
||||
/**
|
||||
* 股票的IN/CHANGE范围为 2-40
|
||||
*/
|
||||
private static final int SYMBOL_CHANGE_MAX_SIZE = 40;
|
||||
|
||||
private static final String SYMBOL_CHANGE_PREFIX = "IN/CHANGE";
|
||||
|
||||
private static final String SYMBOL_LINK_PREFIX = "#EQ.BO";
|
||||
|
||||
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
private static String serviceName;
|
||||
@Value("${refinitiv.market-data.service-name}")
|
||||
public void setServiceName(String serviceName) {
|
||||
RefinitivConsumer.serviceName = serviceName;
|
||||
}
|
||||
|
||||
private static String username;
|
||||
@Value("${refinitiv.market-data.username}")
|
||||
public void setUsername(String username) {
|
||||
RefinitivConsumer.username = username;
|
||||
}
|
||||
|
||||
private static String password;
|
||||
@Value("${refinitiv.market-data.password}")
|
||||
public void setPassword(String password) {
|
||||
RefinitivConsumer.password = password;
|
||||
}
|
||||
|
||||
private static String clientId;
|
||||
@Value("${refinitiv.market-data.clientId}")
|
||||
public void setClientId(String clientId) {
|
||||
RefinitivConsumer.clientId = clientId;
|
||||
}
|
||||
|
||||
private static long timeout;
|
||||
@Value("${refinitiv.market-data.batch-request-timeout}")
|
||||
public void setTimeout(long timeout) {
|
||||
RefinitivConsumer.timeout = timeout;
|
||||
}
|
||||
|
||||
|
||||
@Value("${refinitiv.token.username}")
|
||||
private String tokenUsername;
|
||||
|
||||
@Value("${refinitiv.token.password}")
|
||||
private String tokenPassword;
|
||||
|
||||
@Value("${refinitiv.token.appKey}")
|
||||
private String appKey;
|
||||
@Value("${refinitiv.token.url}")
|
||||
private String tokenUrl;
|
||||
|
||||
|
||||
private static OmmConsumer consumer = null;
|
||||
|
||||
public static final String TOP_ACTIVES_SYMBOL = ".AV.BO";
|
||||
public static final String TOP_GAINERS_SYMBOL = ".PG.BO";
|
||||
public static final String TOP_LOSERS_SYMBOL = ".PL.BO";
|
||||
|
||||
public static final String SCOPE = "trapi";
|
||||
public static final String GRANT_TYPE = "password";
|
||||
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
initialize();
|
||||
}
|
||||
|
||||
private static void initialize() {
|
||||
log.info("Initialize the consumer and connect to market data system....start");
|
||||
OmmConsumerConfig config = EmaFactory.createOmmConsumerConfig();
|
||||
config.username(username)
|
||||
.password(password)
|
||||
.clientId(clientId)
|
||||
.consumerName("Consumer_4");
|
||||
consumer = EmaFactory.createOmmConsumer(config);
|
||||
log.info("Initialize the consumer and connect to market data system....end");
|
||||
}
|
||||
public static OmmConsumer getConsumer() {
|
||||
if (consumer == null) {
|
||||
synchronized (RefinitivConsumer.class) {
|
||||
if (consumer == null) {
|
||||
initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
return consumer;
|
||||
}
|
||||
|
||||
|
||||
public InstrumentData[] getDataBySymbol(String symbol) throws Exception {
|
||||
String[] items = symbol.split(",");
|
||||
log.info("Quote request for: {}", java.util.Arrays.toString(items));
|
||||
// create a batch request
|
||||
Batch btc = new Batch(items, timeout);
|
||||
// price it
|
||||
this.synchronousRequest(btc);
|
||||
// send json array response
|
||||
return btc.getAllInstruments();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取股票详情
|
||||
*
|
||||
* @param symbol ric
|
||||
* @return 结果
|
||||
* @throws Exception e
|
||||
*/
|
||||
public RetifiveStockInfo getDetail(String symbol) throws Exception {
|
||||
InstrumentData[] result = getDataBySymbol(symbol);
|
||||
InstrumentData instrumentData = result[0];
|
||||
// 判断数据有效性
|
||||
if (isInvalidResult(instrumentData)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return RefinitivUtil.decode(instrumentData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取股票推荐TopActives
|
||||
*
|
||||
* @return 结果
|
||||
* @throws Exception e
|
||||
*/
|
||||
public List<RetifiveStockInfo> getTopActives() throws Exception {
|
||||
return getTopStockList(TOP_ACTIVES_SYMBOL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取股票推荐TopGainers
|
||||
*
|
||||
* @return 结果
|
||||
* @throws Exception e
|
||||
*/
|
||||
public List<RetifiveStockInfo> getTopGainers() throws Exception {
|
||||
return getTopStockList(TOP_GAINERS_SYMBOL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取股票推荐TopLosers
|
||||
*
|
||||
* @return 结果
|
||||
* @throws Exception e
|
||||
*/
|
||||
public List<RetifiveStockInfo> getTopLosers() throws Exception {
|
||||
return getTopStockList(TOP_LOSERS_SYMBOL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多个股票详情
|
||||
*
|
||||
* @param symbol ric
|
||||
* @return 结果
|
||||
* @throws Exception e
|
||||
*/
|
||||
public List<RetifiveStockInfo> getDetailList(String symbol) throws Exception {
|
||||
return getStockList(symbol);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多个股票详情
|
||||
*
|
||||
* @param symbol ric
|
||||
* @return 结果
|
||||
* @throws Exception e
|
||||
*/
|
||||
public List<RetifiveStockInfo> getStockList(String symbol) throws Exception {
|
||||
List<RetifiveStockInfo> list = new ArrayList<>();
|
||||
InstrumentData[] result = getDataBySymbol(symbol);
|
||||
for (InstrumentData instrumentData : result) {
|
||||
if (!isInvalidResult(instrumentData)) {
|
||||
RetifiveStockInfo retifiveStockInfo = RefinitivUtil.decode(instrumentData);
|
||||
list.add(retifiveStockInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取多个股票详情
|
||||
*
|
||||
* @param symbol ric
|
||||
* @return 结果
|
||||
* @throws Exception e
|
||||
*/
|
||||
public List<RetifiveStock> getRefinitivStockList(String symbol) throws Exception {
|
||||
List<RetifiveStock> list = new ArrayList<>();
|
||||
InstrumentData[] result = getDataBySymbol(symbol);
|
||||
for (InstrumentData instrumentData : result) {
|
||||
if (!isInvalidResult(instrumentData)) {
|
||||
RetifiveStock retifiveStock = RefinitivUtil.decodeRefinitivStock(instrumentData);
|
||||
list.add(retifiveStock);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有股票的symbol
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public List<String> getSymbolList() {
|
||||
List<String> symbols = new ArrayList<>();
|
||||
int seq = 0;
|
||||
String symbolLink = seq + SYMBOL_LINK_PREFIX;
|
||||
String nextLink = null;
|
||||
try {
|
||||
InstrumentData[] dataBySymbol = this.getDataBySymbol(symbolLink);
|
||||
nextLink = RefinitivUtil.decode(dataBySymbol[0].getDataMap(), symbols);
|
||||
while (StringUtils.isNotBlank(nextLink) && !nextLink.contains("blank data")) {
|
||||
dataBySymbol = this.getDataBySymbol(nextLink);
|
||||
nextLink = RefinitivUtil.decode(dataBySymbol[0].getDataMap(), symbols);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("每天18点定时同步Refinitiv股票数据出错,数据未查出,nextLink = {}", nextLink, e);
|
||||
}
|
||||
|
||||
return symbols;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否可以获取下一页数据
|
||||
*
|
||||
* 如果是要查今天的数据,需要先change2,
|
||||
* 1 如果change2中包含今天的数据
|
||||
* 1)判断最后一条是否为今天的数据
|
||||
* a)如果是今天的数据,需要再查change3,依次类推
|
||||
* b) 如果不是则停止查询,直接取出所有的今天的数据
|
||||
* 2 不包含今天的数据
|
||||
* 1) 判断最后一条是否为今天之后的数据
|
||||
* a) 是,需要再查change3,依次类推
|
||||
* b) 不是,则停止查询,今天没有需要的数据
|
||||
*
|
||||
* @param list InChange数据
|
||||
* @return 结果
|
||||
*/
|
||||
private boolean canGoNext(List<InChangeEntity> list) {
|
||||
// 获取当天的数据
|
||||
List<InChangeEntity> todayData = list.stream().filter(item -> item.getDate().equals(LocalDate.now().toString())).collect(Collectors.toList());
|
||||
// 获取到最后一条数据
|
||||
InChangeEntity lastEntity = list.get(list.size() - 1);
|
||||
if (CollUtil.isNotEmpty(todayData)) {
|
||||
// 如果list中包含今天的数据,则判断最后一条是否为今天的数据
|
||||
return LocalDate.parse(lastEntity.getDate()).isEqual(LocalDate.now());
|
||||
} else {
|
||||
// 如果list中不包含今天的数据,则判断最后一条是否为今天之后的数据
|
||||
return LocalDate.parse(lastEntity.getDate()).isAfter(LocalDate.now());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取要操作的股票
|
||||
*
|
||||
* @param inChangeType 类型
|
||||
* @return 结果
|
||||
*/
|
||||
public Map<InChangeDataTypeEnum, List<InChangeEntity>> getInChangeSymbolList(InChangeType inChangeType) {
|
||||
List<InChangeEntity> allInChangeData = queryInChangeData(inChangeType);
|
||||
return assembleDataMap(allInChangeData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取IN/CHANGE数据
|
||||
*
|
||||
* @param inChangeType 类型
|
||||
* @return 结果
|
||||
*/
|
||||
private List<InChangeEntity> queryInChangeData(InChangeType inChangeType) {
|
||||
List<InChangeEntity> allInChangeData = new ArrayList<>();
|
||||
for (int i = 2; i <= SYMBOL_CHANGE_MAX_SIZE; i++) {
|
||||
String symbol = SYMBOL_CHANGE_PREFIX + i;
|
||||
try {
|
||||
InstrumentData[] dataBySymbol = this.getDataBySymbol(symbol);
|
||||
InstrumentData instrumentData = dataBySymbol[0];
|
||||
if (isInvalidResult(instrumentData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<InChangeEntity> list = RefinitivUtil.decodeInChangeData(instrumentData);
|
||||
allInChangeData.addAll(list);
|
||||
|
||||
if (inChangeType == InChangeType.TODAY) {
|
||||
if (!canGoNext(list)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("每天18点定时同步Refinitiv股票数据IN/CHANGE出错,symbol = {}", symbol, e);
|
||||
}
|
||||
}
|
||||
|
||||
if (inChangeType == InChangeType.TODAY) {
|
||||
// 过滤出今天的数据
|
||||
return allInChangeData.stream().filter(item -> LocalDate.parse(item.getDate()).isEqual(LocalDate.now())).collect(Collectors.toList());
|
||||
} else {
|
||||
// 过滤出不晚于今天的数据
|
||||
return allInChangeData.stream().filter(item -> !LocalDate.parse(item.getDate()).isAfter(LocalDate.now())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装要操作的数据
|
||||
*
|
||||
* @param allInChangeData 要操作的数据
|
||||
* @return 结果
|
||||
*/
|
||||
private Map<InChangeDataTypeEnum, List<InChangeEntity>> assembleDataMap(List<InChangeEntity> allInChangeData) {
|
||||
Map<InChangeDataTypeEnum, List<InChangeEntity>> map = new HashMap<>(100);
|
||||
List<InChangeEntity> delList = new ArrayList<>();
|
||||
// List<InChangeEntity> addList = new ArrayList<>();
|
||||
List<InChangeEntity> updateList = new ArrayList<>();
|
||||
for (int i = 0; i < allInChangeData.size(); i++) {
|
||||
InChangeEntity inChange = allInChangeData.get(i);
|
||||
if (InChangeDataTypeEnum.DEL.name().equals(inChange.getTyp())) {
|
||||
delList.add(inChange);
|
||||
}
|
||||
// if (InChangeDataTypeEnum.ADD.name().equals(inChange.getTyp())) {
|
||||
// addList.add(inChange);
|
||||
// }
|
||||
if (InChangeDataTypeEnum.WAS.name().equals(inChange.getTyp()) && i < allInChangeData.size() - 1) {
|
||||
updateList.addAll(Lists.newArrayList(allInChangeData.get(i + 1), inChange));
|
||||
}
|
||||
}
|
||||
|
||||
Collections.reverse(updateList);
|
||||
map.put(InChangeDataTypeEnum.DEL, delList);
|
||||
// map.put(InChangeDataTypeEnum.ADD, addList);
|
||||
map.put(InChangeDataTypeEnum.WAS, updateList);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取多个推荐股票详情
|
||||
*
|
||||
* @param symbol ric
|
||||
* @return 结果
|
||||
* @throws Exception e
|
||||
*/
|
||||
public List<RetifiveStockInfo> getTopStockList(String symbol) throws Exception {
|
||||
List<RetifiveStockInfo> list = new ArrayList<>();
|
||||
InstrumentData[] result = getDataBySymbol(symbol);
|
||||
if (result.length == 0 || isInvalidResult(result[0])) {
|
||||
return list;
|
||||
}
|
||||
|
||||
List<String> topSymbols = RefinitivUtil.decodeTopData(result[0]);
|
||||
if (CollUtil.isEmpty(topSymbols)) {
|
||||
return list;
|
||||
}
|
||||
return getStockList(String.join(",", topSymbols));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验数据有效性
|
||||
*
|
||||
* @param instrumentData 数据
|
||||
* @return 结果
|
||||
*/
|
||||
private boolean isInvalidResult(InstrumentData instrumentData) {
|
||||
String dataState = instrumentData.getDataState();
|
||||
return CollUtil.isEmpty(instrumentData.getDataMap()) ||
|
||||
StrUtil.containsAny(dataState, "Suspect", "NotFound", "**The record could not be found", "CLOSED");
|
||||
}
|
||||
|
||||
public void synchronousRequest(Batch bRequest) throws Exception {
|
||||
ElementList eList = EmaFactory.createElementList();
|
||||
OmmArray array = EmaFactory.createOmmArray();
|
||||
for (String instr : bRequest.getAllRics()) {
|
||||
array.add(EmaFactory.createOmmArrayEntry().ascii(instr));
|
||||
}
|
||||
eList.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_BATCH_ITEM_LIST, array));
|
||||
try {
|
||||
getConsumer().registerClient(EmaFactory.createReqMsg().serviceName(serviceName).payload(eList).interestAfterRefresh(false), new RefinitivAppClient(), bRequest);
|
||||
} catch (NullPointerException e) {
|
||||
initialize();
|
||||
getConsumer().registerClient(EmaFactory.createReqMsg().serviceName(serviceName).payload(eList).interestAfterRefresh(false), new RefinitivAppClient(), bRequest);
|
||||
}
|
||||
|
||||
// wait for batch to be fulfilled
|
||||
bRequest.await();
|
||||
}
|
||||
|
||||
|
||||
public void disconnect() {
|
||||
if (consumer != null) {
|
||||
consumer.uninitialize();
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public RetifiveStockHistoryResponse getKLink(String symbol, String resolution,String starttime, String endtime){
|
||||
RetifiveStockHistoryResponse result = new RetifiveStockHistoryResponse();
|
||||
String token = getToken();
|
||||
if(StringUtils.isBlank(token)){
|
||||
throw new SysTipsException("token为空");
|
||||
}
|
||||
JSONObject data = JSONObject.parseObject(token);
|
||||
token = data.getString("access_token");
|
||||
String baseURLToday = "https://api.refinitiv.com/data/historical-pricing/v1/views/intraday-summaries/";
|
||||
String baseURLHistory = "https://api.refinitiv.com/data/historical-pricing/v1/views/interday-summaries/";
|
||||
int countback = 5;
|
||||
String interval = null;
|
||||
String resourceEndpoint = null;
|
||||
Date start = new SimpleDateFormat("yyyy-MM-dd").parse(starttime);
|
||||
Date end = new SimpleDateFormat("yyyy-MM-dd").parse(endtime);
|
||||
long duration = end.getTime() - start.getTime();
|
||||
long minutes = TimeUnit.MILLISECONDS.toMinutes(duration);
|
||||
String fields = null;
|
||||
Integer flag = 0;
|
||||
if(StringUtils.equals("1m",resolution)){
|
||||
|
||||
countback = (int)minutes;
|
||||
interval = "PT1M";
|
||||
resourceEndpoint = baseURLToday + symbol;
|
||||
fields = "DATE,HIGH_1,LOW_1,OPEN_PRC,TRDPRC_1,NUM_MOVES";
|
||||
}else
|
||||
if(StringUtils.equals("5m",resolution)){
|
||||
countback = (int) (minutes/5);
|
||||
interval = "PT5M";
|
||||
resourceEndpoint = baseURLToday + symbol;
|
||||
fields = "DATE,HIGH_1,LOW_1,OPEN_PRC,TRDPRC_1,NUM_MOVES";
|
||||
}else
|
||||
if(StringUtils.equals("10m",resolution)){
|
||||
countback = (int) (minutes/10);
|
||||
interval = "PT10M";
|
||||
resourceEndpoint = baseURLToday + symbol;
|
||||
fields = "DATE,HIGH_1,LOW_1,OPEN_PRC,TRDPRC_1,NUM_MOVES";
|
||||
}else
|
||||
if(StringUtils.equals("30m",resolution)){
|
||||
countback = (int) (minutes/30);
|
||||
interval = "PT30M";
|
||||
resourceEndpoint = baseURLToday + symbol;
|
||||
fields = "DATE,HIGH_1,LOW_1,OPEN_PRC,TRDPRC_1,NUM_MOVES";
|
||||
}else
|
||||
if(StringUtils.equals("H",resolution)){
|
||||
countback = (int) (minutes/60);
|
||||
interval = "PT1H";
|
||||
resourceEndpoint = baseURLToday + symbol;
|
||||
fields = "DATE,HIGH_1,LOW_1,OPEN_PRC,TRDPRC_1,NUM_MOVES";
|
||||
}else if(StringUtils.equals("D",resolution)){
|
||||
|
||||
countback = (int)(minutes/24/60);
|
||||
interval ="P1D";
|
||||
fields = "DATE,HIGH_1,LOW_1,OPEN_PRC,OFF_CLOSE,NUM_MOVES";
|
||||
flag = 1;
|
||||
resourceEndpoint = baseURLHistory + symbol;
|
||||
}else if(StringUtils.equals("W",resolution)){
|
||||
|
||||
countback = (int)(minutes/7/24/60);
|
||||
interval ="P1W";
|
||||
fields = "DATE,HIGH_1,LOW_1,OPEN_PRC,OFF_CLOSE,NUM_MOVES";
|
||||
flag = 2;
|
||||
resourceEndpoint = baseURLHistory + symbol;
|
||||
}else if(StringUtils.equals("M",resolution)){
|
||||
|
||||
countback = (int)(minutes/30/24/60);
|
||||
interval ="P1M";
|
||||
fields = "DATE,HIGH_1,LOW_1,OPEN_PRC,OFF_CLOSE,NUM_MOVES";
|
||||
flag = 2;
|
||||
resourceEndpoint = baseURLHistory + symbol;
|
||||
}
|
||||
|
||||
DateTimeFormatter formatterIso = DateTimeFormatter.ISO_INSTANT;
|
||||
String startStr = start.toInstant().atZone(ZoneId.of("UTC")).format(formatterIso);
|
||||
String endStr = end.toInstant().atZone(ZoneId.of("UTC")).format(formatterIso);
|
||||
HttpResponse response = HttpUtil.createGet(resourceEndpoint)
|
||||
.form("eventTypes","trade,quote")
|
||||
.form("start",startStr)
|
||||
.form("end",endStr)
|
||||
.form("count",countback)
|
||||
.form("interval",interval)
|
||||
.form("fields",fields)
|
||||
.header("Authorization","Bearer " + token)
|
||||
.execute();
|
||||
if(response.getStatus() != 200){
|
||||
log.error("获取股票k线信息失败,code:"+response.getStatus());
|
||||
return result;
|
||||
}
|
||||
JSONArray jsonArray = JSONArray.parseArray(response.body());
|
||||
JSONArray dateArray = JSONObject.parseObject(jsonArray.get(0).toString()).getJSONArray("data");
|
||||
List<Long> t = new ArrayList<>(); //时间
|
||||
List<Double> o = new ArrayList<>(); //开盘价
|
||||
List<Double> h = new ArrayList<>(); // 最高价
|
||||
List<Double> l = new ArrayList<>();//最低价
|
||||
List<Double> c = new ArrayList<>();//当前价
|
||||
List<Double> v = new ArrayList<>();//交易量
|
||||
for(int i = 0; i < dateArray.size(); i++){
|
||||
JSONArray date = dateArray.getJSONArray(i);
|
||||
if(date.get(1) == null){
|
||||
continue;
|
||||
}
|
||||
if(StringUtils.equals("D",resolution) || StringUtils.equals("W",resolution) || StringUtils.equals("M",resolution)){
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Date d = formatter.parse(date.get(0).toString());
|
||||
t.add(d.getTime() / 1000);
|
||||
}else {
|
||||
Instant instant = Instant.parse(date.get(0).toString());
|
||||
long timestampMillis = instant.getEpochSecond();
|
||||
t.add(timestampMillis);
|
||||
}
|
||||
if(flag == 0) {
|
||||
o.add(Double.valueOf(date.get(3).toString()));
|
||||
h.add(Double.valueOf(date.get(1).toString()));
|
||||
l.add(Double.valueOf(date.get(2).toString()));
|
||||
c.add(Double.valueOf(date.get(4).toString()));
|
||||
v.add(date.get(5) == null?0:Double.valueOf(date.get(5).toString()));
|
||||
}
|
||||
if(flag == 1){
|
||||
o.add(Double.valueOf(date.get(4).toString()));
|
||||
h.add(Double.valueOf(date.get(2).toString()));
|
||||
l.add(Double.valueOf(date.get(3).toString()));
|
||||
c.add(Double.valueOf(date.get(1).toString()));
|
||||
v.add(date.get(5) == null?0:Double.valueOf(date.get(5).toString()));
|
||||
}
|
||||
if(flag == 2){
|
||||
o.add(Double.valueOf(date.get(1).toString()));
|
||||
h.add(Double.valueOf(date.get(4).toString()));
|
||||
l.add(Double.valueOf(date.get(2).toString()));
|
||||
c.add(Double.valueOf(date.get(5).toString()));
|
||||
v.add(date.get(3) == null?0:Double.valueOf(date.get(3).toString()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
result.setT(t);
|
||||
result.setO(o);
|
||||
result.setH(h);
|
||||
result.setL(l);
|
||||
result.setC(c);
|
||||
result.setV(v);
|
||||
result.setS("ok");
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getToken(){
|
||||
String toekn = null;
|
||||
if(ObjectUtil.isNotNull(redisTemplate.opsForValue().get("token"))){
|
||||
toekn = redisTemplate.opsForValue().get("token").toString();
|
||||
}
|
||||
|
||||
if(StringUtils.isNotBlank(toekn)){
|
||||
JSONObject data = JSONObject.parseObject(toekn);
|
||||
if(Long.valueOf(data.get("expiry_tm").toString()) > System.currentTimeMillis()){
|
||||
return toekn;
|
||||
}
|
||||
toekn = requestNewToken(data.get("refresh_token").toString());
|
||||
return toekn;
|
||||
}
|
||||
toekn = requestNewToken("");
|
||||
return toekn;
|
||||
}
|
||||
|
||||
public String requestNewToken(String refreshToken){
|
||||
|
||||
if(StringUtils.isNotBlank(refreshToken)){
|
||||
HttpResponse response = HttpUtil.createPost(tokenUrl)
|
||||
.form("refresh_token",refreshToken)
|
||||
.form("grant_type","refresh_token")
|
||||
.header("Content-Type", "application/x-www-form-urlencoded")
|
||||
.basicAuth(appKey,"")
|
||||
.execute();
|
||||
if(response.getStatus() != 200){
|
||||
return getNewToken();
|
||||
}
|
||||
JSONObject data = JSONObject.parseObject(response.body());
|
||||
data.put("expiry_tm",System.currentTimeMillis() + (Long.valueOf(data.get("expires_in").toString())-10));
|
||||
String toekn = data.toString();
|
||||
redisTemplate.opsForValue().set("token",toekn);
|
||||
redisTemplate.expire("token",1, TimeUnit.DAYS);
|
||||
return toekn;
|
||||
}
|
||||
// HttpResponse response = HttpUtil.createPost(tokenUrl)
|
||||
// .form("username",tokenUsername)
|
||||
// .form("password",tokenPassword)
|
||||
// .form("grant_type","password")
|
||||
// .form("scope",SCOPE)
|
||||
// .form("takeExclusiveSignOnControl","true")
|
||||
// .header("Content-Type", "application/x-www-form-urlencoded")
|
||||
// .basicAuth(appKey,"")
|
||||
// .execute();
|
||||
// if(response.getStatus() != 200){
|
||||
// throw new SysTipsException("获取token失败");
|
||||
// }
|
||||
// JSONObject data = JSONObject.parseObject(response.body());
|
||||
// data.put("expiry_tm",System.currentTimeMillis() + (Long.valueOf(data.get("expires_in").toString())-10));
|
||||
// String toekn = data.toString();
|
||||
// redisTemplate.opsForValue().set("token",toekn);
|
||||
// redisTemplate.expire("token",1, TimeUnit.DAYS);
|
||||
return getNewToken();
|
||||
}
|
||||
|
||||
public String getNewToken(){
|
||||
HttpResponse response = HttpUtil.createPost(tokenUrl)
|
||||
.form("username",tokenUsername)
|
||||
.form("password",tokenPassword)
|
||||
.form("grant_type","password")
|
||||
.form("scope",SCOPE)
|
||||
.form("takeExclusiveSignOnControl","true")
|
||||
.header("Content-Type", "application/x-www-form-urlencoded")
|
||||
.basicAuth(appKey,"")
|
||||
.execute();
|
||||
if(response.getStatus() != 200){
|
||||
log.error("获取toekn失败,code:"+response.getStatus());
|
||||
return null;
|
||||
}
|
||||
JSONObject data = JSONObject.parseObject(response.body());
|
||||
data.put("expiry_tm",System.currentTimeMillis() + (Long.valueOf(data.get("expires_in").toString())-10));
|
||||
String toekn = data.toString();
|
||||
redisTemplate.opsForValue().set("token",toekn);
|
||||
redisTemplate.expire("token",1, TimeUnit.DAYS);
|
||||
return toekn;
|
||||
}
|
||||
}
|
||||
141
src/main/java/cn/stock/market/listener/AppClient.java
Normal file
141
src/main/java/cn/stock/market/listener/AppClient.java
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
package cn.stock.market.listener;
|
||||
|
||||
import com.thomsonreuters.ema.access.AckMsg;
|
||||
import com.thomsonreuters.ema.access.ElementList;
|
||||
import com.thomsonreuters.ema.access.EmaFactory;
|
||||
import com.thomsonreuters.ema.access.GenericMsg;
|
||||
import com.thomsonreuters.ema.access.Msg;
|
||||
import com.thomsonreuters.ema.access.OmmArray;
|
||||
import com.thomsonreuters.ema.access.OmmConsumer;
|
||||
import com.thomsonreuters.ema.access.OmmConsumerClient;
|
||||
import com.thomsonreuters.ema.access.OmmConsumerConfig;
|
||||
import com.thomsonreuters.ema.access.OmmConsumerEvent;
|
||||
import com.thomsonreuters.ema.access.Payload;
|
||||
import com.thomsonreuters.ema.access.RefreshMsg;
|
||||
import com.thomsonreuters.ema.access.ReqMsg;
|
||||
import com.thomsonreuters.ema.access.StatusMsg;
|
||||
import com.thomsonreuters.ema.access.UpdateMsg;
|
||||
import com.thomsonreuters.ema.rdm.EmaRdm;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AppClient implements OmmConsumerClient {
|
||||
|
||||
private CompletableFuture<RefreshMsg> messageFuture = new CompletableFuture<>();
|
||||
private OmmConsumer consumer;
|
||||
|
||||
private CompletableFuture<List<RefreshMsg>> messagesFuture = new CompletableFuture<>();
|
||||
private ConcurrentHashMap<String, RefreshMsg> messages = new ConcurrentHashMap<>();
|
||||
private AtomicInteger expectedItemCount = new AtomicInteger(0); // 使用AtomicInteger确保线程安全
|
||||
|
||||
|
||||
public CompletableFuture<List<RefreshMsg>> getMessagesFuture() {
|
||||
return messagesFuture;
|
||||
}
|
||||
|
||||
public void resetMessagesFuture() {
|
||||
this.messagesFuture = new CompletableFuture<>(); // 重置CompletableFuture
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
public AppClient(OmmConsumer consumer) {
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
// 根据itemName进行订阅的方法
|
||||
public void subscribe(String itemName) {
|
||||
resetMessageFuture(); // 重置Future以便新的请求
|
||||
this.expectedItemCount = new AtomicInteger(1); // 设置预期的消息数量
|
||||
ReqMsg reqMsg = EmaFactory.createReqMsg().serviceName("ELEKTRON_DD").name(itemName);
|
||||
consumer.registerClient(reqMsg, this);
|
||||
}
|
||||
|
||||
|
||||
public CompletableFuture<RefreshMsg> getMessageFuture() {
|
||||
return messageFuture;
|
||||
}
|
||||
|
||||
public void resetMessageFuture() {
|
||||
this.messageFuture = new CompletableFuture<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event) {
|
||||
// log.error("监听的消息:"+refreshMsg.toString());
|
||||
if(expectedItemCount.get()==1){
|
||||
messageFuture.complete(refreshMsg);
|
||||
}
|
||||
if(expectedItemCount.get()>1){
|
||||
*/
|
||||
/* System.out.println("监听的消息:"+refreshMsg.streamId()+","+refreshMsg.name()+
|
||||
",是否完成:"+refreshMsg.complete());*//*
|
||||
|
||||
RefreshMsg msg = EmaFactory.createRefreshMsg(refreshMsg);
|
||||
messages.put(refreshMsg.name()+"", msg); // 假设每个refreshMsg都有一个uniqueIdentifier方法
|
||||
if (messages.size() == expectedItemCount.get()) { // 使用get()获取当前值
|
||||
List<RefreshMsg> resultList = new ArrayList<>(messages.values());
|
||||
messagesFuture.complete(resultList);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void subscribeList(List<String> itemNames) {
|
||||
resetMessagesFutures(); // 重置Future以便新的请求
|
||||
this.expectedItemCount = new AtomicInteger(itemNames.size()); // 设置预期的消息数量
|
||||
ElementList batch = EmaFactory.createElementList();
|
||||
OmmArray array = EmaFactory.createOmmArray();
|
||||
|
||||
if (!itemNames.isEmpty()) {
|
||||
itemNames.forEach(itemName -> array.add(EmaFactory.createOmmArrayEntry().ascii(itemName)));
|
||||
batch.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_BATCH_ITEM_LIST, array));
|
||||
consumer.registerClient(EmaFactory.createReqMsg().serviceName("ELEKTRON_DD").payload(batch), this);
|
||||
}
|
||||
}
|
||||
|
||||
private void resetMessagesFutures() {
|
||||
this.messages.clear(); // 清理之前的消息记录
|
||||
this.messagesFuture = new CompletableFuture<>();
|
||||
this.expectedItemCount = new AtomicInteger(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateMsg(UpdateMsg updateMsg, OmmConsumerEvent consumerEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusMsg(StatusMsg statusMsg, OmmConsumerEvent consumerEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGenericMsg(GenericMsg genericMsg, OmmConsumerEvent consumerEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAckMsg(AckMsg ackMsg, OmmConsumerEvent consumerEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAllMsg(Msg msg, OmmConsumerEvent consumerEvent) {
|
||||
}
|
||||
// 其他消息处理...
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
package cn.stock.market.listener;
|
||||
|
||||
import com.thomsonreuters.ema.access.AckMsg;
|
||||
import com.thomsonreuters.ema.access.EmaFactory;
|
||||
import com.thomsonreuters.ema.access.GenericMsg;
|
||||
import com.thomsonreuters.ema.access.Msg;
|
||||
import com.thomsonreuters.ema.access.OmmConsumer;
|
||||
import com.thomsonreuters.ema.access.OmmConsumerClient;
|
||||
import com.thomsonreuters.ema.access.OmmConsumerEvent;
|
||||
import com.thomsonreuters.ema.access.RefreshMsg;
|
||||
import com.thomsonreuters.ema.access.ReqMsg;
|
||||
import com.thomsonreuters.ema.access.StatusMsg;
|
||||
import com.thomsonreuters.ema.access.UpdateMsg;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
*/
|
||||
/**
|
||||
* @author gs
|
||||
* @date 2024/4/8 22:01
|
||||
*//*
|
||||
|
||||
@Service
|
||||
public class ConcurrentAppClient implements OmmConsumerClient {
|
||||
private final ConcurrentHashMap<String, CompletableFuture<RefreshMsg>> futures = new ConcurrentHashMap<>();
|
||||
private OmmConsumer consumer;
|
||||
|
||||
@Autowired
|
||||
public ConcurrentAppClient(OmmConsumer consumer) {
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public CompletableFuture<RefreshMsg> subscribe(String itemName) {
|
||||
CompletableFuture<RefreshMsg> future = new CompletableFuture<>();
|
||||
futures.put(itemName, future);
|
||||
ReqMsg reqMsg = EmaFactory.createReqMsg().serviceName("ELEKTRON_DD").name(itemName);
|
||||
consumer.registerClient(reqMsg, this);
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event) {
|
||||
String itemName = refreshMsg.name();
|
||||
CompletableFuture<RefreshMsg> future = futures.remove(itemName);
|
||||
if (future != null) {
|
||||
future.complete(refreshMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateMsg(UpdateMsg updateMsg, OmmConsumerEvent consumerEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusMsg(StatusMsg statusMsg, OmmConsumerEvent consumerEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGenericMsg(GenericMsg genericMsg, OmmConsumerEvent consumerEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAckMsg(AckMsg ackMsg, OmmConsumerEvent consumerEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAllMsg(Msg msg, OmmConsumerEvent consumerEvent) {
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
898
src/main/java/cn/stock/market/listener/EmaConfig.xml
Normal file
898
src/main/java/cn/stock/market/listener/EmaConfig.xml
Normal file
@@ -0,0 +1,898 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EmaConfig>
|
||||
|
||||
<!-- ConsumerGroup provides set of detailed configurations to be used by named consumers -->
|
||||
<!-- Application specifies which configuration to use by setting OmmConsumerConfig::consumerName() -->
|
||||
<ConsumerGroup>
|
||||
<!-- DefaultConsumer parameter defines which consumer configuration is used by OmmConsumer -->
|
||||
<!-- if application does not specify it through OmmConsumerConfig::consumerName() -->
|
||||
<!-- first consumer on the ConsumerList is a DefaultConsumer if this parameter is not specified -->
|
||||
<DefaultConsumer value="Consumer_1"/>
|
||||
<ConsumerList>
|
||||
<Consumer>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="Consumer_1"/>
|
||||
<!-- Channel is optional: defaulted to "RSSL_SOCKET + localhost + 14002" -->
|
||||
<!-- Channel or ChannelSet may be specified -->
|
||||
<Channel value="Channel_1"/>
|
||||
<!-- Dictionary is optional: defaulted to "ChannelDictionary" -->
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Consumer_2"/>
|
||||
<!-- ChannelSet specifies an ordered list of Channels to which OmmConsumer will attempt to -->
|
||||
<!-- connect, one at a time, if the previous one fails to connect -->
|
||||
<ChannelSet value="Channel_1, Channel_2"/>
|
||||
<Dictionary value="Dictionary_2"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Consumer_3"/>
|
||||
<!-- Channel set to "RSSL_ENCRYPTED" -->
|
||||
<Channel value="Channel_3"/>
|
||||
<!-- Dictionary is optional: defaulted to "ChannelDictionary" -->
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Consumer_4"/>
|
||||
<Channel value="Channel_4"/>
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<MaxDispatchCountApiThread value="6500"/>
|
||||
<MaxDispatchCountUserThread value="6500"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<!-- Channel is specified to provide RSSL_WEBSOCKET connection options -->
|
||||
<Name value="Consumer_5"/>
|
||||
<Channel value="Channel_5"/>
|
||||
<Dictionary value="Dictionary_2"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
<DefaultServiceID value="1"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="Consumer_6"/>
|
||||
<Channel value="Channel_6"/>
|
||||
<!-- Dictionary is optional: defaulted to "ChannelDictionary" -->
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
<DefaultServiceID value="1"/>
|
||||
</Consumer>
|
||||
<!-- Consumer with enabled RTT feature -->
|
||||
<Consumer>
|
||||
<Name value="Consumer_7"/>
|
||||
<Channel value="Channel_1"/>
|
||||
<Dictionary value="Dictionary_2"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
<DefaultServiceID value="1"/>
|
||||
<EnableRtt value="1"/>
|
||||
</Consumer>
|
||||
<!-- Consumer for warm standby feature -->
|
||||
<Consumer>
|
||||
<Name value="Consumer_8"/>
|
||||
<WarmStandbyChannelSet value="WarmStandbyChannel_1"/>
|
||||
<Dictionary value="Dictionary_2"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</Consumer>
|
||||
<!-- Performance tools consumers -->
|
||||
<Consumer>
|
||||
<Name value="Perf_Consumer_1"/>
|
||||
<Channel value="Perf_Channel_1"/>
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<MaxDispatchCountApiThread value="6500"/>
|
||||
<MaxDispatchCountUserThread value="6500"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Perf_Consumer_WSJSON_1"/>
|
||||
<Channel value="Perf_Channel_WSJSON_1"/>
|
||||
<Dictionary value="Dictionary_2"/>
|
||||
<MaxDispatchCountApiThread value="6500"/>
|
||||
<MaxDispatchCountUserThread value="6500"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Perf_Consumer_WSRWF_1"/>
|
||||
<Channel value="Perf_Channel_WSRWF_1"/>
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<MaxDispatchCountApiThread value="6500"/>
|
||||
<MaxDispatchCountUserThread value="6500"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Consumer_RRTViewer_SE"/>
|
||||
<Channel value="Channel_RRTViewer_SE"/>
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<!-- 'XmlTraceToStdout == 1' is required for proper working of 'Debug' mode in RRTViewer -->
|
||||
<!-- If XmlTraceToStdout set into '0', 'debug' mode will print only EMA logs. -->
|
||||
<XmlTraceToStdout value="1"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Consumer_RRTViewer_DE"/>
|
||||
<Channel value="Channel_RRTViewer_DE"/>
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<!-- 'XmlTraceToStdout == 1' is required for proper working of 'Debug' mode in RRTViewer -->
|
||||
<!-- If XmlTraceToStdout set into '0', 'debug' mode will print only EMA logs. -->
|
||||
<XmlTraceToStdout value="1"/>
|
||||
</Consumer>
|
||||
</ConsumerList>
|
||||
</ConsumerGroup>
|
||||
|
||||
<!-- NiProviderGroup provides set of detailed configurations to be used by named providers -->
|
||||
<!-- Application specifies which configuration to use by setting OmmNiProviderConfig::providerName() -->
|
||||
<NiProviderGroup>
|
||||
<!-- DefaultNiProvider parameter defines which provider configuration is used by OmmProvider -->
|
||||
<!-- if application does not specify it through OmmNiProviderConfig::providerName() -->
|
||||
<!-- first provider on the NiProviderList is a DefaultNiProvider if this parameter is not specified -->
|
||||
<DefaultNiProvider value="Provider_1"/>
|
||||
<NiProviderList>
|
||||
<!-- Regular providers -->
|
||||
<NiProvider>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="Provider_1"/>
|
||||
<!-- Channel is optional: defaulted to "RSSL_SOCKET + localhost + 14003" -->
|
||||
<Channel value="Channel_7"/>
|
||||
<!-- Directory is optional. -->
|
||||
<!-- the EMA provides hardcoded directory containing a single service named "NI_PUB". -->
|
||||
<!-- the EMA defaults the OmmNiProviderConfig::adminControlDirectory() to ApiControlEnum.-->
|
||||
<!-- the applications may just use the hardcoded "NI_PUB" service to publish all the items.-->
|
||||
<!-- if desired, a custom directory may be configured, named and used instead of the -->
|
||||
<!-- hardcoded one. Please see examples in the DirectoryGroup.-->
|
||||
<!-- the directory may also be specified using OmmNiProviderConfig::addAdminMsg(). -->
|
||||
<!-- if desired the OmmNiProviderConfig::adminControlDirectory() to UserControlEnum -->
|
||||
<!-- which allows applications to specify and control the directory. -->
|
||||
<Directory value="Directory_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</NiProvider>
|
||||
<NiProvider>
|
||||
<Name value="Provider_2"/>
|
||||
<Channel value="Channel_6"/>
|
||||
<Directory value="Directory_2"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</NiProvider>
|
||||
<NiProvider>
|
||||
<Name value="Provider_3"/>
|
||||
<Channel value="Channel_6"/>
|
||||
<Directory value="Directory_3"/>
|
||||
</NiProvider>
|
||||
<NiProvider>
|
||||
<Name value="Provider_4"/>
|
||||
<Channel value="Channel_7"/>
|
||||
<Directory value="Directory_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</NiProvider>
|
||||
<!-- Performance tools niprovider -->
|
||||
<NiProvider>
|
||||
<Name value="Perf_NIProvider_1"/>
|
||||
<Channel value="Perf_NIP_Channel_1"/>
|
||||
<Directory value="Perf_Directory_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
<ItemCountHint value="100000"/>
|
||||
<MaxDispatchCountApiThread value="500"/>
|
||||
<MaxDispatchCountUserThread value="500"/>
|
||||
</NiProvider>
|
||||
</NiProviderList>
|
||||
</NiProviderGroup>
|
||||
|
||||
<!-- IProviderGroup provides set of detailed configurations to be used by named providers -->
|
||||
<!-- Application specifies which configuration to use by setting OmmIProviderConfig::providerName() -->
|
||||
<IProviderGroup>
|
||||
<!-- DefaultIProvider parameter defines which provider configuration is used by OmmProvider -->
|
||||
<!-- if application does not specify it through OmmIProviderConfig::providerName() -->
|
||||
<!-- first provider on the IProviderList is a default provider if this parameter is not specified -->
|
||||
<DefaultIProvider value="Provider_1"/>
|
||||
<IProviderList>
|
||||
<IProvider>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="Provider_1"/>
|
||||
<!-- Server is optional: defaulted to "RSSL_SOCKET + 14002" -->
|
||||
<Server value="Server_1"/>
|
||||
<!-- Directory is optional: defaulted to AdminControl::UserControlEnum -->
|
||||
<!-- source directory configuration to use if OmmIProviderConfig::adminModel() -->
|
||||
<!-- was set to ApiControlEnum -->
|
||||
<!-- this configuration also decides which dictionaries will be loaded at startup -->
|
||||
<!-- this configuration may be overwritten by OmmIProviderConfig::addAdminMsg() -->
|
||||
<Directory value="Directory_2"/>
|
||||
<ItemCountHint value="10000"/>
|
||||
<ServiceCountHint value="10000" />
|
||||
<DispatchTimeoutApiThread value="500" />
|
||||
<MaxDispatchCountApiThread value="500" />
|
||||
<MaxDispatchCountUserThread value="500" />
|
||||
<PipePort value="9009" />
|
||||
<RefreshFirstRequired value="1" />
|
||||
</IProvider>
|
||||
<IProvider>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="Provider_3"/>
|
||||
<!-- Server is optional: now it specifies RSSL_WEBSOCKET connection options -->
|
||||
<Server value="Server_2"/>
|
||||
<!-- Directory is optional: defaulted to AdminControl::UserControlEnum -->
|
||||
<!-- source directory configuration to use if OmmIProviderConfig::adminModel() -->
|
||||
<!-- was set to ApiControlEnum -->
|
||||
<!-- this configuration also decides which dictionaries will be loaded at startup -->
|
||||
<!-- this configuration may be overwritten by OmmIProviderConfig::addAdminMsg() -->
|
||||
<Directory value="Directory_2"/>
|
||||
<ItemCountHint value="10000"/>
|
||||
<ServiceCountHint value="10000" />
|
||||
<DispatchTimeoutApiThread value="500" />
|
||||
<MaxDispatchCountApiThread value="500" />
|
||||
<MaxDispatchCountUserThread value="500" />
|
||||
<PipePort value="9009" />
|
||||
<RefreshFirstRequired value="1" />
|
||||
<SendJsonConvError value="1" />
|
||||
</IProvider>
|
||||
<IProvider>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="EncryptedProvider"/>
|
||||
<!-- Server is optional: defaulted to "RSSL_SOCKET + 14002" -->
|
||||
<Server value="EncryptedServer"/>
|
||||
<!-- Directory is optional: defaulted to AdminControl::UserControlEnum -->
|
||||
<!-- source directory configuration to use if OmmIProviderConfig::adminModel() -->
|
||||
<!-- was set to ApiControlEnum -->
|
||||
<!-- this configuration also decides which dictionaries will be loaded at startup -->
|
||||
<!-- this configuration may be overwritten by OmmIProviderConfig::addAdminMsg() -->
|
||||
<Directory value="Directory_2"/>
|
||||
<ItemCountHint value="10000"/>
|
||||
<ServiceCountHint value="10000" />
|
||||
<DispatchTimeoutApiThread value="500" />
|
||||
<MaxDispatchCountApiThread value="500" />
|
||||
<MaxDispatchCountUserThread value="500" />
|
||||
<PipePort value="9009" />
|
||||
<RefreshFirstRequired value="1" />
|
||||
</IProvider>
|
||||
<!-- Performance tools provider -->
|
||||
<IProvider>
|
||||
<Name value="Perf_Provider_1"/>
|
||||
<Server value="Perf_Server_1"/>
|
||||
<Directory value="Directory_2"/>
|
||||
<ItemCountHint value="100000"/>
|
||||
<ServiceCountHint value="10000"/>
|
||||
<DispatchTimeoutApiThread value="5000" />
|
||||
<MaxDispatchCountApiThread value="10"/>
|
||||
<MaxDispatchCountUserThread value="6500"/>
|
||||
<RefreshFirstRequired value="1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</IProvider>
|
||||
</IProviderList>
|
||||
</IProviderGroup>
|
||||
|
||||
<ChannelGroup>
|
||||
<ChannelList>
|
||||
<Channel>
|
||||
<Name value="Channel_1"/>
|
||||
<!-- ChannelType possible values are: -->
|
||||
<!-- ChannelType::RSSL_SOCKET - TCP IP connection type -->
|
||||
<!-- ChannelType::RSSL_HTTP - Http tunnel connection type -->
|
||||
<!-- ChannelType::RSSL_ENCRYPTED - Https tunnel connection type -->
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<!-- CompressionType is optional: defaulted to None -->
|
||||
<!-- possible values: None, ZLib, LZ4 -->
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- ConnectionPingTimeout is optional: defaulted to 30000 -->
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<!-- TcpNodelay is optional: defaulted to 1 -->
|
||||
<!-- possible values: 1 (tcp_nodelay option set), 0 (tcp_nodelay not set) -->
|
||||
<TcpNodelay value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_2"/>
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_3"/>
|
||||
<ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
<!-- ObjectName is optional: defaulted to "" -->
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_4"/>
|
||||
<ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- EMA discovers a host and a port from RDP service discovery for the specified location
|
||||
when both of them are not set and the session management is enable. -->
|
||||
<Location value="us-east-1"/>
|
||||
<EnableSessionManagement value="1"/>
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_5"/>
|
||||
<ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- EMA discovers a host and a port from RDP service discovery for the specified location
|
||||
when both of them are not set and the session management is enable. -->
|
||||
<Location value="us-east-1"/>
|
||||
<EnableSessionManagement value="1"/>
|
||||
<EncryptedProtocolType value="EncryptedProtocolType::RSSL_WEBSOCKET"/>
|
||||
<WsMaxMsgSize value="61440"/>
|
||||
<WsProtocols value="tr_json2"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_6"/>
|
||||
<ChannelType value="ChannelType::RSSL_WEBSOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="15000"/>
|
||||
<WsMaxMsgSize value="61440"/>
|
||||
<WsProtocols value="rssl.json.v2, rssl.rwf, tr_json2"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_7"/>
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14003"/>
|
||||
<!-- ObjectName is optional: defaulted to "" -->
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_8"/>
|
||||
<ChannelType value="ChannelType::RSSL_HTTP"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14003"/>
|
||||
<!-- ObjectName is optional: defaulted to "" -->
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_9"/>
|
||||
<ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14003"/>
|
||||
<!-- ObjectName is optional: defaulted to "" -->
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_RRTViewer_SE"/>
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_RRTViewer_DE"/>
|
||||
<ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- EMA discovers a host and a port from RDP service discovery for the specified location
|
||||
when both of them are not set and the session management is enable. -->
|
||||
<Location value="us-east-1"/>
|
||||
<EnableSessionManagement value="1"/>
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
|
||||
<!--Performance tools channels -->
|
||||
<Channel>
|
||||
<Name value="Perf_Channel_1"/>
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<NumInputBuffers value="2048"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Perf_Channel_WSJSON_1"/>
|
||||
<ChannelType value="ChannelType::RSSL_WEBSOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="50000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="0"/>
|
||||
<DirectWrite value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
<WsMaxMsgSize value="18432"/>
|
||||
<WsProtocols value="rssl.json.v2"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Perf_Channel_WSRWF_1"/>
|
||||
<ChannelType value="ChannelType::RSSL_WEBSOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="0"/>
|
||||
<DirectWrite value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
<WsProtocols value="rssl.rwf"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Perf_NIP_Channel_1"/>
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<GuaranteedOutputBuffers value="100000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="0"/>
|
||||
<DirectWrite value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14003"/>
|
||||
<InterfaceName value=""/>
|
||||
<HighWaterMark value="6144"/>
|
||||
<NumInputBuffers value="10000"/>
|
||||
<SysRecvBufSize value="65535"/>
|
||||
<SysSendBufSize value="65535"/>
|
||||
</Channel>
|
||||
</ChannelList>
|
||||
</ChannelGroup>
|
||||
|
||||
<ServerGroup>
|
||||
<ServerList>
|
||||
<Server>
|
||||
<Name value="Server_1"/>
|
||||
<ServerType value="ServerType::RSSL_SOCKET"/>
|
||||
<!-- CompressionType is optional: defaulted to None -->
|
||||
<!-- possible values: None, ZLib, LZ4 -->
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- ConnectionPingTimeout is optional: defaulted to 30000 -->
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<!-- TcpNodelay is optional: defaulted to 1 -->
|
||||
<!-- possible values: 1 (tcp_nodelay option set), 0 (tcp_nodelay not set) -->
|
||||
<TcpNodelay value="1"/>
|
||||
<Port value="14002"/>
|
||||
</Server>
|
||||
<Server>
|
||||
<Name value="Server_2"/>
|
||||
<!-- For WS connection server could use also RSSL_SOCKET type -->
|
||||
<ServerType value="ServerType::RSSL_WEBSOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="1"/>
|
||||
<Port value="15000"/>
|
||||
<!-- There are optional and used for applying WS connection -->
|
||||
<MaxFragmentSize value="6144"/>
|
||||
<WsProtocols value="rssl.json.v2, rssl.rwf, tr_json2"/>
|
||||
</Server>
|
||||
<Server>
|
||||
<Name value="EncryptedServer"/>
|
||||
<ServerType value="ServerType::RSSL_ENCRYPTED"/>
|
||||
<!-- CompressionType is optional: defaulted to None -->
|
||||
<!-- possible values: None, ZLib, LZ4 -->
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- ConnectionPingTimeout is optional: defaulted to 30000 -->
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<!-- TcpNodelay is optional: defaulted to 1 -->
|
||||
<!-- possible values: 1 (tcp_nodelay option set), 0 (tcp_nodelay not set) -->
|
||||
<TcpNodelay value="1"/>
|
||||
<Port value="14002"/>
|
||||
</Server>
|
||||
<!--Performance tools server -->
|
||||
<Server>
|
||||
<Name value="Perf_Server_1"/>
|
||||
<ServerType value="ServerType::RSSL_SOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="0"/>
|
||||
<Port value="14002"/>
|
||||
<HighWaterMark value="0"/>
|
||||
<InterfaceName value=""/>
|
||||
<DirectWrite value="1" />
|
||||
<MaxFragmentSize value="6144"/>
|
||||
<NumInputBuffers value="10000"/>
|
||||
<SysRecvBufSize value="65535"/>
|
||||
<SysSendBufSize value="65535"/>
|
||||
</Server>
|
||||
</ServerList>
|
||||
</ServerGroup>
|
||||
|
||||
<WarmStandbyServerInfoGroup>
|
||||
<WarmStandbyServerInfoList>
|
||||
<WarmStandbyServerInfo>
|
||||
<Name value="Server_Info_1"/>
|
||||
<Channel value="Channel_1"/>
|
||||
<PerServiceNameSet value=""/>
|
||||
</WarmStandbyServerInfo>
|
||||
<WarmStandbyServerInfo>
|
||||
<Name value="Server_Info_2"/>
|
||||
<Channel value="Channel_7"/>
|
||||
<PerServiceNameSet value=""/>
|
||||
</WarmStandbyServerInfo>
|
||||
</WarmStandbyServerInfoList>
|
||||
</WarmStandbyServerInfoGroup>
|
||||
|
||||
<WarmStandbyGroup>
|
||||
<WarmStandbyList>
|
||||
<WarmStandbyChannel>
|
||||
<Name value="WarmStandbyChannel_1"/>
|
||||
<StartingActiveServer value="Server_Info_1"/>
|
||||
<StandbyServerSet value="Server_Info_2"/>
|
||||
<WarmStandbyMode value="WarmStandbyMode::LOGIN_BASED"/>
|
||||
</WarmStandbyChannel>
|
||||
</WarmStandbyList>
|
||||
</WarmStandbyGroup>
|
||||
|
||||
<!-- source directory refresh configuration used by provider -->
|
||||
<DirectoryGroup>
|
||||
<!-- DefaultDirectory specifies Directory used as default if providers do not specify Directory name -->
|
||||
<DefaultDirectory value="Directory_1"/>
|
||||
<DirectoryList>
|
||||
<!-- providers refer to the Directory by name -->
|
||||
<!-- Directory is a set of Services (one or more) on which a provider will provide item data -->
|
||||
<Directory>
|
||||
<Name value="Directory_1"/>
|
||||
<Service>
|
||||
<Name value="TEST_NI_PUB"/>
|
||||
<InfoFilter>
|
||||
<!-- optional value; if not specified EMA will assign it -->
|
||||
<ServiceId value="11"/>
|
||||
<!-- optional value -->
|
||||
<Vendor value="company name"/>
|
||||
<!-- possible values: 0 - means consolidation service, 1 - means original provider -->
|
||||
<IsSource value="0"/>
|
||||
<!-- an array of market domains supported by this service -->
|
||||
<!-- domains defined in the RDM Usage Guide may be refered by name -->
|
||||
<!-- names of the RDM defined domains are listed in the EmaRdm.h file -->
|
||||
<!-- e.g. MMT_MARKET_PRICE, MMT_MARKET_BY_ORDER -->
|
||||
<!-- note that the capabilities may be specified with names and or numbers -->
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="MMT_MARKET_PRICE"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
</Capabilities>
|
||||
<!-- list of dictionary names specified in the DictionaryGroup -->
|
||||
<!-- EMA will populate the Service::InfoFilter::DictionariesProvided element -->
|
||||
<!-- with the respective <>ItemName values -->
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
|
||||
<!-- list of dictionary names specified in the DictionaryGroup -->
|
||||
<!-- EMA will populate the Service::InfoFilter::DictionariesUsed element -->
|
||||
<!-- with the respective <>ItemName values -->
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<!-- list of QoS values supported by this service -->
|
||||
<!-- possible values are listed in the OmmQos.h file of the EMA -->
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::InexactDelayed"/>
|
||||
<Rate value="Rate::JustInTimeConflated"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<!-- 0 means does not support, 1 - means supports QoS range -->
|
||||
<SupportsQoSRange value="0"/>
|
||||
<!-- name of item list -->
|
||||
<ItemList value="#.itemlist"/>
|
||||
<!-- 0 means does not accept, 1 - means accepts consumer status -->
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<!-- 0 means does not support, 1 - means supports out of band snapshots -->
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<!-- StateFilter is optional -->
|
||||
<!-- EMA will default the values as follows: -->
|
||||
<!-- for interactive provider -->
|
||||
<!-- - ServiceState is "up" and AcceptingRequests is "Yes" -->
|
||||
<!-- for non interactive provider -->
|
||||
<!-- - ServiceState is "up" and AcceptingRequests is "No" -->
|
||||
<StateFilter>
|
||||
<!-- 0 means service is down, 1 - means service is up (default; 1) -->
|
||||
<ServiceState value="1"/>
|
||||
<!-- 0 means service does not accept, 1 - means service accepts (default; 1) -->
|
||||
<AcceptingRequests value="1"/>
|
||||
<!-- optional; specifies status change to apply to all items provided by this service -->
|
||||
<!-- possible values are listed in the OmmState.h file of the EMA -->
|
||||
<Status>
|
||||
<!-- possible values are: Open, Close, CloseRecover -->
|
||||
<StreamState value="StreamState::Open"/>
|
||||
<!-- possibe values are: NoChange, Ok, Suspect -->
|
||||
<DataState value="DataState::Ok"/>
|
||||
<!-- possible values are: None, DacsDown, etc -->
|
||||
<StatusCode value="StatusCode::None"/>
|
||||
<!-- a text field -->
|
||||
<StatusText value=""/>
|
||||
</Status>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
<Service>
|
||||
<Name value="NI_PUB"/>
|
||||
<InfoFilter>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<Vendor value="company name"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="6"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
</Capabilities>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
<Status>
|
||||
<StreamState value="StreamState::Open"/>
|
||||
<DataState value="DataState::Ok"/>
|
||||
<StatusCode value="StatusCode::None"/>
|
||||
<StatusText value=""/>
|
||||
</Status>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
</Directory>
|
||||
<Directory>
|
||||
<Name value="Directory_2"/>
|
||||
<Service>
|
||||
<Name value="DIRECT_FEED"/>
|
||||
<InfoFilter>
|
||||
<ServiceId value="1"/>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<Vendor value="company name"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="6"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_PRICE"/>
|
||||
<CapabilitiesEntry value="MMT_DICTIONARY"/>
|
||||
<CapabilitiesEntry value="200"/>
|
||||
</Capabilities>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
<QoSEntry>
|
||||
<Timeliness value="100"/>
|
||||
<Rate value="100"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
</Directory>
|
||||
<Directory>
|
||||
<Name value="Directory_3"/>
|
||||
<Service>
|
||||
<Name value="TEST_NI_PUB"/>
|
||||
<InfoFilter>
|
||||
<ServiceId value="11"/>
|
||||
<Vendor value="company name"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="MMT_MARKET_PRICE"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
</Capabilities>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::InexactDelayed"/>
|
||||
<Rate value="Rate::JustInTimeConflated"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
<Status>
|
||||
<StreamState value="StreamState::Open"/>
|
||||
<DataState value="DataState::Ok"/>
|
||||
<StatusCode value="StatusCode::None"/>
|
||||
<StatusText value=""/>
|
||||
</Status>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
<Service>
|
||||
<Name value="NI_PUB"/>
|
||||
<InfoFilter>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
|
||||
<Vendor value="company name"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="6"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
</Capabilities>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
<Status>
|
||||
<StreamState value="StreamState::Open"/>
|
||||
<DataState value="DataState::Ok"/>
|
||||
<StatusCode value="StatusCode::None"/>
|
||||
<StatusText value=""/>
|
||||
</Status>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
</Directory>
|
||||
|
||||
<Directory>
|
||||
<Name value="Directory_4"/>
|
||||
<Service>
|
||||
<Name value="DIRECT_FEED"/>
|
||||
<InfoFilter>
|
||||
<ServiceId value="1"/>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<Vendor value="company name"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="6"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_PRICE"/>
|
||||
<CapabilitiesEntry value="MMT_DICTIONARY"/>
|
||||
<CapabilitiesEntry value="200"/>
|
||||
</Capabilities>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
<QoSEntry>
|
||||
<Timeliness value="100"/>
|
||||
<Rate value="100"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
</Directory>
|
||||
<Directory>
|
||||
<Name value="Perf_Directory_1"/>
|
||||
<Service>
|
||||
<Name value="NI_PUB"/>
|
||||
<InfoFilter>
|
||||
<ServiceId value="1"/>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<Vendor value="RefinitivDevTestLab"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="MMT_DICTIONARY"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_PRICE"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_PRICE"/>
|
||||
<CapabilitiesEntry value="200"/>
|
||||
</Capabilities>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
<QoSEntry>
|
||||
<Timeliness value="100"/>
|
||||
<Rate value="100"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
</Directory>
|
||||
</DirectoryList>
|
||||
</DirectoryGroup>
|
||||
<DictionaryGroup>
|
||||
<DictionaryList>
|
||||
<Dictionary>
|
||||
<Name value="Dictionary_1"/>
|
||||
<!-- dictionaryType is optional: defaulted to ChannelDictionary" -->
|
||||
<!-- possible values: ChannelDictionary, FileDictionary -->
|
||||
<!-- if dictionaryType is set to ChannelDictionary, file names are ignored -->
|
||||
<DictionaryType value="DictionaryType::ChannelDictionary"/>
|
||||
</Dictionary>
|
||||
<Dictionary>
|
||||
<Name value="Dictionary_2"/>
|
||||
<DictionaryType value="DictionaryType::FileDictionary"/>
|
||||
<!-- dictionary names are optional: defaulted to RDMFieldDictionary and enumtype.def -->
|
||||
<RdmFieldDictionaryFileName value="./RDMFieldDictionary"/>
|
||||
<EnumTypeDefFileName value="./enumtype.def"/>
|
||||
</Dictionary>
|
||||
<Dictionary>
|
||||
<Name value="Dictionary_3"/>
|
||||
<!-- providers always assume DictionaryType = DictionaryType::FileDictionary -->
|
||||
<DictionaryType value="DictionaryType::FileDictionary"/>
|
||||
<!-- dictionary file names are optional: defaulted to ./RDMFieldDictionary and ./enumtype.def -->
|
||||
<RdmFieldDictionaryFileName value="./RDMFieldDictionary"/>
|
||||
<EnumTypeDefFileName value="./enumtype.def"/>
|
||||
<!-- <dictionary>ItemName represents the names shown in DictionariesProvided and DictionariesUsed
|
||||
elements of the Directory InfoFilter -->
|
||||
<!-- <dictionary>ItemName is optional; default values are "RWFFld" for the RdmFieldDictionary
|
||||
and "RWFEnum" for the enumtype.def -->
|
||||
<RdmFieldDictionaryItemName value="RWFFld"/>
|
||||
<EnumTypeDefItemName value="RWFEnum"/>
|
||||
</Dictionary>
|
||||
</DictionaryList>
|
||||
</DictionaryGroup>
|
||||
</EmaConfig>
|
||||
25
src/main/java/cn/stock/market/listener/MongoConfig.java
Normal file
25
src/main/java/cn/stock/market/listener/MongoConfig.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package cn.stock.market.listener;
|
||||
|
||||
import com.mongodb.client.MongoClients;
|
||||
import com.mongodb.client.MongoClient;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
|
||||
@Configuration
|
||||
public class MongoConfig {
|
||||
|
||||
@Bean
|
||||
public MongoClient mongoClient() {
|
||||
// 连接到MongoDB服务器(示例中使用默认的MongoDB端口)
|
||||
// 请根据你的实际情况修改这里的连接字符串
|
||||
return MongoClients.create("mongodb://root:123456@localhost:27017");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MongoTemplate mongoTemplate() {
|
||||
// 创建并返回MongoTemplate的实例,需要提供MongoClient实例和数据库名
|
||||
// 替换"yourDatabase"为你的数据库名
|
||||
return new MongoTemplate(mongoClient(), "company");
|
||||
}
|
||||
}
|
||||
38
src/main/java/cn/stock/market/listener/MyAppRunner.java
Normal file
38
src/main/java/cn/stock/market/listener/MyAppRunner.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
package cn.stock.market.listener;
|
||||
|
||||
import com.thomsonreuters.ema.access.EmaFactory;
|
||||
import com.thomsonreuters.ema.access.OmmConsumer;
|
||||
import com.thomsonreuters.ema.access.OmmConsumerConfig;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MyAppRunner implements ApplicationRunner {
|
||||
static String userName = "GE-A-10288435-3-15856";
|
||||
static String password = "8EyCWDQ%XITcGRM@RhKokxX05FZJe1";
|
||||
static String clientId = "662b37b071144c9f8f2507d93037a019a010ae0e";
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
// 在这里写入您的初始化代码
|
||||
System.out.println("应用已启动,执行初始化代码...");
|
||||
|
||||
// The "Consumer_4" uses EncryptedProtocolType::RSSL_SOCKET while the "Consumer_5" uses EncryptedProtocolType::RSSL_WEBSOCKET predefined in EmaConfig.xml
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OmmConsumer getOmmConsumer() {
|
||||
OmmConsumer consumer = null;
|
||||
OmmConsumerConfig config = EmaFactory.createOmmConsumerConfig();
|
||||
config.username(userName);
|
||||
config.password(password);
|
||||
config.clientId(clientId);
|
||||
consumer = EmaFactory.createOmmConsumer(config.consumerName( "Consumer_4"));
|
||||
return consumer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.stock.market.listener;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
/**
|
||||
* @author gs
|
||||
* @date 2024/4/8 21:00
|
||||
*/
|
||||
@Document("stock_info")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class StockInfoRefinitiv {
|
||||
private String stockName;
|
||||
private String stockCode;
|
||||
private String stockType;
|
||||
private String status;
|
||||
private String commandStr;
|
||||
}
|
||||
19
src/main/java/cn/stock/market/listener/SymbolRefinitiv.java
Normal file
19
src/main/java/cn/stock/market/listener/SymbolRefinitiv.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package cn.stock.market.listener;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
/**
|
||||
* @author gs
|
||||
* @date 2024/4/8 17:20
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Document("symbol")
|
||||
public class SymbolRefinitiv {
|
||||
private String symbol;
|
||||
private String stockType;
|
||||
private String commandStr;
|
||||
}
|
||||
@@ -5,8 +5,6 @@ import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
@@ -187,26 +185,32 @@ public class DateTimeUtil {
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
|
||||
public static String formatDateTimeFor24H(String inputDateTime,String inputFormatStr){
|
||||
String outputDateTime = "";
|
||||
// 1. 解析日期时间
|
||||
SimpleDateFormat inputFormat = new SimpleDateFormat(inputFormatStr, Locale.ENGLISH);
|
||||
Date date = null;
|
||||
try {
|
||||
date = inputFormat.parse(inputDateTime);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (date != null) {
|
||||
// 2. 转换为24小时制
|
||||
SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
outputDateTime = outputFormat.format(date);
|
||||
}
|
||||
return outputDateTime;
|
||||
/**
|
||||
* 获取某个时间的凌晨时间
|
||||
* @param time
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
public static Date getDayOfMorning(Date time,Integer date){
|
||||
Calendar lastDate = Calendar.getInstance();
|
||||
lastDate.setTime(time);
|
||||
lastDate.add(Calendar.DATE,date);
|
||||
lastDate.set(Calendar.HOUR_OF_DAY,0);
|
||||
lastDate.set(Calendar.MINUTE,0);
|
||||
lastDate.set(Calendar.SECOND,0);
|
||||
lastDate.set(Calendar.MILLISECOND,0);
|
||||
return lastDate.getTime();
|
||||
}
|
||||
|
||||
//获取某个时间的前/后时间,以年为单位
|
||||
public static Date getDayOfYear(Date time,Integer date){
|
||||
Calendar lastDate = Calendar.getInstance();
|
||||
lastDate.setTime(time);
|
||||
lastDate.add(Calendar.YEAR,date);
|
||||
return lastDate.getTime();
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
parseToDateByMinute(10);
|
||||
}
|
||||
|
||||
@@ -212,59 +212,6 @@ public class HttpClientRequest {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String doEttechchartsGet(String url) {
|
||||
CloseableHttpClient httpClient = null;
|
||||
CloseableHttpResponse response = null;
|
||||
String result = "";
|
||||
|
||||
try {
|
||||
httpClient = HttpClients.createDefault();
|
||||
|
||||
HttpGet httpGet = new HttpGet(url);
|
||||
|
||||
// httpGet.setHeader(":authority","ettechcharts.indiatimes.com");
|
||||
// httpGet.setHeader(":method","GET");
|
||||
// httpGet.setHeader(":scheme","https");
|
||||
httpGet.setHeader("accept","*/*");
|
||||
httpGet.setHeader("accept-encoding","gzip, deflate, br");
|
||||
httpGet.setHeader("accept-language","zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6");
|
||||
httpGet.setHeader("user-agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36");
|
||||
httpGet.setHeader("Referer", "https://economictimes.indiatimes.com/");
|
||||
|
||||
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000).setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
|
||||
|
||||
httpGet.setConfig(requestConfig);
|
||||
|
||||
response = httpClient.execute(httpGet);
|
||||
|
||||
HttpEntity entity = response.getEntity();
|
||||
|
||||
result = EntityUtils.toString(entity);
|
||||
} catch (ClientProtocolException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
if (null != response) {
|
||||
try {
|
||||
response.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (null != httpClient) {
|
||||
try {
|
||||
httpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String url = "https://marketapi.intoday.in/widget/topgainer/view?exchange=nse";
|
||||
String str = doGet(url);
|
||||
|
||||
@@ -1,181 +0,0 @@
|
||||
package cn.stock.market.utils;
|
||||
|
||||
import cn.stock.market.dto.StockHistoryRequest;
|
||||
import cn.stock.market.dto.StockHistoryResponse;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import okhttp3.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class NseIndiaRequest {
|
||||
private static final String NSE_INDIA_URL = "https://www.nseindia.com";
|
||||
private static final String NSE_INDIA_CHART_URL = "https://charting.nseindia.com";
|
||||
private static final OkHttpClient client;
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
static {
|
||||
client = new OkHttpClient.Builder()
|
||||
.cookieJar(new CookieJar() {
|
||||
private final Map<String, List<Cookie>> cookieStore = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
|
||||
cookieStore.put(url.host(), cookies);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cookie> loadForRequest(HttpUrl url) {
|
||||
List<Cookie> cookies = cookieStore.get(url.host());
|
||||
return cookies != null ? cookies : new ArrayList<Cookie>();
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
private static Request createRequest(String url) {
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.header("accept", "application/json, text/plain, */*")
|
||||
.header("accept-language", "en-US,en;q=0.9")
|
||||
.header("cache-control", "no-cache")
|
||||
.header("pragma", "no-cache")
|
||||
.header("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36")
|
||||
.build();
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
private static void initCookie(String url) {
|
||||
Request request = createRequest(url);
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (!response.isSuccessful()) {
|
||||
throw new IOException("Failed to fetch initial cookies");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to initialize cookies", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer getCode(String symbol) {
|
||||
Request request = createRequest(NSE_INDIA_CHART_URL + "//Charts/GetEQMasters").newBuilder()
|
||||
.addHeader("referer", NSE_INDIA_CHART_URL)
|
||||
.addHeader("origin", NSE_INDIA_CHART_URL)
|
||||
.build();
|
||||
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (!response.isSuccessful()) {
|
||||
throw new IOException("Failed to get EQ code");
|
||||
}
|
||||
|
||||
String result = response.body().string();
|
||||
|
||||
String regex = "(\\d+)\\|" + symbol + "\\|.*";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(result);
|
||||
|
||||
if (matcher.find()) {
|
||||
return Integer.valueOf(matcher.group(1));
|
||||
}
|
||||
throw new IOException("No data found");
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to get EQ code", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static JSONObject stockByJYSFromHttp(String stockType, String symbol, String nseIndiaId) {
|
||||
initCookie(NSE_INDIA_URL);
|
||||
|
||||
String url = NSE_INDIA_URL + "/api/quote-equity?symbol=" + nseIndiaId;
|
||||
Request request = createRequest(url).newBuilder()
|
||||
.addHeader("referer", NSE_INDIA_URL)
|
||||
.addHeader("origin", NSE_INDIA_URL)
|
||||
.build();
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (!response.isSuccessful()) {
|
||||
throw new IOException("Request failed with code: " + response.code());
|
||||
}
|
||||
|
||||
JSONObject jsonData = JSONObject.parseObject(response.body().string());
|
||||
JSONObject data =jsonData.getJSONObject("priceInfo");
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
json.put("pricepercentchange",data.getString("pChange"));
|
||||
json.put("stockType",stockType);
|
||||
json.put("pricechange",data.getString("change"));
|
||||
json.put("pricecurrent",data.getString("lastPrice"));
|
||||
json.put("priceprevclose",data.getString("previousClose"));
|
||||
json.put("PREVDATE","");
|
||||
json.put("VOL",jsonData.getJSONObject("preOpenMarket").getString("totalTradedVolume"));
|
||||
json.put("dataSourceType","3");
|
||||
json.put("symbol",symbol);
|
||||
json.put("BSEID",symbol);
|
||||
json.put("NSEID",symbol);
|
||||
json.put("LTH",data.getString("upperCP"));
|
||||
json.put("LTL",data.getString("lowerCP"));
|
||||
json.put("OPN",data.getString("open"));
|
||||
|
||||
return json;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to fetch data", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static StockHistoryResponse stockKLineFromHttp(StockHistoryRequest stockHistoryRequest, String resolution) {
|
||||
initCookie(NSE_INDIA_CHART_URL);
|
||||
|
||||
Integer code = getCode(stockHistoryRequest.getSymbol());
|
||||
|
||||
int interval = 1;
|
||||
if (StringUtils.equals("H", resolution)) {
|
||||
resolution = "I";
|
||||
interval = 60;
|
||||
}
|
||||
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("chartPeriod", resolution);
|
||||
body.put("chartStart", 0);
|
||||
body.put("exch", "N");
|
||||
body.put("fromDate", 0);
|
||||
body.put("instrType", "C");
|
||||
body.put("scripCode", code);
|
||||
body.put("timeInterval", interval);
|
||||
body.put("toDate", stockHistoryRequest.getTo() + 18000);
|
||||
body.put("ulToken", code);
|
||||
|
||||
String payload;
|
||||
try {
|
||||
payload = objectMapper.writeValueAsString(body);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to serialize body", e);
|
||||
}
|
||||
|
||||
RequestBody requestBody = RequestBody.create(
|
||||
MediaType.get("application/json; charset=utf-8"),
|
||||
payload
|
||||
);
|
||||
|
||||
Request request = createRequest(NSE_INDIA_CHART_URL + "//Charts/symbolhistoricaldata/").newBuilder()
|
||||
.addHeader("referer", NSE_INDIA_CHART_URL)
|
||||
.addHeader("origin", NSE_INDIA_CHART_URL)
|
||||
.post(requestBody)
|
||||
.build();
|
||||
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (!response.isSuccessful()) {
|
||||
throw new IOException("Request failed with code: " + response.code());
|
||||
}
|
||||
|
||||
StockHistoryResponse result = objectMapper.readValue(response.body().string(), StockHistoryResponse.class);
|
||||
|
||||
return result;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to fetch data", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
317
src/main/java/cn/stock/market/utils/RefinitivUtil.java
Normal file
317
src/main/java/cn/stock/market/utils/RefinitivUtil.java
Normal file
@@ -0,0 +1,317 @@
|
||||
package cn.stock.market.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stock.market.constant.MonthEnum;
|
||||
import cn.stock.market.domain.basic.entity.RetifiveStock;
|
||||
import cn.stock.market.dto.RetifiveStockInfo;
|
||||
import cn.stock.market.lesg.InChangeEntity;
|
||||
import cn.stock.market.lesg.InstrumentData;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* RefinitivUtil
|
||||
* Refinitiv数据解析工具
|
||||
*
|
||||
* @author jnerh
|
||||
* @since 2024/04/11 10:20
|
||||
*/
|
||||
@Slf4j
|
||||
public class RefinitivUtil {
|
||||
|
||||
public static final String BLANK_DATA = "(blank data)";
|
||||
public static final List<String> STOCK_CODE_FIELDS = Lists.newArrayList("EXCHCODE", "PROV_SYMB", "MNEMONIC", "SRC_SYMB");
|
||||
|
||||
public static final String BSE_SYMBOL_SUFFIX = ".BO";
|
||||
|
||||
private static RetifiveStockInfo handleData(RetifiveStockInfo retifiveStockInfo) {
|
||||
Field[] fields = retifiveStockInfo.getClass().getDeclaredFields();
|
||||
Arrays.stream(fields).forEach(field -> {
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
try {
|
||||
Object obj = field.get(retifiveStockInfo);
|
||||
if (obj instanceof String) {
|
||||
String objStr = (String) obj;
|
||||
field.set(retifiveStockInfo, objStr.replace(BLANK_DATA, ""));
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
log.error("Refinitiv数据源处理数据出错,", e);
|
||||
}
|
||||
});
|
||||
|
||||
// 未开盘时,将当前价设为昨日收盘价
|
||||
try {
|
||||
Field statusField = retifiveStockInfo.getClass().getDeclaredField("status");
|
||||
ReflectionUtils.makeAccessible(statusField);
|
||||
Object obj = statusField.get(retifiveStockInfo);
|
||||
if (obj instanceof String) {
|
||||
String objStr = (String) obj;
|
||||
if (StringUtils.equals(objStr, "1")) {
|
||||
Field lastPriceField = retifiveStockInfo.getClass().getDeclaredField("lastPrice");
|
||||
Field previousPriceField = retifiveStockInfo.getClass().getDeclaredField("previousPrice");
|
||||
ReflectionUtils.makeAccessible(previousPriceField);
|
||||
ReflectionUtils.makeAccessible(lastPriceField);
|
||||
lastPriceField.set(retifiveStockInfo, previousPriceField.get(retifiveStockInfo));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Refinitiv数据源获取status出错,", e);
|
||||
}
|
||||
return retifiveStockInfo;
|
||||
}
|
||||
|
||||
|
||||
public static RetifiveStockInfo decode(InstrumentData data) {
|
||||
Map<String, String> dataMap = data.getDataMap();
|
||||
RetifiveStockInfo stockInfo = RetifiveStockInfo.builder().symbol(data.getRic()).build();
|
||||
dataMap.forEach((k, v) -> {
|
||||
if (k.equals("DSPLY_NAME")) {
|
||||
stockInfo.setStockName(v);
|
||||
}
|
||||
if (StrUtil.isBlank(stockInfo.getStockCode()) && StrUtil.isNotBlank(parseStockCode(k, v))) {
|
||||
stockInfo.setStockCode(v);
|
||||
}
|
||||
if (k.equals("INST_PHASE")) {
|
||||
stockInfo.setStatus(v);
|
||||
}
|
||||
if (k.equals("OPEN_PRC")) {
|
||||
stockInfo.setOpenPrice(v);
|
||||
}
|
||||
if (k.equals("HST_CLOSE")) {
|
||||
stockInfo.setPreviousPrice(v);
|
||||
}
|
||||
if (k.equals("52WK_HIGH")) {
|
||||
stockInfo.setWeek52HighPrice(v);
|
||||
}
|
||||
if (k.equals("52WK_LOW")) {
|
||||
stockInfo.setWeek52LowPrice(v);
|
||||
}
|
||||
if (k.equals("PCTCHNG")) {
|
||||
stockInfo.setPerchg(v);
|
||||
}
|
||||
if (k.equals("NETCHNG_1")) {
|
||||
stockInfo.setChange(v);
|
||||
}
|
||||
if (k.equals("HIGH_1")) {
|
||||
stockInfo.setHighPrice(v);
|
||||
}
|
||||
if (k.equals("LOW_1")) {
|
||||
stockInfo.setLowPrice(v);
|
||||
}
|
||||
if (k.equals("IRGVOL")) {
|
||||
stockInfo.setVolume(v);
|
||||
}
|
||||
if (k.equals("TRDPRC_1")) {
|
||||
stockInfo.setLastPrice(v);
|
||||
}
|
||||
if (k.equals("RDN_EXCHID")) {
|
||||
String stockType = v;
|
||||
if (StrUtil.equals(stockType, "145")) {
|
||||
//孟买国家交易所
|
||||
stockType = "bse";
|
||||
} else if (StrUtil.equals(stockType, "147")) {
|
||||
//印度国家交易所
|
||||
stockType = "nse";
|
||||
}
|
||||
stockInfo.setStockType(stockType);
|
||||
}
|
||||
});
|
||||
|
||||
return handleData(stockInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析股票代码
|
||||
*
|
||||
* @param k 字段名
|
||||
* @param v 字段值
|
||||
* @return 股票代码
|
||||
*/
|
||||
private static String parseStockCode(String k, String v) {
|
||||
if (isValidStockCode(k, v)) {
|
||||
return v;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为股票代码
|
||||
*
|
||||
* @param k 字段名
|
||||
* @param v 字段值
|
||||
* @return 是否为股票代码
|
||||
*/
|
||||
public static boolean isValidStockCode(String k, String v) {
|
||||
return STOCK_CODE_FIELDS.contains(k) && !StrUtil.contains(v, "blank data");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解析为RetifiveStock
|
||||
*
|
||||
* @param data 查出的数据
|
||||
* @return 结果
|
||||
*/
|
||||
public static RetifiveStock decodeRefinitivStock(InstrumentData data) {
|
||||
Map<String, String> dataMap = data.getDataMap();
|
||||
RetifiveStock stock= RetifiveStock.builder().symbol(data.getRic()).saveTime(new Date()).build();
|
||||
dataMap.forEach((k, v) -> {
|
||||
if (k.equals("DSPLY_NAME")) {
|
||||
stock.setStockName(v);
|
||||
}
|
||||
if (StrUtil.isBlank(stock.getStockCode()) && StrUtil.isNotBlank(parseStockCode(k, v))) {
|
||||
stock.setStockCode(v);
|
||||
}
|
||||
if (k.equals("RDN_EXCHID")) {
|
||||
String stockType = v;
|
||||
if (StrUtil.equals(stockType, "145")) {
|
||||
//孟买国家交易所
|
||||
stockType = "bse";
|
||||
} else if (StrUtil.equals(stockType, "147")) {
|
||||
//印度国家交易所
|
||||
stockType = "nse";
|
||||
}
|
||||
stock.setStockType(stockType);
|
||||
}
|
||||
});
|
||||
|
||||
return stock;
|
||||
}
|
||||
|
||||
public static List<String> decodeTopData(InstrumentData instrumentData) {
|
||||
List<String> list = new ArrayList<>(100);
|
||||
instrumentData.getDataMap().forEach((k, v) -> {
|
||||
if (k.startsWith("BR_LINK")) {
|
||||
if (!v.contains("blank data")) {
|
||||
list.add(k);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
List<String> stringList = list.stream().sorted(topComparator()).collect(Collectors.toList());
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String key : stringList) {
|
||||
result.add(instrumentData.getDataMap().get(key));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static List<InChangeEntity> decodeInChangeData(InstrumentData instrumentData) {
|
||||
List<String> list = new ArrayList<>(100);
|
||||
instrumentData.getDataMap().forEach((k, v) -> {
|
||||
if (StrUtil.contains(k, "ROW80_") && !StrUtil.containsAny(v, "IN/CHANGE")) {
|
||||
list.add(k);
|
||||
}
|
||||
});
|
||||
|
||||
List<String> inChangeSymbolList = list.stream().sorted(inChangeComparator()).collect(Collectors.toList());
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String key : inChangeSymbolList) {
|
||||
result.add(instrumentData.getDataMap().get(key));
|
||||
}
|
||||
|
||||
String flagStr = result.remove(0);
|
||||
int dateBeginIdx = 0;
|
||||
int dateEndIdx = flagStr.indexOf("DESCRIPTION") - 1;
|
||||
int descriptionBeginIdx = flagStr.indexOf("DESCRIPTION");
|
||||
int descriptionEndIdx = flagStr.indexOf("TYP") - 1;
|
||||
int typBeginIdx = flagStr.indexOf("TYP");
|
||||
int typEndIdx = flagStr.indexOf("RIC") - 1;
|
||||
int ricBeginIdx = flagStr.indexOf("RIC");
|
||||
int ricEndIdx = flagStr.indexOf("ISIN") - 1;
|
||||
int isinBeginIdx = flagStr.indexOf("ISIN");
|
||||
int isinEndIdx = flagStr.indexOf("CODE") - 1;
|
||||
int codeBeginIdx = flagStr.indexOf("CODE");
|
||||
int codeEndIdx = flagStr.indexOf("CLS") - 1;
|
||||
int clsBeginIdx = flagStr.indexOf("CLS");
|
||||
List<InChangeEntity> inChangeEntityList = new ArrayList<>();
|
||||
for (String data : result) {
|
||||
String date = data.substring(dateBeginIdx, dateEndIdx).trim();
|
||||
String description = data.substring(descriptionBeginIdx, descriptionEndIdx).trim();
|
||||
String typ = data.substring(typBeginIdx, typEndIdx).trim();
|
||||
String ric = parseInChangeRic(data.substring(ricBeginIdx, ricEndIdx).trim());
|
||||
if (!ric.endsWith(BSE_SYMBOL_SUFFIX)) {
|
||||
// 暂无相关权限处理非孟买国家交易所的股票
|
||||
continue;
|
||||
}
|
||||
|
||||
String isin = data.substring(isinBeginIdx, isinEndIdx).trim();
|
||||
String codeTicker = data.substring(codeBeginIdx, codeEndIdx).trim();
|
||||
String cls = data.substring(clsBeginIdx).trim();
|
||||
InChangeEntity inChangeEntity = InChangeEntity.builder()
|
||||
.date(parseInChangeDate(date))
|
||||
.description(description)
|
||||
.typ(typ)
|
||||
.ric(ric)
|
||||
.isin(isin)
|
||||
.codeTicker(codeTicker)
|
||||
.cls(cls)
|
||||
.build();
|
||||
inChangeEntityList.add(inChangeEntity);
|
||||
}
|
||||
|
||||
return inChangeEntityList;
|
||||
}
|
||||
|
||||
private static String parseInChangeDate(String date) {
|
||||
String day = date.substring(0, 2);
|
||||
String month = date.substring(2, 5);
|
||||
String year = date.substring(5);
|
||||
return String.format("20%s-%s-%s", year, Objects.requireNonNull(MonthEnum.of(month)).remark(), day);
|
||||
}
|
||||
|
||||
private static String parseInChangeRic(String ric) {
|
||||
return StrUtil.replace(ric, "<", "")
|
||||
.replace(">", "");
|
||||
}
|
||||
|
||||
private static Comparator<String> topComparator() {
|
||||
String flag = "BR_LINK";
|
||||
return (s1, s2) -> {
|
||||
String seqStr1 = s1.substring(flag.indexOf(s1) + flag.length() + 1);
|
||||
String seqStr2 = s2.substring(flag.indexOf(s2) + flag.length() + 1);
|
||||
int seq1 = Integer.parseInt(seqStr1);
|
||||
int seq2 = Integer.parseInt(seqStr2);
|
||||
return seq1 - seq2;
|
||||
};
|
||||
}
|
||||
|
||||
private static Comparator<String> inChangeComparator() {
|
||||
String flag = "ROW80_";
|
||||
return (s1, s2) -> {
|
||||
String seqStr1 = s1.substring(flag.indexOf(s1) + flag.length() + 1);
|
||||
String seqStr2 = s2.substring(flag.indexOf(s2) + flag.length() + 1);
|
||||
int seq1 = Integer.parseInt(seqStr1);
|
||||
int seq2 = Integer.parseInt(seqStr2);
|
||||
return seq1 - seq2;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static String decode(Map<String, String> dataMap, List<String> symbols) {
|
||||
String nextLink = null;
|
||||
if (dataMap.get("NEXT_LR") == null) {
|
||||
return nextLink;
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> entry : dataMap.entrySet()) {
|
||||
if (entry.getKey().startsWith("LINK_") && !entry.getValue().contains("blank data")) {
|
||||
symbols.add(entry.getValue());
|
||||
}
|
||||
|
||||
if (entry.getKey().startsWith("NEXT_LR")) {
|
||||
nextLink = entry.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return nextLink;
|
||||
}
|
||||
}
|
||||
@@ -65,50 +65,6 @@ public class RequestCacheUtils {
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据时间创建缓存
|
||||
* @param key key
|
||||
* @param duration 时间(毫秒)
|
||||
* @return
|
||||
*/
|
||||
public static Cache<String, ServerResponse<?>> cacheByMilliseconds(String key,long duration) {
|
||||
if(! map.containsKey(key)) {
|
||||
log.info("创建缓存: {}", key);
|
||||
Cache<String, ServerResponse<?>> cache = CacheBuilder.newBuilder()
|
||||
.maximumSize(1000)
|
||||
.expireAfterWrite(duration,TimeUnit.MILLISECONDS)
|
||||
.weakValues()
|
||||
.recordStats()
|
||||
.build(
|
||||
// new CacheLoader<String, Object>() {
|
||||
// @Override
|
||||
// public Object load(String key) throws Exception {
|
||||
// return func.apply(key);
|
||||
// }
|
||||
// }
|
||||
);
|
||||
map.put(key, cache);
|
||||
}
|
||||
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static <T> ServerResponse<T> cache(String module, String key,long duration, Function<String, ServerResponse<?>> func) {
|
||||
Cache<String, ServerResponse<?>> cache = cacheByMilliseconds(module,duration);
|
||||
AtomicBoolean bool = new AtomicBoolean(true);
|
||||
ServerResponse<T> response = (ServerResponse<T>) cache.get(key, () -> {
|
||||
bool.set(false);
|
||||
return func.apply(key);
|
||||
});
|
||||
|
||||
if(bool.get()) {
|
||||
log.info("命中缓存 module: {}, key: {}, 时间戳: {}", module, key, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
ServerResponse<Object> response = null;
|
||||
|
||||
@@ -20,7 +20,7 @@ import cn.stock.market.domain.basic.service.SiteArticleService;
|
||||
import cn.stock.market.utils.ServerResponse;
|
||||
|
||||
@Controller
|
||||
@RequestMapping({"/market/api/market/art/","/market/api/market/art/","/api/market/art/", "/api/hq/art/"})
|
||||
@RequestMapping({"/api/market/art/", "/api/hq/art/"})
|
||||
@Api(tags = "公告信息")
|
||||
public class ArticleApiController extends BaseController {
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -36,7 +35,7 @@ public class BTodayStockController {
|
||||
@Autowired
|
||||
private BtodayStockService btodayStockService;
|
||||
|
||||
@GetMapping({"/market/api/bToday/kLine","/api/bToday/kLine"})
|
||||
@GetMapping("/api/bToday/kLine")
|
||||
@ApiOperation(value = "股票详情K线图",httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="exchange",value = "BSE或者NSE"),
|
||||
@@ -141,7 +140,7 @@ public class BTodayStockController {
|
||||
"fromredis: 标志是否来自 Redis 缓存,false 表示不是", response = JSONObject.class),
|
||||
|
||||
})
|
||||
@GetMapping({"/market/api/bToday/stockDetail","/api/bToday/stockDetail"})
|
||||
@GetMapping("/api/bToday/stockDetail")
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
public com.alibaba.fastjson.JSONObject getPriceChartCompanyPullView(
|
||||
@RequestParam(value = "exchange") String exchange,
|
||||
@@ -160,19 +159,6 @@ public class BTodayStockController {
|
||||
|
||||
String forObject = restTemplate.getForObject(apiUrl, String.class);
|
||||
JSONObject jsonObject = JSON.parseObject(forObject);
|
||||
JSONArray arryData = jsonObject.getJSONArray("data");
|
||||
if (arryData != null&&arryData.size()>0) {
|
||||
try {
|
||||
JSONObject jsonObject1 = arryData.getJSONObject(0);
|
||||
String price = jsonObject1.getString("price");
|
||||
double priceValue = Double.parseDouble(price);
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
jsonObject1.put("price", df.format(priceValue));
|
||||
} catch (NumberFormatException e) {
|
||||
// Handle the case where price is not a valid double
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
jsonObject.put("id",btodayStock.getId());
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||
* @created Dec 4, 2018 10:22:44 PM
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping({"/market/api/hq/","/api/hq/"})
|
||||
@RequestMapping("/api/hq/")
|
||||
@ApiIgnore
|
||||
public class InfoController {
|
||||
@Value("${spring.application.name}")
|
||||
@@ -40,7 +40,6 @@ public class InfoController {
|
||||
public Map<String, Object> test(@RequestParam(required = false) String key) {
|
||||
Map<String, Object> map = Maps.newHashMap();
|
||||
map.put("stockMarketDbUrl", stockMarketDbUrl);
|
||||
map.put("stockMarketDbUrl1", stockMarketDbUrl);
|
||||
if(StringUtils.isNotBlank(key)) {
|
||||
map.put("key", PropertiesUtil.getProperty(key));
|
||||
}
|
||||
|
||||
720
src/main/java/cn/stock/market/web/MessageRetifiveController.java
Normal file
720
src/main/java/cn/stock/market/web/MessageRetifiveController.java
Normal file
@@ -0,0 +1,720 @@
|
||||
/*
|
||||
package cn.stock.market.web;
|
||||
|
||||
import cn.stock.market.domain.basic.entity.RetifiveStock;
|
||||
import cn.stock.market.domain.basic.service.RetifiveStockService;
|
||||
import cn.stock.market.dto.RetifiveStockInfo;
|
||||
import cn.stock.market.infrastructure.db.po.QRetifiveStockPO;
|
||||
import cn.stock.market.listener.AppClient;
|
||||
import cn.stock.market.listener.ConcurrentAppClient;
|
||||
import cn.stock.market.listener.StockInfoRefinitiv;
|
||||
import cn.stock.market.listener.SymbolRefinitiv;
|
||||
import cn.stock.market.utils.ServerResponse;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.querydsl.core.types.Predicate;
|
||||
import com.thomsonreuters.ema.access.DataType;
|
||||
import com.thomsonreuters.ema.access.FieldEntry;
|
||||
import com.thomsonreuters.ema.access.FieldList;
|
||||
import com.thomsonreuters.ema.access.RefreshMsg;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("/retifive/**")
|
||||
public class MessageRetifiveController {
|
||||
|
||||
@Autowired
|
||||
private AppClient appClient;
|
||||
|
||||
@Autowired
|
||||
private ConcurrentAppClient concurrentAppClient;
|
||||
|
||||
@Autowired
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Autowired
|
||||
private RetifiveStockService retifiveStockService;
|
||||
|
||||
@GetMapping("/message")
|
||||
public ServerResponse<?> getMessage(@RequestParam String itemName) {
|
||||
RefreshMsg refreshMsg = null;
|
||||
try {
|
||||
appClient.subscribe(itemName); // 根据itemName订阅
|
||||
// 等待消息
|
||||
refreshMsg = appClient.getMessageFuture().get(10, TimeUnit.SECONDS);// 设置超时时间,例如10秒
|
||||
return ServerResponse.createBySuccess("操作成功",refreshMsg.toString());
|
||||
} catch (Exception e) {
|
||||
return ServerResponse.createByError();
|
||||
} finally {
|
||||
// 可能需要重置或清理资源
|
||||
appClient.resetMessageFuture();
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/getStockSymbolList")
|
||||
public ServerResponse<?> getStockList() {
|
||||
RefreshMsg refreshMsg = null;
|
||||
List<String> itemNameList = generateItemNames();
|
||||
String nextLink = "";
|
||||
for (String itemName : itemNameList) {
|
||||
try {
|
||||
appClient.subscribe(itemName); // 根据itemName订阅
|
||||
// 等待消息
|
||||
refreshMsg = appClient.getMessageFuture().get(10, TimeUnit.SECONDS);// 设置超时时间,例如10秒
|
||||
System.out.println(refreshMsg.name());
|
||||
if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType()){
|
||||
nextLink = decode1(refreshMsg.payload().fieldList(),refreshMsg.name());
|
||||
while (StringUtils.isNotBlank(nextLink)&&!nextLink.contains("blank data")){
|
||||
appClient.subscribe(nextLink); // 根据itemName订阅
|
||||
// 等待消息
|
||||
refreshMsg = appClient.getMessageFuture().get(10, TimeUnit.SECONDS);// 设置超时时间,例如10秒
|
||||
nextLink = decode1(refreshMsg.payload().fieldList(),refreshMsg.name());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取列表异常link:"+nextLink,e);
|
||||
return ServerResponse.createByError();
|
||||
} finally {
|
||||
// 可能需要重置或清理资源
|
||||
appClient.resetMessageFuture();
|
||||
}
|
||||
}
|
||||
return ServerResponse.createBySuccess("操作成功");
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
/* @GetMapping("/getStockInfoList")
|
||||
@Deprecated
|
||||
public ServerResponse<?> getStockInfoList() {
|
||||
ExecutorService executorService = Executors.newFixedThreadPool(5); // 创建一个固定大小的线程池
|
||||
List<SymbolRefinitiv> collect = mongoTemplate.query(SymbolRefinitiv.class).stream().collect(Collectors.toList());
|
||||
List<StockInfoRefinitiv> collect2 = mongoTemplate.query(StockInfoRefinitiv.class).stream().collect(Collectors.toList());
|
||||
|
||||
List<SymbolRefinitiv> difference = collect.stream()
|
||||
.filter(symbol -> collect2.stream()
|
||||
.noneMatch(stockInfo -> stockInfo.getCommandStr().equals(symbol.getSymbol())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<String> itemNameList = difference.stream().map(SymbolRefinitiv::getSymbol).collect(Collectors.toList());
|
||||
|
||||
// 计算每个线程应处理的元素数量
|
||||
int size = itemNameList.size();
|
||||
int chunkSize = size / 5; // 假设列表可以均匀分配
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int start = i * chunkSize;
|
||||
int end = (i == 4) ? size : (start + chunkSize); // 最后一个线程可能需要处理更多的元素
|
||||
List<String> sublist = itemNameList.subList(start, end);
|
||||
// 将子列表的处理提交给线程池
|
||||
executorService.submit(() -> {
|
||||
for (String itemName : sublist) {
|
||||
try {
|
||||
CompletableFuture<RefreshMsg> future = concurrentAppClient.subscribe(itemName);
|
||||
RefreshMsg refreshMsg = future.get(10, TimeUnit.SECONDS);
|
||||
if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType()){
|
||||
// List<FieldEntry> safeList = Collections.synchronizedList(new ArrayList<>(refreshMsg.payload().fieldList()));
|
||||
decode2(refreshMsg.payload().fieldList(),refreshMsg.name());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取列表异常link:"+itemName,e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
executorService.shutdown();
|
||||
try {
|
||||
if (!executorService.awaitTermination(60, TimeUnit.SECONDS)) {
|
||||
executorService.shutdownNow();
|
||||
}
|
||||
} catch (InterruptedException ie) {
|
||||
executorService.shutdownNow();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
return ServerResponse.createBySuccess("操作成功");
|
||||
}*//*
|
||||
|
||||
|
||||
|
||||
@GetMapping("/testStockInfoList2")
|
||||
public ServerResponse<?> getStockInfoList2() {
|
||||
List<String> collect = mongoTemplate.query(SymbolRefinitiv.class).stream().map(SymbolRefinitiv::getSymbol).collect(Collectors.toList());
|
||||
// 计算每个线程应处理的元素数量
|
||||
for (String itemName : collect) {
|
||||
try {
|
||||
appClient.subscribe(itemName); // 根据itemName订阅
|
||||
// 等待消息
|
||||
RefreshMsg refreshMsg = appClient.getMessageFuture().get(10, TimeUnit.SECONDS);// 设置超时时间,例如10秒
|
||||
if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType()){
|
||||
// List<FieldEntry> safeList = Collections.synchronizedList(new ArrayList<>(refreshMsg.payload().fieldList()));
|
||||
decode2(refreshMsg.payload().fieldList(),refreshMsg.name());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取列表异常link:"+itemName,e);
|
||||
} finally {
|
||||
// 可能需要重置或清理资源
|
||||
appClient.resetMessageFuture();
|
||||
}
|
||||
}
|
||||
|
||||
return ServerResponse.createBySuccess("操作成功");
|
||||
}
|
||||
|
||||
@GetMapping("/getStockDetail")
|
||||
public ServerResponse<?> getStockInfoList2(String itemName) {
|
||||
|
||||
// 计算每个线程应处理的元素数量
|
||||
try {
|
||||
appClient.subscribe(itemName); // 根据itemName订阅
|
||||
// 等待消息
|
||||
RefreshMsg refreshMsg = appClient.getMessageFuture().get(10, TimeUnit.SECONDS);// 设置超时时间,例如10秒
|
||||
if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType()){
|
||||
RetifiveStockInfo retifiveStockInfo = decode3(refreshMsg.payload().fieldList(), refreshMsg.name());
|
||||
//获取股票id
|
||||
RetifiveStock stock = retifiveStockService.repository().findBtStockByCoCode(itemName);
|
||||
if(stock != null){
|
||||
retifiveStockInfo.setId(stock.getId());
|
||||
}
|
||||
return ServerResponse.createBySuccess("操作成功",retifiveStockInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取股票详情link:"+itemName,e);
|
||||
} finally {
|
||||
// 可能需要重置或清理资源
|
||||
appClient.resetMessageFuture();
|
||||
}
|
||||
|
||||
return ServerResponse.createBySuccess("操作成功");
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getStockDetailList")
|
||||
public ServerResponse<?> getStockDetailList(String itemName) {
|
||||
|
||||
// 计算每个线程应处理的元素数量
|
||||
String[] itemNames = itemName.split(",");
|
||||
List<RetifiveStockInfo> list = Lists.newArrayList();
|
||||
for (String name : itemNames) {
|
||||
try {
|
||||
appClient.subscribe(name); // 根据itemName订阅
|
||||
// 等待消息
|
||||
RefreshMsg refreshMsg = appClient.getMessageFuture().get(10, TimeUnit.SECONDS);// 设置超时时间,例如10秒
|
||||
if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType()){
|
||||
RetifiveStockInfo retifiveStockInfo = decode3(refreshMsg.payload().fieldList(), refreshMsg.name());
|
||||
list.add(retifiveStockInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取股票详情link:"+name,e);
|
||||
} finally {
|
||||
// 可能需要重置或清理资源
|
||||
appClient.resetMessageFuture();
|
||||
}
|
||||
}
|
||||
return ServerResponse.createBySuccess("操作成功",list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/getBSETopActivesList")
|
||||
public ServerResponse<?> getGainerList(String itemName) {
|
||||
// 计算每个线程应处理的元素数量
|
||||
String name = ".AV.BO";
|
||||
List<RetifiveStockInfo> list = Lists.newArrayList();
|
||||
try {
|
||||
appClient.subscribe(name); // 根据itemName订阅
|
||||
// 等待消息
|
||||
RefreshMsg refreshMsg = appClient.getMessageFuture().get(10, TimeUnit.SECONDS);// 设置超时时间,例如10秒
|
||||
if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType()){
|
||||
List<String> strings = decode4(refreshMsg.payload().fieldList());
|
||||
if(strings.size()>0){
|
||||
appClient.subscribeList(strings); // 根据itemName订阅
|
||||
// 等待消息
|
||||
List<RefreshMsg> refreshMsgs = appClient.getMessagesFuture().get(10, TimeUnit.SECONDS);
|
||||
for (RefreshMsg msg : refreshMsgs) {
|
||||
list.add(decode3(msg.payload().fieldList(),msg.name()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取股票详情link:"+name,e);
|
||||
} finally {
|
||||
// 可能需要重置或清理资源
|
||||
appClient.resetMessageFuture();
|
||||
}
|
||||
return ServerResponse.createBySuccess("操作成功",list);
|
||||
}
|
||||
|
||||
@GetMapping("/getBSETopGainerList")
|
||||
public ServerResponse<?> getBSETopGainerList() {
|
||||
|
||||
// 计算每个线程应处理的元素数量
|
||||
String name = ".PG.BO";
|
||||
List<RetifiveStockInfo> list = Lists.newArrayList();
|
||||
try {
|
||||
appClient.subscribe(name); // 根据itemName订阅
|
||||
// 等待消息
|
||||
RefreshMsg refreshMsg = appClient.getMessageFuture().get(10, TimeUnit.SECONDS);// 设置超时时间,例如10秒
|
||||
if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType()){
|
||||
List<String> strings = decode4(refreshMsg.payload().fieldList());
|
||||
appClient.subscribeList(strings); // 根据itemName订阅
|
||||
// 等待消息
|
||||
List<RefreshMsg> refreshMsgs = appClient.getMessagesFuture().get(10, TimeUnit.SECONDS);
|
||||
for (RefreshMsg msg : refreshMsgs) {
|
||||
list.add(decode3(msg.payload().fieldList(),msg.name()));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取股票详情link:"+name,e);
|
||||
} finally {
|
||||
// 可能需要重置或清理资源
|
||||
appClient.resetMessageFuture();
|
||||
}
|
||||
return ServerResponse.createBySuccess("操作成功",list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/getBSETopLoserList")
|
||||
public ServerResponse<?> getBSETopLoserList() {
|
||||
|
||||
// 计算每个线程应处理的元素数量
|
||||
String name = ".PL.BO";
|
||||
List<RetifiveStockInfo> list = Lists.newArrayList();
|
||||
try {
|
||||
appClient.subscribe(name); // 根据itemName订阅
|
||||
// 等待消息
|
||||
RefreshMsg refreshMsg = appClient.getMessageFuture().get(10, TimeUnit.SECONDS);// 设置超时时间,例如10秒
|
||||
if (DataType.DataTypes.FIELD_LIST == refreshMsg.payload().dataType()){
|
||||
List<String> strings = decode4(refreshMsg.payload().fieldList());
|
||||
appClient.subscribeList(strings); // 根据itemName订阅
|
||||
// 等待消息
|
||||
List<RefreshMsg> refreshMsgs = appClient.getMessagesFuture().get(10, TimeUnit.SECONDS);
|
||||
for (RefreshMsg msg : refreshMsgs) {
|
||||
list.add(decode3(msg.payload().fieldList(),msg.name()));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取股票详情link:"+name,e);
|
||||
} finally {
|
||||
// 可能需要重置或清理资源
|
||||
appClient.resetMessageFuture();
|
||||
}
|
||||
return ServerResponse.createBySuccess("操作成功",list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private List<String> decode4(FieldList fieldList) {
|
||||
List<String> list = Lists.newArrayList();
|
||||
String nextLink = "";
|
||||
for (FieldEntry fieldEntry : fieldList){
|
||||
// System.err.println("Fid: " + fieldEntry.fieldId() + " Name = " + fieldEntry.name() + " DataType: " + DataType.asString(fieldEntry.load().dataType()) + " Value: "+ fieldEntry.load().toString());
|
||||
if(fieldEntry.name().startsWith("BR_LINK")){
|
||||
nextLink = fieldEntry.load().toString();
|
||||
if(!nextLink.contains("blank data")){
|
||||
list.add(nextLink);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
/* void decode(FieldList fieldList)
|
||||
{
|
||||
for (FieldEntry fieldEntry : fieldList)
|
||||
{
|
||||
System.out.print("Fid: " + fieldEntry.fieldId() + " Name = " + fieldEntry.name() + " DataType: " + DataType.asString(fieldEntry.load().dataType()) + " Value: ");
|
||||
|
||||
if (Data.DataCode.BLANK == fieldEntry.code())
|
||||
System.out.println(" blank");
|
||||
else
|
||||
switch (fieldEntry.loadType())
|
||||
{
|
||||
case DataType.DataTypes.REAL :
|
||||
System.out.println(fieldEntry.real().asDouble());
|
||||
break;
|
||||
case DataType.DataTypes.DATE :
|
||||
System.out.println(fieldEntry.date().day() + " / " + fieldEntry.date().month() + " / " + fieldEntry.date().year());
|
||||
break;
|
||||
case DataType.DataTypes.TIME :
|
||||
System.out.println(fieldEntry.time().hour() + " / " + fieldEntry.time().minute() + " / " + fieldEntry.time().second() + fieldEntry.time().millisecond());
|
||||
break;
|
||||
case DataType.DataTypes.INT :
|
||||
System.out.println(fieldEntry.intValue());
|
||||
break;
|
||||
case DataType.DataTypes.UINT :
|
||||
System.out.println(fieldEntry.uintValue());
|
||||
break;
|
||||
case DataType.DataTypes.ASCII :
|
||||
System.out.println(fieldEntry.ascii());
|
||||
break;
|
||||
case DataType.DataTypes.ENUM :
|
||||
System.out.println(fieldEntry.hasEnumDisplay() ? fieldEntry.enumDisplay() : fieldEntry.enumValue());
|
||||
break;
|
||||
case DataType.DataTypes.RMTES :
|
||||
System.out.println(fieldEntry.rmtes());
|
||||
break;
|
||||
case DataType.DataTypes.ERROR :
|
||||
System.out.println("(" + fieldEntry.error().errorCodeAsString() + ")");
|
||||
break;
|
||||
default :
|
||||
System.out.println();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*//*
|
||||
|
||||
|
||||
String decode1(FieldList fieldList,String name)
|
||||
{
|
||||
Iterator<FieldEntry> iter = fieldList.iterator();
|
||||
FieldEntry fieldEntry;
|
||||
String nextLink = "";
|
||||
while (iter.hasNext())
|
||||
{
|
||||
fieldEntry = iter.next();
|
||||
//System.out.println("Fid: " + fieldEntry.fieldId() + " Name: " + fieldEntry.name() + " value: " + fieldEntry.load());
|
||||
if(fieldEntry.name().startsWith("LINK_")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.ASCII){
|
||||
String symbol = fieldEntry.load().toString();
|
||||
if(!symbol.contains("blank data")){
|
||||
mongoTemplate.insert(new SymbolRefinitiv(symbol,"bse",name));
|
||||
*/
|
||||
/* RetifiveStock retifiveStockPO = new RetifiveStock();
|
||||
retifiveStockPO.setSymbol(name);
|
||||
retifiveStockPO.setStockType("bse");
|
||||
retifiveStockService.repository().save(retifiveStockPO);*//*
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if(fieldEntry.name().startsWith("NEXT_LR")){
|
||||
nextLink = fieldEntry.load().toString();
|
||||
if(nextLink.contains("blank data")){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().startsWith("NEXT_LR")){
|
||||
nextLink = fieldEntry.load().toString();
|
||||
if(nextLink.contains("blank data")){
|
||||
break;
|
||||
}
|
||||
}
|
||||
String stockName = "";
|
||||
if(fieldEntry.name().equals("DSPLY_NAME")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.RMTES) {
|
||||
stockName = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
String stockCode = "";
|
||||
if(fieldEntry.name().equals("PROV_SYMB")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.RMTES) {
|
||||
stockCode = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
String status = "";
|
||||
if(fieldEntry.name().equals("TRD_STATUS")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.RMTES) {
|
||||
status = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
StockInfoRefinitiv stockInfoRefinitiv = new StockInfoRefinitiv();
|
||||
stockInfoRefinitiv.setStockName(stockName);
|
||||
stockInfoRefinitiv.setStockCode(stockCode);
|
||||
stockInfoRefinitiv.setStatus(status);
|
||||
stockInfoRefinitiv.setStockType("bse");
|
||||
stockInfoRefinitiv.setCommandStr(name);
|
||||
}
|
||||
return nextLink;
|
||||
}
|
||||
|
||||
void decode2(FieldList fieldList,String name)
|
||||
{
|
||||
Iterator<FieldEntry> iter = fieldList.iterator();
|
||||
FieldEntry fieldEntry;
|
||||
String stockName = "";
|
||||
String stockCode = "";
|
||||
String status = "";
|
||||
String price = "";
|
||||
String openPrice = "";
|
||||
String previousPrice = "";
|
||||
String percentChange = "";
|
||||
String week52High ="";
|
||||
String week52Low = "";
|
||||
String high = "";
|
||||
String low = "";
|
||||
String volume = "";//实时交易数量
|
||||
String stockType = "";
|
||||
String changeValue = "";
|
||||
while (iter.hasNext())
|
||||
{
|
||||
fieldEntry = iter.next();
|
||||
// System.out.println("Fid: " + fieldEntry.fieldId() + " Name: " + fieldEntry.name() +" Unit: "+DataType.asString(fieldEntry.loadType()) + " value: " + fieldEntry.load());
|
||||
if(fieldEntry.name().equals("DSPLY_NAME")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.RMTES) {
|
||||
stockName = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
if(fieldEntry.name().equals("PROV_SYMB")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.RMTES) {
|
||||
stockCode = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("INST_PHASE")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.ENUM) {
|
||||
status = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("OPEN_PRC")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
openPrice = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("HST_CLOSE")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
previousPrice = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("52WK_HIGH")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
week52High = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("52WK_LOW")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
week52Low = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("PCTCHNG")){ // NETCHNG_1
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
percentChange = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("NETCHNG_1")){ // NETCHNG_1
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
changeValue = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("HIGH_1")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
high = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("LOW_1")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
low = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
if(fieldEntry.name().equals("IRGVOL")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
volume = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("TRDPRC_1")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
price = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
if(fieldEntry.name().equals("RDN_EXCHID")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.ENUM) {
|
||||
stockType = fieldEntry.load().toString();
|
||||
if(StringUtils.equals(stockType,"145")){
|
||||
stockType = "bse";//孟买国家交易所
|
||||
}else if(StringUtils.equals(stockType,"147")){
|
||||
stockType = "nse";//印度国家交易所
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/*StockInfoRefinitiv stockInfoRefinitiv = new StockInfoRefinitiv();
|
||||
stockInfoRefinitiv.setStockName(stockName);
|
||||
stockInfoRefinitiv.setStockCode(stockCode);
|
||||
stockInfoRefinitiv.setStatus(status);
|
||||
stockInfoRefinitiv.setStockType("bse");
|
||||
stockInfoRefinitiv.setCommandStr(name);
|
||||
mongoTemplate.insert(stockInfoRefinitiv);*//*
|
||||
|
||||
|
||||
*/
|
||||
/* RetifiveStockInfo retifiveStockInfo = RetifiveStockInfo.builder().stockCode(stockCode).stockName(stockName).symbol(name).status(status)
|
||||
.openPrice(openPrice).currentPrice(price).highPrice(high).lowPrice(low).previousPrice(previousPrice).changePercent(percentChange)
|
||||
.volume(volume).week52HighPrice(week52High).week52LowPrice(week52Low).stockType(stockType).changeValue(changeValue)
|
||||
.build();*//*
|
||||
|
||||
|
||||
RetifiveStock retifiveStock = RetifiveStock.builder().stockType(stockType).saveTime(new Date()).isLock(0).isShow(0)
|
||||
.stockCode(stockCode).symbol(name).stockName(stockName).build();
|
||||
List<RetifiveStock> all = retifiveStockService.repository().findAll(QRetifiveStockPO.retifiveStockPO.symbol.eq(name));
|
||||
if(CollectionUtils.isEmpty(all)){
|
||||
retifiveStockService.repository().save(retifiveStock);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RetifiveStockInfo decode3(FieldList fieldList, String name)
|
||||
{
|
||||
Iterator<FieldEntry> iter = fieldList.iterator();
|
||||
FieldEntry fieldEntry;
|
||||
String stockName = "";
|
||||
String stockCode = "";
|
||||
String status = "";
|
||||
String price = "";
|
||||
String openPrice = "";
|
||||
String previousPrice = "";
|
||||
String percentChange = "";
|
||||
String week52High ="";
|
||||
String week52Low = "";
|
||||
String high = "";
|
||||
String low = "";
|
||||
String volume = "";//实时交易数量
|
||||
String stockType = "";
|
||||
String changeValue = "";
|
||||
while (iter.hasNext())
|
||||
{
|
||||
fieldEntry = iter.next();
|
||||
// System.out.println("Fid: " + fieldEntry.fieldId() + " Name: " + fieldEntry.name() +" Unit: "+DataType.asString(fieldEntry.loadType()) + " value: " + fieldEntry.load());
|
||||
if(fieldEntry.name().equals("DSPLY_NAME")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.RMTES) {
|
||||
stockName = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
if(fieldEntry.name().equals("PROV_SYMB")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.RMTES) {
|
||||
stockCode = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("INST_PHASE")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.ENUM) {
|
||||
status = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("OPEN_PRC")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
openPrice = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("HST_CLOSE")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
previousPrice = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("52WK_HIGH")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
week52High = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("52WK_LOW")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
week52Low = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("PCTCHNG")){ // NETCHNG_1
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
percentChange = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("NETCHNG_1")){ // NETCHNG_1
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
changeValue = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("HIGH_1")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
high = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("LOW_1")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
low = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
if(fieldEntry.name().equals("IRGVOL")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
volume = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if(fieldEntry.name().equals("TRDPRC_1")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.REAL) {
|
||||
price = fieldEntry.load().toString();
|
||||
}
|
||||
}
|
||||
if(fieldEntry.name().equals("RDN_EXCHID")){
|
||||
if(fieldEntry.loadType() == DataType.DataTypes.ENUM) {
|
||||
stockType = fieldEntry.load().toString();
|
||||
if(StringUtils.equals(stockType,"145")){
|
||||
stockType = "bse";//孟买国家交易所
|
||||
}else if(StringUtils.equals(stockType,"147")){
|
||||
stockType = "nse";//印度国家交易所
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RetifiveStockInfo retifiveStockInfo = RetifiveStockInfo.builder().stockCode(stockCode).stockName(stockName).symbol(name).status(status)
|
||||
.openPrice(openPrice).lastPrice(price).highPrice(high).lowPrice(low).previousPrice(previousPrice).perchg(percentChange)
|
||||
.volume(volume).week52HighPrice(week52High).week52LowPrice(week52Low).stockType(stockType).change(changeValue)
|
||||
.build();
|
||||
|
||||
return retifiveStockInfo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static List<String> generateItemNames() {
|
||||
List<String> itemNames = new ArrayList<>();
|
||||
|
||||
// 从字母 'A' 到 'Z'
|
||||
for (char letter = 'A'; letter <= 'Z'; letter++) {
|
||||
String itemName = "0#" + letter + ".BO";
|
||||
itemNames.add(itemName);
|
||||
}
|
||||
|
||||
return itemNames;
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,13 +1,12 @@
|
||||
package cn.stock.market.web;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.stock.market.MoneyStockSuggestDTO;
|
||||
import cn.stock.market.domain.basic.entity.MoneyStock;
|
||||
import cn.stock.market.domain.basic.repository.MoneyStockRepository;
|
||||
import cn.stock.market.dto.StockHistoryRequest;
|
||||
import cn.stock.market.dto.StockHistoryResponse;
|
||||
import cn.stock.market.infrastructure.db.po.QMoneyStockPO;
|
||||
import cn.stock.market.utils.NseIndiaRequest;
|
||||
import cn.stock.market.utils.RequestCacheUtils;
|
||||
import cn.stock.market.utils.ServerResponse;
|
||||
import cn.stock.market.web.annotations.EncryptFilter;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -38,7 +37,9 @@ import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -60,11 +61,13 @@ public class MoneyApiController {
|
||||
|
||||
private static final String EXTERNAL_API_URL = "https://priceapi.moneycontrol.com/techCharts/indianMarket/stock/history";
|
||||
|
||||
@ApiOperation(value = "股票详情信息", httpMethod = "GET")
|
||||
|
||||
|
||||
@ApiOperation(value = "股票详情信息",httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "stockType", value = "BSE或者NSE"),
|
||||
@ApiImplicitParam(name = "symbol", value = "scId值"),
|
||||
@ApiImplicitParam(name = "id", value = "id值"),
|
||||
@ApiImplicitParam(name="stockType",value = "BSE或者NSE"),
|
||||
@ApiImplicitParam(name="symbol",value = "scId值"),
|
||||
@ApiImplicitParam(name="id",value = "id值"),
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "" +
|
||||
@@ -163,67 +166,53 @@ public class MoneyApiController {
|
||||
"priceprevclose: 前一交易日的收盘价\n" +
|
||||
"30DayAvg: 过去30天的平均", response = JSONObject.class),
|
||||
})
|
||||
@GetMapping({"/market/api/market/money/getStockDetail", "/api/market/money/getStockDetail"})
|
||||
@GetMapping("/api/market/money/getStockDetail")
|
||||
@ResponseBody
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
|
||||
public ServerResponse getStockDetail(@RequestParam String stockType, @RequestParam String symbol) {
|
||||
public ServerResponse getStockDetail(@RequestParam String stockType, @RequestParam String symbol ) {
|
||||
String url = String.format("https://priceapi.moneycontrol.com/pricefeed/%s/equitycash/%s",stockType,symbol);
|
||||
MoneyStock moneyStock = moneyStockRepository.findOne(QMoneyStockPO.moneyStockPO.stockType.eq(stockType)
|
||||
.and(QMoneyStockPO.moneyStockPO.moneyScId.eq(symbol))
|
||||
.and(QMoneyStockPO.moneyStockPO.isLock.eq(0))
|
||||
.and(QMoneyStockPO.moneyStockPO.isShow.eq(0)))
|
||||
.and(QMoneyStockPO.moneyStockPO.moneyScId.eq(symbol))
|
||||
.and(QMoneyStockPO.moneyStockPO.isLock.eq(0))
|
||||
.and(QMoneyStockPO.moneyStockPO.isShow.eq(0)))
|
||||
.orElse(null);
|
||||
/* if(moneyStock==null){
|
||||
return ServerResponse.createByErrorMsg("没有找到该股票");
|
||||
}*/
|
||||
// 设置重试次数
|
||||
if ("ANI".equals(symbol)) {
|
||||
JSONObject json1 = new JSONObject();
|
||||
json1.put("company", "Archit Nuwood Industries Ltd");
|
||||
json1.put("pricepercentchange", "Archit Nuwood Industries Ltd");
|
||||
json1.put("stockType", stockType);
|
||||
json1.put("pricecurrent", "386");
|
||||
json1.put("dataSourceType", "3");
|
||||
json1.put("symbol", "ANI");
|
||||
json1.put("BSEID", "ANI");
|
||||
json1.put("NSEID", "ANI");
|
||||
return ServerResponse.createBySuccess(json1);
|
||||
}
|
||||
|
||||
String url = String.format("https://priceapi.moneycontrol.com/pricefeed/%s/equitycash/%s", stockType, symbol);
|
||||
int maxRetries = 3;
|
||||
for (int retry = 1; retry <= maxRetries; retry++) {
|
||||
try {
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, null, String.class);
|
||||
JSONObject json1 = new JSONObject();
|
||||
if (responseEntity.getStatusCode().value() == 200 && responseEntity.getBody() != null) {
|
||||
if (responseEntity.getStatusCode().value() == 200 && responseEntity.getBody() != null ) {
|
||||
JSONObject data = JSONObject.parseObject(responseEntity.getBody()).getJSONObject("data");
|
||||
if (data != null) {
|
||||
json1.put("company", data.getString("SC_FULLNM"));
|
||||
json1.put("pricepercentchange", data.getString("pricepercentchange"));
|
||||
json1.put("stockType", stockType);
|
||||
json1.put("pricechange", data.getString("pricechange"));
|
||||
json1.put("pricecurrent", data.getString("pricecurrent"));
|
||||
json1.put("priceprevclose", data.getString("priceprevclose"));
|
||||
json1.put("PREVDATE", data.getString("PREVDATE"));
|
||||
json1.put("VOL", data.getString("VOL"));
|
||||
json1.put("dataSourceType", "3");
|
||||
json1.put("symbol", data.getString("symbol"));
|
||||
json1.put("BSEID", data.getString("BSEID"));
|
||||
json1.put("NSEID", data.getString("NSEID"));
|
||||
json1.put("LTH", data.getString("HP"));
|
||||
json1.put("LTL", data.getString("LP"));
|
||||
json1.put("OPN", data.getString("OPN"));
|
||||
if (null != moneyStock) {
|
||||
json1.put("id", moneyStock.getId());
|
||||
if(data!=null){
|
||||
json1.put("company",data.getString("company"));
|
||||
json1.put("pricepercentchange",data.getString("pricepercentchange"));
|
||||
json1.put("stockType",stockType);
|
||||
json1.put("pricechange",data.getString("pricechange"));
|
||||
json1.put("pricecurrent",data.getString("pricecurrent"));
|
||||
json1.put("priceprevclose",data.getString("priceprevclose"));
|
||||
json1.put("PREVDATE",data.getString("PREVDATE"));
|
||||
json1.put("VOL",data.getString("VOL"));
|
||||
json1.put("dataSourceType","3");
|
||||
json1.put("symbol",data.getString("symbol"));
|
||||
json1.put("BSEID",data.getString("BSEID"));
|
||||
json1.put("NSEID",data.getString("NSEID"));
|
||||
json1.put("LTH",data.getString("HP"));
|
||||
json1.put("LTL",data.getString("LP"));
|
||||
json1.put("OPN",data.getString("OPN"));
|
||||
if(null!=moneyStock){
|
||||
json1.put("id",moneyStock.getId());
|
||||
}
|
||||
if (StringUtils.equals(data.getString("pricecurrent"), "0.00")
|
||||
&& (!StringUtils.equals(data.getString("priceprevclose"), "0.00"))) {
|
||||
json1.put("pricecurrent", data.getString("priceprevclose"));
|
||||
if(StringUtils.equals(data.getString("pricecurrent"),"0.00")
|
||||
&& (!StringUtils.equals(data.getString("priceprevclose"),"0.00"))){
|
||||
json1.put("pricecurrent",data.getString("priceprevclose"));
|
||||
}
|
||||
}
|
||||
if (json1.size() > 0)
|
||||
return ServerResponse.createBySuccess(json1);
|
||||
return ServerResponse.createBySuccess(json1);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
@@ -237,31 +226,20 @@ public class MoneyApiController {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (moneyStock != null && moneyStock.getNseIndiaId() != null && !moneyStock.getNseIndiaId().isEmpty()) {
|
||||
try {
|
||||
// Get data from nseindia
|
||||
JSONObject json = NseIndiaRequest.stockByJYSFromHttp(stockType, symbol, moneyStock.getNseIndiaId());
|
||||
json.put("id", moneyStock.getId());
|
||||
json.put("company",moneyStock.getStockName());
|
||||
return ServerResponse.createBySuccess(json);
|
||||
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private static List<MoneyStockSuggestDTO> nseActives() {
|
||||
|
||||
private static List<MoneyStockSuggestDTO> nseActives() {
|
||||
List<MoneyStockSuggestDTO> list = new ArrayList<>();
|
||||
String url = "https://www.moneycontrol.com/stocks/marketstats/nse-mostactive-stocks/nifty-50-9/";
|
||||
try {
|
||||
Document doc = Jsoup.connect(url).get();
|
||||
int size = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div.bsr_table.hist_tbl_hm > table > tbody > tr").size();
|
||||
for (int i = 1; i <= size; i++) {
|
||||
for (int i =1;i<=size;i++){
|
||||
MoneyStockSuggestDTO dto = new MoneyStockSuggestDTO();
|
||||
Element company_a = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td.PR > span > a").first();
|
||||
Element company_a = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child("+i+") > td.PR > span > a").first();
|
||||
if (company_a != null) {
|
||||
String stockUrl = company_a.attr("href");
|
||||
String stockName = company_a.text();
|
||||
@@ -269,7 +247,7 @@ public class MoneyApiController {
|
||||
dto.setStockUrl(stockUrl);
|
||||
}
|
||||
|
||||
String highPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(2)").first());
|
||||
String highPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child("+i+") > td:nth-child(2)").first());
|
||||
dto.setHighPrice(highPrice);
|
||||
|
||||
String lowPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(3)").first());
|
||||
@@ -294,7 +272,7 @@ public class MoneyApiController {
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<MoneyStockSuggestDTO> bseActives() {
|
||||
private static List<MoneyStockSuggestDTO> bseActives() {
|
||||
List<MoneyStockSuggestDTO> list = new ArrayList<>();
|
||||
|
||||
String url = "https://www.moneycontrol.com/stocks/marketstats/bsemact1/index.php";
|
||||
@@ -302,9 +280,9 @@ public class MoneyApiController {
|
||||
Document doc = Jsoup.connect(url).get();
|
||||
int size = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr").size();
|
||||
System.err.println(size);
|
||||
for (int i = 1; i <= size; i++) {
|
||||
for (int i =1;i<=size;i++){
|
||||
MoneyStockSuggestDTO dto = new MoneyStockSuggestDTO();
|
||||
Element company_a = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td.PR > span > a").first();
|
||||
Element company_a = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child("+i+") > td.PR > span > a").first();
|
||||
if (company_a != null) {
|
||||
String stockUrl = company_a.attr("href");
|
||||
String stockName = company_a.text();
|
||||
@@ -333,19 +311,19 @@ public class MoneyApiController {
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("occur Exception", e);
|
||||
log.error("occur Exception",e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<MoneyStockSuggestDTO> bseGainer() {
|
||||
private static List<MoneyStockSuggestDTO> bseGainer() {
|
||||
String url = "https://www.moneycontrol.com/stocks/marketstats/bse-gainer/sensex_4/";
|
||||
List<MoneyStockSuggestDTO> list = Lists.newArrayList();
|
||||
try {
|
||||
Document doc = Jsoup.connect(url).get();
|
||||
int size = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr").size();
|
||||
for (int i = 1; i <= size; i++) {
|
||||
Element company_a = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td.PR > span > a").first();
|
||||
for (int i =1;i<=size;i++){
|
||||
Element company_a = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child("+i+") > td.PR > span > a").first();
|
||||
MoneyStockSuggestDTO dto = new MoneyStockSuggestDTO();
|
||||
if (company_a != null) {
|
||||
String stockUrl = company_a.attr("href");
|
||||
@@ -389,9 +367,9 @@ public class MoneyApiController {
|
||||
try {
|
||||
Document doc = Jsoup.connect(url).get();
|
||||
int size = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr").size();
|
||||
for (int i = 1; i <= size; i++) {
|
||||
for (int i =1;i<=size;i++){
|
||||
MoneyStockSuggestDTO dto = new MoneyStockSuggestDTO();
|
||||
Element company_a = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td.PR > span > h3 > a").first();
|
||||
Element company_a = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child("+i+") > td.PR > span > h3 > a").first();
|
||||
if (company_a != null) {
|
||||
String stockUrl = company_a.attr("href");
|
||||
String stockName = company_a.text();
|
||||
@@ -426,20 +404,20 @@ public class MoneyApiController {
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<MoneyStockSuggestDTO> nseTopLoser() {
|
||||
private static List<MoneyStockSuggestDTO> nseTopLoser() {
|
||||
String url = "https://www.moneycontrol.com/stocks/marketstats/nseloser/index.php";
|
||||
List<MoneyStockSuggestDTO> list = Lists.newArrayList();
|
||||
|
||||
try {
|
||||
Document doc = Jsoup.connect(url).get();
|
||||
int size = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr").size();
|
||||
for (int i = 1; i <= size; i++) {
|
||||
for (int i =1;i<=size;i++){
|
||||
MoneyStockSuggestDTO dto = new MoneyStockSuggestDTO();
|
||||
Element company_a = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td.PR > span > h3 > a").first();
|
||||
Element company_a = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child("+i+") > td.PR > span > h3 > a").first();
|
||||
if (company_a != null) {
|
||||
String stockUrl = company_a.attr("href");
|
||||
String stockName = company_a.text();
|
||||
dto.setStockUrl(stockUrl);
|
||||
dto.setStockUrl(stockUrl);
|
||||
dto.setStockName(stockName);
|
||||
}
|
||||
|
||||
@@ -466,7 +444,7 @@ public class MoneyApiController {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<MoneyStockSuggestDTO> bseTopLoser() {
|
||||
@@ -476,7 +454,7 @@ public class MoneyApiController {
|
||||
try {
|
||||
Document doc = Jsoup.connect(url).get();
|
||||
int size = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr").size();
|
||||
for (int i = 1; i <= size; i++) {
|
||||
for (int i =1;i<=size;i++){
|
||||
Element company_a = doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td.PR > span > a").first();
|
||||
MoneyStockSuggestDTO dto = new MoneyStockSuggestDTO();
|
||||
if (company_a != null) {
|
||||
@@ -521,15 +499,17 @@ public class MoneyApiController {
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "股票推荐TopGainer", httpMethod = "GET")
|
||||
|
||||
|
||||
@ApiOperation(value = "股票推荐TopGainer",httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "stockType", value = "BSE或者NSE"),
|
||||
@ApiImplicitParam(name="stockType",value = "BSE或者NSE"),
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "" +
|
||||
"股票推荐相关: top gainer", response = JSONObject.class),
|
||||
})
|
||||
@GetMapping({"/market/api/market/money/getTopGainer", "/api/market/money/getTopGainer"})
|
||||
@GetMapping("/api/market/money/getTopGainer")
|
||||
@ResponseBody
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
|
||||
@@ -545,17 +525,15 @@ public class MoneyApiController {
|
||||
} else if (StringUtils.equals(stockType, "bse")) {
|
||||
moneyStockSuggestDTOS = bseGainer();
|
||||
}
|
||||
Map<Object, Boolean> map = new HashMap<>();
|
||||
moneyStockSuggestDTOS = moneyStockSuggestDTOS.stream()
|
||||
.filter(f -> StringUtils.isNotBlank(f.getStockName()))
|
||||
.filter(i -> map.putIfAbsent(i.getStockName(), Boolean.TRUE) == null).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(moneyStockSuggestDTOS)) {
|
||||
|
||||
moneyStockSuggestDTOS = moneyStockSuggestDTOS.stream().filter(f->StringUtils.isNotBlank(f.getStockName())).collect(Collectors.toList());
|
||||
if(CollectionUtils.isNotEmpty(moneyStockSuggestDTOS)){
|
||||
List<String> selfUlrList = moneyStockSuggestDTOS.stream().map(MoneyStockSuggestDTO::getStockName).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(selfUlrList)) {
|
||||
if(CollectionUtils.isNotEmpty(selfUlrList)){
|
||||
List<MoneyStock> all = moneyStockRepository.findAll(QMoneyStockPO.moneyStockPO.stockName.in(selfUlrList));
|
||||
if (CollectionUtils.isNotEmpty(all)) {
|
||||
moneyStockSuggestDTOS.stream().filter(f -> all.stream().anyMatch(s -> s.getStockName().equals(f.getStockName())))
|
||||
.forEach(f -> f.setScId(all.stream().filter(s -> s.getStockName().equals(f.getStockName())).findFirst().orElse(null).getMoneyScId()));
|
||||
if(CollectionUtils.isNotEmpty(all)){
|
||||
moneyStockSuggestDTOS.stream().filter(f->all.stream().anyMatch(s->s.getStockName().equals(f.getStockName())))
|
||||
.forEach(f->f.setScId(all.stream().filter(s->s.getStockName().equals(f.getStockName())).findFirst().orElse(null).getMoneyScId()));
|
||||
}
|
||||
}
|
||||
gainerStockSuggestCache.put(stockType, moneyStockSuggestDTOS);
|
||||
@@ -566,47 +544,44 @@ public class MoneyApiController {
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "股票推荐TopLoser", httpMethod = "GET")
|
||||
@ApiOperation(value = "股票推荐TopLoser",httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "stockType", value = "BSE或者NSE"),
|
||||
@ApiImplicitParam(name="stockType",value = "BSE或者NSE"),
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "" +
|
||||
"股票推荐相关: TopLoser", response = JSONObject.class),
|
||||
})
|
||||
@GetMapping({"/market/api/market/money/getTopLoser", "/api/market/money/getTopLoser"})
|
||||
@GetMapping("/api/market/money/getTopLoser")
|
||||
@ResponseBody
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
|
||||
public List<MoneyStockSuggestDTO> getTopLoser(@RequestParam String stockType) {
|
||||
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;
|
||||
moneyStockSuggestDTOS = loserStockSuggestCache.getIfPresent(stockType);
|
||||
if (null == moneyStockSuggestDTOS) {
|
||||
if (StringUtils.equals(stockType, "nse")) {
|
||||
if(null==moneyStockSuggestDTOS){
|
||||
if(StringUtils.equals(stockType,"nse")){
|
||||
moneyStockSuggestDTOS = nseTopLoser();
|
||||
} else if (StringUtils.equals(stockType, "bse")) {
|
||||
}else if(StringUtils.equals(stockType,"bse")){
|
||||
moneyStockSuggestDTOS = bseTopLoser();
|
||||
}
|
||||
Map<Object, Boolean> map = new HashMap<>();
|
||||
moneyStockSuggestDTOS = moneyStockSuggestDTOS.stream()
|
||||
.filter(f -> StringUtils.isNotBlank(f.getStockName()))
|
||||
.filter(i -> map.putIfAbsent(i.getStockName(), Boolean.TRUE) == null).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(moneyStockSuggestDTOS)) {
|
||||
moneyStockSuggestDTOS.stream().forEach(f -> f.setDispId(extractLastSegment(f.getStockUrl())));
|
||||
moneyStockSuggestDTOS = moneyStockSuggestDTOS.stream().filter(f->StringUtils.isNotBlank(f.getStockName())).collect(Collectors.toList());
|
||||
if(CollectionUtils.isNotEmpty(moneyStockSuggestDTOS)){
|
||||
moneyStockSuggestDTOS.stream().forEach(f->f.setDispId(extractLastSegment(f.getStockUrl())));
|
||||
List<String> selfUlrList = moneyStockSuggestDTOS.stream().map(MoneyStockSuggestDTO::getStockName).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(selfUlrList)) {
|
||||
if(CollectionUtils.isNotEmpty(selfUlrList)){
|
||||
List<MoneyStock> all = moneyStockRepository.findAll(QMoneyStockPO.moneyStockPO.stockName.in(selfUlrList));
|
||||
if (CollectionUtils.isNotEmpty(all)) {
|
||||
moneyStockSuggestDTOS.stream().filter(f -> all.stream().anyMatch(s -> s.getStockName().equals(f.getStockName())))
|
||||
.forEach(f -> f.setScId(all.stream().filter(s -> s.getStockName().equals(f.getStockName())).findFirst().orElse(null).getMoneyScId()));
|
||||
if(CollectionUtils.isNotEmpty(all)){
|
||||
moneyStockSuggestDTOS.stream().filter(f->all.stream().anyMatch(s->s.getStockName().equals(f.getStockName())))
|
||||
.forEach(f->f.setScId(all.stream().filter(s->s.getStockName().equals(f.getStockName())).findFirst().orElse(null).getMoneyScId()));
|
||||
}
|
||||
List<MoneyStockSuggestDTO> noScIdList = moneyStockSuggestDTOS.stream().filter(f -> StringUtils.isBlank(f.getScId())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(noScIdList)) {
|
||||
List<MoneyStockSuggestDTO> noScIdList = moneyStockSuggestDTOS.stream().filter(f->StringUtils.isBlank(f.getScId())).collect(Collectors.toList());
|
||||
if(CollectionUtils.isNotEmpty(noScIdList)){
|
||||
List<String> dispIdList = noScIdList.stream().map(MoneyStockSuggestDTO::getDispId).collect(Collectors.toList());
|
||||
List<MoneyStock> all1 = moneyStockRepository.findAll(QMoneyStockPO.moneyStockPO.selfDispId.in(dispIdList));
|
||||
if (CollectionUtils.isNotEmpty(all1)) {
|
||||
moneyStockSuggestDTOS.stream().filter(f -> all1.stream().anyMatch(s -> s.getSelfDispId().equals(f.getDispId())))
|
||||
.forEach(f -> f.setScId(all.stream().filter(s -> s.getSelfDispId().equals(f.getDispId())).findFirst().orElse(null).getMoneyScId()));
|
||||
if(CollectionUtils.isNotEmpty(all1)){
|
||||
moneyStockSuggestDTOS.stream().filter(f->all1.stream().anyMatch(s->s.getSelfDispId().equals(f.getDispId())))
|
||||
.forEach(f->f.setScId(all.stream().filter(s->s.getSelfDispId().equals(f.getDispId())).findFirst().orElse(null).getMoneyScId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -617,47 +592,46 @@ public class MoneyApiController {
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "股票推荐TopActive", httpMethod = "GET")
|
||||
|
||||
|
||||
@ApiOperation(value = "股票推荐TopActive",httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "stockType", value = "BSE或者NSE"),
|
||||
@ApiImplicitParam(name="stockType",value = "BSE或者NSE"),
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "" +
|
||||
"股票推荐相关: top active", response = JSONObject.class),
|
||||
})
|
||||
@GetMapping({"/market/api/market/money/getTopActives", "/api/market/money/getTopActives"})
|
||||
@GetMapping("/api/market/money/getTopActives")
|
||||
@ResponseBody
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
|
||||
public List<MoneyStockSuggestDTO> getTopActive(@RequestParam String stockType) {
|
||||
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;
|
||||
moneyStockSuggestDTOS = activesStockSuggestCache.getIfPresent(stockType);
|
||||
if (moneyStockSuggestDTOS == null) {
|
||||
if (StringUtils.equals(stockType, "nse")) {
|
||||
if(moneyStockSuggestDTOS ==null){
|
||||
if(StringUtils.equals(stockType,"nse")){
|
||||
moneyStockSuggestDTOS = nseActives();
|
||||
} else if (StringUtils.equals(stockType, "bse")) {
|
||||
}else if(StringUtils.equals(stockType,"bse")){
|
||||
moneyStockSuggestDTOS = bseActives();
|
||||
}
|
||||
Map<Object, Boolean> map = new HashMap<>();
|
||||
moneyStockSuggestDTOS = moneyStockSuggestDTOS.stream()
|
||||
.filter(f -> StringUtils.isNotBlank(f.getStockName()))
|
||||
.filter(i -> map.putIfAbsent(i.getStockName(), Boolean.TRUE) == null).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(moneyStockSuggestDTOS)) {
|
||||
moneyStockSuggestDTOS.stream().forEach(f -> f.setDispId(extractLastSegment(f.getStockUrl())));
|
||||
moneyStockSuggestDTOS = moneyStockSuggestDTOS.stream().filter(f->StringUtils.isNotBlank(f.getStockName())).collect(Collectors.toList());
|
||||
if(CollectionUtils.isNotEmpty(moneyStockSuggestDTOS)){
|
||||
moneyStockSuggestDTOS.stream().forEach(f->f.setDispId(extractLastSegment(f.getStockUrl())));
|
||||
List<String> selfUlrList = moneyStockSuggestDTOS.stream().map(MoneyStockSuggestDTO::getStockName).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(selfUlrList)) {
|
||||
if(CollectionUtils.isNotEmpty(selfUlrList)){
|
||||
List<MoneyStock> all = moneyStockRepository.findAll(QMoneyStockPO.moneyStockPO.stockName.in(selfUlrList));
|
||||
if (CollectionUtils.isNotEmpty(all)) {
|
||||
moneyStockSuggestDTOS.stream().filter(f -> all.stream().anyMatch(s -> s.getStockName().equals(f.getStockName())))
|
||||
.forEach(f -> f.setScId(all.stream().filter(s -> s.getStockName().equals(f.getStockName())).findFirst().orElse(null).getMoneyScId()));
|
||||
if(CollectionUtils.isNotEmpty(all)){
|
||||
moneyStockSuggestDTOS.stream().filter(f->all.stream().anyMatch(s->s.getStockName().equals(f.getStockName())))
|
||||
.forEach(f->f.setScId(all.stream().filter(s->s.getStockName().equals(f.getStockName())).findFirst().orElse(null).getMoneyScId()));
|
||||
}
|
||||
List<MoneyStockSuggestDTO> noScIdList = moneyStockSuggestDTOS.stream().filter(f -> StringUtils.isBlank(f.getScId())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(noScIdList)) {
|
||||
List<MoneyStockSuggestDTO> noScIdList = moneyStockSuggestDTOS.stream().filter(f->StringUtils.isBlank(f.getScId())).collect(Collectors.toList());
|
||||
if(CollectionUtils.isNotEmpty(noScIdList)){
|
||||
List<String> dispIdList = noScIdList.stream().map(MoneyStockSuggestDTO::getDispId).collect(Collectors.toList());
|
||||
List<MoneyStock> all1 = moneyStockRepository.findAll(QMoneyStockPO.moneyStockPO.selfDispId.in(dispIdList));
|
||||
if (CollectionUtils.isNotEmpty(all1)) {
|
||||
moneyStockSuggestDTOS.stream().filter(f -> all1.stream().anyMatch(s -> s.getSelfDispId().equals(f.getDispId())))
|
||||
.forEach(f -> f.setScId(all.stream().filter(s -> s.getSelfDispId().equals(f.getDispId())).findFirst().orElse(null).getMoneyScId()));
|
||||
if(CollectionUtils.isNotEmpty(all1)){
|
||||
moneyStockSuggestDTOS.stream().filter(f->all1.stream().anyMatch(s->s.getSelfDispId().equals(f.getDispId())))
|
||||
.forEach(f->f.setScId(all.stream().filter(s->s.getSelfDispId().equals(f.getDispId())).findFirst().orElse(null).getMoneyScId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -669,8 +643,9 @@ public class MoneyApiController {
|
||||
}
|
||||
|
||||
|
||||
@GetMapping({"/market/api/market/money/history/kLine", "/api/market/money/history/kLine"})
|
||||
@ApiOperation(value = "获取kline的money数据源", notes = "获取kline的money数据源", response = StockHistoryResponse.class)
|
||||
|
||||
@GetMapping("/api/market/money/history/kLine")
|
||||
@ApiOperation(value = "获取kline的money数据源", notes = "获取kline的money数据源",response = StockHistoryResponse.class)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "symbol", value = "Stock symbol 对应的是NSEID 或者是BSEID", required = true, dataType = "String", paramType = "query"),
|
||||
@ApiImplicitParam(name = "resolution", value = "单位:60 1D 1W 1D 对应H,D,W,Y", required = true, dataType = "String", paramType = "query"),
|
||||
@@ -680,36 +655,36 @@ public class MoneyApiController {
|
||||
@ApiImplicitParam(name = "currencyCode", value = "INR 不变", required = true, dataType = "String", paramType = "query")
|
||||
})
|
||||
@ResponseBody
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
public ResponseEntity<StockHistoryResponse> getStockHistory(@RequestParam String symbol,
|
||||
@RequestParam String resolution
|
||||
) {
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
public ResponseEntity<StockHistoryResponse> getStockHistory( @RequestParam String symbol,
|
||||
@RequestParam String resolution
|
||||
) {
|
||||
// 向外部API发起请求,并获取响应
|
||||
StockHistoryRequest request = new StockHistoryRequest();
|
||||
request.setSymbol(symbol);
|
||||
Long to = null;
|
||||
Long from = null;
|
||||
int countback = 5;
|
||||
if (StringUtils.equals("H", resolution)) {
|
||||
to = (long) (System.currentTimeMillis() / 1000);
|
||||
from = to - (60 * 60);
|
||||
countback = 60;
|
||||
request.setResolution("1");
|
||||
} else if (StringUtils.equals("D", resolution)) {
|
||||
to = (long) (System.currentTimeMillis() / 1000);
|
||||
from = to - (24 * 60 * 60);
|
||||
countback = 390;
|
||||
request.setResolution("1");
|
||||
} else if (StringUtils.equals("W", resolution)) {
|
||||
to = (long) (System.currentTimeMillis() / 1000);
|
||||
from = to - (7 * 24 * 60 * 60);
|
||||
countback = 471;
|
||||
request.setResolution("5");
|
||||
} else if (StringUtils.equals("M", resolution)) {
|
||||
to = (long) (System.currentTimeMillis() / 1000);
|
||||
from = to - (35 * 24 * 60 * 60);
|
||||
countback = 328;
|
||||
request.setResolution("30");
|
||||
if(StringUtils.equals("H",resolution)){
|
||||
to = (long) (System.currentTimeMillis() / 1000);
|
||||
from = to - (1* 24 * 60 * 60 );
|
||||
countback = 16;
|
||||
request.setResolution("60");
|
||||
}else if(StringUtils.equals("D",resolution)){
|
||||
to = (long) (System.currentTimeMillis() / 1000);
|
||||
from = to - (24 * 60 * 60 );
|
||||
countback = 30;
|
||||
request.setResolution("60");
|
||||
}else if(StringUtils.equals("W",resolution)){
|
||||
to = (long) (System.currentTimeMillis() / 1000);
|
||||
from = to - (10 * 24 * 60 * 60 );
|
||||
countback = 30;
|
||||
request.setResolution("1D");
|
||||
}else if(StringUtils.equals("M",resolution)){
|
||||
to = (long) (System.currentTimeMillis() / 1000);
|
||||
from = to - (35 * 24 * 60 * 60 );
|
||||
countback = 30;
|
||||
request.setResolution("1D");
|
||||
}
|
||||
|
||||
request.setFrom(from);
|
||||
@@ -717,7 +692,7 @@ public class MoneyApiController {
|
||||
request.setCountback(countback);
|
||||
request.setCurrencyCode("INR");
|
||||
String apiUrl = buildApiUrl(request);
|
||||
log.info("request url:" + apiUrl);
|
||||
log.info("request url:"+apiUrl);
|
||||
StockHistoryResponse response = null;
|
||||
int maxRetries = 3;
|
||||
int retryCount = 0;
|
||||
@@ -740,27 +715,10 @@ public class MoneyApiController {
|
||||
}
|
||||
}
|
||||
|
||||
if (response != null && !response.getS().equals("error")) {
|
||||
setResponse(response, resolution);
|
||||
if (response != null) {
|
||||
// API request successful, return the response
|
||||
return ResponseEntity.ok(response);
|
||||
} else {
|
||||
try {
|
||||
MoneyStock moneyStock = moneyStockRepository.findOne((QMoneyStockPO.moneyStockPO.moneyScId.eq(symbol))
|
||||
.and(QMoneyStockPO.moneyStockPO.isLock.eq(0))
|
||||
.and(QMoneyStockPO.moneyStockPO.isShow.eq(0)))
|
||||
.orElse(null);
|
||||
|
||||
if (moneyStock != null && moneyStock.getNseIndiaChartId() != null && !moneyStock.getNseIndiaChartId().isEmpty()) {
|
||||
request.setSymbol(moneyStock.getNseIndiaChartId());
|
||||
response = NseIndiaRequest.stockKLineFromHttp(request, resolution);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to get data from nseindia.", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).build();
|
||||
}
|
||||
|
||||
// All retries failed, return an error response
|
||||
log.error("Failed to get a successful response after {} retries.", maxRetries);
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
@@ -768,49 +726,7 @@ public class MoneyApiController {
|
||||
// 返回响应
|
||||
}
|
||||
|
||||
private void setResponse(StockHistoryResponse response, String resolution) {
|
||||
if (!"ok".equals(response.getS())) {
|
||||
return;
|
||||
}
|
||||
if (Objects.isNull(response.getT())) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.equals("H", resolution) || StringUtils.equals("D", resolution)) {
|
||||
List<Long> t = new ArrayList<>();
|
||||
List<Double> o = new ArrayList<>();
|
||||
List<Double> h = new ArrayList<>();
|
||||
List<Double> l = new ArrayList<>();
|
||||
List<Double> c = new ArrayList<>();
|
||||
List<Long> v = new ArrayList<>();
|
||||
|
||||
//根据时间过滤,只留当天的数据
|
||||
Date currentTime = new Date();
|
||||
//判断最后一条是不是当天的数据,如果不是,把最后一条的时间作为当天的时间
|
||||
long getTime = response.getT().get(response.getT().size() - 1) * 1000L;
|
||||
if (!DateUtil.isSameDay(currentTime, new Date(getTime))) {
|
||||
currentTime = new Date(getTime);
|
||||
}
|
||||
int i = 0;
|
||||
for (Long time : response.getT()) {
|
||||
time = time * 1000;
|
||||
if (DateUtil.isSameDay(currentTime, new Date(time))) {
|
||||
t.add(response.getT().get(i));
|
||||
o.add(response.getO().get(i));
|
||||
h.add(response.getH().get(i));
|
||||
l.add(response.getL().get(i));
|
||||
c.add(response.getC().get(i));
|
||||
v.add(response.getV().get(i));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
response.setT(t);
|
||||
response.setO(o);
|
||||
response.setH(h);
|
||||
response.setL(l);
|
||||
response.setC(c);
|
||||
response.setV(v);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String buildApiUrl(StockHistoryRequest request) {
|
||||
@@ -818,9 +734,7 @@ public class MoneyApiController {
|
||||
return String.format("%s?symbol=%s&resolution=%s&from=%d&to=%d&countback=%d¤cyCode=%s",
|
||||
EXTERNAL_API_URL, request.getSymbol(), request.getResolution(), request.getFrom(),
|
||||
request.getTo(), request.getCountback(), request.getCurrencyCode());
|
||||
}
|
||||
|
||||
;
|
||||
};
|
||||
|
||||
|
||||
private static String extractLastSegment(String url) {
|
||||
@@ -836,16 +750,13 @@ public class MoneyApiController {
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// nseGainer();
|
||||
//// nseActives();
|
||||
//// nseTopLoser();
|
||||
////
|
||||
//// bseActives();
|
||||
//// bseGainer();
|
||||
//// bseTopLoser();
|
||||
System.out.println(new Date());
|
||||
System.out.println(new Date(1713949200000L));
|
||||
System.out.println(DateUtil.isSameDay(new Date(), new Date(1713949200000L)));
|
||||
nseGainer();
|
||||
nseActives();
|
||||
nseTopLoser();
|
||||
|
||||
bseActives();
|
||||
bseGainer();
|
||||
bseTopLoser();
|
||||
}
|
||||
|
||||
private Cache<String, List<MoneyStockSuggestDTO>> gainerStockSuggestCache = CacheBuilder.newBuilder()
|
||||
|
||||
@@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -24,7 +23,7 @@ import java.net.URL;
|
||||
public class MoneyProxyApiControl {
|
||||
|
||||
|
||||
@GetMapping({"/market/api/proxy/queryStockMoneyProxy","/api/proxy/queryStockMoneyProxy"})
|
||||
@RequestMapping(value = "/api/proxy/queryStockMoneyProxy",method = RequestMethod.GET)
|
||||
public JSONObject queryStockByMoneyIdAndExchangeType(String scId,String exchangeType){
|
||||
return stockByMoneyIdAndExchangeTypeFromHttp(scId,exchangeType);
|
||||
}
|
||||
|
||||
148
src/main/java/cn/stock/market/web/RefinitivApiController.java
Normal file
148
src/main/java/cn/stock/market/web/RefinitivApiController.java
Normal file
@@ -0,0 +1,148 @@
|
||||
package cn.stock.market.web;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stock.market.domain.basic.entity.RetifiveStock;
|
||||
import cn.stock.market.domain.basic.service.RetifiveStockService;
|
||||
import cn.stock.market.dto.RetifiveStockHistoryResponse;
|
||||
import cn.stock.market.dto.RetifiveStockInfo;
|
||||
import cn.stock.market.lesg.RefinitivConsumer;
|
||||
import cn.stock.market.utils.ServerResponse;
|
||||
import cn.stock.market.web.annotations.EncryptFilter;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.stock.market.lesg.RefinitivConsumer.*;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@Api(value = "/RefinitivApiController", tags = "Refinitiv股票行情")
|
||||
@Slf4j
|
||||
@RequestMapping({"/api/market/refinitiv", "/api/hq/refinitiv"})
|
||||
public class RefinitivApiController {
|
||||
|
||||
@Resource
|
||||
private RefinitivConsumer refinitivConsumer;
|
||||
@Autowired
|
||||
private RetifiveStockService retifiveStockService;
|
||||
|
||||
@ApiOperation(value = "股票详情信息", httpMethod = "GET", response = RetifiveStockInfo.class)
|
||||
@ApiImplicitParams({@ApiImplicitParam(name = "symbol", value = "symbol值")})
|
||||
@GetMapping("/getStockDetail")
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
public ServerResponse<?> getStockDetail(String symbol) {
|
||||
try {
|
||||
RetifiveStockInfo retifiveStockInfo = refinitivConsumer.getDetail(symbol);
|
||||
if (ObjUtil.isNull(retifiveStockInfo)) {
|
||||
log.error("该symbol = {} 未在数据源中查询到", symbol);
|
||||
return ServerResponse.createBySuccess("操作成功", null);
|
||||
}
|
||||
|
||||
//获取股票id
|
||||
RetifiveStock stock = retifiveStockService.repository().findBtStockByCoCode(symbol);
|
||||
if(stock != null){
|
||||
retifiveStockInfo.setId(stock.getId());
|
||||
}
|
||||
return ServerResponse.createBySuccess("操作成功", retifiveStockInfo);
|
||||
} catch (Exception e) {
|
||||
log.error("获取股票详情link:" + symbol, e);
|
||||
}
|
||||
|
||||
return ServerResponse.createBySuccess("操作成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "股票详情列表", httpMethod = "GET", response = RetifiveStockInfo.class)
|
||||
@ApiImplicitParams({@ApiImplicitParam(name = "symbol", value = "symbol值, 多个时以英文逗号分隔")})
|
||||
@GetMapping("/getStockDetailList")
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
public ServerResponse<?> getStockDetailList(String symbol) {
|
||||
try {
|
||||
return ServerResponse.createBySuccess("操作成功", refinitivConsumer.getDetailList(symbol));
|
||||
} catch (Exception e) {
|
||||
log.error("获取股票详情列表报错,", e);
|
||||
}
|
||||
|
||||
return ServerResponse.createByError();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取股票推荐TopActives", httpMethod = "GET", response = RetifiveStockInfo.class)
|
||||
@GetMapping("/getTopActives")
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
public ServerResponse<?> getTopActives(@RequestParam String stockType) {
|
||||
if (StrUtil.equalsIgnoreCase(stockType, "nse")) {
|
||||
return ServerResponse.createBySuccess("操作成功", new ArrayList<>());
|
||||
}
|
||||
|
||||
try {
|
||||
List<RetifiveStockInfo> result = refinitivConsumer.getTopActives();
|
||||
return ServerResponse.createBySuccess("操作成功", result);
|
||||
} catch (Exception e) {
|
||||
log.error("获取股票详情link:" + TOP_ACTIVES_SYMBOL, e);
|
||||
}
|
||||
|
||||
return ServerResponse.createByError();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取股票推荐TopGainers", httpMethod = "GET", response = RetifiveStockInfo.class)
|
||||
@GetMapping("/getTopGainers")
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
public ServerResponse<?> getTopGainers(@RequestParam String stockType) {
|
||||
if (StrUtil.equalsIgnoreCase(stockType, "nse")) {
|
||||
return ServerResponse.createBySuccess("操作成功", new ArrayList<>());
|
||||
}
|
||||
|
||||
try {
|
||||
List<RetifiveStockInfo> result = refinitivConsumer.getTopGainers();
|
||||
return ServerResponse.createBySuccess("操作成功", result);
|
||||
} catch (Exception e) {
|
||||
log.error("获取股票详情link:" + TOP_GAINERS_SYMBOL, e);
|
||||
}
|
||||
|
||||
return ServerResponse.createByError();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取股票推荐TopLosers", httpMethod = "GET", response = RetifiveStockInfo.class)
|
||||
@GetMapping("/getTopLosers")
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
public ServerResponse<?> getTopLosers(@RequestParam String stockType) {
|
||||
if (StrUtil.equalsIgnoreCase(stockType, "nse")) {
|
||||
return ServerResponse.createBySuccess("操作成功", new ArrayList<>());
|
||||
}
|
||||
|
||||
try {
|
||||
List<RetifiveStockInfo> result = refinitivConsumer.getTopLosers();
|
||||
return ServerResponse.createBySuccess("操作成功", result);
|
||||
} catch (Exception e) {
|
||||
log.error("获取股票详情link:" + TOP_LOSERS_SYMBOL, e);
|
||||
}
|
||||
|
||||
return ServerResponse.createByError();
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "查询股票K线", httpMethod = "GET", response = RetifiveStockHistoryResponse.class)
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "symbol",value = "股票对应代码(symbol)",dataType ="String",required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "resolution", value = "单位:60 1D 1W 1D 对应H,D,W,Y", required = true, dataType = "String", paramType = "query"),
|
||||
})
|
||||
@GetMapping("/getKlink")
|
||||
@EncryptFilter(decryptRequest = false)
|
||||
public ServerResponse<?> getKlink(@RequestParam("symbol") String symbol, @RequestParam("resolution") String resolution,
|
||||
@RequestParam("starttime") String starttime,@RequestParam("endtime") String endtime) {
|
||||
return ServerResponse.createBySuccess(refinitivConsumer.getKLink(symbol,resolution,starttime,endtime));
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import cn.stock.market.domain.basic.service.SiteNewsService;
|
||||
import cn.stock.market.utils.ServerResponse;
|
||||
|
||||
@Controller
|
||||
@RequestMapping({"/market/api/market/news/", "/market/api/hq/news/","/api/market/news/", "/api/hq/news/"})
|
||||
@RequestMapping({"/api/market/news/", "/api/hq/news/"})
|
||||
@Api(tags="新闻资讯")
|
||||
public class SiteNewsController {
|
||||
private static final Logger log = LoggerFactory.getLogger(SiteNewsController.class);
|
||||
|
||||
@@ -3,8 +3,6 @@ package cn.stock.market.web;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -14,7 +12,6 @@ import cn.qutaojing.common.jpa.ConditionBuilder;
|
||||
import cn.stock.market.domain.basic.entity.SiteNews;
|
||||
import cn.stock.market.domain.basic.repository.SiteNewsRepository;
|
||||
import cn.stock.market.infrastructure.db.po.QSiteNewsPO;
|
||||
import cn.stock.market.infrastructure.job.InvestingTask;
|
||||
import cn.stock.market.web.annotations.EncryptFilter;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -59,7 +56,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
@Controller
|
||||
@Api(value = "/StockApiController", tags = "股票行情")
|
||||
@RequestMapping({"/market/api/market/stock/", "/market/api/hq/stock/","/api/market/stock/", "/api/hq/stock/"})
|
||||
@RequestMapping({"/api/market/stock/", "/api/hq/stock/"})
|
||||
public class StockApiController {
|
||||
private static final Logger log = LoggerFactory.getLogger(StockApiController.class);
|
||||
|
||||
@@ -172,22 +169,15 @@ public class StockApiController {
|
||||
|
||||
@RequestMapping({"test.do"})
|
||||
@ResponseBody
|
||||
public ServerResponse test(/*@RequestParam("url") String url, @RequestParam("pageNum") Integer pageNum*/) {
|
||||
public ServerResponse test(@RequestParam("url") String url, @RequestParam("pageNum") Integer pageNum) {
|
||||
String news = stockService.getNews();
|
||||
List<String> newsList = Arrays.asList(news.split("<a href="));
|
||||
newsList = newsList.subList(1, newsList.size());
|
||||
newsList.forEach( n -> {
|
||||
String contentUrl = n.substring(1, n.indexOf("class=\"img-smllnews\"") - 2);
|
||||
String id = contentUrl.substring(contentUrl.lastIndexOf("-") + 1, contentUrl.lastIndexOf("_"));
|
||||
String imgUrl = InvestingTask.extractImgSrc(n);
|
||||
// String time = n.substring(n.indexOf("Last Updated") + 23, n.indexOf("IST") - 9);
|
||||
// Extract the date and time using regex
|
||||
Pattern pattern = Pattern.compile("Updated On :<!-- --> <!-- -->(.*?)<!-- -->");
|
||||
Matcher matcher = pattern.matcher(n);
|
||||
String time = "";
|
||||
if (matcher.find()) {
|
||||
time = matcher.group(1).trim();
|
||||
}
|
||||
String imgUrl = n.substring(n.indexOf("img loading=\"lazy\" src=") + 24, n.indexOf("?"));
|
||||
String time = n.substring(n.indexOf("Last Updated") + 23, n.indexOf("IST") - 9);
|
||||
|
||||
SiteNews siteNews = new SiteNews();
|
||||
siteNews.setAddTime(new Date());
|
||||
@@ -248,19 +238,10 @@ public class StockApiController {
|
||||
@ResponseBody
|
||||
public ServerResponse getIndiaIndexByToday() {
|
||||
String INDEX_CODE = "TODAY_INDEX";
|
||||
return RequestCacheUtils.cache("getIndiaIndexByToday.do", INDEX_CODE,6000, (string) -> {
|
||||
return RequestCacheUtils.cache("getIndiaIndexByToday.do", INDEX_CODE, (string) -> {
|
||||
return this.stockService.getIndexByBtoday();
|
||||
});
|
||||
}
|
||||
@RequestMapping({"getIndiaIndexByEttech.do"})
|
||||
@ApiOperation(value = "印度--获取指定指数信息-Ettech", httpMethod = "GET")
|
||||
@ResponseBody
|
||||
public ServerResponse getIndiaIndexByEttech() {
|
||||
String INDEX_CODE = "TODAY_INDEX";
|
||||
return RequestCacheUtils.cache("getIndiaIndexByEttech.do", INDEX_CODE, (string) -> {
|
||||
return this.stockService.getEttechcharts();
|
||||
});
|
||||
}
|
||||
|
||||
//根据股票id查询 股票指数、大盘指数信息
|
||||
@RequestMapping({"getMarketByStockGid.do"})
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@Controller
|
||||
@Api(value = "/TodayApiController", tags = "today股票行情")
|
||||
@RequestMapping({"/market/api/market/today/","/api/market/today/"})
|
||||
@RequestMapping({"/api/market/today/"})
|
||||
public class TodayApiController {
|
||||
|
||||
@RequestMapping({"getTopGainers.do"})
|
||||
|
||||
898
src/main/resources/EmaConfig.xml
Normal file
898
src/main/resources/EmaConfig.xml
Normal file
@@ -0,0 +1,898 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<EmaConfig>
|
||||
|
||||
<!-- ConsumerGroup provides set of detailed configurations to be used by named consumers -->
|
||||
<!-- Application specifies which configuration to use by setting OmmConsumerConfig::consumerName() -->
|
||||
<ConsumerGroup>
|
||||
<!-- DefaultConsumer parameter defines which consumer configuration is used by OmmConsumer -->
|
||||
<!-- if application does not specify it through OmmConsumerConfig::consumerName() -->
|
||||
<!-- first consumer on the ConsumerList is a DefaultConsumer if this parameter is not specified -->
|
||||
<DefaultConsumer value="Consumer_1"/>
|
||||
<ConsumerList>
|
||||
<Consumer>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="Consumer_1"/>
|
||||
<!-- Channel is optional: defaulted to "RSSL_SOCKET + localhost + 14002" -->
|
||||
<!-- Channel or ChannelSet may be specified -->
|
||||
<Channel value="Channel_1"/>
|
||||
<!-- Dictionary is optional: defaulted to "ChannelDictionary" -->
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Consumer_2"/>
|
||||
<!-- ChannelSet specifies an ordered list of Channels to which OmmConsumer will attempt to -->
|
||||
<!-- connect, one at a time, if the previous one fails to connect -->
|
||||
<ChannelSet value="Channel_1, Channel_2"/>
|
||||
<Dictionary value="Dictionary_2"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Consumer_3"/>
|
||||
<!-- Channel set to "RSSL_ENCRYPTED" -->
|
||||
<Channel value="Channel_3"/>
|
||||
<!-- Dictionary is optional: defaulted to "ChannelDictionary" -->
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Consumer_4"/>
|
||||
<Channel value="Channel_4"/>
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<MaxDispatchCountApiThread value="6500"/>
|
||||
<MaxDispatchCountUserThread value="6500"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<!-- Channel is specified to provide RSSL_WEBSOCKET connection options -->
|
||||
<Name value="Consumer_5"/>
|
||||
<Channel value="Channel_5"/>
|
||||
<Dictionary value="Dictionary_2"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
<DefaultServiceID value="1"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="Consumer_6"/>
|
||||
<Channel value="Channel_6"/>
|
||||
<!-- Dictionary is optional: defaulted to "ChannelDictionary" -->
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
<DefaultServiceID value="1"/>
|
||||
</Consumer>
|
||||
<!-- Consumer with enabled RTT feature -->
|
||||
<Consumer>
|
||||
<Name value="Consumer_7"/>
|
||||
<Channel value="Channel_1"/>
|
||||
<Dictionary value="Dictionary_2"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
<DefaultServiceID value="1"/>
|
||||
<EnableRtt value="1"/>
|
||||
</Consumer>
|
||||
<!-- Consumer for warm standby feature -->
|
||||
<Consumer>
|
||||
<Name value="Consumer_8"/>
|
||||
<WarmStandbyChannelSet value="WarmStandbyChannel_1"/>
|
||||
<Dictionary value="Dictionary_2"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</Consumer>
|
||||
<!-- Performance tools consumers -->
|
||||
<Consumer>
|
||||
<Name value="Perf_Consumer_1"/>
|
||||
<Channel value="Perf_Channel_1"/>
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<MaxDispatchCountApiThread value="6500"/>
|
||||
<MaxDispatchCountUserThread value="6500"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Perf_Consumer_WSJSON_1"/>
|
||||
<Channel value="Perf_Channel_WSJSON_1"/>
|
||||
<Dictionary value="Dictionary_2"/>
|
||||
<MaxDispatchCountApiThread value="6500"/>
|
||||
<MaxDispatchCountUserThread value="6500"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Perf_Consumer_WSRWF_1"/>
|
||||
<Channel value="Perf_Channel_WSRWF_1"/>
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<MaxDispatchCountApiThread value="6500"/>
|
||||
<MaxDispatchCountUserThread value="6500"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Consumer_RRTViewer_SE"/>
|
||||
<Channel value="Channel_RRTViewer_SE"/>
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<!-- 'XmlTraceToStdout == 1' is required for proper working of 'Debug' mode in RRTViewer -->
|
||||
<!-- If XmlTraceToStdout set into '0', 'debug' mode will print only EMA logs. -->
|
||||
<XmlTraceToStdout value="1"/>
|
||||
</Consumer>
|
||||
<Consumer>
|
||||
<Name value="Consumer_RRTViewer_DE"/>
|
||||
<Channel value="Channel_RRTViewer_DE"/>
|
||||
<Dictionary value="Dictionary_1"/>
|
||||
<!-- 'XmlTraceToStdout == 1' is required for proper working of 'Debug' mode in RRTViewer -->
|
||||
<!-- If XmlTraceToStdout set into '0', 'debug' mode will print only EMA logs. -->
|
||||
<XmlTraceToStdout value="1"/>
|
||||
</Consumer>
|
||||
</ConsumerList>
|
||||
</ConsumerGroup>
|
||||
|
||||
<!-- NiProviderGroup provides set of detailed configurations to be used by named providers -->
|
||||
<!-- Application specifies which configuration to use by setting OmmNiProviderConfig::providerName() -->
|
||||
<NiProviderGroup>
|
||||
<!-- DefaultNiProvider parameter defines which provider configuration is used by OmmProvider -->
|
||||
<!-- if application does not specify it through OmmNiProviderConfig::providerName() -->
|
||||
<!-- first provider on the NiProviderList is a DefaultNiProvider if this parameter is not specified -->
|
||||
<DefaultNiProvider value="Provider_1"/>
|
||||
<NiProviderList>
|
||||
<!-- Regular providers -->
|
||||
<NiProvider>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="Provider_1"/>
|
||||
<!-- Channel is optional: defaulted to "RSSL_SOCKET + localhost + 14003" -->
|
||||
<Channel value="Channel_7"/>
|
||||
<!-- Directory is optional. -->
|
||||
<!-- the EMA provides hardcoded directory containing a single service named "NI_PUB". -->
|
||||
<!-- the EMA defaults the OmmNiProviderConfig::adminControlDirectory() to ApiControlEnum.-->
|
||||
<!-- the applications may just use the hardcoded "NI_PUB" service to publish all the items.-->
|
||||
<!-- if desired, a custom directory may be configured, named and used instead of the -->
|
||||
<!-- hardcoded one. Please see examples in the DirectoryGroup.-->
|
||||
<!-- the directory may also be specified using OmmNiProviderConfig::addAdminMsg(). -->
|
||||
<!-- if desired the OmmNiProviderConfig::adminControlDirectory() to UserControlEnum -->
|
||||
<!-- which allows applications to specify and control the directory. -->
|
||||
<Directory value="Directory_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</NiProvider>
|
||||
<NiProvider>
|
||||
<Name value="Provider_2"/>
|
||||
<Channel value="Channel_6"/>
|
||||
<Directory value="Directory_2"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</NiProvider>
|
||||
<NiProvider>
|
||||
<Name value="Provider_3"/>
|
||||
<Channel value="Channel_6"/>
|
||||
<Directory value="Directory_3"/>
|
||||
</NiProvider>
|
||||
<NiProvider>
|
||||
<Name value="Provider_4"/>
|
||||
<Channel value="Channel_7"/>
|
||||
<Directory value="Directory_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</NiProvider>
|
||||
<!-- Performance tools niprovider -->
|
||||
<NiProvider>
|
||||
<Name value="Perf_NIProvider_1"/>
|
||||
<Channel value="Perf_NIP_Channel_1"/>
|
||||
<Directory value="Perf_Directory_1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
<ItemCountHint value="100000"/>
|
||||
<MaxDispatchCountApiThread value="500"/>
|
||||
<MaxDispatchCountUserThread value="500"/>
|
||||
</NiProvider>
|
||||
</NiProviderList>
|
||||
</NiProviderGroup>
|
||||
|
||||
<!-- IProviderGroup provides set of detailed configurations to be used by named providers -->
|
||||
<!-- Application specifies which configuration to use by setting OmmIProviderConfig::providerName() -->
|
||||
<IProviderGroup>
|
||||
<!-- DefaultIProvider parameter defines which provider configuration is used by OmmProvider -->
|
||||
<!-- if application does not specify it through OmmIProviderConfig::providerName() -->
|
||||
<!-- first provider on the IProviderList is a default provider if this parameter is not specified -->
|
||||
<DefaultIProvider value="Provider_1"/>
|
||||
<IProviderList>
|
||||
<IProvider>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="Provider_1"/>
|
||||
<!-- Server is optional: defaulted to "RSSL_SOCKET + 14002" -->
|
||||
<Server value="Server_1"/>
|
||||
<!-- Directory is optional: defaulted to AdminControl::UserControlEnum -->
|
||||
<!-- source directory configuration to use if OmmIProviderConfig::adminModel() -->
|
||||
<!-- was set to ApiControlEnum -->
|
||||
<!-- this configuration also decides which dictionaries will be loaded at startup -->
|
||||
<!-- this configuration may be overwritten by OmmIProviderConfig::addAdminMsg() -->
|
||||
<Directory value="Directory_2"/>
|
||||
<ItemCountHint value="10000"/>
|
||||
<ServiceCountHint value="10000" />
|
||||
<DispatchTimeoutApiThread value="500" />
|
||||
<MaxDispatchCountApiThread value="500" />
|
||||
<MaxDispatchCountUserThread value="500" />
|
||||
<PipePort value="9009" />
|
||||
<RefreshFirstRequired value="1" />
|
||||
</IProvider>
|
||||
<IProvider>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="Provider_3"/>
|
||||
<!-- Server is optional: now it specifies RSSL_WEBSOCKET connection options -->
|
||||
<Server value="Server_2"/>
|
||||
<!-- Directory is optional: defaulted to AdminControl::UserControlEnum -->
|
||||
<!-- source directory configuration to use if OmmIProviderConfig::adminModel() -->
|
||||
<!-- was set to ApiControlEnum -->
|
||||
<!-- this configuration also decides which dictionaries will be loaded at startup -->
|
||||
<!-- this configuration may be overwritten by OmmIProviderConfig::addAdminMsg() -->
|
||||
<Directory value="Directory_2"/>
|
||||
<ItemCountHint value="10000"/>
|
||||
<ServiceCountHint value="10000" />
|
||||
<DispatchTimeoutApiThread value="500" />
|
||||
<MaxDispatchCountApiThread value="500" />
|
||||
<MaxDispatchCountUserThread value="500" />
|
||||
<PipePort value="9009" />
|
||||
<RefreshFirstRequired value="1" />
|
||||
<SendJsonConvError value="1" />
|
||||
</IProvider>
|
||||
<IProvider>
|
||||
<!-- Name is mandatory -->
|
||||
<Name value="EncryptedProvider"/>
|
||||
<!-- Server is optional: defaulted to "RSSL_SOCKET + 14002" -->
|
||||
<Server value="EncryptedServer"/>
|
||||
<!-- Directory is optional: defaulted to AdminControl::UserControlEnum -->
|
||||
<!-- source directory configuration to use if OmmIProviderConfig::adminModel() -->
|
||||
<!-- was set to ApiControlEnum -->
|
||||
<!-- this configuration also decides which dictionaries will be loaded at startup -->
|
||||
<!-- this configuration may be overwritten by OmmIProviderConfig::addAdminMsg() -->
|
||||
<Directory value="Directory_2"/>
|
||||
<ItemCountHint value="10000"/>
|
||||
<ServiceCountHint value="10000" />
|
||||
<DispatchTimeoutApiThread value="500" />
|
||||
<MaxDispatchCountApiThread value="500" />
|
||||
<MaxDispatchCountUserThread value="500" />
|
||||
<PipePort value="9009" />
|
||||
<RefreshFirstRequired value="1" />
|
||||
</IProvider>
|
||||
<!-- Performance tools provider -->
|
||||
<IProvider>
|
||||
<Name value="Perf_Provider_1"/>
|
||||
<Server value="Perf_Server_1"/>
|
||||
<Directory value="Directory_2"/>
|
||||
<ItemCountHint value="100000"/>
|
||||
<ServiceCountHint value="10000"/>
|
||||
<DispatchTimeoutApiThread value="5000" />
|
||||
<MaxDispatchCountApiThread value="10"/>
|
||||
<MaxDispatchCountUserThread value="6500"/>
|
||||
<RefreshFirstRequired value="1"/>
|
||||
<XmlTraceToStdout value="0"/>
|
||||
</IProvider>
|
||||
</IProviderList>
|
||||
</IProviderGroup>
|
||||
|
||||
<ChannelGroup>
|
||||
<ChannelList>
|
||||
<Channel>
|
||||
<Name value="Channel_1"/>
|
||||
<!-- ChannelType possible values are: -->
|
||||
<!-- ChannelType::RSSL_SOCKET - TCP IP connection type -->
|
||||
<!-- ChannelType::RSSL_HTTP - Http tunnel connection type -->
|
||||
<!-- ChannelType::RSSL_ENCRYPTED - Https tunnel connection type -->
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<!-- CompressionType is optional: defaulted to None -->
|
||||
<!-- possible values: None, ZLib, LZ4 -->
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- ConnectionPingTimeout is optional: defaulted to 30000 -->
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<!-- TcpNodelay is optional: defaulted to 1 -->
|
||||
<!-- possible values: 1 (tcp_nodelay option set), 0 (tcp_nodelay not set) -->
|
||||
<TcpNodelay value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_2"/>
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_3"/>
|
||||
<ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
<!-- ObjectName is optional: defaulted to "" -->
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_4"/>
|
||||
<ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- EMA discovers a host and a port from RDP service discovery for the specified location
|
||||
when both of them are not set and the session management is enable. -->
|
||||
<Location value="us-east-1"/>
|
||||
<EnableSessionManagement value="1"/>
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_5"/>
|
||||
<ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- EMA discovers a host and a port from RDP service discovery for the specified location
|
||||
when both of them are not set and the session management is enable. -->
|
||||
<Location value="us-east-1"/>
|
||||
<EnableSessionManagement value="1"/>
|
||||
<EncryptedProtocolType value="EncryptedProtocolType::RSSL_WEBSOCKET"/>
|
||||
<WsMaxMsgSize value="61440"/>
|
||||
<WsProtocols value="tr_json2"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_6"/>
|
||||
<ChannelType value="ChannelType::RSSL_WEBSOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="15000"/>
|
||||
<WsMaxMsgSize value="61440"/>
|
||||
<WsProtocols value="rssl.json.v2, rssl.rwf, tr_json2"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_7"/>
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14003"/>
|
||||
<!-- ObjectName is optional: defaulted to "" -->
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_8"/>
|
||||
<ChannelType value="ChannelType::RSSL_HTTP"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14003"/>
|
||||
<!-- ObjectName is optional: defaulted to "" -->
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_9"/>
|
||||
<ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14003"/>
|
||||
<!-- ObjectName is optional: defaulted to "" -->
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_RRTViewer_SE"/>
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Channel_RRTViewer_DE"/>
|
||||
<ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- EMA discovers a host and a port from RDP service discovery for the specified location
|
||||
when both of them are not set and the session management is enable. -->
|
||||
<Location value="us-east-1"/>
|
||||
<EnableSessionManagement value="1"/>
|
||||
<ObjectName value=""/>
|
||||
</Channel>
|
||||
|
||||
<!--Performance tools channels -->
|
||||
<Channel>
|
||||
<Name value="Perf_Channel_1"/>
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<NumInputBuffers value="2048"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Perf_Channel_WSJSON_1"/>
|
||||
<ChannelType value="ChannelType::RSSL_WEBSOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="50000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="0"/>
|
||||
<DirectWrite value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
<WsMaxMsgSize value="18432"/>
|
||||
<WsProtocols value="rssl.json.v2"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Perf_Channel_WSRWF_1"/>
|
||||
<ChannelType value="ChannelType::RSSL_WEBSOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="0"/>
|
||||
<DirectWrite value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14002"/>
|
||||
<WsProtocols value="rssl.rwf"/>
|
||||
</Channel>
|
||||
<Channel>
|
||||
<Name value="Perf_NIP_Channel_1"/>
|
||||
<ChannelType value="ChannelType::RSSL_SOCKET"/>
|
||||
<GuaranteedOutputBuffers value="100000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="0"/>
|
||||
<DirectWrite value="1"/>
|
||||
<Host value="localhost"/>
|
||||
<Port value="14003"/>
|
||||
<InterfaceName value=""/>
|
||||
<HighWaterMark value="6144"/>
|
||||
<NumInputBuffers value="10000"/>
|
||||
<SysRecvBufSize value="65535"/>
|
||||
<SysSendBufSize value="65535"/>
|
||||
</Channel>
|
||||
</ChannelList>
|
||||
</ChannelGroup>
|
||||
|
||||
<ServerGroup>
|
||||
<ServerList>
|
||||
<Server>
|
||||
<Name value="Server_1"/>
|
||||
<ServerType value="ServerType::RSSL_SOCKET"/>
|
||||
<!-- CompressionType is optional: defaulted to None -->
|
||||
<!-- possible values: None, ZLib, LZ4 -->
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- ConnectionPingTimeout is optional: defaulted to 30000 -->
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<!-- TcpNodelay is optional: defaulted to 1 -->
|
||||
<!-- possible values: 1 (tcp_nodelay option set), 0 (tcp_nodelay not set) -->
|
||||
<TcpNodelay value="1"/>
|
||||
<Port value="14002"/>
|
||||
</Server>
|
||||
<Server>
|
||||
<Name value="Server_2"/>
|
||||
<!-- For WS connection server could use also RSSL_SOCKET type -->
|
||||
<ServerType value="ServerType::RSSL_WEBSOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="1"/>
|
||||
<Port value="15000"/>
|
||||
<!-- There are optional and used for applying WS connection -->
|
||||
<MaxFragmentSize value="6144"/>
|
||||
<WsProtocols value="rssl.json.v2, rssl.rwf, tr_json2"/>
|
||||
</Server>
|
||||
<Server>
|
||||
<Name value="EncryptedServer"/>
|
||||
<ServerType value="ServerType::RSSL_ENCRYPTED"/>
|
||||
<!-- CompressionType is optional: defaulted to None -->
|
||||
<!-- possible values: None, ZLib, LZ4 -->
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<!-- ConnectionPingTimeout is optional: defaulted to 30000 -->
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<!-- TcpNodelay is optional: defaulted to 1 -->
|
||||
<!-- possible values: 1 (tcp_nodelay option set), 0 (tcp_nodelay not set) -->
|
||||
<TcpNodelay value="1"/>
|
||||
<Port value="14002"/>
|
||||
</Server>
|
||||
<!--Performance tools server -->
|
||||
<Server>
|
||||
<Name value="Perf_Server_1"/>
|
||||
<ServerType value="ServerType::RSSL_SOCKET"/>
|
||||
<CompressionType value="CompressionType::None"/>
|
||||
<GuaranteedOutputBuffers value="5000"/>
|
||||
<ConnectionPingTimeout value="30000"/>
|
||||
<TcpNodelay value="0"/>
|
||||
<Port value="14002"/>
|
||||
<HighWaterMark value="0"/>
|
||||
<InterfaceName value=""/>
|
||||
<DirectWrite value="1" />
|
||||
<MaxFragmentSize value="6144"/>
|
||||
<NumInputBuffers value="10000"/>
|
||||
<SysRecvBufSize value="65535"/>
|
||||
<SysSendBufSize value="65535"/>
|
||||
</Server>
|
||||
</ServerList>
|
||||
</ServerGroup>
|
||||
|
||||
<WarmStandbyServerInfoGroup>
|
||||
<WarmStandbyServerInfoList>
|
||||
<WarmStandbyServerInfo>
|
||||
<Name value="Server_Info_1"/>
|
||||
<Channel value="Channel_1"/>
|
||||
<PerServiceNameSet value=""/>
|
||||
</WarmStandbyServerInfo>
|
||||
<WarmStandbyServerInfo>
|
||||
<Name value="Server_Info_2"/>
|
||||
<Channel value="Channel_7"/>
|
||||
<PerServiceNameSet value=""/>
|
||||
</WarmStandbyServerInfo>
|
||||
</WarmStandbyServerInfoList>
|
||||
</WarmStandbyServerInfoGroup>
|
||||
|
||||
<WarmStandbyGroup>
|
||||
<WarmStandbyList>
|
||||
<WarmStandbyChannel>
|
||||
<Name value="WarmStandbyChannel_1"/>
|
||||
<StartingActiveServer value="Server_Info_1"/>
|
||||
<StandbyServerSet value="Server_Info_2"/>
|
||||
<WarmStandbyMode value="WarmStandbyMode::LOGIN_BASED"/>
|
||||
</WarmStandbyChannel>
|
||||
</WarmStandbyList>
|
||||
</WarmStandbyGroup>
|
||||
|
||||
<!-- source directory refresh configuration used by provider -->
|
||||
<DirectoryGroup>
|
||||
<!-- DefaultDirectory specifies Directory used as default if providers do not specify Directory name -->
|
||||
<DefaultDirectory value="Directory_1"/>
|
||||
<DirectoryList>
|
||||
<!-- providers refer to the Directory by name -->
|
||||
<!-- Directory is a set of Services (one or more) on which a provider will provide item data -->
|
||||
<Directory>
|
||||
<Name value="Directory_1"/>
|
||||
<Service>
|
||||
<Name value="TEST_NI_PUB"/>
|
||||
<InfoFilter>
|
||||
<!-- optional value; if not specified EMA will assign it -->
|
||||
<ServiceId value="11"/>
|
||||
<!-- optional value -->
|
||||
<Vendor value="company name"/>
|
||||
<!-- possible values: 0 - means consolidation service, 1 - means original provider -->
|
||||
<IsSource value="0"/>
|
||||
<!-- an array of market domains supported by this service -->
|
||||
<!-- domains defined in the RDM Usage Guide may be refered by name -->
|
||||
<!-- names of the RDM defined domains are listed in the EmaRdm.h file -->
|
||||
<!-- e.g. MMT_MARKET_PRICE, MMT_MARKET_BY_ORDER -->
|
||||
<!-- note that the capabilities may be specified with names and or numbers -->
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="MMT_MARKET_PRICE"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
</Capabilities>
|
||||
<!-- list of dictionary names specified in the DictionaryGroup -->
|
||||
<!-- EMA will populate the Service::InfoFilter::DictionariesProvided element -->
|
||||
<!-- with the respective <>ItemName values -->
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
|
||||
<!-- list of dictionary names specified in the DictionaryGroup -->
|
||||
<!-- EMA will populate the Service::InfoFilter::DictionariesUsed element -->
|
||||
<!-- with the respective <>ItemName values -->
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<!-- list of QoS values supported by this service -->
|
||||
<!-- possible values are listed in the OmmQos.h file of the EMA -->
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::InexactDelayed"/>
|
||||
<Rate value="Rate::JustInTimeConflated"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<!-- 0 means does not support, 1 - means supports QoS range -->
|
||||
<SupportsQoSRange value="0"/>
|
||||
<!-- name of item list -->
|
||||
<ItemList value="#.itemlist"/>
|
||||
<!-- 0 means does not accept, 1 - means accepts consumer status -->
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<!-- 0 means does not support, 1 - means supports out of band snapshots -->
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<!-- StateFilter is optional -->
|
||||
<!-- EMA will default the values as follows: -->
|
||||
<!-- for interactive provider -->
|
||||
<!-- - ServiceState is "up" and AcceptingRequests is "Yes" -->
|
||||
<!-- for non interactive provider -->
|
||||
<!-- - ServiceState is "up" and AcceptingRequests is "No" -->
|
||||
<StateFilter>
|
||||
<!-- 0 means service is down, 1 - means service is up (default; 1) -->
|
||||
<ServiceState value="1"/>
|
||||
<!-- 0 means service does not accept, 1 - means service accepts (default; 1) -->
|
||||
<AcceptingRequests value="1"/>
|
||||
<!-- optional; specifies status change to apply to all items provided by this service -->
|
||||
<!-- possible values are listed in the OmmState.h file of the EMA -->
|
||||
<Status>
|
||||
<!-- possible values are: Open, Close, CloseRecover -->
|
||||
<StreamState value="StreamState::Open"/>
|
||||
<!-- possibe values are: NoChange, Ok, Suspect -->
|
||||
<DataState value="DataState::Ok"/>
|
||||
<!-- possible values are: None, DacsDown, etc -->
|
||||
<StatusCode value="StatusCode::None"/>
|
||||
<!-- a text field -->
|
||||
<StatusText value=""/>
|
||||
</Status>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
<Service>
|
||||
<Name value="NI_PUB"/>
|
||||
<InfoFilter>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<Vendor value="company name"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="6"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
</Capabilities>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
<Status>
|
||||
<StreamState value="StreamState::Open"/>
|
||||
<DataState value="DataState::Ok"/>
|
||||
<StatusCode value="StatusCode::None"/>
|
||||
<StatusText value=""/>
|
||||
</Status>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
</Directory>
|
||||
<Directory>
|
||||
<Name value="Directory_2"/>
|
||||
<Service>
|
||||
<Name value="DIRECT_FEED"/>
|
||||
<InfoFilter>
|
||||
<ServiceId value="1"/>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<Vendor value="company name"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="6"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_PRICE"/>
|
||||
<CapabilitiesEntry value="MMT_DICTIONARY"/>
|
||||
<CapabilitiesEntry value="200"/>
|
||||
</Capabilities>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
<QoSEntry>
|
||||
<Timeliness value="100"/>
|
||||
<Rate value="100"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
</Directory>
|
||||
<Directory>
|
||||
<Name value="Directory_3"/>
|
||||
<Service>
|
||||
<Name value="TEST_NI_PUB"/>
|
||||
<InfoFilter>
|
||||
<ServiceId value="11"/>
|
||||
<Vendor value="company name"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="MMT_MARKET_PRICE"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
</Capabilities>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::InexactDelayed"/>
|
||||
<Rate value="Rate::JustInTimeConflated"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
<Status>
|
||||
<StreamState value="StreamState::Open"/>
|
||||
<DataState value="DataState::Ok"/>
|
||||
<StatusCode value="StatusCode::None"/>
|
||||
<StatusText value=""/>
|
||||
</Status>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
<Service>
|
||||
<Name value="NI_PUB"/>
|
||||
<InfoFilter>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
|
||||
<Vendor value="company name"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="6"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
</Capabilities>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
<Status>
|
||||
<StreamState value="StreamState::Open"/>
|
||||
<DataState value="DataState::Ok"/>
|
||||
<StatusCode value="StatusCode::None"/>
|
||||
<StatusText value=""/>
|
||||
</Status>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
</Directory>
|
||||
|
||||
<Directory>
|
||||
<Name value="Directory_4"/>
|
||||
<Service>
|
||||
<Name value="DIRECT_FEED"/>
|
||||
<InfoFilter>
|
||||
<ServiceId value="1"/>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<Vendor value="company name"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="6"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_PRICE"/>
|
||||
<CapabilitiesEntry value="MMT_DICTIONARY"/>
|
||||
<CapabilitiesEntry value="200"/>
|
||||
</Capabilities>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
<QoSEntry>
|
||||
<Timeliness value="100"/>
|
||||
<Rate value="100"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
</Directory>
|
||||
<Directory>
|
||||
<Name value="Perf_Directory_1"/>
|
||||
<Service>
|
||||
<Name value="NI_PUB"/>
|
||||
<InfoFilter>
|
||||
<ServiceId value="1"/>
|
||||
<DictionariesProvided>
|
||||
<DictionariesProvidedEntry value="Dictionary_3"/>
|
||||
</DictionariesProvided>
|
||||
<DictionariesUsed>
|
||||
<DictionariesUsedEntry value="Dictionary_3"/>
|
||||
</DictionariesUsed>
|
||||
<Vendor value="RefinitivDevTestLab"/>
|
||||
<IsSource value="0"/>
|
||||
<Capabilities>
|
||||
<CapabilitiesEntry value="MMT_DICTIONARY"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_PRICE"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_ORDER"/>
|
||||
<CapabilitiesEntry value="MMT_MARKET_BY_PRICE"/>
|
||||
<CapabilitiesEntry value="200"/>
|
||||
</Capabilities>
|
||||
<QoS>
|
||||
<QoSEntry>
|
||||
<Timeliness value="Timeliness::RealTime"/>
|
||||
<Rate value="Rate::TickByTick"/>
|
||||
</QoSEntry>
|
||||
<QoSEntry>
|
||||
<Timeliness value="100"/>
|
||||
<Rate value="100"/>
|
||||
</QoSEntry>
|
||||
</QoS>
|
||||
<SupportsQoSRange value="0"/>
|
||||
<ItemList value="#.itemlist"/>
|
||||
<AcceptingConsumerStatus value="0"/>
|
||||
<SupportsOutOfBandSnapshots value="0"/>
|
||||
</InfoFilter>
|
||||
<StateFilter>
|
||||
<ServiceState value="1"/>
|
||||
<AcceptingRequests value="1"/>
|
||||
</StateFilter>
|
||||
</Service>
|
||||
</Directory>
|
||||
</DirectoryList>
|
||||
</DirectoryGroup>
|
||||
<DictionaryGroup>
|
||||
<DictionaryList>
|
||||
<Dictionary>
|
||||
<Name value="Dictionary_1"/>
|
||||
<!-- dictionaryType is optional: defaulted to ChannelDictionary" -->
|
||||
<!-- possible values: ChannelDictionary, FileDictionary -->
|
||||
<!-- if dictionaryType is set to ChannelDictionary, file names are ignored -->
|
||||
<DictionaryType value="DictionaryType::ChannelDictionary"/>
|
||||
</Dictionary>
|
||||
<Dictionary>
|
||||
<Name value="Dictionary_2"/>
|
||||
<DictionaryType value="DictionaryType::FileDictionary"/>
|
||||
<!-- dictionary names are optional: defaulted to RDMFieldDictionary and enumtype.def -->
|
||||
<RdmFieldDictionaryFileName value="./RDMFieldDictionary"/>
|
||||
<EnumTypeDefFileName value="./enumtype.def"/>
|
||||
</Dictionary>
|
||||
<Dictionary>
|
||||
<Name value="Dictionary_3"/>
|
||||
<!-- providers always assume DictionaryType = DictionaryType::FileDictionary -->
|
||||
<DictionaryType value="DictionaryType::FileDictionary"/>
|
||||
<!-- dictionary file names are optional: defaulted to ./RDMFieldDictionary and ./enumtype.def -->
|
||||
<RdmFieldDictionaryFileName value="./RDMFieldDictionary"/>
|
||||
<EnumTypeDefFileName value="./enumtype.def"/>
|
||||
<!-- <dictionary>ItemName represents the names shown in DictionariesProvided and DictionariesUsed
|
||||
elements of the Directory InfoFilter -->
|
||||
<!-- <dictionary>ItemName is optional; default values are "RWFFld" for the RdmFieldDictionary
|
||||
and "RWFEnum" for the enumtype.def -->
|
||||
<RdmFieldDictionaryItemName value="RWFFld"/>
|
||||
<EnumTypeDefItemName value="RWFEnum"/>
|
||||
</Dictionary>
|
||||
</DictionaryList>
|
||||
</DictionaryGroup>
|
||||
</EmaConfig>
|
||||
@@ -3,9 +3,9 @@ spring:
|
||||
show-sql: true
|
||||
# Redis配置
|
||||
redis:
|
||||
host: lb-b6sze686-7db6hgvsx05ef8nz.clb.sg-tencentclb.net
|
||||
password: a5v8b86P4mVzFlUqJV
|
||||
port: 56379
|
||||
host: 149.88.86.7
|
||||
password: ruTZ9J3gaDhknJ
|
||||
port: 36379
|
||||
database: 1
|
||||
lettuce:
|
||||
pool:
|
||||
@@ -17,9 +17,9 @@ spring:
|
||||
datasource:
|
||||
stock-market:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://lb-1ju43bvw-p0ecnv4by9ju8six.clb.ap-singapore.tencentclb.com:53306/india_stock?useUnicode=true&characterEncoding=utf-8
|
||||
url: jdbc:mysql://149.88.86.7:33306/india_stock?useUnicode=true&characterEncoding=utf-8
|
||||
username: root
|
||||
password: uNejHIFQGJOUtYTmE
|
||||
password: 33BsUUcnXRYgwtIND
|
||||
maxActive: 500
|
||||
testWhileIdle: true
|
||||
validationQuery: SELECT 1
|
||||
@@ -59,3 +59,16 @@ news:
|
||||
src: eastmoney
|
||||
token: f86299eb129c44545eb8ff53d64902353225652efe63cc4dc95f8936
|
||||
fields: content,channels
|
||||
|
||||
refinitiv:
|
||||
market-data:
|
||||
service-name: ELEKTRON_DD
|
||||
username: GE-A-10288435-3-15856
|
||||
password: 8EyCWDQ%XITcGRM@RhKokxX05FZJe1
|
||||
clientId: 662b37b071144c9f8f2507d93037a019a010ae0e
|
||||
batch-request-timeout: 60000
|
||||
token:
|
||||
username: GE-A-10288435-3-16229
|
||||
password: Pyc^U)D9k-u))N8n+M3zYa=,+CoQujkvjizR
|
||||
appKey: 87aa0e9fcb034b2aa63344bc41cc3a3f8aeadd6c
|
||||
url: https://api.refinitiv.com/auth/oauth2/v1/token
|
||||
@@ -69,3 +69,10 @@ swagger:
|
||||
enable: true
|
||||
username: admin
|
||||
password: 123321
|
||||
refinitiv:
|
||||
market-data:
|
||||
service-name: ELEKTRON_DD
|
||||
username: GE-A-10288435-3-15856
|
||||
password: 8EyCWDQ%XITcGRM@RhKokxX05FZJe1
|
||||
clientId: 662b37b071144c9f8f2507d93037a019a010ae0e
|
||||
batch-request-timeout: 60000
|
||||
@@ -1,5 +1,5 @@
|
||||
server:
|
||||
port: 8188
|
||||
port: 8189
|
||||
spring:
|
||||
application:
|
||||
name: stock-market
|
||||
|
||||
@@ -31,9 +31,9 @@ public class JpaDDDGen {
|
||||
*/
|
||||
public static DataSource getMySQLDataSource() {
|
||||
MysqlDataSource mysqlDS = new MysqlDataSource();
|
||||
mysqlDS.setURL("jdbc:mysql://43.132.212.180:33306/india_stock?useUnicode=true&characterEncoding=utf-8");
|
||||
mysqlDS.setURL("jdbc:mysql://149.88.86.7:33306/india_stock?useUnicode=true&characterEncoding=utf-8");
|
||||
mysqlDS.setUser("root");
|
||||
mysqlDS.setPassword("33BsUUcnXRYgwt");
|
||||
mysqlDS.setPassword("33BsUUcnXRYgwtIND");
|
||||
return mysqlDS;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class JpaDDDGen {
|
||||
/**
|
||||
* cs_statistic - 要生成的数据库表
|
||||
*/
|
||||
Cons.tableNameToEntiyMapping.put("money_stock", null);
|
||||
Cons.tableNameToEntiyMapping.put("twelve_stock", null);
|
||||
|
||||
ToolDDD.g(getMySQLDataSource().getConnection());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user