@watsonserve/stock-base 0.0.28 → 0.0.30

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.
Files changed (2) hide show
  1. package/index.js +8 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -19,7 +19,7 @@ export class StockLoader extends DividendLoader {
19
19
  end += A_DAY_S;
20
20
  }
21
21
  // recording to SG calendar, we will move it to next day(Monday, 1) if holiday is Sunday(0)
22
- if (!new Date(start).getUTCDay()) {
22
+ if (!new Date(start * 1000).getUTCDay()) {
23
23
  end += A_DAY_S;
24
24
  }
25
25
  const firstOne = pre[0];
@@ -29,11 +29,11 @@ export class StockLoader extends DividendLoader {
29
29
  }, []);
30
30
  }
31
31
  async loadHolidaysHK() {
32
- const resp = await fetch('https://www.hkex.com.hk/News/HKEX-Calendar/Subscribe-Calendar?sc_lang=zh-HK');
32
+ const resp = await fetch('https://www.hkex.com.hk/News/HKEX-Calendar/Subscribe-Calendar?sc_lang=en');
33
33
  const text = (await resp.text()).replace(/\r\n/g, '\n').replace(/\n\n/g, '\n'); // handle line folding
34
34
  return text.split('\nEND:VEVENT\nBEGIN:VEVENT\n').reduce((pre, blk) => {
35
35
  const ev = new Map(blk.split('\n').map(line => line.split(':', 2)));
36
- if ('香港市場休市' !== ev.get('DESCRIPTION'))
36
+ if (!['香港市場休市', 'Hong Kong Market is closed'].includes(ev.get('DESCRIPTION') || ''))
37
37
  return pre;
38
38
  const start = parseUTCDate(ev.get('DTSTART;VALUE=DATE') || '');
39
39
  let end = parseUTCDate(ev.get('DTEND;VALUE=DATE') || '');
@@ -45,7 +45,11 @@ export class StockLoader extends DividendLoader {
45
45
  lastOne.end = end;
46
46
  }
47
47
  else {
48
- pre.push({ market: 'HK', title: ev.get('SUMMARY') || '', start, end });
48
+ let title = ev.get('SUMMARY') || '';
49
+ if (title.startsWith('香港公眾假期 - ') || title.startsWith('Hong Kong Public Holidays - ')) {
50
+ title = title.split(' - ')[1];
51
+ }
52
+ pre.push({ market: 'HK', title: title, start, end });
49
53
  }
50
54
  return pre;
51
55
  }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@watsonserve/stock-base",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "index.js",