From 582e69b6b9127324c178bff8cc7d190eeca2af86 Mon Sep 17 00:00:00 2001 From: rplees Date: Tue, 5 Dec 2023 11:29:28 +0800 Subject: [PATCH 1/4] no message --- .../stock/market/infrastructure/api/investing/InvestingApis.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java b/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java index d53a99f..c735792 100644 --- a/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java +++ b/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java @@ -62,6 +62,7 @@ public class InvestingApis { vo.setName(pair_name_base); vo.setCname(pair_name_base); vo.setCode(pair_ID); + vo.setTargetId(pair_ID); String 昨收 = find_overview_table_value_with_key(overview_table, "昨收"); vo.setClose(numberToString(昨收)); From b58363ebb08edecaedbe074ca9bceb703fbc3d59 Mon Sep 17 00:00:00 2001 From: rplees Date: Tue, 5 Dec 2023 14:03:35 +0800 Subject: [PATCH 2/4] no message --- .../cn/stock/market/infrastructure/db/po/QStockPO.java | 4 ++-- .../market/infrastructure/api/investing/InvestingApis.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/generated/cn/stock/market/infrastructure/db/po/QStockPO.java b/src/main/generated/cn/stock/market/infrastructure/db/po/QStockPO.java index 90be42c..79fce48 100644 --- a/src/main/generated/cn/stock/market/infrastructure/db/po/QStockPO.java +++ b/src/main/generated/cn/stock/market/infrastructure/db/po/QStockPO.java @@ -33,7 +33,7 @@ public class QStockPO extends EntityPathBase { public final StringPath stockCode = createString("stockCode"); - public final NumberPath stockExchangeId = createNumber("stockExchangeId", Integer.class); + public final StringPath stockExchangeId = createString("stockExchangeId"); public final StringPath stockGid = createString("stockGid"); @@ -45,7 +45,7 @@ public class QStockPO extends EntityPathBase { public final NumberPath stockState = createNumber("stockState", Integer.class); - public final NumberPath stockSymbol = createNumber("stockSymbol", Integer.class); + public final StringPath stockSymbol = createString("stockSymbol"); public final StringPath stockType = createString("stockType"); diff --git a/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java b/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java index c735792..0720def 100644 --- a/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java +++ b/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java @@ -244,9 +244,9 @@ public class InvestingApis { item.put("volume", _ar.get(5)); return item; }).filter(val -> { -// if("min".equalsIgnoreCase(string)) { -// return DateUtil.isSameDay(nowDate, new Date(val.getLong("date"))); -// } + if("min".equalsIgnoreCase(string)) { + return DateUtil.isSameDay(nowDate, new Date(val.getLong("date"))); + } return true; }) .collect(Collectors.toList()) From 49f48ab3070576209ec22661c9f668bde465fcb5 Mon Sep 17 00:00:00 2001 From: rplees Date: Tue, 5 Dec 2023 14:30:47 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=E5=8D=B0=E5=BA=A6=E7=83=AD=E9=97=A8?= =?UTF-8?q?=E8=82=A1=E7=A5=A8=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/investing/InvestingApis.java | 36 +++++++++++++++++++ .../api/investing/InvestingInvokerApis.java | 20 +++++++++++ .../stock/market/web/StockApiController.java | 7 ++++ 3 files changed, 63 insertions(+) diff --git a/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java b/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java index 0720def..6bdcf45 100644 --- a/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java +++ b/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java @@ -195,6 +195,42 @@ public class InvestingApis { return page; } + public PageInfo 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 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 page = new PageInfo<>(); + page.setPageNum(currPage); + page.setPageSize(pageSize); + page.setTotal(json.getIntValue("total")); + page.setPages(totalPages); + page.setList(items); + return page; + } + public List thirdIndiaList() throws IOException { List list = Lists.newArrayList(); Stopwatch stopwatch = Stopwatch.createStarted(); diff --git a/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingInvokerApis.java b/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingInvokerApis.java index f8fbf3d..5627b1c 100644 --- a/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingInvokerApis.java +++ b/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingInvokerApis.java @@ -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); + } /** * diff --git a/src/main/java/cn/stock/market/web/StockApiController.java b/src/main/java/cn/stock/market/web/StockApiController.java index b259023..9b5f462 100644 --- a/src/main/java/cn/stock/market/web/StockApiController.java +++ b/src/main/java/cn/stock/market/web/StockApiController.java @@ -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"}) From a5ec41bb278efa55c4bfa7645eecd6845c90d13a Mon Sep 17 00:00:00 2001 From: rplees Date: Tue, 5 Dec 2023 15:06:53 +0800 Subject: [PATCH 4/4] no message --- .../api/investing/InvestingApis.java | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java b/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java index 6bdcf45..0720def 100644 --- a/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java +++ b/src/main/java/cn/stock/market/infrastructure/api/investing/InvestingApis.java @@ -195,42 +195,6 @@ public class InvestingApis { return page; } - public PageInfo 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 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 page = new PageInfo<>(); - page.setPageNum(currPage); - page.setPageSize(pageSize); - page.setTotal(json.getIntValue("total")); - page.setPages(totalPages); - page.setList(items); - return page; - } - public List thirdIndiaList() throws IOException { List list = Lists.newArrayList(); Stopwatch stopwatch = Stopwatch.createStarted();