feat:印度热门股票列表
This commit is contained in:
@@ -195,6 +195,42 @@ public class InvestingApis {
|
||||
return page;
|
||||
}
|
||||
|
||||
public PageInfo<IndiaStockVO> page_nifty100(int currPage, int pageSize) throws IOException {
|
||||
JSONObject json = InvestingInvokerApis.of().__page_nifty100(currPage, pageSize);
|
||||
|
||||
int totalPages = (json.getIntValue("total") / json.getIntValue("pageSize")) + 1;
|
||||
log.info("总页码数: {}", totalPages);
|
||||
|
||||
List<IndiaStockVO> items = json.getJSONArray("data").stream().map(val -> {
|
||||
JSONObject j = (JSONObject) val;
|
||||
IndiaStockVO vo = new IndiaStockVO();
|
||||
vo.setName(j.getString("Name"));
|
||||
vo.setCname(j.getString("Name"));
|
||||
vo.setCode(j.getString("Symbol"));
|
||||
vo.setIsLock(0);
|
||||
vo.setIsShow(0);
|
||||
vo.setNowPrice(numberToString(j.getString("Last")));
|
||||
vo.setOpen("--");
|
||||
vo.setClose("--");
|
||||
vo.setNumber(numberToString(j.getString("Chg")));
|
||||
vo.setRate(numberToString(j.getString("ChgPct")));
|
||||
vo.setHigh(numberToString(j.getString("High")));
|
||||
vo.setLow(numberToString(j.getString("Low")));
|
||||
vo.setUrl(numberToString(j.getString("Url")));
|
||||
vo.setTargetId(j.getString("Id"));
|
||||
vo.setType("印度");
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
PageInfo<IndiaStockVO> page = new PageInfo<>();
|
||||
page.setPageNum(currPage);
|
||||
page.setPageSize(pageSize);
|
||||
page.setTotal(json.getIntValue("total"));
|
||||
page.setPages(totalPages);
|
||||
page.setList(items);
|
||||
return page;
|
||||
}
|
||||
|
||||
public List<IndiaStockVO> thirdIndiaList() throws IOException {
|
||||
List<IndiaStockVO> list = Lists.newArrayList();
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
|
||||
@@ -125,6 +125,26 @@ public class InvestingInvokerApis {
|
||||
log.info("第{}页码, 耗时: {} 毫秒, 返回原始值: {}, 准备解析中.", pageNum, stopwatch.elapsed(TimeUnit.MILLISECONDS), body);
|
||||
return JSON.parseObject(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 与 __page 的区别
|
||||
* api/financialdata/assets/equitiesByCountry/default
|
||||
* api/financialdata/assets/equitiesByCountry/17943
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public JSONObject __page_nifty100(int pageNum, int pageSize) throws IOException {
|
||||
String tmpl = "https://api.investing.com/api/financialdata/assets/equitiesByCountry/17943?fields-list=id,name,symbol,high,low,last,lastPairDecimal,change,changePercent,volume,time,isOpen,url,flag,countryNameTranslated,exchangeId,performanceDay,performanceWeek,performanceMonth,performanceYtd,performanceYear,performance3Year,technicalHour,technicalDay,technicalWeek,technicalMonth,avgVolume,fundamentalMarketCap,fundamentalRevenue,fundamentalRatio,fundamentalBeta,pairType&country-id=14&page={}&page-size={}&include-major-indices=false&include-additional-indices=false&include-primary-sectors=false&include-other-indices=false&limit=0";
|
||||
String url = StrFormatter.format(tmpl, pageNum, pageSize);
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
log.info("url: {}", url);
|
||||
Builder builder = builderGet(url);
|
||||
String body = httpClient().newCall(builder.build()).execute().body().string();
|
||||
log.info("第{}页码, 耗时: {} 毫秒, 返回原始值: {}, 准备解析中.", pageNum, stopwatch.elapsed(TimeUnit.MILLISECONDS), body);
|
||||
return JSON.parseObject(body);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -137,6 +137,13 @@ public class StockApiController {
|
||||
public ServerResponse getINDStockList(@RequestParam("pageSize") Integer pageSize, @RequestParam("pageNum") Integer pageNum) throws IOException {
|
||||
return ServerResponse.createBySuccess(InvestingInvokerApis.of().__page(pageNum, pageSize));
|
||||
}
|
||||
|
||||
@RequestMapping({"getTopINDStockList.do"})
|
||||
@ApiOperation(value = "印度热门股票列表", httpMethod = "GET")
|
||||
@ResponseBody
|
||||
public ServerResponse getTopINDStockList(@RequestParam("pageSize") Integer pageSize, @RequestParam("pageNum") Integer pageNum) throws IOException {
|
||||
return ServerResponse.createBySuccess(InvestingInvokerApis.of().__page_nifty100(pageNum, pageSize));
|
||||
}
|
||||
|
||||
//印度股票时线-K线
|
||||
@RequestMapping({"getINDTimeK.do"})
|
||||
|
||||
Reference in New Issue
Block a user