@steerprotocol/app-loader 0.0.8 → 0.0.9

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/lib/index.js +17 -6
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -216,13 +216,18 @@ function instantiate(module, imports = {}) {
216
216
  }
217
217
  }
218
218
  function generateCandles(data, candleSize) {
219
- if (data[0] === undefined || Object.keys(data[0]).length === 0) {
219
+ const _data = data.map((point) => {
220
+ return Object.assign(Object.assign({}, point), {
221
+ // This will convert the timestamp to milliseconds if it's in seconds
222
+ timestamp: point.timestamp && String(point.timestamp).length == 10 ? point.timestamp * 1000 : point.timestamp });
223
+ });
224
+ if (_data[0] === undefined || Object.keys(_data[0]).length === 0) {
220
225
  return [];
221
226
  }
222
227
  const series = (0, pondjs_1.timeSeries)({
223
228
  name: 'candles',
224
- columns: [...Object.keys(data[0])],
225
- points: data.map((point) => {
229
+ columns: [...Object.keys(_data[0])],
230
+ points: _data.map((point) => {
226
231
  return [...Object.values(point)].map(value => Number(value));
227
232
  }),
228
233
  });
@@ -234,12 +239,18 @@ function instantiate(module, imports = {}) {
234
239
  low: ['price', (0, pondjs_1.min)()],
235
240
  close: ['price', (0, pondjs_1.last)()],
236
241
  open: ['price', (0, pondjs_1.first)()],
237
- volume: ['volume', (0, pondjs_1.sum)()],
242
+ volume: ['volume', (values) => {
243
+ const cleanValues = pondjs_1.filter.ignoreMissing(values);
244
+ if (!cleanValues) {
245
+ return 0;
246
+ }
247
+ return cleanValues.reduce((a, b) => Math.abs(a) + Math.abs(b), 0);
248
+ }],
238
249
  },
239
250
  })
240
251
  .fill({
241
- fieldSpec: 'value',
242
- method: 2,
252
+ fieldSpec: 'price',
253
+ method: types_1.FillMethod.Pad,
243
254
  });
244
255
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
245
256
  // @ts-ignore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steerprotocol/app-loader",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "App Loader for Steer Protocol",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",