@watsonserve/stock-base 0.0.26 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,6 @@ function toDivPoint(fullNc, div) {
11
11
  paid: ~~(paid.getTime() / 1000)
12
12
  };
13
13
  }
14
- const rxDate = /\d+/g;
15
14
  export class DividendLoader extends PriceLoader {
16
15
  async __laodIbmCode(nc) {
17
16
  const resp = await super.get(`https://api.sgx.com/marketmetadata/v2?stock-code=${nc}`);
@@ -28,9 +27,6 @@ export class DividendLoader extends PriceLoader {
28
27
  const list = [];
29
28
  for (const item of entitlementlist) {
30
29
  const { detail, announcement_date, ex_date, payment_date, announcement_URL } = item;
31
- const announcement_ymd = announcement_date.match(rxDate).slice(0, 3);
32
- const ex_ymd = ex_date.match(rxDate)?.slice(0, 3);
33
- const payment_ymd = payment_date.match(rxDate)?.slice(0, 3);
34
30
  const divid = Array.from(detail.match(/(USD|HKD|GBP) (\d+\.\d+)/g) || [])
35
31
  .reduce((pre, item) => {
36
32
  const [currency, amount] = item.split(' ');
@@ -39,9 +35,9 @@ export class DividendLoader extends PriceLoader {
39
35
  }, {});
40
36
  list.push({
41
37
  ...(divid['HKD'] || divid['USD'] || divid['GBP']),
42
- annc: new Date(Date.UTC.apply(null, announcement_ymd)),
43
- ex: ex_ymd && new Date(Date.UTC.apply(null, ex_ymd)) || null,
44
- paid: payment_ymd && new Date(Date.UTC.apply(null, payment_ymd)) || null,
38
+ annc: new Date(announcement_date.substring(0, 10)),
39
+ ex: new Date(ex_date.substring(0, 10)),
40
+ paid: new Date(payment_date.substring(0, 10)),
45
41
  announcement_URL
46
42
  });
47
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@watsonserve/stock-base",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "index.js",