@steerprotocol/strategy-utils 0.0.1 → 0.0.2
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.
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { JSON } from "assemblyscript-json";
|
|
2
|
+
|
|
3
|
+
export class Price {
|
|
4
|
+
constructor(
|
|
5
|
+
public high: f32,
|
|
6
|
+
public low: f32,
|
|
7
|
+
public open: f32,
|
|
8
|
+
public close: f32
|
|
9
|
+
) {}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const parsePrices = (_prices: String): Array<JSON.Value> => {
|
|
13
|
+
const prices = _prices;
|
|
14
|
+
// Parse an object using the JSON object
|
|
15
|
+
let jsonObj: JSON.Obj = <JSON.Obj>JSON.parse(prices);
|
|
16
|
+
|
|
17
|
+
const val = jsonObj.getValue("data");
|
|
18
|
+
if (val != null) {
|
|
19
|
+
if (val.isArr) {
|
|
20
|
+
const pricesArray = (<JSON.Arr>val).valueOf();
|
|
21
|
+
return pricesArray;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return [];
|
|
25
|
+
};
|
package/assembly/utils/Ranges.ts
CHANGED
package/assembly/utils/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Price';
|