wenay-common 1.0.69 → 1.0.71
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.
|
@@ -11,6 +11,7 @@ export declare function funcTimeW(): {
|
|
|
11
11
|
cleanByTime(type: tType, ms?: number): void;
|
|
12
12
|
weight(type: tType, ms?: number): number;
|
|
13
13
|
byWeight(type: tType, weight?: number): number;
|
|
14
|
+
byWeightTimeNow(type: tType, timeNow?: number, weight?: number): number;
|
|
14
15
|
};
|
|
15
16
|
export declare const FuncTimeWait: {
|
|
16
17
|
data: any[];
|
|
@@ -18,5 +19,6 @@ export declare const FuncTimeWait: {
|
|
|
18
19
|
cleanByTime(type: tType, ms?: number): void;
|
|
19
20
|
weight(type: tType, ms?: number): number;
|
|
20
21
|
byWeight(type: tType, weight?: number): number;
|
|
22
|
+
byWeightTimeNow(type: tType, timeNow?: number, weight?: number): number;
|
|
21
23
|
};
|
|
22
24
|
export {};
|
|
@@ -58,6 +58,22 @@ function funcTimeW() {
|
|
|
58
58
|
}
|
|
59
59
|
return 0;
|
|
60
60
|
},
|
|
61
|
+
byWeightTimeNow(type, timeNow = Date.now(), weight = 50000) {
|
|
62
|
+
if (!dStatic[type])
|
|
63
|
+
return 0;
|
|
64
|
+
const [arr, timeStamp] = [dStatic[type], Date.now()];
|
|
65
|
+
let [sum, i] = [0, arr.length - 1];
|
|
66
|
+
for (; i >= 0; i--) {
|
|
67
|
+
if (arr[i][0] <= timeNow)
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
for (; i >= 0; i--) {
|
|
71
|
+
sum += arr[i][1];
|
|
72
|
+
if (sum > weight)
|
|
73
|
+
return arr[i + 1][0] ?? 0;
|
|
74
|
+
}
|
|
75
|
+
return 0;
|
|
76
|
+
},
|
|
61
77
|
};
|
|
62
78
|
}
|
|
63
79
|
exports.funcTimeW = funcTimeW;
|
package/lib/Exchange/LoadBase.js
CHANGED
|
@@ -12,10 +12,13 @@ function LoadQuoteBase(setting, data) {
|
|
|
12
12
|
async function waitLimit(weight = 1) {
|
|
13
13
|
await (0, Common_1.sleepAsync)(0);
|
|
14
14
|
const t1 = funcTimeWait_1.FuncTimeWait.byWeight(keyName, setting.maxLoadBars) - (Date.now() - time) - 1;
|
|
15
|
-
funcTimeWait_1.FuncTimeWait.add({ type: keyName, weight: weight });
|
|
16
15
|
if (t1 > 0) {
|
|
16
|
+
funcTimeWait_1.FuncTimeWait.add({ type: keyName, weight: weight, timeStamp: Date.now() + t1 });
|
|
17
17
|
await (0, Common_1.sleepAsync)(t1);
|
|
18
18
|
}
|
|
19
|
+
else {
|
|
20
|
+
funcTimeWait_1.FuncTimeWait.add({ type: keyName, weight: weight, timeStamp: Date.now() });
|
|
21
|
+
}
|
|
19
22
|
await (0, Common_1.sleepAsync)(0);
|
|
20
23
|
}
|
|
21
24
|
const mapTimeToName = new Map(intervalToName.map((e) => [e.time.sec, e]));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wenay-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.71",
|
|
4
4
|
"description": "math math math",
|
|
5
5
|
"strict": true,
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"npm": "^9.6.7",
|
|
32
32
|
"ts-node": "^10.9.1",
|
|
33
33
|
"xmlhttprequest": "^1.8.0",
|
|
34
|
-
"wenay-common": "^1.0.
|
|
34
|
+
"wenay-common": "^1.0.69"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/create-hmac": "^1.1.0",
|