@watsonserve/stock-base 0.0.18 → 0.0.20

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 (3) hide show
  1. package/dao.js +11 -2
  2. package/package.json +1 -1
  3. package/types/dao.d.ts +2 -0
package/dao.js CHANGED
@@ -45,7 +45,15 @@ export function toDivPoints(market, nc, data) {
45
45
  new Point('Dividend').tag('nc', `${nc}.${market}`).tag('type', 'paid').tag('currency', curr).floatField('amount', amount).timestamp(paid)
46
46
  ];
47
47
  }
48
- function groupBy(key, list, delKey = false) {
48
+ export function toBonusPoint(fullNc, data) {
49
+ const { ratio, ex } = data;
50
+ return new Point('Bonus')
51
+ .tag('nc', fullNc)
52
+ .tag('type', 'ex')
53
+ .floatField('radio', ratio)
54
+ .timestamp(ex);
55
+ }
56
+ export function groupBy(key, list, delKey = false) {
49
57
  return list.reduce((pre, item) => {
50
58
  const foo = item[key];
51
59
  const fooList = pre[foo] || [];
@@ -103,6 +111,7 @@ export class InfluxDAO {
103
111
  ${filters}
104
112
  |> last()
105
113
  |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")`;
114
+ // console.debug(fluxQuery);
106
115
  return new Promise((resolve, reject) => {
107
116
  const list = [];
108
117
  queryClient.queryRows(fluxQuery, {
@@ -147,7 +156,7 @@ export class InfluxDAO {
147
156
  });
148
157
  });
149
158
  }
150
- static ignore = new Set(['BRK.B']);
159
+ static ignore = new Set(['BRK.B.US', 'BRK_B.US']);
151
160
  async readDividend(ncs) {
152
161
  const divs = await this._readDividend(ncs);
153
162
  // const none = ncs.filter(nc => !divs[nc]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@watsonserve/stock-base",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "keywords": [],
package/types/dao.d.ts CHANGED
@@ -28,6 +28,8 @@ export declare function latestDay(): string;
28
28
  export declare function toFxPoint(sgd: number, hkd: number, cny: number, timestamp: number): Point;
29
29
  export declare function toStockPoint(market: EnMarket, st: IStock, timestamp: number): Point;
30
30
  export declare function toDivPoints(market: string, nc: string, data: IDividend): Point[];
31
+ export declare function toBonusPoint(fullNc: string, data: IDividend): Point;
32
+ export declare function groupBy<T extends Record<string, any>>(key: string, list: T[], delKey?: boolean): Record<string, T[]>;
31
33
  export declare class InfluxDAO {
32
34
  private origin;
33
35
  private org;