股票详情接口提供
This commit is contained in:
@@ -180,7 +180,7 @@ public class MoneyScraper {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
retryAttempts++;
|
||||
log.error(Thread.currentThread().getName()+",Exception during HTTP request: " +retryAttempts);
|
||||
log.error(Thread.currentThread().getName()+",Exception during HTTP request time: " +retryAttempts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
147
src/main/java/cn/stock/market/web/MoneyApiController.java
Normal file
147
src/main/java/cn/stock/market/web/MoneyApiController.java
Normal file
@@ -0,0 +1,147 @@
|
||||
package cn.stock.market.web;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* @author gs
|
||||
* @date 2024/1/4 10:25
|
||||
*/
|
||||
@RestController
|
||||
@Api(value = "/MoneyApiController", tags = "money股票行情")
|
||||
public class MoneyApiController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
|
||||
@ApiOperation(value = "股票详情信息",httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name="stockType",value = "BSE或者NSE"),
|
||||
@ApiImplicitParam(name="symbol",value = "scId值"),
|
||||
})
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "" +
|
||||
"HN: 公司的名称(हिन्दी में - Hindi)\n" +
|
||||
"HP: 当前股价\n" +
|
||||
"DISPID: 行业/部门代码\n" +
|
||||
"cl5yPerChange: 过去5年的百分比变化\n" +
|
||||
"BIDQ 和 BIDP: 买入报价和数量\n" +
|
||||
"newSubsector: 新的子部门\n" +
|
||||
"cl1mDt: 过去1个月的数据日期\n" +
|
||||
"P_C: 市盈率\n" +
|
||||
"YR: 年份\n" +
|
||||
"cl2yVal: 过去2年的数值\n" +
|
||||
"SC_SUBSEC: 子部门\n" +
|
||||
"sc_ttm_cons 和 SC_TTM: 市盈率\n" +
|
||||
"clYtdVal: 本年度截至目前的数值\n" +
|
||||
"cl6mDt: 过去6个月的数据日期\n" +
|
||||
"cl1wVal: 过去1周的数值\n" +
|
||||
"lastupd_epoch: 最后更新时间的 Epoch 时间戳\n" +
|
||||
"cl1mChange: 过去1个月的数值变化\n" +
|
||||
"cl3mChange: 过去3个月的数值变化\n" +
|
||||
"pricecurrent: 当前股价\n" +
|
||||
"150DayAvg: 过去150天的平均值\n" +
|
||||
"clYtdChange: 本年度截至目前的数值变化\n" +
|
||||
"tot_buy_qty: 总买入数量\n" +
|
||||
"clYtdDt: 本年度截至目前的数据日期\n" +
|
||||
"Group: 组别\n" +
|
||||
"ACCOD: 账户代码\n" +
|
||||
"cl3yDt: 过去3年的数据日期\n" +
|
||||
"LTHDate: 最高值的日期\n" +
|
||||
"cl3mDt: 过去3个月的数据日期\n" +
|
||||
"DYCONS: 息率\n" +
|
||||
"NSEID: NSE 股票代码\n" +
|
||||
"52H: 52周最高价\n" +
|
||||
"AvgDelVolPer_8day: 过去8天的平均成交量百分比\n" +
|
||||
"52L: 52周最低价\n" +
|
||||
"BV: 每股净值\n" +
|
||||
"MKTLOT: 市场手数\n" +
|
||||
"DVolAvg20: 过去20天的平均成交量\n" +
|
||||
"OFFERP 和 OFFERQ: 卖出报价和数量\n" +
|
||||
"cl6mVal: 过去6个月的数值\n" +
|
||||
"AvgVolQtyDel_20day: 过去20天的平均成交量数量\n" +
|
||||
"cl1mVal: 过去1个月的数值\n" +
|
||||
"PBCONS: 市净率\n" +
|
||||
"5DayAvg: 过去5天的平均值\n" +
|
||||
"AvgDelVolPer_3day: 过去3天的平均成交量百分比\n" +
|
||||
"sessionId: 会话ID\n" +
|
||||
"TID: 交易ID\n" +
|
||||
"SHRS: 股本总额\n" +
|
||||
"50DayAvg: 过去50天的平均值\n" +
|
||||
"cl3yChange: 过去3年的数值变化\n" +
|
||||
"im_scid: 未知字段\n" +
|
||||
"DVolAvg10: 过去10天的平均成交量\n" +
|
||||
"AvgVolQtyTraded_20day: 过去20天的平均成交量交易数量\n" +
|
||||
"symbol: 股票符号\n" +
|
||||
"LP: 最后价格\n" +
|
||||
"lower_circuit_limit 和 upper_circuit_limit: 跌停价和涨停价\n" +
|
||||
"ty: 未知字段\n" +
|
||||
"cl1wDt: 过去1周的数据日期\n" +
|
||||
"cl5yDt: 过去5年的数据日期\n" +
|
||||
"IND_PE: 行业市盈率\n" +
|
||||
"cl1yPerChange: 过去1年的百分比变化\n" +
|
||||
"cl3yVal: 过去3年的数值\n" +
|
||||
"52HDate: 52周最高价的日期\n" +
|
||||
"OPN: 开盘价\n" +
|
||||
"cl1mPerChange: 过去1个月的百分比变化\n" +
|
||||
"DTTIME: 交易时间\n" +
|
||||
"SC_FULLNM: 完整的行业/部门名称\n" +
|
||||
"DVolAvg5: 过去5天的平均成交量\n" +
|
||||
"LTLDate: 最低值的日期\n" +
|
||||
"DY: 息率\n" +
|
||||
"etf: 是否为ETF\n" +
|
||||
"clYtdPerChange: 本年度截至目前的百分比变化\n" +
|
||||
"isinid: ISIN 编号\n" +
|
||||
"cl2yDt: 过去2年的数据日期\n" +
|
||||
"slug: 股票的 slug\n" +
|
||||
"AvgDelVolPer_20day: 过去20天的平均成交量百分比\n" +
|
||||
"cl5yVal: 过去5年的数值\n" +
|
||||
"market_state: 市场状态\n" +
|
||||
"cl2yPerChange: 过去2年的百分比变化\n" +
|
||||
"pricechange: 价格变化\n" +
|
||||
"AvgDelVolPer_5day: 过去5天的平均成交量百分比\n" +
|
||||
"200DayAvg: 过去200天的平均值\n" +
|
||||
"VOL: 成交量\n" +
|
||||
"pricepercentchange: 价格百分比变化\n" +
|
||||
"exchange: 交易所\n" +
|
||||
"sc_mapindex: 行业/部门地图索引\n" +
|
||||
"DVolAvg30: 过去30天的平均成交量\n" +
|
||||
"cl1wChange: 过去1周的数值变化\n" +
|
||||
"AVGP: 平均价格\n" +
|
||||
"LTH: 最高价\n" +
|
||||
"cl3yPerChange: 过去3年的百分比变化\n" +
|
||||
"LTL: 最低价\n" +
|
||||
"cl3mPerChange: 过去3个月的百分比变化\n" +
|
||||
"PECONS: 市盈率\n" +
|
||||
"priceprevclose: 前一交易日的收盘价\n" +
|
||||
"30DayAvg: 过去30天的平均", response = JSONObject.class),
|
||||
})
|
||||
@GetMapping("/api/market/money/getStockDetail")
|
||||
@ResponseBody
|
||||
public JSONObject forwardRequest(@RequestParam String stockType, @RequestParam String symbol) {
|
||||
String url = String.format("https://priceapi.moneycontrol.com/pricefeed/%s/equitycash/%s",stockType,symbol);
|
||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, null, String.class);
|
||||
if (responseEntity.getStatusCode().value()==200&&responseEntity.getBody()!=null){
|
||||
return JSONObject.parseObject(responseEntity.getBody());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user