新增印度股票行情接口
This commit is contained in:
@@ -10,7 +10,7 @@ import java.util.Objects;
|
|||||||
import javax.persistence.EntityExistsException;
|
import javax.persistence.EntityExistsException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import cn.stock.market.dto.model.HKStockNewInfo;
|
import cn.stock.market.dto.model.*;
|
||||||
import cn.stock.market.infrastructure.api.sina.vo.HotSearchVO;
|
import cn.stock.market.infrastructure.api.sina.vo.HotSearchVO;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
@@ -37,9 +37,6 @@ import cn.qutaojing.common.utils.SpringUtils;
|
|||||||
import cn.stock.market.domain.basic.entity.Stock;
|
import cn.stock.market.domain.basic.entity.Stock;
|
||||||
import cn.stock.market.domain.basic.factory.StockFactory;
|
import cn.stock.market.domain.basic.factory.StockFactory;
|
||||||
import cn.stock.market.domain.basic.repository.StockRepository;
|
import cn.stock.market.domain.basic.repository.StockRepository;
|
||||||
import cn.stock.market.dto.model.StockAdminListVO;
|
|
||||||
import cn.stock.market.dto.model.StockListVO;
|
|
||||||
import cn.stock.market.dto.model.StockVO;
|
|
||||||
import cn.stock.market.infrastructure.api.qq.QqStockApi;
|
import cn.stock.market.infrastructure.api.qq.QqStockApi;
|
||||||
import cn.stock.market.infrastructure.api.sina.SinaStockApi;
|
import cn.stock.market.infrastructure.api.sina.SinaStockApi;
|
||||||
import cn.stock.market.infrastructure.api.sina.vo.MarketVO;
|
import cn.stock.market.infrastructure.api.sina.vo.MarketVO;
|
||||||
@@ -71,6 +68,8 @@ public class StockService {
|
|||||||
final StockFactory factory;
|
final StockFactory factory;
|
||||||
final RestTemplate restTemplate;
|
final RestTemplate restTemplate;
|
||||||
|
|
||||||
|
String apikey = "VF7SHRYOFIYHCIKE";
|
||||||
|
|
||||||
public ServerResponse getMarket() {
|
public ServerResponse getMarket() {
|
||||||
String market_url = "https://hq.sinajs.cn/rn=1520407404627&list=s_sh000001,s_sz399001,s_sz399006,s_sz399300,s_sz399005,s_sz399673,s_sz399106,s_sz399004,s_sz399100";
|
String market_url = "https://hq.sinajs.cn/rn=1520407404627&list=s_sh000001,s_sz399001,s_sz399006,s_sz399300,s_sz399005,s_sz399673,s_sz399106,s_sz399004,s_sz399100";
|
||||||
String result = null;
|
String result = null;
|
||||||
@@ -598,6 +597,93 @@ public class StockService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//印度股票个股详情
|
||||||
|
public ServerResponse getStockInfo(String stockCode) {
|
||||||
|
String sina_result = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
INDStockInfo indStockInfo = new INDStockInfo();
|
||||||
|
sina_result = HttpClientRequest.doGet("https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol="+stockCode+"&apikey="+apikey);
|
||||||
|
JSONObject json = JSONObject.parseObject(sina_result).getJSONObject("Global Quote");
|
||||||
|
|
||||||
|
indStockInfo.setSymbol(json.getString("01. symbol"));
|
||||||
|
indStockInfo.setOpen(json.getString("02. open"));
|
||||||
|
indStockInfo.setHigh(json.getString("03. high"));
|
||||||
|
indStockInfo.setLow(json.getString("04. low"));
|
||||||
|
indStockInfo.setPrice(json.getString("05. price"));
|
||||||
|
indStockInfo.setVolume(json.getString("06. volume"));
|
||||||
|
indStockInfo.setClose(json.getString("08. previous close"));
|
||||||
|
indStockInfo.setChange(json.getString("09. change"));
|
||||||
|
indStockInfo.setPercent(json.getString("10. change percent"));
|
||||||
|
return ServerResponse.createBySuccess(indStockInfo);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取出错,错误信息 = {}", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//印度股票时线-K线
|
||||||
|
public ServerResponse getTimeK(String stockCode) {
|
||||||
|
String sina_result = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
sina_result = HttpClientRequest.doGet("https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol="+stockCode+"&interval=5min&apikey="+apikey);
|
||||||
|
JSONObject json = JSONObject.parseObject(sina_result).getJSONObject("Time Series (Daily)");
|
||||||
|
|
||||||
|
return ServerResponse.createBySuccess(json);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取出错,错误信息 = {}", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//印度股票日线-K线
|
||||||
|
public ServerResponse getDayK(String stockCode) {
|
||||||
|
String sina_result = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
sina_result = HttpClientRequest.doGet("https://www.alphavantage.co/query?function=TIME_SERIES_DAILY_ADJUSTED&symbol="+stockCode+"&outputsize=full&apikey="+apikey);
|
||||||
|
JSONObject json = JSONObject.parseObject(sina_result).getJSONObject("Time Series (Daily)");
|
||||||
|
|
||||||
|
return ServerResponse.createBySuccess(json);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取出错,错误信息 = {}", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//印度股票周线-K线
|
||||||
|
public ServerResponse getWeekK(String stockCode) {
|
||||||
|
String sina_result = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
sina_result = HttpClientRequest.doGet("https://www.alphavantage.co/query?function=TIME_SERIES_WEEKLY&symbol="+stockCode+"&apikey="+apikey);
|
||||||
|
JSONObject json = JSONObject.parseObject(sina_result).getJSONObject("Time Series (Daily)");
|
||||||
|
|
||||||
|
return ServerResponse.createBySuccess(json);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取出错,错误信息 = {}", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//印度股票月线-K线
|
||||||
|
public ServerResponse getMonthK(String stockCode) {
|
||||||
|
String sina_result = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
sina_result = HttpClientRequest.doGet("https://www.alphavantage.co/query?function=TIME_SERIES_MONTHLY&symbol="+stockCode+"&apikey="+apikey);
|
||||||
|
JSONObject json = JSONObject.parseObject(sina_result).getJSONObject("Time Series (Daily)");
|
||||||
|
|
||||||
|
return ServerResponse.createBySuccess(json);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取出错,错误信息 = {}", e);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public ServerResponse getNewStockList() {
|
public ServerResponse getNewStockList() {
|
||||||
try {
|
try {
|
||||||
JSONObject jsonParam = new JSONObject();
|
JSONObject jsonParam = new JSONObject();
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package cn.stock.market.dto.model;
|
package cn.stock.market.dto.model;
|
||||||
|
|
||||||
|
import cn.stock.market.utils.HttpClientRequest;
|
||||||
import com.ag.utils.Jsons;
|
import com.ag.utils.Jsons;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
|
|||||||
30
src/main/java/cn/stock/market/dto/model/INDStockInfo.java
Normal file
30
src/main/java/cn/stock/market/dto/model/INDStockInfo.java
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package cn.stock.market.dto.model;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("香港新股信息")
|
||||||
|
public class INDStockInfo {
|
||||||
|
@ApiModelProperty("股票代码")
|
||||||
|
private String symbol;
|
||||||
|
@ApiModelProperty("开盘价")
|
||||||
|
private String open;
|
||||||
|
@ApiModelProperty("最高")
|
||||||
|
private String high;
|
||||||
|
@ApiModelProperty("最低")
|
||||||
|
private String low;
|
||||||
|
@ApiModelProperty("价格")
|
||||||
|
private String price;
|
||||||
|
@ApiModelProperty("成交量")
|
||||||
|
private String volume;
|
||||||
|
@ApiModelProperty("昨收")
|
||||||
|
private String close;
|
||||||
|
@ApiModelProperty("涨跌额")
|
||||||
|
private String change;
|
||||||
|
@ApiModelProperty("涨跌幅")
|
||||||
|
private String percent;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -114,6 +114,46 @@ public class StockApiController {
|
|||||||
return this.stockService.getNewStock();
|
return this.stockService.getNewStock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//印度股票个股详情
|
||||||
|
@RequestMapping({"getINDStockInfo.do"})
|
||||||
|
@ApiOperation(value = "印度股票个股详情", httpMethod = "GET")
|
||||||
|
@ResponseBody
|
||||||
|
public ServerResponse getINDStockInfo(@RequestParam("stockCode") String stockCode) {
|
||||||
|
return this.stockService.getStockInfo(stockCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//印度股票时线-K线
|
||||||
|
@RequestMapping({"getINDTimeK.do"})
|
||||||
|
@ApiOperation(value = "印度股票时线-K线", httpMethod = "GET")
|
||||||
|
@ResponseBody
|
||||||
|
public ServerResponse getINDTimeK(@RequestParam("stockCode") String stockCode) {
|
||||||
|
return this.stockService.getTimeK(stockCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//印度股票日线-K线
|
||||||
|
@RequestMapping({"getINDDayK.do"})
|
||||||
|
@ApiOperation(value = "印度股票日线-K线", httpMethod = "GET")
|
||||||
|
@ResponseBody
|
||||||
|
public ServerResponse getINDDayK(@RequestParam("stockCode") String stockCode) {
|
||||||
|
return this.stockService.getDayK(stockCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//印度股票周线-K线
|
||||||
|
@RequestMapping({"getINDWeekK.do"})
|
||||||
|
@ApiOperation(value = "印度股票周线-K线", httpMethod = "GET")
|
||||||
|
@ResponseBody
|
||||||
|
public ServerResponse getINDWeekK(@RequestParam("stockCode") String stockCode) {
|
||||||
|
return this.stockService.getWeekK(stockCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
//印度股票月线-K线
|
||||||
|
@RequestMapping({"getINDMonthK.do"})
|
||||||
|
@ApiOperation(value = "印度股票月线-K线", httpMethod = "GET")
|
||||||
|
@ResponseBody
|
||||||
|
public ServerResponse getINDMonthK(@RequestParam("stockCode") String stockCode) {
|
||||||
|
return this.stockService.getMonthK(stockCode);
|
||||||
|
}
|
||||||
|
|
||||||
//根据股票id查询 股票指数、大盘指数信息
|
//根据股票id查询 股票指数、大盘指数信息
|
||||||
@RequestMapping({"getMarketByStockGid.do"})
|
@RequestMapping({"getMarketByStockGid.do"})
|
||||||
@ApiOperation(value = "根据股票id查询 股票指数、大盘指数信息", httpMethod = "GET")
|
@ApiOperation(value = "根据股票id查询 股票指数、大盘指数信息", httpMethod = "GET")
|
||||||
|
|||||||
Reference in New Issue
Block a user