@steerprotocol/app-loader 0.1.5 → 0.2.0
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.
- package/lib/Candle.d.ts +12 -0
- package/lib/Candle.js +32 -0
- package/lib/RawTradeData.d.ts +6 -0
- package/lib/RawTradeData.js +11 -0
- package/lib/index.d.ts +18 -151
- package/lib/index.js +266 -274
- package/package.json +4 -2
package/lib/Candle.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class Candle {
|
|
2
|
+
timestamp: number;
|
|
3
|
+
high: number;
|
|
4
|
+
low: number;
|
|
5
|
+
open: number;
|
|
6
|
+
close: number;
|
|
7
|
+
volume: number;
|
|
8
|
+
constructor(timestamp: number, high: number, low: number, open: number, close: number, volume: number);
|
|
9
|
+
toString(): string;
|
|
10
|
+
}
|
|
11
|
+
export declare function encodeCandle(candle: Candle): Uint32Array;
|
|
12
|
+
export declare function decodeCandle(buffer: Uint32Array): Candle;
|
package/lib/Candle.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeCandle = exports.encodeCandle = exports.Candle = void 0;
|
|
4
|
+
class Candle {
|
|
5
|
+
constructor(timestamp, high, low, open, close, volume) {
|
|
6
|
+
this.timestamp = timestamp;
|
|
7
|
+
this.high = high;
|
|
8
|
+
this.low = low;
|
|
9
|
+
this.open = open;
|
|
10
|
+
this.close = close;
|
|
11
|
+
this.volume = volume;
|
|
12
|
+
}
|
|
13
|
+
toString() {
|
|
14
|
+
return JSON.stringify(this);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Candle = Candle;
|
|
18
|
+
function encodeCandle(candle) {
|
|
19
|
+
return new Uint32Array([
|
|
20
|
+
candle.timestamp,
|
|
21
|
+
candle.high,
|
|
22
|
+
candle.low,
|
|
23
|
+
candle.open,
|
|
24
|
+
candle.close,
|
|
25
|
+
candle.volume
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
exports.encodeCandle = encodeCandle;
|
|
29
|
+
function decodeCandle(buffer) {
|
|
30
|
+
return new Candle(buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
|
|
31
|
+
}
|
|
32
|
+
exports.decodeCandle = decodeCandle;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RawTradeData = void 0;
|
|
4
|
+
class RawTradeData {
|
|
5
|
+
constructor(timestamp, price, volume) {
|
|
6
|
+
this.timestamp = timestamp;
|
|
7
|
+
this.price = price;
|
|
8
|
+
this.volume = volume;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.RawTradeData = RawTradeData;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,162 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(timestamp: number, price: number, volume: number);
|
|
6
|
-
}
|
|
7
|
-
export declare class Candle {
|
|
8
|
-
timestamp: number;
|
|
9
|
-
high: number;
|
|
10
|
-
low: number;
|
|
11
|
-
open: number;
|
|
12
|
-
close: number;
|
|
13
|
-
volume: number;
|
|
14
|
-
constructor(timestamp: number, high: number, low: number, open: number, close: number, volume: number);
|
|
15
|
-
toString(): string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* assembly/index/initialize
|
|
19
|
-
* @param config `~lib/string/String`
|
|
20
|
-
*/
|
|
1
|
+
import { Candle } from './Candle';
|
|
2
|
+
import { RawTradeData } from './RawTradeData';
|
|
3
|
+
export { Candle, RawTradeData };
|
|
4
|
+
declare function responseHandler(body: ArrayBuffer, statusCode: number, redirected: number, callbackID: number): void;
|
|
21
5
|
declare function initialize(config: string): void;
|
|
22
|
-
/**
|
|
23
|
-
* assembly/index/execute
|
|
24
|
-
* @returns `~lib/string/String`
|
|
25
|
-
*/
|
|
26
|
-
declare function execute(): string;
|
|
27
|
-
/**
|
|
28
|
-
* assembly/index/execute
|
|
29
|
-
* @param param_1 `~lib/string/String`
|
|
30
|
-
* @returns `~lib/string/String`
|
|
31
|
-
*/
|
|
32
|
-
declare function execute(param_1: string): string;
|
|
33
|
-
/**
|
|
34
|
-
* assembly/index/execute
|
|
35
|
-
* @param param_1 `~lib/string/String`
|
|
36
|
-
* @param param_2 `~lib/string/String`
|
|
37
|
-
* @returns `~lib/string/String`
|
|
38
|
-
*/
|
|
39
|
-
declare function execute(param_1: string, param_2: string): string;
|
|
40
|
-
/**
|
|
41
|
-
* assembly/index/execute
|
|
42
|
-
* @param param_1 `~lib/string/String`
|
|
43
|
-
* @param param_2 `~lib/string/String`
|
|
44
|
-
* @param param_3 `~lib/string/String`
|
|
45
|
-
* @returns `~lib/string/String`
|
|
46
|
-
*/
|
|
47
|
-
declare function execute(param_1: string, param_2: string, param_3: string): string;
|
|
48
|
-
/**
|
|
49
|
-
* assembly/index/execute
|
|
50
|
-
* @param param_1 `~lib/string/String`
|
|
51
|
-
* @param param_2 `~lib/string/String`
|
|
52
|
-
* @param param_3 `~lib/string/String`
|
|
53
|
-
* @param param_4 `~lib/string/String`
|
|
54
|
-
* @returns `~lib/string/String`
|
|
55
|
-
*/
|
|
56
|
-
declare function execute(param_1: string, param_2: string, param_3: string, param_4: string): string;
|
|
57
|
-
/**
|
|
58
|
-
* assembly/index/execute
|
|
59
|
-
* @param param_1 `~lib/string/String`
|
|
60
|
-
* @param param_2 `~lib/string/String`
|
|
61
|
-
* @param param_3 `~lib/string/String`
|
|
62
|
-
* @param param_4 `~lib/string/String`
|
|
63
|
-
* @param param_5 `~lib/string/String`
|
|
64
|
-
* @returns `~lib/string/String`
|
|
65
|
-
*/
|
|
66
|
-
declare function execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string): string;
|
|
67
|
-
/**
|
|
68
|
-
* assembly/index/execute
|
|
69
|
-
* @param param_1 `~lib/string/String`
|
|
70
|
-
* @param param_2 `~lib/string/String`
|
|
71
|
-
* @param param_3 `~lib/string/String`
|
|
72
|
-
* @param param_4 `~lib/string/String`
|
|
73
|
-
* @param param_5 `~lib/string/String`
|
|
74
|
-
* @param param_6 `~lib/string/String`
|
|
75
|
-
* @returns `~lib/string/String`
|
|
76
|
-
*/
|
|
77
|
-
declare function execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string): string;
|
|
78
|
-
/**
|
|
79
|
-
* assembly/index/execute
|
|
80
|
-
* @param param_1 `~lib/string/String`
|
|
81
|
-
* @param param_2 `~lib/string/String`
|
|
82
|
-
* @param param_3 `~lib/string/String`
|
|
83
|
-
* @param param_4 `~lib/string/String`
|
|
84
|
-
* @param param_5 `~lib/string/String`
|
|
85
|
-
* @param param_6 `~lib/string/String`
|
|
86
|
-
* @param param_7 `~lib/string/String`
|
|
87
|
-
* @returns `~lib/string/String`
|
|
88
|
-
*/
|
|
89
|
-
declare function execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string): string;
|
|
90
|
-
/**
|
|
91
|
-
* assembly/index/execute
|
|
92
|
-
* @param param_1 `~lib/string/String`
|
|
93
|
-
* @param param_2 `~lib/string/String`
|
|
94
|
-
* @param param_3 `~lib/string/String`
|
|
95
|
-
* @param param_4 `~lib/string/String`
|
|
96
|
-
* @param param_5 `~lib/string/String`
|
|
97
|
-
* @param param_6 `~lib/string/String`
|
|
98
|
-
* @param param_7 `~lib/string/String`
|
|
99
|
-
* @param param_8 `~lib/string/String`
|
|
100
|
-
* @returns `~lib/string/String`
|
|
101
|
-
*/
|
|
102
|
-
declare function execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string, param_8: string): string;
|
|
103
|
-
/**
|
|
104
|
-
* assembly/index/execute
|
|
105
|
-
* @param param_1 `~lib/string/String`
|
|
106
|
-
* @param param_2 `~lib/string/String`
|
|
107
|
-
* @param param_3 `~lib/string/String`
|
|
108
|
-
* @param param_4 `~lib/string/String`
|
|
109
|
-
* @param param_5 `~lib/string/String`
|
|
110
|
-
* @param param_6 `~lib/string/String`
|
|
111
|
-
* @param param_7 `~lib/string/String`
|
|
112
|
-
* @param param_8 `~lib/string/String`
|
|
113
|
-
* @param param_9 `~lib/string/String`
|
|
114
|
-
* @returns `~lib/string/String`
|
|
115
|
-
*/
|
|
116
|
-
declare function execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string, param_8: string, param_9: string): string;
|
|
117
|
-
/**
|
|
118
|
-
* assembly/index/execute
|
|
119
|
-
* @param param_1 `~lib/string/String`
|
|
120
|
-
* @param param_2 `~lib/string/String`
|
|
121
|
-
* @param param_3 `~lib/string/String`
|
|
122
|
-
* @param param_4 `~lib/string/String`
|
|
123
|
-
* @param param_5 `~lib/string/String`
|
|
124
|
-
* @param param_6 `~lib/string/String`
|
|
125
|
-
* @param param_7 `~lib/string/String`
|
|
126
|
-
* @param param_8 `~lib/string/String`
|
|
127
|
-
* @param param_9 `~lib/string/String`
|
|
128
|
-
* @param param_10 `~lib/string/String`
|
|
129
|
-
* @returns `~lib/string/String`
|
|
130
|
-
*/
|
|
131
|
-
declare function execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string, param_8: string, param_9: string, param_10: string): string;
|
|
132
|
-
/**
|
|
133
|
-
* assembly/index/config
|
|
134
|
-
* @returns `~lib/string/String`
|
|
135
|
-
*/
|
|
136
6
|
declare function config(): string;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
*/
|
|
141
|
-
declare function version(): number;
|
|
142
|
-
export declare function transform(): string;
|
|
7
|
+
declare function version(): string;
|
|
8
|
+
declare function transform(): string;
|
|
9
|
+
declare function execute(...params: string[]): string;
|
|
143
10
|
export type WasmModule = {
|
|
11
|
+
responseHandler: typeof responseHandler;
|
|
144
12
|
initialize: typeof initialize;
|
|
145
13
|
execute: typeof execute;
|
|
146
|
-
"execute(param_1: string)":
|
|
147
|
-
"execute(param_1: string, param_2: string)":
|
|
148
|
-
"execute(param_1: string, param_2: string, param_3: string)":
|
|
149
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string)":
|
|
150
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string)":
|
|
151
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string)":
|
|
152
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string)":
|
|
153
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string, param_8: string)":
|
|
154
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string, param_8: string, param_9: string)":
|
|
155
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string, param_8: string, param_9: string, param_10: string)":
|
|
14
|
+
"execute(param_1: string)": typeof execute;
|
|
15
|
+
"execute(param_1: string, param_2: string)": typeof execute;
|
|
16
|
+
"execute(param_1: string, param_2: string, param_3: string)": typeof execute;
|
|
17
|
+
"execute(param_1: string, param_2: string, param_3: string, param_4: string)": typeof execute;
|
|
18
|
+
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string)": typeof execute;
|
|
19
|
+
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string)": typeof execute;
|
|
20
|
+
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string)": typeof execute;
|
|
21
|
+
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string, param_8: string)": typeof execute;
|
|
22
|
+
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string, param_8: string, param_9: string)": typeof execute;
|
|
23
|
+
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string, param_8: string, param_9: string, param_10: string)": typeof execute;
|
|
156
24
|
config: typeof config;
|
|
157
25
|
version: typeof version;
|
|
158
26
|
transform: typeof transform;
|
|
159
27
|
memory: WebAssembly.Memory;
|
|
160
28
|
};
|
|
161
29
|
export declare const loadWasm: (input: string | ArrayBuffer, imports?: {}) => Promise<WasmModule>;
|
|
162
|
-
export {};
|
package/lib/index.js
CHANGED
|
@@ -31,181 +31,222 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
34
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.loadWasm = exports.
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
this.timestamp = timestamp;
|
|
49
|
-
this.high = high;
|
|
50
|
-
this.low = low;
|
|
51
|
-
this.open = open;
|
|
52
|
-
this.close = close;
|
|
53
|
-
this.volume = volume;
|
|
54
|
-
}
|
|
55
|
-
toString() {
|
|
56
|
-
return JSON.stringify(this);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.Candle = Candle;
|
|
38
|
+
exports.loadWasm = exports.RawTradeData = exports.Candle = void 0;
|
|
39
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
40
|
+
const ccxt_1 = __importDefault(require("ccxt"));
|
|
41
|
+
const timestring_1 = __importDefault(require("timestring"));
|
|
42
|
+
const Candle_1 = require("./Candle");
|
|
43
|
+
Object.defineProperty(exports, "Candle", { enumerable: true, get: function () { return Candle_1.Candle; } });
|
|
44
|
+
const RawTradeData_1 = require("./RawTradeData");
|
|
45
|
+
Object.defineProperty(exports, "RawTradeData", { enumerable: true, get: function () { return RawTradeData_1.RawTradeData; } });
|
|
46
|
+
let _fetchGETSyncPtr = 0;
|
|
47
|
+
let _fetchPOSTSyncPtr = 0;
|
|
48
|
+
let ASYNCIFY_PTR = 0;
|
|
49
|
+
let ASYNCIFY_MEM;
|
|
50
|
+
let _exports;
|
|
60
51
|
function instantiate(module, imports = {}) {
|
|
61
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
53
|
const adaptedImports = {
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
64
54
|
// @ts-ignore
|
|
65
55
|
env: Object.assign(Object.create(globalThis), imports.env || {}, {
|
|
66
56
|
abort(message, fileName, lineNumber, columnNumber) {
|
|
67
|
-
// ~lib/builtins/abort(~lib/string/String | null?, ~lib/string/String | null?, u32?, u32?) => void
|
|
68
|
-
message = __liftString(message >>> 0);
|
|
69
|
-
fileName = __liftString(fileName >>> 0);
|
|
70
|
-
lineNumber >>>= 0;
|
|
71
|
-
columnNumber >>>= 0;
|
|
72
57
|
(() => {
|
|
73
|
-
|
|
74
|
-
throw new Error(`${message} in ${fileName}:${lineNumber}:${columnNumber}`);
|
|
58
|
+
throw Error(`${__liftString(message)} in ${__liftString(fileName)}:${lineNumber}:${columnNumber}`);
|
|
75
59
|
})();
|
|
76
60
|
},
|
|
77
61
|
generateCandles(data, candleSize) {
|
|
78
|
-
const _data = __liftString(data
|
|
79
|
-
const _candleSize = __liftString(candleSize
|
|
80
|
-
|
|
81
|
-
|
|
62
|
+
const _data = __liftString(data) || '[]';
|
|
63
|
+
const _candleSize = __liftString(candleSize) || '69m';
|
|
64
|
+
const candles = generateCandles(JSON.parse(_data), _candleSize);
|
|
65
|
+
// We could pack this data into binary before sending...
|
|
66
|
+
// Much faster
|
|
67
|
+
// Which are 32 bit and which are 64?
|
|
68
|
+
// I'll assume 32 bits for now though I believe timestamp should be 64
|
|
69
|
+
/*
|
|
70
|
+
const decodedCandles: Candle[] = [];
|
|
71
|
+
|
|
72
|
+
for (let i = 0; i < __liftBuffer(data).byteLength >> 2; i++) {
|
|
73
|
+
decodedCandles.push(decodeCandle(new Uint32Array(data, i * 6, 6)));
|
|
74
|
+
}
|
|
75
|
+
const candles =
|
|
76
|
+
|
|
77
|
+
let buffer = new Uint32Array(candles.length * 6);
|
|
78
|
+
for (let i = 0; i < candles.length; i++) {
|
|
79
|
+
const candle = candles[i];
|
|
80
|
+
// Pack it into
|
|
81
|
+
|
|
82
|
+
// Structure: [timestamp, high, low, open, close, volume]
|
|
83
|
+
// Stride: 24 bytes
|
|
84
|
+
// This is essentially what FASS does
|
|
85
|
+
|
|
86
|
+
buffer.set(
|
|
87
|
+
encodeCandle(candle),
|
|
88
|
+
i
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
return __lowerBuffer(buffer);*/
|
|
92
|
+
return __lowerString(JSON.stringify(candles));
|
|
93
|
+
},
|
|
94
|
+
'console.log': (text) => {
|
|
95
|
+
console.log(__liftString(text));
|
|
96
|
+
},
|
|
97
|
+
ccxt_fetchOHLCV: (exchangeId, symbol, timeframe, limit, since) => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
let ohlcv = '[]';
|
|
99
|
+
const _exchangeId = __liftString(exchangeId >>> 0);
|
|
100
|
+
const _symbol = __liftString(symbol >>> 0);
|
|
101
|
+
const _timeframe = __liftString(timeframe >>> 0);
|
|
102
|
+
const _since = since >>> 0;
|
|
103
|
+
const _limit = limit >>> 0;
|
|
104
|
+
if (_exchangeId &&
|
|
105
|
+
_symbol &&
|
|
106
|
+
_timeframe &&
|
|
107
|
+
_since &&
|
|
108
|
+
_limit) {
|
|
109
|
+
try {
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
const data = yield new ccxt_1.default[_exchangeId]({}).fetchOHLCV(_symbol, _timeframe, _limit, _since);
|
|
113
|
+
ccxt_1.default;
|
|
114
|
+
ohlcv = JSON.stringify(data);
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
process.env.DEBUG && console.error(e);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return __lowerString(ohlcv);
|
|
121
|
+
})
|
|
82
122
|
}),
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
123
|
+
'as-fetch': {
|
|
124
|
+
_initAsyncify(frame_ptr, stack_ptr) {
|
|
125
|
+
ASYNCIFY_PTR = frame_ptr;
|
|
126
|
+
ASYNCIFY_MEM[ASYNCIFY_PTR >> 2] = ASYNCIFY_PTR + 8;
|
|
127
|
+
// I don't know if I need to reserve all this memory...
|
|
128
|
+
ASYNCIFY_MEM[ASYNCIFY_PTR + 4 >> 2] = stack_ptr;
|
|
86
129
|
},
|
|
87
|
-
|
|
130
|
+
_fetchPOSTSync(url, mode, headers, body) {
|
|
131
|
+
var _a;
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
const currentState = _exports.asyncify_get_state();
|
|
134
|
+
if (currentState === 2) {
|
|
135
|
+
//console.log("asyncify_stop_rewind() [resume wasm]");
|
|
136
|
+
// @ts-ignore
|
|
137
|
+
_exports.asyncify_stop_rewind();
|
|
138
|
+
return _fetchPOSTSyncPtr;
|
|
139
|
+
}
|
|
140
|
+
else if (currentState === 0) {
|
|
141
|
+
//console.log("asyncify_start_unwind() [pause wasm]");
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
_exports.asyncify_start_unwind(ASYNCIFY_PTR);
|
|
144
|
+
fetch((_a = __liftString(url)) !== null && _a !== void 0 ? _a : '', {
|
|
145
|
+
method: "POST",
|
|
146
|
+
mode: modeToString(mode) || "cors",
|
|
147
|
+
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
148
|
+
body: __liftBuffer(body)
|
|
149
|
+
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
//console.log("asyncify_stop_unwind() [unpause wasm]");
|
|
151
|
+
// @ts-ignore
|
|
152
|
+
_exports.asyncify_stop_unwind();
|
|
153
|
+
const value = yield res.arrayBuffer();
|
|
154
|
+
// @ts-ignore
|
|
155
|
+
_fetchPOSTSyncPtr = _exports.__new(value.byteLength, 1);
|
|
156
|
+
new Uint8Array(_exports.memory.buffer).set(new Uint8Array(value), _fetchPOSTSyncPtr);
|
|
157
|
+
//console.log("asyncify_start_rewind() [resuming wasm]");
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
_exports.asyncify_start_rewind(ASYNCIFY_PTR);
|
|
160
|
+
// @ts-ignore
|
|
161
|
+
// Set to your execute function that your fetch calls are in. I would go and create a _start func
|
|
162
|
+
_exports.execute();
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
_fetchGETSync(url, mode, headers) {
|
|
167
|
+
// @ts-ignore
|
|
168
|
+
const currentState = _exports.asyncify_get_state();
|
|
169
|
+
if (currentState === 2) {
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
//console.log("asyncify_stop_rewind() [resume wasm]");
|
|
172
|
+
_exports.asyncify_stop_rewind();
|
|
173
|
+
return _fetchGETSyncPtr;
|
|
174
|
+
}
|
|
175
|
+
else if (currentState === 0) {
|
|
176
|
+
// @ts-ignore
|
|
177
|
+
//console.log("asyncify_start_unwind() [pause wasm]");
|
|
178
|
+
_exports.asyncify_start_unwind(ASYNCIFY_PTR);
|
|
179
|
+
fetch(__liftString(url) || "", {
|
|
180
|
+
method: "GET",
|
|
181
|
+
mode: modeToString(mode) || "cors",
|
|
182
|
+
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || []
|
|
183
|
+
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
// @ts-ignore
|
|
185
|
+
//console.log("asyncify_stop_unwind() [unpause wasm]");
|
|
186
|
+
_exports.asyncify_stop_unwind();
|
|
187
|
+
const value = yield res.arrayBuffer();
|
|
188
|
+
// @ts-ignore
|
|
189
|
+
_fetchGETSyncPtr = _exports.__new(value.byteLength, 1);
|
|
190
|
+
new Uint8Array(_exports.memory.buffer).set(new Uint8Array(value), _fetchGETSyncPtr);
|
|
191
|
+
// @ts-ignore
|
|
192
|
+
//console.log("asyncify_start_rewind() [resuming wasm]");
|
|
193
|
+
_exports.asyncify_start_rewind(ASYNCIFY_PTR);
|
|
194
|
+
// @ts-ignore
|
|
195
|
+
_exports.execute();
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
_fetchGET(url, mode, headers, callbackID) {
|
|
200
|
+
fetch(__liftString(url) || "", {
|
|
201
|
+
method: "GET",
|
|
202
|
+
mode: modeToString(mode) || "cors",
|
|
203
|
+
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || []
|
|
204
|
+
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
const body = yield res.arrayBuffer();
|
|
206
|
+
_exports.responseHandler(body, res.status, res.redirected ? 1 : 0, callbackID);
|
|
207
|
+
}));
|
|
208
|
+
},
|
|
209
|
+
_fetchPOST(url, mode, headers, body, callbackID) {
|
|
210
|
+
fetch(__liftString(url) || "", {
|
|
211
|
+
method: "POST",
|
|
212
|
+
mode: modeToString(mode) || "cors",
|
|
213
|
+
body: body,
|
|
214
|
+
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
215
|
+
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
const body = yield res.arrayBuffer();
|
|
217
|
+
_exports.responseHandler(body, res.status, res.redirected ? 1 : 0, callbackID);
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
},
|
|
88
221
|
};
|
|
89
|
-
|
|
90
|
-
// @ts-ignore
|
|
222
|
+
//@ts-ignore
|
|
91
223
|
const { exports } = yield WebAssembly.instantiate(module, adaptedImports);
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
93
224
|
// @ts-ignore
|
|
94
225
|
const memory = exports.memory || imports.env.memory;
|
|
226
|
+
_exports = exports;
|
|
227
|
+
ASYNCIFY_MEM = new Uint32Array(memory.buffer);
|
|
95
228
|
const adaptedExports = Object.setPrototypeOf({
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
"execute()": () => {
|
|
102
|
-
// assembly/index/execute(~lib/string/String) => ~lib/string/String
|
|
103
|
-
// const _pricesPointer = __lowerString(_prices) || __notnull()
|
|
104
|
-
return __liftString(exports.execute() >>> 0);
|
|
105
|
-
},
|
|
106
|
-
"execute(param_1: string)": (param_1) => {
|
|
107
|
-
// assembly/index/execute(~lib/string/String) => ~lib/string/String
|
|
108
|
-
const _paramPointer = __lowerString(param_1) || __notnull();
|
|
109
|
-
return __liftString(exports.execute(_paramPointer) >>> 0);
|
|
110
|
-
},
|
|
111
|
-
"execute(param_1: string, param_2: string)": (param_1, param_2) => {
|
|
112
|
-
// assembly/index/execute(~lib/string/String) => ~lib/string/String
|
|
113
|
-
const _paramPointer1 = __lowerString(param_1) || __notnull();
|
|
114
|
-
const _paramPointer2 = __lowerString(param_2) || __notnull();
|
|
115
|
-
return __liftString(exports.execute(_paramPointer1, _paramPointer2) >>> 0);
|
|
116
|
-
},
|
|
117
|
-
"execute(param_1: string, param_2: string, param_3: string)": (param_1, param_2, param_3) => {
|
|
118
|
-
// assembly/index/execute(~lib/string/String) => ~lib/string/String
|
|
119
|
-
const _paramPointer1 = __lowerString(param_1) || __notnull();
|
|
120
|
-
const _paramPointer2 = __lowerString(param_2) || __notnull();
|
|
121
|
-
const _paramPointer3 = __lowerString(param_3) || __notnull();
|
|
122
|
-
return __liftString(exports.execute(_paramPointer1, _paramPointer2, _paramPointer3) >>> 0);
|
|
123
|
-
},
|
|
124
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string)": (param_1, param_2, param_3, param_4) => {
|
|
125
|
-
// assembly/index/execute(~lib/string/String) => ~lib/string/String
|
|
126
|
-
const _paramPointer1 = __lowerString(param_1) || __notnull();
|
|
127
|
-
const _paramPointer2 = __lowerString(param_2) || __notnull();
|
|
128
|
-
const _paramPointer3 = __lowerString(param_3) || __notnull();
|
|
129
|
-
const _paramPointer4 = __lowerString(param_4) || __notnull();
|
|
130
|
-
return __liftString(exports.execute(_paramPointer1, _paramPointer2, _paramPointer3, _paramPointer4) >>> 0);
|
|
131
|
-
},
|
|
132
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string)": (param_1, param_2, param_3, param_4, param_5) => {
|
|
133
|
-
// assembly/index/execute(~lib/string/String) => ~lib/string/String
|
|
134
|
-
const _paramPointer1 = __lowerString(param_1) || __notnull();
|
|
135
|
-
const _paramPointer2 = __lowerString(param_2) || __notnull();
|
|
136
|
-
const _paramPointer3 = __lowerString(param_3) || __notnull();
|
|
137
|
-
const _paramPointer4 = __lowerString(param_4) || __notnull();
|
|
138
|
-
const _paramPointer5 = __lowerString(param_5) || __notnull();
|
|
139
|
-
return __liftString(exports.execute(_paramPointer1, _paramPointer2, _paramPointer3, _paramPointer4, _paramPointer5) >>> 0);
|
|
140
|
-
},
|
|
141
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string)": (param_1, param_2, param_3, param_4, param_5, param_6) => {
|
|
142
|
-
// assembly/index/execute(~lib/string/String) => ~lib/string/String
|
|
143
|
-
const _paramPointer1 = __lowerString(param_1) || __notnull();
|
|
144
|
-
const _paramPointer2 = __lowerString(param_2) || __notnull();
|
|
145
|
-
const _paramPointer3 = __lowerString(param_3) || __notnull();
|
|
146
|
-
const _paramPointer4 = __lowerString(param_4) || __notnull();
|
|
147
|
-
const _paramPointer5 = __lowerString(param_5) || __notnull();
|
|
148
|
-
const _paramPointer6 = __lowerString(param_6) || __notnull();
|
|
149
|
-
return __liftString(exports.execute(_paramPointer1, _paramPointer2, _paramPointer3, _paramPointer4, _paramPointer5, _paramPointer6) >>> 0);
|
|
150
|
-
},
|
|
151
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string)": (param_1, param_2, param_3, param_4, param_5, param_6, param_7) => {
|
|
152
|
-
// assembly/index/execute(~lib/string/String) => ~lib/string/String
|
|
153
|
-
const _paramPointer1 = __lowerString(param_1) || __notnull();
|
|
154
|
-
const _paramPointer2 = __lowerString(param_2) || __notnull();
|
|
155
|
-
const _paramPointer3 = __lowerString(param_3) || __notnull();
|
|
156
|
-
const _paramPointer4 = __lowerString(param_4) || __notnull();
|
|
157
|
-
const _paramPointer5 = __lowerString(param_5) || __notnull();
|
|
158
|
-
const _paramPointer6 = __lowerString(param_6) || __notnull();
|
|
159
|
-
const _paramPointer7 = __lowerString(param_7) || __notnull();
|
|
160
|
-
return __liftString(exports.execute(_paramPointer1, _paramPointer2, _paramPointer3, _paramPointer4, _paramPointer5, _paramPointer6, _paramPointer7) >>> 0);
|
|
161
|
-
},
|
|
162
|
-
"execute(param_1: string, param_2: string, param_3: string, param_4: string, param_5: string, param_6: string, param_7: string, param_8: string)": (param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8) => {
|
|
163
|
-
// assembly/index/execute(~lib/string/String) => ~lib/string/String
|
|
164
|
-
const _paramPointer1 = __lowerString(param_1) || __notnull();
|
|
165
|
-
const _paramPointer2 = __lowerString(param_2) || __notnull();
|
|
166
|
-
const _paramPointer3 = __lowerString(param_3) || __notnull();
|
|
167
|
-
const _paramPointer4 = __lowerString(param_4) || __notnull();
|
|
168
|
-
const _paramPointer5 = __lowerString(param_5) || __notnull();
|
|
169
|
-
const _paramPointer6 = __lowerString(param_6) || __notnull();
|
|
170
|
-
const _paramPointer7 = __lowerString(param_7) || __notnull();
|
|
171
|
-
const _paramPointer8 = __lowerString(param_8) || __notnull();
|
|
172
|
-
return __liftString(exports.execute(_paramPointer1, _paramPointer2, _paramPointer3, _paramPointer4, _paramPointer5, _paramPointer6, _paramPointer7, _paramPointer8) >>> 0);
|
|
229
|
+
responseHandler(body, statusCode, redirected, callbackID) {
|
|
230
|
+
if (exports['responseHandler']) {
|
|
231
|
+
exports.responseHandler(__lowerBuffer(body), statusCode, redirected ? 1 : 0, callbackID);
|
|
232
|
+
}
|
|
173
233
|
},
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const _paramPointer1 = __lowerString(param_1) || __notnull();
|
|
177
|
-
const _paramPointer2 = __lowerString(param_2) || __notnull();
|
|
178
|
-
const _paramPointer3 = __lowerString(param_3) || __notnull();
|
|
179
|
-
const _paramPointer4 = __lowerString(param_4) || __notnull();
|
|
180
|
-
const _paramPointer5 = __lowerString(param_5) || __notnull();
|
|
181
|
-
const _paramPointer6 = __lowerString(param_6) || __notnull();
|
|
182
|
-
const _paramPointer7 = __lowerString(param_7) || __notnull();
|
|
183
|
-
const _paramPointer8 = __lowerString(param_8) || __notnull();
|
|
184
|
-
const _paramPointer9 = __lowerString(param_9) || __notnull();
|
|
185
|
-
return __liftString(exports.execute(_paramPointer1, _paramPointer2, _paramPointer3, _paramPointer4, _paramPointer5, _paramPointer6, _paramPointer7, _paramPointer8, _paramPointer9) >>> 0);
|
|
234
|
+
initialize(config) {
|
|
235
|
+
exports.initialize(__lowerString(config));
|
|
186
236
|
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const _paramPointer5 = __lowerString(param_5) || __notnull();
|
|
194
|
-
const _paramPointer6 = __lowerString(param_6) || __notnull();
|
|
195
|
-
const _paramPointer7 = __lowerString(param_7) || __notnull();
|
|
196
|
-
const _paramPointer8 = __lowerString(param_8) || __notnull();
|
|
197
|
-
const _paramPointer9 = __lowerString(param_9) || __notnull();
|
|
198
|
-
const _paramPointer10 = __lowerString(param_10) || __notnull();
|
|
199
|
-
return __liftString(exports.execute(_paramPointer1, _paramPointer2, _paramPointer3, _paramPointer4, _paramPointer5, _paramPointer6, _paramPointer7, _paramPointer8, _paramPointer9, _paramPointer10) >>> 0);
|
|
237
|
+
execute(...params) {
|
|
238
|
+
const loweredArgs = new Array(params.length);
|
|
239
|
+
for (let i = 0; i < params.length; i++) {
|
|
240
|
+
loweredArgs[i] = __lowerString(params[i]);
|
|
241
|
+
}
|
|
242
|
+
return __liftString(exports.execute(...loweredArgs));
|
|
200
243
|
},
|
|
201
244
|
config() {
|
|
202
|
-
|
|
203
|
-
return __liftString(exports.config() >>> 0);
|
|
245
|
+
return __liftString(exports.config());
|
|
204
246
|
},
|
|
205
247
|
transform() {
|
|
206
248
|
try {
|
|
207
|
-
|
|
208
|
-
return __liftString(exports.transform() >>> 0);
|
|
249
|
+
return __liftString(exports.transform());
|
|
209
250
|
}
|
|
210
251
|
catch (e) {
|
|
211
252
|
console.error(e);
|
|
@@ -213,22 +254,34 @@ function instantiate(module, imports = {}) {
|
|
|
213
254
|
}
|
|
214
255
|
},
|
|
215
256
|
}, exports);
|
|
257
|
+
function __liftBuffer(pointer) {
|
|
258
|
+
if (!pointer)
|
|
259
|
+
return null;
|
|
260
|
+
return memory.buffer.slice(pointer, pointer + new Uint32Array(memory.buffer)[(pointer - 4) >>> 2]);
|
|
261
|
+
}
|
|
262
|
+
function __lowerBuffer(value) {
|
|
263
|
+
if (value == null)
|
|
264
|
+
return 0;
|
|
265
|
+
// @ts-ignore
|
|
266
|
+
const pointer = exports.__new(value.byteLength, 1);
|
|
267
|
+
new Uint8Array(memory.buffer).set(new Uint8Array(value), pointer);
|
|
268
|
+
return pointer;
|
|
269
|
+
}
|
|
216
270
|
function __liftString(pointer) {
|
|
217
271
|
if (!pointer)
|
|
218
272
|
return null;
|
|
219
|
-
const end = pointer + new Uint32Array(memory.buffer)[pointer - 4 >>> 2] >>> 1;
|
|
220
|
-
|
|
221
|
-
let start = pointer >>> 1;
|
|
222
|
-
let string = '';
|
|
273
|
+
const end = (pointer + new Uint32Array(memory.buffer)[(pointer - 4) >>> 2]) >>> 1, memoryU16 = new Uint16Array(memory.buffer);
|
|
274
|
+
let start = pointer >>> 1, string = '';
|
|
223
275
|
while (end - start > 1024)
|
|
224
|
-
string += String.fromCharCode(...memoryU16.subarray(start, start += 1024));
|
|
276
|
+
string += String.fromCharCode(...memoryU16.subarray(start, (start += 1024)));
|
|
225
277
|
return string + String.fromCharCode(...memoryU16.subarray(start, end));
|
|
226
278
|
}
|
|
227
279
|
function __lowerString(value) {
|
|
228
280
|
if (value === null)
|
|
229
281
|
return 0;
|
|
230
282
|
const length = value.length;
|
|
231
|
-
|
|
283
|
+
// @ts-ignore
|
|
284
|
+
const pointer = exports.__new(length << 1, 2);
|
|
232
285
|
const memoryU16 = new Uint16Array(memory.buffer);
|
|
233
286
|
for (let i = 0; i < length; ++i)
|
|
234
287
|
memoryU16[(pointer >>> 1) + i] = value.charCodeAt(i);
|
|
@@ -237,51 +290,12 @@ function instantiate(module, imports = {}) {
|
|
|
237
290
|
function __liftArray(liftElement, align, pointer) {
|
|
238
291
|
if (!pointer)
|
|
239
292
|
return null;
|
|
240
|
-
const dataStart = __getU32(pointer + 4);
|
|
241
|
-
const length = __dataview.getUint32(pointer + 12, true);
|
|
242
|
-
const values = new Array(length);
|
|
293
|
+
const dataStart = __getU32(pointer + 4), length = __dataview.getUint32(pointer + 12, true), values = new Array(length);
|
|
243
294
|
for (let i = 0; i < length; ++i)
|
|
244
|
-
values[i] = liftElement(dataStart + (i << align
|
|
295
|
+
values[i] = liftElement(dataStart + (i << align));
|
|
245
296
|
return values;
|
|
246
297
|
}
|
|
247
|
-
function __lowerArray(lowerElement, id, align, values) {
|
|
248
|
-
if (values === null)
|
|
249
|
-
return 0;
|
|
250
|
-
const length = values.length;
|
|
251
|
-
const buffer = exports.__pin(exports.__new(length << align, 1)) >>> 0;
|
|
252
|
-
const header = exports.__pin(exports.__new(16, id)) >>> 0;
|
|
253
|
-
__setU32(header + 0, buffer);
|
|
254
|
-
__dataview.setUint32(header + 4, buffer, true);
|
|
255
|
-
__dataview.setUint32(header + 8, length << align, true);
|
|
256
|
-
__dataview.setUint32(header + 12, length, true);
|
|
257
|
-
for (let i = 0; i < length; ++i)
|
|
258
|
-
lowerElement(buffer + (i << align >>> 0), values[i]);
|
|
259
|
-
exports.__unpin(buffer);
|
|
260
|
-
exports.__unpin(header);
|
|
261
|
-
return header;
|
|
262
|
-
}
|
|
263
|
-
class Internref extends Number {
|
|
264
|
-
}
|
|
265
|
-
function __lowerInternref(value) {
|
|
266
|
-
if (value === null)
|
|
267
|
-
return 0;
|
|
268
|
-
if (value instanceof Internref)
|
|
269
|
-
return value.valueOf();
|
|
270
|
-
throw new TypeError('internref expected');
|
|
271
|
-
}
|
|
272
|
-
function __notnull() {
|
|
273
|
-
throw new TypeError('value must not be null');
|
|
274
|
-
}
|
|
275
298
|
let __dataview = new DataView(memory.buffer);
|
|
276
|
-
function __setU32(pointer, value) {
|
|
277
|
-
try {
|
|
278
|
-
__dataview.setUint32(pointer, value, true);
|
|
279
|
-
}
|
|
280
|
-
catch (_a) {
|
|
281
|
-
__dataview = new DataView(memory.buffer);
|
|
282
|
-
__dataview.setUint32(pointer, value, true);
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
299
|
function __getU32(pointer) {
|
|
286
300
|
try {
|
|
287
301
|
return __dataview.getUint32(pointer, true);
|
|
@@ -291,94 +305,60 @@ function instantiate(module, imports = {}) {
|
|
|
291
305
|
return __dataview.getUint32(pointer, true);
|
|
292
306
|
}
|
|
293
307
|
}
|
|
294
|
-
function __getF32(pointer) {
|
|
295
|
-
try {
|
|
296
|
-
return __dataview.getFloat32(pointer, true);
|
|
297
|
-
}
|
|
298
|
-
catch (_a) {
|
|
299
|
-
__dataview = new DataView(memory.buffer);
|
|
300
|
-
return __dataview.getFloat32(pointer, true);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
function __getF64(pointer) {
|
|
304
|
-
try {
|
|
305
|
-
return __dataview.getFloat64(pointer, true);
|
|
306
|
-
}
|
|
307
|
-
catch (_a) {
|
|
308
|
-
__dataview = new DataView(memory.buffer);
|
|
309
|
-
return __dataview.getFloat64(pointer, true);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
308
|
function generateCandles(data, candleSize) {
|
|
309
|
+
const candleWidth = (0, timestring_1.default)(candleSize, 'ms', {});
|
|
310
|
+
if (data.length === 0) {
|
|
311
|
+
throw new Error('Input data is empty');
|
|
312
|
+
}
|
|
313
313
|
const _data = data.map((point) => {
|
|
314
|
-
return Object.assign(Object.assign({}, point), {
|
|
314
|
+
return Object.assign(Object.assign({}, point), {
|
|
315
315
|
// This will convert the timestamp to milliseconds if it's in seconds
|
|
316
|
-
timestamp: point.timestamp && String(point.timestamp).length == 10 ? point.timestamp * 1000 : point.timestamp
|
|
316
|
+
timestamp: point.timestamp && String(point.timestamp).length == 10 ? point.timestamp * 1000 : point.timestamp,
|
|
317
|
+
});
|
|
317
318
|
});
|
|
318
319
|
if (_data[0] === undefined || Object.keys(_data[0]).length === 0) {
|
|
319
320
|
return [];
|
|
320
321
|
}
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
.points.map((p) => {
|
|
356
|
-
// Convert time range to timestamp of beginning of range
|
|
357
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
358
|
-
// @ts-ignore
|
|
359
|
-
p[0] = new pondjs_1.Index(p[0])
|
|
360
|
-
.toTimeRange()
|
|
361
|
-
.toTime(types_1.TimeAlignment.Begin)
|
|
362
|
-
.toDate()
|
|
363
|
-
.getTime();
|
|
364
|
-
return p;
|
|
365
|
-
})
|
|
366
|
-
.map((p) => {
|
|
367
|
-
return {
|
|
368
|
-
timestamp: p[0],
|
|
369
|
-
high: p[1],
|
|
370
|
-
low: p[2],
|
|
371
|
-
close: p[3],
|
|
372
|
-
open: p[4],
|
|
373
|
-
volume: p[5],
|
|
374
|
-
};
|
|
375
|
-
});
|
|
322
|
+
const ohlcvData = [];
|
|
323
|
+
let i = 0;
|
|
324
|
+
let currentTimestamp = Math.floor(_data[0].timestamp / candleWidth) * candleWidth;
|
|
325
|
+
let open = _data[0].price;
|
|
326
|
+
let high = _data[0].price;
|
|
327
|
+
let low = _data[0].price;
|
|
328
|
+
let close = _data[0].price;
|
|
329
|
+
let volume = 0.0;
|
|
330
|
+
while (i < _data.length) {
|
|
331
|
+
open = close;
|
|
332
|
+
high = close;
|
|
333
|
+
low = close;
|
|
334
|
+
volume = 0.0;
|
|
335
|
+
let innerI = i;
|
|
336
|
+
while (innerI < _data.length && _data[innerI].timestamp < currentTimestamp + candleWidth) {
|
|
337
|
+
open = innerI === 0 ? _data[innerI].price : open;
|
|
338
|
+
high = Math.max(high, _data[innerI].price);
|
|
339
|
+
low = Math.min(low, _data[innerI].price);
|
|
340
|
+
close = _data[innerI].price;
|
|
341
|
+
volume += _data[innerI].volume;
|
|
342
|
+
innerI++;
|
|
343
|
+
}
|
|
344
|
+
ohlcvData.push({
|
|
345
|
+
timestamp: currentTimestamp,
|
|
346
|
+
high,
|
|
347
|
+
low,
|
|
348
|
+
open,
|
|
349
|
+
close,
|
|
350
|
+
volume,
|
|
351
|
+
});
|
|
352
|
+
currentTimestamp += candleWidth;
|
|
353
|
+
i = innerI;
|
|
354
|
+
}
|
|
355
|
+
return ohlcvData;
|
|
376
356
|
}
|
|
377
357
|
return adaptedExports;
|
|
378
358
|
});
|
|
379
359
|
}
|
|
380
360
|
const loadWasm = (input, imports = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
381
|
-
|
|
361
|
+
const mod = (yield instantiate(yield (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
382
362
|
if (typeof input === 'string') {
|
|
383
363
|
try {
|
|
384
364
|
return yield globalThis.WebAssembly.compileStreaming(globalThis.fetch(input));
|
|
@@ -390,6 +370,18 @@ const loadWasm = (input, imports = {}) => __awaiter(void 0, void 0, void 0, func
|
|
|
390
370
|
else {
|
|
391
371
|
return globalThis.WebAssembly.compile(input);
|
|
392
372
|
}
|
|
393
|
-
}))(), imports);
|
|
373
|
+
}))(), imports));
|
|
374
|
+
return mod;
|
|
394
375
|
});
|
|
395
376
|
exports.loadWasm = loadWasm;
|
|
377
|
+
function modeToString(mode) {
|
|
378
|
+
if (mode == 1)
|
|
379
|
+
return 'cors';
|
|
380
|
+
if (mode == 2)
|
|
381
|
+
return 'no-cors';
|
|
382
|
+
if (mode == 3)
|
|
383
|
+
return 'same-origin';
|
|
384
|
+
if (mode == 4)
|
|
385
|
+
return 'navigate';
|
|
386
|
+
return null;
|
|
387
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steerprotocol/app-loader",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "App Loader for Steer Protocol",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"homepage": "https://github.com/hebertcisco/ts-npm-package-boilerplate#readme",
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/jest": "29.2.4",
|
|
35
|
+
"@types/timestring": "^6.0.2",
|
|
35
36
|
"@typescript-eslint/eslint-plugin": "5.46.0",
|
|
36
37
|
"@typescript-eslint/parser": "5.47.1",
|
|
37
38
|
"eslint": "8.30.0",
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
"lib/**/*"
|
|
46
47
|
],
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"
|
|
49
|
+
"ccxt": "^3.0.30",
|
|
50
|
+
"timestring": "^7.0.0"
|
|
49
51
|
}
|
|
50
52
|
}
|