wenay-common 1.0.89 → 1.0.90
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/Common/ByteStream.d.ts +3 -3
- package/lib/Common/Color.d.ts +1 -1
- package/lib/Common/Common.d.ts +25 -18
- package/lib/Common/Common.js +104 -57
- package/lib/Common/Time.d.ts +36 -11
- package/lib/Common/Time.js +75 -37
- package/lib/Common/commonsServer.d.ts +11 -2
- package/lib/Common/commonsServer.js +10 -7
- package/lib/Common/inputAutoStep.js +5 -5
- package/lib/Common/node_console.d.ts +1 -0
- package/lib/Common/node_console.js +4 -2
- package/lib/Common/waitRun.js +2 -2
- package/lib/Exchange/Bars.d.ts +2 -2
- package/lib/Exchange/Bars.js +25 -13
- package/lib/Exchange/CParams.js +8 -5
- package/lib/Exchange/LoadBase.js +2 -2
- package/lib/Exchange/MarketData.d.ts +2 -2
- package/lib/Exchange/MarketData.js +24 -12
- package/lib/client.d.ts +2 -2
- package/lib/client.js +21 -9
- package/lib/index.d.ts +2 -2
- package/lib/index.js +22 -10
- package/package.json +1 -1
|
@@ -48,7 +48,7 @@ export declare class ByteStreamW {
|
|
|
48
48
|
pushUnicode(text: string | null): this;
|
|
49
49
|
}
|
|
50
50
|
type ReaderFromBytes<T> = {
|
|
51
|
-
read(stream: ByteStreamR
|
|
51
|
+
read(stream: ByteStreamR): T;
|
|
52
52
|
};
|
|
53
53
|
declare class ByteStreamR_<throwable extends boolean> {
|
|
54
54
|
protected _wstream?: Readonly<ByteStreamW>;
|
|
@@ -83,8 +83,8 @@ declare class ByteStreamR_<throwable extends boolean> {
|
|
|
83
83
|
readArray<T>(func: (stream: ByteStreamR) => NonNullable<T>): T[];
|
|
84
84
|
readArray<T extends NumericTypes | Nullable<NumericTypes>>(type: T): T extends NumericTypes ? number[] : (number | null)[];
|
|
85
85
|
readArray<T>(reader: ReaderFromBytes<NonNullable<T>>): T[];
|
|
86
|
-
protected _readArrayByFunc<T>(func: (stream: ByteStreamR
|
|
87
|
-
protected _readArrayOfNumeric(type: NumericTypes):
|
|
86
|
+
protected _readArrayByFunc<T>(func: (stream: ByteStreamR) => T): T[] | null;
|
|
87
|
+
protected _readArrayOfNumeric(type: NumericTypes): any;
|
|
88
88
|
protected _readArrayByReader<T>(reader: ReaderFromBytes<T>): T[] | null;
|
|
89
89
|
private _readNullableString;
|
|
90
90
|
readAnsi(): string | null;
|
package/lib/Common/Color.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ declare type Nominal<T, Name extends string> = T & {
|
|
|
2
2
|
[Symbol.species]: Name;
|
|
3
3
|
};
|
|
4
4
|
export type ColorNumber = Nominal<number, 'Color'>;
|
|
5
|
-
export type ColorString = `rgb(${number},${number},${number})` | `rgba(${number},${number},${number},${number})`;
|
|
5
|
+
export type ColorString = `rgb(${number},${number},${number})` | `rgba(${number},${number},${number},${number})` | `#${string}`;
|
|
6
6
|
export type ColorRGB = Readonly<{
|
|
7
7
|
red: number;
|
|
8
8
|
green: number;
|
package/lib/Common/Common.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Immutable, KeysWithoutType, Mutable, MutableFull, ReadonlyFull } from "./BaseTypes";
|
|
2
|
+
import "./node_console";
|
|
2
3
|
export declare function GetEnumKeys<TT extends {
|
|
3
4
|
[key: string]: any;
|
|
4
5
|
}>(T: TT): readonly (keyof typeof T)[];
|
|
5
6
|
type const_Date = Omit<Date, "setTime" | "setFullYear" | "setMonth" | "setDate" | "setHours" | "setMinutes" | "setSeconds" | "setMilliseconds" | "setUTCFullYear" | "setUTCMonth" | "setUTCDate" | "setUTCHours" | "setUTCMinutes" | "setUTCSeconds" | "setUTCMilliseconds">;
|
|
6
|
-
export declare function isDate<T>(value: T & (Extract<T, const_Date>)): value is Extract<
|
|
7
|
+
export declare function isDate<T>(value: T & (Extract<T, const_Date> extends never ? never : T)): value is Extract<typeof value, const_Date>;
|
|
8
|
+
export { Mutable };
|
|
7
9
|
export declare function shallowClone<T>(val: T): Mutable<T>;
|
|
8
10
|
export declare function _deepClone<T>(src: T, map?: Map<object, object>): T;
|
|
9
11
|
export declare function deepClone<T>(object: T): T;
|
|
@@ -12,13 +14,17 @@ export declare function deepCloneObject<T extends object>(object: T): T;
|
|
|
12
14
|
export declare function deepCloneObjectMutable<T extends object>(object: T): MutableFull<T>;
|
|
13
15
|
export declare function toImmutable<T extends object>(object: T): Immutable<T>;
|
|
14
16
|
export declare function readonlyFull<T>(arg: T): ReadonlyFull<T>;
|
|
17
|
+
export declare function deepEqual<T extends {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}>(object1: T, object2: T): boolean;
|
|
20
|
+
export declare function shallowEqual<T extends {
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
} | undefined>(object1: T, object2: T): boolean;
|
|
23
|
+
export declare function arrayShallowEqual<T extends unknown>(arr1: readonly T[], arr2: readonly T[]): boolean;
|
|
15
24
|
export declare function sleepAsync(msec?: number): Promise<unknown>;
|
|
16
25
|
export declare class CBase {
|
|
17
26
|
readonly [key: number]: void;
|
|
18
27
|
}
|
|
19
|
-
export declare function GetEnumValues(T: {
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
}): readonly any[];
|
|
22
28
|
export declare enum E_SORTMODE {
|
|
23
29
|
DESCEND = 0,
|
|
24
30
|
ASCEND = 1
|
|
@@ -65,28 +71,36 @@ export declare function CreateArrayProxy<T extends {
|
|
|
65
71
|
}, T2 extends {
|
|
66
72
|
[key: number]: T[number];
|
|
67
73
|
}>(target: T, srcArray: T2): T;
|
|
74
|
+
declare class __NumMap<T> {
|
|
75
|
+
[nkey: number]: T;
|
|
76
|
+
keys(): Generator<number, void, unknown>;
|
|
77
|
+
values(): Generator<T, void, unknown>;
|
|
78
|
+
entries(): Generator<readonly [number, T], void, unknown>;
|
|
79
|
+
clone(): __NumMap<unknown> & this;
|
|
80
|
+
clear(): void;
|
|
81
|
+
}
|
|
68
82
|
export declare class __MyMap<K extends {
|
|
69
83
|
valueOf(): number;
|
|
70
84
|
}, V> {
|
|
71
|
-
protected map: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
76
|
-
};
|
|
85
|
+
protected map: __NumMap<{
|
|
86
|
+
key: K;
|
|
87
|
+
value: V;
|
|
88
|
+
}>;
|
|
77
89
|
protected keys?: readonly K[] | null;
|
|
78
90
|
protected values?: readonly V[] | null;
|
|
79
91
|
protected createArrays(): void;
|
|
80
|
-
protected OnModify(key: K): void;
|
|
92
|
+
protected OnModify?(key: K): void;
|
|
81
93
|
Set(key: K, value: V): void;
|
|
82
94
|
Get(key: K): V | undefined;
|
|
83
95
|
Contains(key: K): boolean;
|
|
84
96
|
TryAdd(key: K, value: V): boolean;
|
|
85
97
|
Add(key: K, value: V): void;
|
|
86
98
|
Remove(key: K): void;
|
|
99
|
+
Clear(): void;
|
|
87
100
|
Count(): number;
|
|
88
101
|
get sortedKeys(): readonly K[];
|
|
89
102
|
get Values(): readonly V[];
|
|
103
|
+
assign(other: __MyMap<K, V>): void;
|
|
90
104
|
}
|
|
91
105
|
export declare class MyMap<K extends {
|
|
92
106
|
valueOf(): number;
|
|
@@ -186,12 +200,6 @@ export declare class Mutex {
|
|
|
186
200
|
static createLock(): PromiseLike<() => void>;
|
|
187
201
|
}
|
|
188
202
|
export declare function copyToClipboard(textToCopy: string): Promise<any>;
|
|
189
|
-
export declare function deepEqual<T extends {
|
|
190
|
-
[key: string]: any;
|
|
191
|
-
}>(object1: T, object2: T): boolean;
|
|
192
|
-
export declare function shallowEqual<T extends {
|
|
193
|
-
[key: string]: any;
|
|
194
|
-
} | undefined>(object1: T, object2: T): boolean;
|
|
195
203
|
export type ObjectID<TObject, TOwner> = {
|
|
196
204
|
readonly value: number;
|
|
197
205
|
readonly [Symbol.species]: ObjectID<TObject, TOwner>;
|
|
@@ -231,4 +239,3 @@ export declare class CCachedValue2<TKey extends [any, any], TVal> extends CCache
|
|
|
231
239
|
constructor();
|
|
232
240
|
}
|
|
233
241
|
export declare function isObjectCastableTo<T extends object>(object: object, members: readonly (keyof T)[]): object is T;
|
|
234
|
-
export {};
|
package/lib/Common/Common.js
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CCachedValueT = exports.WeakMapExt = exports.MapExt = exports.CObjectID = exports.
|
|
26
|
+
exports.CCachedValueT = exports.WeakMapExt = exports.MapExt = exports.CObjectID = exports.copyToClipboard = exports.Mutex = exports.MyTimerInterval = exports.createCancellableTaskWrapper = exports.createCancellableTimer = exports.CancelablePromise = exports.CancelToken = exports.JSON_clone = exports.VirtualItems = exports.ArraySet = exports.ArrayMap = exports.StructSet = exports.StructMap = exports.MyNumMap = exports.MyMap = exports.__MyMap = exports.CreateArrayProxy = exports.ArrayItemHandler = exports.DblToStrAuto = exports.GetDblPrecision = exports.GetDblPrecision2 = exports.MaxCommonDivisorOnArray = exports.MaxCommonDivisor = exports.NormalizeDouble = exports._BSearchNearest = exports.BSearchNearest = exports.BSearchDefault = exports.BSearchAsync = exports.BSearch = exports.E_MATCH = exports.E_SORTMODE = exports.CBase = exports.sleepAsync = exports.arrayShallowEqual = exports.shallowEqual = exports.deepEqual = exports.readonlyFull = exports.toImmutable = exports.deepCloneObjectMutable = exports.deepCloneObject = exports.deepCloneMutable = exports.deepClone = exports._deepClone = exports.shallowClone = exports.isDate = exports.GetEnumKeys = void 0;
|
|
4
27
|
exports.isObjectCastableTo = exports.CCachedValue2 = void 0;
|
|
28
|
+
require("./node_console");
|
|
5
29
|
function GetEnumKeys(T) { return Object.keys(T).filter(k => isNaN(k)); }
|
|
6
30
|
exports.GetEnumKeys = GetEnumKeys;
|
|
7
31
|
function isDate(value) {
|
|
@@ -10,6 +34,12 @@ function isDate(value) {
|
|
|
10
34
|
exports.isDate = isDate;
|
|
11
35
|
{
|
|
12
36
|
let aaa;
|
|
37
|
+
let bbb;
|
|
38
|
+
if (isDate(bbb))
|
|
39
|
+
bbb.getDate();
|
|
40
|
+
let ccc;
|
|
41
|
+
if (isDate(ccc))
|
|
42
|
+
ccc.getDate();
|
|
13
43
|
}
|
|
14
44
|
if (0)
|
|
15
45
|
Object.prototype.valueOf = function () {
|
|
@@ -74,6 +104,48 @@ function toImmutable(object) {
|
|
|
74
104
|
exports.toImmutable = toImmutable;
|
|
75
105
|
function readonlyFull(arg) { return arg; }
|
|
76
106
|
exports.readonlyFull = readonlyFull;
|
|
107
|
+
function deepEqual(object1, object2) {
|
|
108
|
+
if (object1 == object2)
|
|
109
|
+
return true;
|
|
110
|
+
const keys1 = Object.keys(object1);
|
|
111
|
+
const keys2 = Object.keys(object2);
|
|
112
|
+
if (keys1.length != keys2.length)
|
|
113
|
+
return false;
|
|
114
|
+
for (const key of keys1) {
|
|
115
|
+
const val1 = object1[key];
|
|
116
|
+
const val2 = object2[key];
|
|
117
|
+
if (val1 === val2)
|
|
118
|
+
continue;
|
|
119
|
+
const areObjects = typeof (val1) == "object" && typeof (val2) == "object" && val1 != null && val2 != null;
|
|
120
|
+
if (!areObjects || !deepEqual(val1, val2))
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
exports.deepEqual = deepEqual;
|
|
126
|
+
function shallowEqual(object1, object2) {
|
|
127
|
+
if (!object1 || !object2)
|
|
128
|
+
return object1 == object2;
|
|
129
|
+
const keys1 = Object.keys(object1);
|
|
130
|
+
const keys2 = Object.keys(object2);
|
|
131
|
+
if (keys1.length != keys2.length) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
for (const key of keys1) {
|
|
135
|
+
const val1 = object1[key];
|
|
136
|
+
const val2 = object2[key];
|
|
137
|
+
if (val1 !== val2)
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
exports.shallowEqual = shallowEqual;
|
|
143
|
+
function arrayShallowEqual(arr1, arr2) {
|
|
144
|
+
if (arr1.length != arr2.length)
|
|
145
|
+
return false;
|
|
146
|
+
return arr1.every((item, i) => arr2[i] == item);
|
|
147
|
+
}
|
|
148
|
+
exports.arrayShallowEqual = arrayShallowEqual;
|
|
77
149
|
async function sleepAsync(msec = 0) {
|
|
78
150
|
return new Promise((resolve, reject) => { setTimeout(resolve, msec); });
|
|
79
151
|
}
|
|
@@ -81,10 +153,6 @@ exports.sleepAsync = sleepAsync;
|
|
|
81
153
|
class CBase {
|
|
82
154
|
}
|
|
83
155
|
exports.CBase = CBase;
|
|
84
|
-
function GetEnumValues(T) { let arr = []; for (let k of Object.keys(T))
|
|
85
|
-
if (isNaN(k))
|
|
86
|
-
arr.push(T[k]); return arr; }
|
|
87
|
-
exports.GetEnumValues = GetEnumValues;
|
|
88
156
|
var E_SORTMODE;
|
|
89
157
|
(function (E_SORTMODE) {
|
|
90
158
|
E_SORTMODE[E_SORTMODE["DESCEND"] = 0] = "DESCEND";
|
|
@@ -330,38 +398,55 @@ function CreateArrayProxy(target, getterOrArray, setter) {
|
|
|
330
398
|
return new Proxy(target, ArrayItemHandler((target, i) => getterOrArray(i), setter ? (target, i, value) => setter(i, value) : undefined));
|
|
331
399
|
}
|
|
332
400
|
exports.CreateArrayProxy = CreateArrayProxy;
|
|
401
|
+
class __NumMap {
|
|
402
|
+
*keys() { for (let keyStr of Object.keys(this)) {
|
|
403
|
+
let key = Number(keyStr);
|
|
404
|
+
yield key;
|
|
405
|
+
} }
|
|
406
|
+
*values() { for (let keyStr of Object.keys(this)) {
|
|
407
|
+
yield this[keyStr];
|
|
408
|
+
} }
|
|
409
|
+
*entries() { for (let keyStr of Object.keys(this)) {
|
|
410
|
+
let key = Number(keyStr);
|
|
411
|
+
yield [key, this[keyStr]];
|
|
412
|
+
} }
|
|
413
|
+
clone() { return Object.assign(new __NumMap, this); }
|
|
414
|
+
clear() { for (let k of Object.keys(this))
|
|
415
|
+
delete this[k]; }
|
|
416
|
+
}
|
|
333
417
|
class __MyMap {
|
|
334
|
-
map =
|
|
418
|
+
map = new __NumMap;
|
|
335
419
|
keys;
|
|
336
420
|
values;
|
|
337
421
|
createArrays() {
|
|
338
422
|
let thisKeys = this.keys = [];
|
|
339
423
|
let thisValues = this.values = [];
|
|
340
|
-
for (let
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
thisValues.push(pair.value);
|
|
345
|
-
}
|
|
424
|
+
for (let pair of this.map.values()) {
|
|
425
|
+
thisKeys.push(pair.key);
|
|
426
|
+
thisValues.push(pair.value);
|
|
427
|
+
}
|
|
346
428
|
}
|
|
347
429
|
OnModify(key) { }
|
|
348
|
-
Set(key, value) { this.map[key.valueOf()] = { key, value }; this.keys = null; this.OnModify(key); }
|
|
430
|
+
Set(key, value) { this.map[key.valueOf()] = { key, value }; this.keys = null; this.OnModify?.(key); }
|
|
349
431
|
Get(key) { let pair = this.map[key.valueOf()]; return pair ? pair.value : undefined; }
|
|
350
432
|
Contains(key) { return this.map[key.valueOf()] != undefined; }
|
|
351
433
|
TryAdd(key, value) { if (!this.Contains(key))
|
|
352
434
|
return false; this.Set(key, value); return true; }
|
|
353
435
|
Add(key, value) { if (!this.TryAdd(key, value))
|
|
354
436
|
throw `Key ${key} is already exists for ${typeof value}`; }
|
|
355
|
-
Remove(key) { delete (this.map[key.valueOf()]); this.keys = null; this.OnModify(key); }
|
|
437
|
+
Remove(key) { delete (this.map[key.valueOf()]); this.keys = null; this.OnModify?.(key); }
|
|
438
|
+
Clear() { let pairs = this.OnModify ? this.map.values() : []; this.map.clear(); this.keys = undefined; this.values = undefined; for (let p of pairs)
|
|
439
|
+
this.OnModify(p.key); }
|
|
356
440
|
Count() { return this.sortedKeys.length; }
|
|
357
441
|
get sortedKeys() { if (!this.keys)
|
|
358
442
|
this.createArrays(); return this.keys; }
|
|
359
443
|
get Values() { if (!this.keys)
|
|
360
444
|
this.createArrays(); return this.values; }
|
|
445
|
+
assign(other) { this.map = other.map.clone(); this.keys = other.keys; this.values = other.values; }
|
|
361
446
|
}
|
|
362
447
|
exports.__MyMap = __MyMap;
|
|
363
448
|
class MyMap extends __MyMap {
|
|
364
|
-
Clone() { let newobj = new MyMap(); newobj.
|
|
449
|
+
Clone() { let newobj = new MyMap(); newobj.assign(this); return newobj; }
|
|
365
450
|
}
|
|
366
451
|
exports.MyMap = MyMap;
|
|
367
452
|
class MyNumMap extends __MyMap {
|
|
@@ -369,7 +454,7 @@ class MyNumMap extends __MyMap {
|
|
|
369
454
|
super();
|
|
370
455
|
return CreateArrayProxy(this, (i) => this.Get(i), (key, value) => this.Set(key, value ?? (() => { throw "undefined value"; })()));
|
|
371
456
|
}
|
|
372
|
-
Clone() { let newobj = new MyNumMap(); newobj.
|
|
457
|
+
Clone() { let newobj = new MyNumMap(); newobj.assign(this); return newobj; }
|
|
373
458
|
}
|
|
374
459
|
exports.MyNumMap = MyNumMap;
|
|
375
460
|
class StructMap {
|
|
@@ -433,7 +518,7 @@ class VirtualItems {
|
|
|
433
518
|
constructor(itemGetter, lengthGetter) {
|
|
434
519
|
this.getLength = lengthGetter;
|
|
435
520
|
this.getValue = itemGetter;
|
|
436
|
-
return CreateArrayProxy(this,
|
|
521
|
+
return CreateArrayProxy(this, itemGetter);
|
|
437
522
|
}
|
|
438
523
|
}
|
|
439
524
|
exports.VirtualItems = VirtualItems;
|
|
@@ -493,8 +578,7 @@ class MyTimerInterval {
|
|
|
493
578
|
_timer;
|
|
494
579
|
_onstop;
|
|
495
580
|
constructor(period_ms, onTimer, onStop) { this._timer = setInterval(onTimer, period_ms); this._onstop = onStop; }
|
|
496
|
-
stop() { clearInterval(this._timer);
|
|
497
|
-
this._onstop(); }
|
|
581
|
+
stop() { clearInterval(this._timer); this._onstop?.(); }
|
|
498
582
|
}
|
|
499
583
|
exports.MyTimerInterval = MyTimerInterval;
|
|
500
584
|
class Mutex {
|
|
@@ -523,7 +607,7 @@ exports.Mutex = Mutex;
|
|
|
523
607
|
async function copyToClipboard(textToCopy) {
|
|
524
608
|
const moduleName = 'child_process';
|
|
525
609
|
if (typeof window != "object")
|
|
526
|
-
return (await Promise.resolve(`${moduleName}`).then(s => require(s))).spawn('clip').stdin.end(textToCopy);
|
|
610
|
+
return (await Promise.resolve(`${moduleName}`).then(s => __importStar(require(s)))).spawn('clip').stdin.end(textToCopy);
|
|
527
611
|
if (navigator.clipboard && window.isSecureContext) {
|
|
528
612
|
return navigator.clipboard.writeText(textToCopy);
|
|
529
613
|
}
|
|
@@ -543,43 +627,6 @@ async function copyToClipboard(textToCopy) {
|
|
|
543
627
|
}
|
|
544
628
|
}
|
|
545
629
|
exports.copyToClipboard = copyToClipboard;
|
|
546
|
-
function deepEqual(object1, object2) {
|
|
547
|
-
if (object1 == object2)
|
|
548
|
-
return true;
|
|
549
|
-
const keys1 = Object.keys(object1);
|
|
550
|
-
const keys2 = Object.keys(object2);
|
|
551
|
-
if (keys1.length != keys2.length) {
|
|
552
|
-
return false;
|
|
553
|
-
}
|
|
554
|
-
for (const key of keys1) {
|
|
555
|
-
const val1 = object1[key];
|
|
556
|
-
const val2 = object2[key];
|
|
557
|
-
if (val1 === val2)
|
|
558
|
-
continue;
|
|
559
|
-
const areObjects = typeof (val1) == "object" && typeof (val2) == "object" && val1 != null && val2 != null;
|
|
560
|
-
if (!areObjects || !deepEqual(val1, val2))
|
|
561
|
-
return false;
|
|
562
|
-
}
|
|
563
|
-
return true;
|
|
564
|
-
}
|
|
565
|
-
exports.deepEqual = deepEqual;
|
|
566
|
-
function shallowEqual(object1, object2) {
|
|
567
|
-
if (!object1 || !object2)
|
|
568
|
-
return object1 == object2;
|
|
569
|
-
const keys1 = Object.keys(object1);
|
|
570
|
-
const keys2 = Object.keys(object2);
|
|
571
|
-
if (keys1.length != keys2.length) {
|
|
572
|
-
return false;
|
|
573
|
-
}
|
|
574
|
-
for (const key of keys1) {
|
|
575
|
-
const val1 = object1[key];
|
|
576
|
-
const val2 = object2[key];
|
|
577
|
-
if (val1 !== val2)
|
|
578
|
-
return false;
|
|
579
|
-
}
|
|
580
|
-
return true;
|
|
581
|
-
}
|
|
582
|
-
exports.shallowEqual = shallowEqual;
|
|
583
630
|
class CObjectID {
|
|
584
631
|
static #id = 1;
|
|
585
632
|
value = CObjectID.#id++;
|
package/lib/Common/Time.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { const_Date } from "./BaseTypes";
|
|
2
|
+
export type DateString = `${number}-${number}-${number}`;
|
|
3
|
+
export type TimeStringHHMM = `${number}:${number}`;
|
|
4
|
+
export type TimeStringHHMMSS = `${number}:${number}:${number}`;
|
|
5
|
+
export type TimeStringHHMMSS_ms = `${number}:${number}:${number}.${number}`;
|
|
6
|
+
type TimeString_ = ` ${TimeStringHHMM | TimeStringHHMMSS | TimeStringHHMMSS_ms}`;
|
|
7
|
+
export type DateTimeString = `${DateString}${TimeString_ | ""}${"Z" | ""}`;
|
|
8
|
+
export { const_Date };
|
|
9
|
+
export declare const H1_S = 3600;
|
|
10
|
+
export declare const D1_S: number;
|
|
11
|
+
export declare const W1_S: number;
|
|
12
|
+
export declare const W1_MS: number;
|
|
13
|
+
export declare const D1_MS: number;
|
|
14
|
+
export declare const H1_MS: number;
|
|
15
|
+
export declare const M1_MS: number;
|
|
2
16
|
declare enum __E_TF {
|
|
3
17
|
S1 = 1,
|
|
4
18
|
S2 = 2,
|
|
@@ -30,15 +44,14 @@ declare enum __E_TF {
|
|
|
30
44
|
H8 = 28,
|
|
31
45
|
H12 = 29,
|
|
32
46
|
D1 = 30,
|
|
33
|
-
W1 = 31
|
|
47
|
+
W1 = 31,
|
|
48
|
+
MN1 = 32,
|
|
49
|
+
MN2 = 33,
|
|
50
|
+
MN3 = 34,
|
|
51
|
+
MN4 = 35,
|
|
52
|
+
MN6 = 36,
|
|
53
|
+
Y1 = 37
|
|
34
54
|
}
|
|
35
|
-
export declare const H1_S = 3600;
|
|
36
|
-
export declare const D1_S: number;
|
|
37
|
-
export declare const W1_S: number;
|
|
38
|
-
export declare const W1_MS: number;
|
|
39
|
-
export declare const D1_MS: number;
|
|
40
|
-
export declare const H1_MS: number;
|
|
41
|
-
export declare const M1_MS: number;
|
|
42
55
|
export interface IPeriod {
|
|
43
56
|
readonly msec: number;
|
|
44
57
|
readonly name: string;
|
|
@@ -58,6 +71,8 @@ export declare class TIME_UNIT {
|
|
|
58
71
|
static readonly Hour: TIME_UNIT;
|
|
59
72
|
static readonly Day: TIME_UNIT;
|
|
60
73
|
static readonly Week: TIME_UNIT;
|
|
74
|
+
static readonly Month: TIME_UNIT;
|
|
75
|
+
static readonly Year: TIME_UNIT;
|
|
61
76
|
readonly [key: number]: void;
|
|
62
77
|
}
|
|
63
78
|
declare type Nominal<T, Name extends string> = T & {
|
|
@@ -75,10 +90,13 @@ export declare class TF implements IPeriod {
|
|
|
75
90
|
valueOf(): number;
|
|
76
91
|
toString(): string;
|
|
77
92
|
private constructor();
|
|
93
|
+
private static constructFromSec;
|
|
78
94
|
static get<T extends string>(name: T): TF | (T extends __E_TF_KEY ? never : null);
|
|
79
95
|
static getAsserted(name: string): TF;
|
|
80
|
-
static fromName<T extends string>(name: T): TF | (T extends "S1" | "S2" | "S3" | "S4" | "S5" | "S6" | "S10" | "S12" | "S15" | "S20" | "S30" | "M1" | "M2" | "M3" | "M4" | "M5" | "M6" | "M10" | "M12" | "M15" | "M20" | "M30" | "H1" | "H2" | "H3" | "H4" | "H6" | "H8" | "H12" | "D1" | "W1" ? never : null);
|
|
96
|
+
static fromName<T extends string>(name: T): TF | (T extends "S1" | "S2" | "S3" | "S4" | "S5" | "S6" | "S10" | "S12" | "S15" | "S20" | "S30" | "M1" | "M2" | "M3" | "M4" | "M5" | "M6" | "M10" | "M12" | "M15" | "M20" | "M30" | "H1" | "H2" | "H3" | "H4" | "H6" | "H8" | "H12" | "D1" | "W1" | "MN1" | "MN2" | "MN3" | "MN4" | "MN6" | "Y1" ? never : null);
|
|
81
97
|
static fromSec(value: number): TF | null;
|
|
98
|
+
static createCustomFromSec(sec: number): TF;
|
|
99
|
+
static createCustom(unit: TIME_UNIT, unitCount: number): TF;
|
|
82
100
|
static readonly all: readonly TF[];
|
|
83
101
|
private static readonly _mapBySec;
|
|
84
102
|
static readonly S1: TF;
|
|
@@ -112,6 +130,12 @@ export declare class TF implements IPeriod {
|
|
|
112
130
|
static readonly H12: TF;
|
|
113
131
|
static readonly D1: TF;
|
|
114
132
|
static readonly W1: TF;
|
|
133
|
+
static readonly MN1: TF;
|
|
134
|
+
static readonly MN2: TF;
|
|
135
|
+
static readonly MN3: TF;
|
|
136
|
+
static readonly MN4: TF;
|
|
137
|
+
static readonly MN6: TF;
|
|
138
|
+
static readonly Y1: TF;
|
|
115
139
|
static min(): never;
|
|
116
140
|
static min(...args: [TF, ...TF[]] | [[TF, ...TF[]]]): TF;
|
|
117
141
|
static min(...args: TF[] | [Iterable<TF>]): TF | null;
|
|
@@ -146,9 +170,11 @@ export declare class Period implements IPeriod {
|
|
|
146
170
|
static Name(tf: TF): string;
|
|
147
171
|
IndexFromTime(time: const_Date): number;
|
|
148
172
|
getStartTime(currentTime: const_Date): MyDate;
|
|
149
|
-
static StartTimeForIndex(tf: TF, index: number): MyDate;
|
|
150
173
|
private static getW1Shift_ms;
|
|
174
|
+
static W1Shift_ms: number;
|
|
175
|
+
static year0: number;
|
|
151
176
|
static IndexFromTime(tf: TF, time: const_Date): number;
|
|
177
|
+
static StartTimeForIndex(tf: TF, index: number): MyDate;
|
|
152
178
|
static StartTime(tf: TF, currentTime: const_Date, shiftPeriods?: number): MyDate;
|
|
153
179
|
static EndTime(tf: TF, currentTime: const_Date): Date;
|
|
154
180
|
}
|
|
@@ -178,4 +204,3 @@ export declare class CDelayer {
|
|
|
178
204
|
type NullableTime = const_Date | undefined | null;
|
|
179
205
|
export declare function MinTime<T1 extends NullableTime, T2 extends NullableTime>(time1: T1, time2: T2): T1 | NonNullable<T2>;
|
|
180
206
|
export declare function MaxTime<T1 extends NullableTime, T2 extends NullableTime>(time1: T1, time2: T2): T1 | NonNullable<T2>;
|
|
181
|
-
export {};
|
package/lib/Common/Time.js
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MaxTime = exports.MinTime = exports.CDelayer = exports.durationToStr_h_mm_ss_ms = exports.durationToStr_h_mm_ss = exports.durationToStrNullable = exports.durationToStr = exports.toPrintObject = exports.convertDatesToStrings = exports.timeToString_yyyymmdd_hhmmss_offset = exports.timeToString_yyyymmdd_hhmm_offset = exports.timeLocalToStr_yyyymmdd_hhmmss_ms = exports.timeLocalToStr_yyyymmdd_hhmmss = exports.timeLocalToStr_yyyymmdd_hhmm = exports.timeLocalToStr_yyyymmdd = exports.timeLocalToStr_hhmmss_ms = exports.timeLocalToStr_hhmmss = exports.timeToStr_yyyymmdd_hhmmss_ms = exports.timeToStr_yyyymmdd_hhmmss = exports.timeToStr_yyyymmdd_hhmm = exports.timeToStr_hhmmss = exports.timeToStr_hhmmss_ms = exports.Period = exports.PeriodSpan = exports.TF = exports.TIME_UNIT = exports.M1_MS = exports.H1_MS = exports.D1_MS = exports.W1_MS = exports.W1_S = exports.D1_S = exports.H1_S = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("./common");
|
|
5
5
|
function GetEnumKeys(T) { return Object.keys(T).filter(k => isNaN(k)); }
|
|
6
|
+
{
|
|
7
|
+
let t1 = "2022-05-01";
|
|
8
|
+
let t2 = "2022-05-01 01:01";
|
|
9
|
+
let t3 = "2022-05-01 01:01:10";
|
|
10
|
+
}
|
|
11
|
+
exports.H1_S = 3600;
|
|
12
|
+
exports.D1_S = 3600 * 24;
|
|
13
|
+
exports.W1_S = exports.D1_S * 7;
|
|
14
|
+
exports.W1_MS = exports.W1_S * 1000;
|
|
15
|
+
exports.D1_MS = exports.D1_S * 1000;
|
|
16
|
+
exports.H1_MS = exports.H1_S * 1000;
|
|
17
|
+
exports.M1_MS = 60 * 1000;
|
|
6
18
|
var __E_TF;
|
|
7
19
|
(function (__E_TF) {
|
|
8
20
|
__E_TF[__E_TF["S1"] = 1] = "S1";
|
|
@@ -36,16 +48,15 @@ var __E_TF;
|
|
|
36
48
|
__E_TF[__E_TF["H12"] = 29] = "H12";
|
|
37
49
|
__E_TF[__E_TF["D1"] = 30] = "D1";
|
|
38
50
|
__E_TF[__E_TF["W1"] = 31] = "W1";
|
|
51
|
+
__E_TF[__E_TF["MN1"] = 32] = "MN1";
|
|
52
|
+
__E_TF[__E_TF["MN2"] = 33] = "MN2";
|
|
53
|
+
__E_TF[__E_TF["MN3"] = 34] = "MN3";
|
|
54
|
+
__E_TF[__E_TF["MN4"] = 35] = "MN4";
|
|
55
|
+
__E_TF[__E_TF["MN6"] = 36] = "MN6";
|
|
56
|
+
__E_TF[__E_TF["Y1"] = 37] = "Y1";
|
|
39
57
|
})(__E_TF || (__E_TF = {}));
|
|
40
58
|
;
|
|
41
|
-
exports.H1_S
|
|
42
|
-
exports.D1_S = 3600 * 24;
|
|
43
|
-
exports.W1_S = exports.D1_S * 7;
|
|
44
|
-
exports.W1_MS = exports.W1_S * 1000;
|
|
45
|
-
exports.D1_MS = exports.D1_S * 1000;
|
|
46
|
-
exports.H1_MS = exports.H1_S * 1000;
|
|
47
|
-
exports.M1_MS = 60 * 1000;
|
|
48
|
-
const __Tf_S = [0, 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60, 120, 180, 240, 300, 360, 600, 720, 900, 1200, 1800, exports.H1_S, exports.H1_S * 2, exports.H1_S * 3, exports.H1_S * 4, exports.H1_S * 6, exports.H1_S * 8, exports.H1_S * 12, exports.D1_S, exports.W1_S];
|
|
59
|
+
const __Tf_S = [0, 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, 60, 120, 180, 240, 300, 360, 600, 720, 900, 1200, 1800, exports.H1_S, 2 * exports.H1_S, 3 * exports.H1_S, 4 * exports.H1_S, 6 * exports.H1_S, 8 * exports.H1_S, 12 * exports.H1_S, exports.D1_S, exports.W1_S, 30 * exports.D1_S, 60 * exports.D1_S, 90 * exports.D1_S, 120 * exports.D1_S, 180 * exports.D1_S, 365 * exports.D1_S];
|
|
49
60
|
class TIME_UNIT {
|
|
50
61
|
index;
|
|
51
62
|
msec;
|
|
@@ -65,7 +76,9 @@ class TIME_UNIT {
|
|
|
65
76
|
static Minute = new TIME_UNIT(60 * 1000, "minute", "M");
|
|
66
77
|
static Hour = new TIME_UNIT(exports.H1_S * 1000, "hour", "H");
|
|
67
78
|
static Day = new TIME_UNIT(exports.D1_S * 1000, "day", "D");
|
|
68
|
-
static Week = new TIME_UNIT(exports.D1_S * 1000
|
|
79
|
+
static Week = new TIME_UNIT(7 * exports.D1_S * 1000, "week", "W");
|
|
80
|
+
static Month = new TIME_UNIT(30 * exports.D1_S * 1000, "month", "MN");
|
|
81
|
+
static Year = new TIME_UNIT(365 * exports.D1_S * 1000, "year", "Y");
|
|
69
82
|
}
|
|
70
83
|
exports.TIME_UNIT = TIME_UNIT;
|
|
71
84
|
class TF {
|
|
@@ -77,13 +90,21 @@ class TF {
|
|
|
77
90
|
index;
|
|
78
91
|
valueOf() { return this.msec; }
|
|
79
92
|
toString() { return this.name; }
|
|
80
|
-
constructor(
|
|
81
|
-
this.
|
|
82
|
-
this.
|
|
83
|
-
this.msec =
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
86
|
-
this.
|
|
93
|
+
constructor(unit, unitCount, index, msec, name) {
|
|
94
|
+
this.unit = unit;
|
|
95
|
+
this.unitCount = unitCount;
|
|
96
|
+
this.msec = msec ?? unit.msec * unitCount;
|
|
97
|
+
this.sec = Math.floor(this.msec / 1000);
|
|
98
|
+
this.index = index;
|
|
99
|
+
this.name = name ?? (unit.sign + unitCount);
|
|
100
|
+
}
|
|
101
|
+
static constructFromSec(sec, name) {
|
|
102
|
+
let msec = sec * 1000;
|
|
103
|
+
let index = __Tf_S.indexOf(sec);
|
|
104
|
+
let units = [TIME_UNIT.Year, TIME_UNIT.Month, TIME_UNIT.Week, TIME_UNIT.Day, TIME_UNIT.Hour, TIME_UNIT.Minute, TIME_UNIT.Second, TIME_UNIT.MSecond];
|
|
105
|
+
let unit = units.find((u) => Math.floor(sec % u.sec) == 0);
|
|
106
|
+
let unitCount = Math.floor(sec / unit.sec);
|
|
107
|
+
return new TF(unit, unitCount, index, msec, name);
|
|
87
108
|
}
|
|
88
109
|
static get(name) {
|
|
89
110
|
let key = __E_TF[name];
|
|
@@ -94,11 +115,13 @@ class TF {
|
|
|
94
115
|
static getAsserted(name) { return TF.get(name) ?? (() => { throw "Unknown timeframe: " + name; })(); }
|
|
95
116
|
static fromName(name) { return this.get(name); }
|
|
96
117
|
static fromSec(value) { return this._mapBySec[value]; }
|
|
118
|
+
static createCustomFromSec(sec) { return TF.constructFromSec(sec); }
|
|
119
|
+
static createCustom(unit, unitCount) { return new TF(unit, unitCount, -1); }
|
|
97
120
|
static all = function () {
|
|
98
121
|
let i = 1;
|
|
99
122
|
let arr = [];
|
|
100
123
|
for (let key of GetEnumKeys(__E_TF)) {
|
|
101
|
-
arr[__E_TF[key]] =
|
|
124
|
+
arr[__E_TF[key]] = TF.constructFromSec(__Tf_S[i], key);
|
|
102
125
|
i++;
|
|
103
126
|
}
|
|
104
127
|
return arr;
|
|
@@ -140,6 +163,12 @@ class TF {
|
|
|
140
163
|
static H12 = TF.get("H12");
|
|
141
164
|
static D1 = TF.get("D1");
|
|
142
165
|
static W1 = TF.get("W1");
|
|
166
|
+
static MN1 = TF.get("MN1");
|
|
167
|
+
static MN2 = TF.get("MN2");
|
|
168
|
+
static MN3 = TF.get("MN3");
|
|
169
|
+
static MN4 = TF.get("MN4");
|
|
170
|
+
static MN6 = TF.get("MN4");
|
|
171
|
+
static Y1 = TF.get("Y1");
|
|
143
172
|
static min(...args) {
|
|
144
173
|
let tfs = ((args[0] && !(args[0] instanceof TF)) ? args[0] : args);
|
|
145
174
|
let index = 999;
|
|
@@ -182,41 +211,50 @@ class Period {
|
|
|
182
211
|
get name() { return this.tf.name; }
|
|
183
212
|
valueOf() { return this.msec; }
|
|
184
213
|
span(time) { return new PeriodSpan(this.tf, time); }
|
|
185
|
-
constructor(tf) { this.tf = tf; return (0,
|
|
214
|
+
constructor(tf) { this.tf = tf; return (0, common_1.CreateArrayProxy)(this, (i) => new PeriodSpan(tf, i)); }
|
|
186
215
|
static Seconds(tf) { return tf.sec; }
|
|
187
216
|
static Name(tf) { return tf.name; }
|
|
188
217
|
IndexFromTime(time) {
|
|
189
218
|
return Period.IndexFromTime(this.tf, time);
|
|
190
219
|
}
|
|
191
220
|
getStartTime(currentTime) { return Period.StartTime(this.tf, currentTime); }
|
|
192
|
-
static StartTimeForIndex(tf, index) {
|
|
193
|
-
let tfmsec = Period.Seconds(tf) * 1000;
|
|
194
|
-
if (tf == TF.W1) {
|
|
195
|
-
return new MyDate(index * exports.W1_MS - this.getW1Shift_ms());
|
|
196
|
-
}
|
|
197
|
-
return new MyDate(index * tfmsec);
|
|
198
|
-
}
|
|
199
221
|
static getW1Shift_ms() {
|
|
200
222
|
const day0 = new Date(0).getUTCDay();
|
|
201
223
|
const tshift = exports.D1_MS * Math.trunc((day0 + 6) % 7);
|
|
202
224
|
return tshift;
|
|
203
225
|
}
|
|
226
|
+
static W1Shift_ms = this.getW1Shift_ms();
|
|
227
|
+
static year0 = new Date(0).getUTCFullYear();
|
|
204
228
|
static IndexFromTime(tf, time) {
|
|
205
|
-
|
|
206
|
-
|
|
229
|
+
const tf_msec = tf.msec;
|
|
230
|
+
if (tf.unit == TIME_UNIT.Week) {
|
|
231
|
+
return Math.floor((time.valueOf() + Period.W1Shift_ms) / tf_msec);
|
|
232
|
+
}
|
|
233
|
+
if (tf.unit == TIME_UNIT.Month) {
|
|
234
|
+
return Math.floor(((time.getFullYear() - Period.year0) * 12 + time.getMonth()) / tf.unitCount);
|
|
207
235
|
}
|
|
208
|
-
|
|
209
|
-
|
|
236
|
+
if (tf.unit == TIME_UNIT.Year) {
|
|
237
|
+
return time.getFullYear() - Period.year0;
|
|
238
|
+
}
|
|
239
|
+
return Math.floor(time.valueOf() / tf_msec);
|
|
210
240
|
}
|
|
211
|
-
static
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
return new MyDate(
|
|
241
|
+
static StartTimeForIndex(tf, index) {
|
|
242
|
+
const tf_msec = tf.msec;
|
|
243
|
+
if (tf.unit == TIME_UNIT.Week) {
|
|
244
|
+
return new MyDate(index * tf_msec - this.getW1Shift_ms());
|
|
215
245
|
}
|
|
216
|
-
|
|
217
|
-
|
|
246
|
+
if (tf.unit == TIME_UNIT.Month) {
|
|
247
|
+
return new MyDate(Period.year0 + Math.floor(index * tf.unitCount / 12), Math.floor(index * tf.unitCount % 12), 1);
|
|
248
|
+
}
|
|
249
|
+
if (tf.unit == TIME_UNIT.Year)
|
|
250
|
+
return new MyDate(Period.year0 + index, 0, 1);
|
|
251
|
+
return new MyDate(index * tf_msec);
|
|
252
|
+
}
|
|
253
|
+
static StartTime(tf, currentTime, shiftPeriods = 0) {
|
|
254
|
+
let index = this.IndexFromTime(tf, currentTime) + shiftPeriods;
|
|
255
|
+
return this.StartTimeForIndex(tf, index);
|
|
218
256
|
}
|
|
219
|
-
static EndTime(tf, currentTime) { return
|
|
257
|
+
static EndTime(tf, currentTime) { return this.StartTime(tf, currentTime, +1).ToShiftedMsTime(-1); }
|
|
220
258
|
}
|
|
221
259
|
exports.Period = Period;
|
|
222
260
|
function str2(n) { return n <= 9 ? '0' + n : '' + n; }
|
|
@@ -3,7 +3,11 @@ export type tRequestScreenerT<T> = {
|
|
|
3
3
|
callbacksId?: string[];
|
|
4
4
|
request: any[];
|
|
5
5
|
};
|
|
6
|
-
export declare function funcPromiseServer<T extends object>(data: screenerSoc<tSocketData<tRequestScreenerT<T>>>, obj: T
|
|
6
|
+
export declare function funcPromiseServer<T extends object>(data: screenerSoc<tSocketData<tRequestScreenerT<T>>>, obj: T, myCatch?: (r: {
|
|
7
|
+
data: string | any;
|
|
8
|
+
key: keyof T;
|
|
9
|
+
arguments: any[];
|
|
10
|
+
}) => void): void;
|
|
7
11
|
export declare function funcPromiseServer2<T extends object>(sendMessage: screenerSoc222<tSocketData<tRequestScreenerT<T>>>, obj: T): (datum: any) => Promise<void>;
|
|
8
12
|
export declare function funcPromiseServerPost<T extends object>(data: screenerPost<tRequestScreenerT<T>>, obj: T): void;
|
|
9
13
|
type tSocketData<T> = ({
|
|
@@ -83,10 +87,15 @@ export declare function CreatAPIFacadeClient<T extends object>({ socketKey, sock
|
|
|
83
87
|
space: tMethodToPromise2<typeNoVoid2<T>>;
|
|
84
88
|
all: tMethodToPromise2<T>;
|
|
85
89
|
};
|
|
86
|
-
export declare function CreatAPIFacadeServer<T extends object>({ object, socket, socketKey }: {
|
|
90
|
+
export declare function CreatAPIFacadeServer<T extends object>({ object, socket, socketKey, myCatch }: {
|
|
87
91
|
socket: any;
|
|
88
92
|
object: T;
|
|
89
93
|
socketKey: string;
|
|
94
|
+
myCatch?: (r: {
|
|
95
|
+
data: string | any;
|
|
96
|
+
key: keyof T;
|
|
97
|
+
arguments: any[];
|
|
98
|
+
}) => void;
|
|
90
99
|
}): void;
|
|
91
100
|
export declare function fMiniTest(): void;
|
|
92
101
|
export declare class CTestWeb {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CTestWeb = exports.fMiniTest = exports.CreatAPIFacadeServer = exports.CreatAPIFacadeClient = exports.funcScreenerClient3 = exports.funcScreenerClient2 = exports.FFuncMyF = exports.funcForWebSocket = exports.funcPromiseServerPost = exports.funcPromiseServer2 = exports.funcPromiseServer = void 0;
|
|
4
|
-
const
|
|
5
|
-
function funcPromiseServer(data, obj) {
|
|
4
|
+
const common_1 = require("./common");
|
|
5
|
+
function funcPromiseServer(data, obj, myCatch) {
|
|
6
6
|
const buf = data;
|
|
7
7
|
data.api({
|
|
8
8
|
onMessage: async (datum) => {
|
|
@@ -33,13 +33,13 @@ function funcPromiseServer(data, obj) {
|
|
|
33
33
|
const a = await (async () => buf(...request))()
|
|
34
34
|
.catch((e) => {
|
|
35
35
|
data.sendMessage({ mapId: datum.mapId, error: e });
|
|
36
|
-
throw e;
|
|
36
|
+
throw { data: e, key: key, arguments: request };
|
|
37
37
|
});
|
|
38
38
|
if (datum.wait !== false)
|
|
39
39
|
data.sendMessage({ mapId: datum.mapId, data: a ?? undefined });
|
|
40
40
|
}
|
|
41
41
|
else
|
|
42
|
-
throw "это не функция";
|
|
42
|
+
throw myCatch?.({ data: "это не функция", key: key, arguments: request });
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
}
|
|
@@ -236,11 +236,14 @@ function CreatAPIFacadeClient({ socketKey, socket }) {
|
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
238
|
exports.CreatAPIFacadeClient = CreatAPIFacadeClient;
|
|
239
|
-
function CreatAPIFacadeServer({ object, socket, socketKey }) {
|
|
239
|
+
function CreatAPIFacadeServer({ object, socket, socketKey, myCatch }) {
|
|
240
240
|
funcPromiseServer({
|
|
241
241
|
sendMessage: (data) => socket.emit(socketKey, data),
|
|
242
242
|
api: (api) => {
|
|
243
|
-
socket.on(socketKey, (d) => api.onMessage(d))
|
|
243
|
+
socket.on(socketKey, (d) => (async () => api.onMessage(d))()
|
|
244
|
+
.catch((e) => {
|
|
245
|
+
myCatch?.(e);
|
|
246
|
+
}));
|
|
244
247
|
}
|
|
245
248
|
}, object);
|
|
246
249
|
}
|
|
@@ -253,7 +256,7 @@ class CTestWeb {
|
|
|
253
256
|
return a + b;
|
|
254
257
|
}
|
|
255
258
|
async func2(a, b) {
|
|
256
|
-
await (0,
|
|
259
|
+
await (0, common_1.sleepAsync)(1000);
|
|
257
260
|
return a * b;
|
|
258
261
|
}
|
|
259
262
|
fun3(a, b) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SetAutoStepForElement = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("./common");
|
|
5
5
|
function SetAutoStepForElement(element, params = { maxStep: 1 }) {
|
|
6
6
|
function parse(valueStr) { let val = parseFloat(valueStr); return isNaN(val) ? null : val; }
|
|
7
7
|
const { minStep, maxStep = 1 } = params;
|
|
8
|
-
const maxDigits = minStep ? (0,
|
|
8
|
+
const maxDigits = minStep ? (0, common_1.GetDblPrecision)(minStep) : undefined;
|
|
9
9
|
const stepDefault = parse(element.step);
|
|
10
10
|
const minDefault = parse(element.min);
|
|
11
11
|
const maxDefault = parse(element.max);
|
|
@@ -18,12 +18,12 @@ function SetAutoStepForElement(element, params = { maxStep: 1 }) {
|
|
|
18
18
|
let digits = (dotPos >= 0) ? valueStr.length - dotPos - 1 : 0;
|
|
19
19
|
digits = Math.max(digits, minDigits);
|
|
20
20
|
if (digits > 10)
|
|
21
|
-
digits = (0,
|
|
21
|
+
digits = (0, common_1.GetDblPrecision2)(parseFloat(valueStr), minDigits, 10);
|
|
22
22
|
if (maxDigits != null)
|
|
23
23
|
digits = Math.min(digits, maxDigits);
|
|
24
|
-
let step = (0,
|
|
24
|
+
let step = (0, common_1.NormalizeDouble)(Math.pow(0.1, digits), digits);
|
|
25
25
|
if (minStep)
|
|
26
|
-
step = (0,
|
|
26
|
+
step = (0, common_1.NormalizeDouble)(Math.round(step / minStep) * minStep, digits);
|
|
27
27
|
if (maxDefault != null && minDefault != null)
|
|
28
28
|
if (maxDefault - minDefault < step * 2)
|
|
29
29
|
return _step;
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
let wrapCallSite;
|
|
4
4
|
if (1)
|
|
5
|
-
if (
|
|
5
|
+
if (typeof self != 'object' && typeof window != "object") {
|
|
6
|
+
let require = eval('require');
|
|
6
7
|
try {
|
|
7
8
|
require('source-map-support').install();
|
|
8
9
|
wrapCallSite = require('source-map-support').wrapCallSite;
|
|
9
10
|
}
|
|
10
|
-
catch {
|
|
11
|
+
catch (e) {
|
|
12
|
+
console.warn(e);
|
|
11
13
|
}
|
|
12
14
|
for (let methodName of ['debug', 'log', 'warn', 'error']) {
|
|
13
15
|
const originalLoggingMethod = console[methodName];
|
package/lib/Common/waitRun.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.waitRun = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("./common");
|
|
5
5
|
function waitRun() {
|
|
6
6
|
let lastTime = Date.now();
|
|
7
7
|
let funcAsync = Promise.resolve();
|
|
@@ -26,7 +26,7 @@ function waitRun() {
|
|
|
26
26
|
if (!busy) {
|
|
27
27
|
busy = true;
|
|
28
28
|
funcAsync = funcAsync.then(async () => {
|
|
29
|
-
await (0,
|
|
29
|
+
await (0, common_1.sleepAsync)(ms);
|
|
30
30
|
lastFunc1?.();
|
|
31
31
|
busy = false;
|
|
32
32
|
return;
|
package/lib/Exchange/Bars.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference path="../Common/BaseTypes.d.ts" />
|
|
2
|
-
import * as lib from "../Common/
|
|
3
|
-
import { IItems, ParsedUrlQueryInputMy, SearchMatchMode } from "../Common/
|
|
2
|
+
import * as lib from "../Common/common";
|
|
3
|
+
import { IItems, ParsedUrlQueryInputMy, SearchMatchMode } from "../Common/common";
|
|
4
4
|
import { TF } from "../Common/Time";
|
|
5
5
|
import { ByteStreamR, ByteStreamW, Nullable, NumericTypes } from "../Common/ByteStream";
|
|
6
6
|
import { const_Date, ReadonlyFull } from "../Common/BaseTypes";
|
package/lib/Exchange/Bars.js
CHANGED
|
@@ -10,13 +10,25 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
27
|
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
29
|
exports.findBarsShallow = exports.CTimeSeries = exports.CTimeSeriesBase = exports.CreateRandomBars = exports.CBarsMutableExt = exports.CBarsMutable = exports.CBarsMutableBase = exports.CBars = exports.CBarsBase = exports.IBars = exports.CTick = exports.CBar = exports.CBarBase = exports.OHLC = void 0;
|
|
18
|
-
const lib = require("../Common/
|
|
19
|
-
const
|
|
30
|
+
const lib = __importStar(require("../Common/common"));
|
|
31
|
+
const common_1 = require("../Common/common");
|
|
20
32
|
const Time_1 = require("../Common/Time");
|
|
21
33
|
__exportStar(require("../Common/Time"), exports);
|
|
22
34
|
class OHLC {
|
|
@@ -102,7 +114,7 @@ class IBars {
|
|
|
102
114
|
get firstTime() { return this.count > 0 ? this.data[0].time : null; }
|
|
103
115
|
get lastTime() { return this.count > 0 ? this.data[this.count - 1].time : null; }
|
|
104
116
|
get lastCloseTime() { return this.count > 0 ? this.closeTime(this.count - 1) : null; }
|
|
105
|
-
Values(getter) { return new
|
|
117
|
+
Values(getter) { return new common_1.VirtualItems((i) => getter(this.data[i]), () => this.data.length); }
|
|
106
118
|
get times() { return this.Values((bar) => bar.time); }
|
|
107
119
|
get opens() { return this.Values((bar) => bar.open); }
|
|
108
120
|
get highs() { return this.Values((bar) => bar.high); }
|
|
@@ -112,7 +124,7 @@ class IBars {
|
|
|
112
124
|
entries() { return this.data.entries(); }
|
|
113
125
|
indexOf(time, match) {
|
|
114
126
|
time = Time_1.Period.StartTime(this.Tf, time);
|
|
115
|
-
return lib.BSearch(this.data, time, (bar, time) => bar.time.valueOf() - time.valueOf(), match ? match :
|
|
127
|
+
return lib.BSearch(this.data, time, (bar, time) => bar.time.valueOf() - time.valueOf(), match ? match : common_1.BSearch.EQUAL);
|
|
116
128
|
}
|
|
117
129
|
indexOfLessOrEqual(time) { return this.indexOf(time, "lessOrEqual"); }
|
|
118
130
|
concat(newBars) {
|
|
@@ -139,8 +151,8 @@ class IBars {
|
|
|
139
151
|
yield this.data[i];
|
|
140
152
|
}
|
|
141
153
|
getArray(startTime, lastTime) {
|
|
142
|
-
let istart = startTime ? this.indexOf(startTime,
|
|
143
|
-
let ilast = lastTime ? this.indexOf(lastTime,
|
|
154
|
+
let istart = startTime ? this.indexOf(startTime, common_1.BSearch.GREAT_OR_EQUAL) : 0;
|
|
155
|
+
let ilast = lastTime ? this.indexOf(lastTime, common_1.BSearch.LESS_OR_EQUAL) : this.data.length - 1;
|
|
144
156
|
if (istart == -1 || istart > ilast)
|
|
145
157
|
return null;
|
|
146
158
|
return this.data.slice(istart, ilast + 1);
|
|
@@ -359,8 +371,8 @@ function CreateRandomBars(tf, startTime, endTimeOrCount, startPrice = 100, volat
|
|
|
359
371
|
let bars = new Array(count);
|
|
360
372
|
let price = startPrice;
|
|
361
373
|
let periodSpan = period.span(startTime);
|
|
362
|
-
let digits = (0,
|
|
363
|
-
function norm(value) { return (0,
|
|
374
|
+
let digits = (0, common_1.GetDblPrecision)(tickSizeNum);
|
|
375
|
+
function norm(value) { return (0, common_1.NormalizeDouble)(Math.round(value / tickSizeNum) * tickSizeNum, digits); }
|
|
364
376
|
const [volatFactor, volatNum] = typeof volatility == "string" ? [Number(volatility.slice(0, -1)) / 100, undefined] : [undefined, volatility];
|
|
365
377
|
for (let i = 0; i < count; i++) {
|
|
366
378
|
const volat = volatNum ?? volatFactor * price;
|
|
@@ -385,9 +397,9 @@ class CTimeSeriesBase {
|
|
|
385
397
|
get times() { return new lib.VirtualItems((i) => this.time(i), () => this.length); }
|
|
386
398
|
get values() { return new lib.VirtualItems((i) => this.value(i), () => this.length); }
|
|
387
399
|
get length() { return this.points.length; }
|
|
388
|
-
indexOf(time, match) { return (0,
|
|
400
|
+
indexOf(time, match) { return (0, common_1.BSearch)(this.times, time, match); }
|
|
389
401
|
constructor() {
|
|
390
|
-
return (0,
|
|
402
|
+
return (0, common_1.CreateArrayProxy)(this, (i) => this.points[i]);
|
|
391
403
|
}
|
|
392
404
|
[Symbol.iterator]() { return this.points[Symbol.iterator](); }
|
|
393
405
|
}
|
|
@@ -428,14 +440,14 @@ function _findBars(srcBars, barsToFind, mode) {
|
|
|
428
440
|
return -1;
|
|
429
441
|
let start = 0;
|
|
430
442
|
let end = len - 1;
|
|
431
|
-
let iStart = (0,
|
|
432
|
-
let iEnd = (0,
|
|
443
|
+
let iStart = (0, common_1.BSearch)(srcBars, barsToFind[start].time, (bar, time) => bar.time.valueOf() - time.valueOf());
|
|
444
|
+
let iEnd = (0, common_1.BSearch)(srcBars, barsToFind[end].time, (bar, time) => bar.time.valueOf() - time.valueOf());
|
|
433
445
|
if (iStart < 0 || iEnd < 0 || iEnd - iStart + 1 != len)
|
|
434
446
|
return -1;
|
|
435
447
|
let delta = start - iStart;
|
|
436
448
|
if (mode == "deep") {
|
|
437
449
|
for (let i = iStart; i <= iEnd; i++)
|
|
438
|
-
if (!(0,
|
|
450
|
+
if (!(0, common_1.deepEqual)(srcBars[i], barsToFind[i + delta]))
|
|
439
451
|
return -1;
|
|
440
452
|
}
|
|
441
453
|
else
|
package/lib/Exchange/CParams.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeParamValuesToInfos = exports.GetSimpleParams = exports.enableAllParams = exports.iterateParams = exports.isParamGroup = exports.isParamGroupOrArray = exports.CParamsReadonly = exports.CParams = exports.isParamBase = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const common_1 = require("../Common/common");
|
|
5
|
+
{
|
|
6
|
+
let ts = "2025-06-01 16:25:25";
|
|
7
|
+
}
|
|
6
8
|
{
|
|
7
9
|
let x = { value: 5, range: [5, 6] };
|
|
8
10
|
}
|
|
@@ -32,14 +34,14 @@ function* iterateParams(obj, currentPath = []) {
|
|
|
32
34
|
if (typeof param == "object") {
|
|
33
35
|
const valKey = "value";
|
|
34
36
|
let value = param[valKey];
|
|
35
|
-
if (typeof value == "object" && !(0,
|
|
37
|
+
if (typeof value == "object" && !(0, common_1.isDate)(value) && !Array.isArray(value))
|
|
36
38
|
yield* iterateParams(value, keyPath.concat(valKey));
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
exports.iterateParams = iterateParams;
|
|
41
43
|
function enableAllParams(params, enabled = true) {
|
|
42
|
-
const paramsInfoClone = (0,
|
|
44
|
+
const paramsInfoClone = (0, common_1.deepCloneMutable)(params);
|
|
43
45
|
for (let [key, param] of iterateParams(paramsInfoClone)) {
|
|
44
46
|
if (isParamBase(param) && param.enabled != null)
|
|
45
47
|
param.enabled = enabled;
|
|
@@ -104,7 +106,8 @@ class Test extends CParams {
|
|
|
104
106
|
};
|
|
105
107
|
}
|
|
106
108
|
function GetSimpleParams(params) {
|
|
107
|
-
|
|
109
|
+
const simpleParamsBase = params instanceof Array ? [] : {};
|
|
110
|
+
let simpleParams = simpleParamsBase;
|
|
108
111
|
for (let key in params) {
|
|
109
112
|
const param = params[key];
|
|
110
113
|
simpleParams[key] =
|
package/lib/Exchange/LoadBase.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LoadQuoteBase = void 0;
|
|
4
|
-
const
|
|
4
|
+
const common_1 = require("../Common/common");
|
|
5
5
|
const Time_1 = require("../Common/Time");
|
|
6
6
|
const funcTimeWait_1 = require("../Common/funcTimeWait");
|
|
7
7
|
function LoadQuoteBase(setting, data) {
|
|
@@ -16,7 +16,7 @@ function LoadQuoteBase(setting, data) {
|
|
|
16
16
|
const t1 = funcTimeWait_1.FuncTimeWait.byWeight(keyName, setting.countConnect) - (Date.now() - time) + 1;
|
|
17
17
|
if (t1 > 0) {
|
|
18
18
|
funcTimeWait_1.FuncTimeWait.add({ type: keyName, weight: weight, timeStamp: Date.now() + t1 });
|
|
19
|
-
await (0,
|
|
19
|
+
await (0, common_1.sleepAsync)(t1);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
22
|
funcTimeWait_1.FuncTimeWait.add({ type: keyName, weight: weight, timeStamp: Date.now() });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MyNumMap, ParsedUrlQueryInputMy } from "../Common/
|
|
1
|
+
import { MyNumMap, ParsedUrlQueryInputMy } from "../Common/common";
|
|
2
2
|
import { CBar, CBarsMutableBase, IBars, IBarsImmutable, ITick, TF } from "./Bars";
|
|
3
3
|
import { const_Date } from "../Common/BaseTypes";
|
|
4
4
|
export * from "./Bars";
|
|
@@ -75,4 +75,4 @@ export declare class CQuotesHistoryMutable2 extends CQuotesHistory {
|
|
|
75
75
|
protected _CreateNewBars(tf: TF): CBarsInternal | null;
|
|
76
76
|
Update(other: CQuotesHistory, endTime?: const_Date): void;
|
|
77
77
|
}
|
|
78
|
-
export { deepEqual } from "../Common/
|
|
78
|
+
export { deepEqual } from "../Common/common";
|
|
@@ -10,13 +10,25 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
27
|
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
29
|
exports.deepEqual = exports.CQuotesHistoryMutable2 = exports.CQuotesHistoryMutable = exports.CQuotesHistory = void 0;
|
|
18
|
-
const lib = require("../Common/
|
|
19
|
-
const
|
|
30
|
+
const lib = __importStar(require("../Common/common"));
|
|
31
|
+
const common_1 = require("../Common/common");
|
|
20
32
|
const Bars_1 = require("./Bars");
|
|
21
33
|
__exportStar(require("./Bars"), exports);
|
|
22
34
|
class CBarsInternal extends Bars_1.CBarsMutableBase {
|
|
@@ -30,8 +42,8 @@ class CBarsInternal extends Bars_1.CBarsMutableBase {
|
|
|
30
42
|
}
|
|
31
43
|
class CQuotesHistory {
|
|
32
44
|
_modifyCounter = 0;
|
|
33
|
-
barsMainMap = new
|
|
34
|
-
barsInfoMap = new
|
|
45
|
+
barsMainMap = new common_1.MyNumMap();
|
|
46
|
+
barsInfoMap = new common_1.MyNumMap();
|
|
35
47
|
_ticksize;
|
|
36
48
|
_minTf;
|
|
37
49
|
_GetTickSize() { let val = 0; for (let bars of this.barsMainMap.Values)
|
|
@@ -39,7 +51,7 @@ class CQuotesHistory {
|
|
|
39
51
|
name;
|
|
40
52
|
static fromParsedJSON(data) {
|
|
41
53
|
let d = data;
|
|
42
|
-
let map = Object.assign(new
|
|
54
|
+
let map = Object.assign(new common_1.MyNumMap(), { ...d.barsMainMap });
|
|
43
55
|
return new CQuotesHistory(map.Values.map((bars) => Bars_1.CBars.fromParsedJSON(bars)), d.name);
|
|
44
56
|
}
|
|
45
57
|
get stateID() { return this._modifyCounter; }
|
|
@@ -103,12 +115,12 @@ class CQuotesHistory {
|
|
|
103
115
|
_CombineBars(myBars, newBars, startTime, endtime) {
|
|
104
116
|
if (!newBars)
|
|
105
117
|
return myBars;
|
|
106
|
-
let ibar = myBars.indexOf(startTime,
|
|
118
|
+
let ibar = myBars.indexOf(startTime, common_1.E_MATCH.GREAT_OR_EQUAL);
|
|
107
119
|
if (ibar == -1)
|
|
108
120
|
ibar = myBars.count;
|
|
109
121
|
let lastBars = [];
|
|
110
122
|
if (endtime) {
|
|
111
|
-
let ilast = myBars.indexOf(endtime,
|
|
123
|
+
let ilast = myBars.indexOf(endtime, common_1.E_MATCH.LESS_OR_EQUAL) + 1;
|
|
112
124
|
lastBars = myBars.data.slice(ilast, myBars.length);
|
|
113
125
|
}
|
|
114
126
|
let resultBars;
|
|
@@ -126,7 +138,7 @@ class CQuotesHistory {
|
|
|
126
138
|
return this._CombineBars(myBars, addedBarsArrConverted, startTime);
|
|
127
139
|
}
|
|
128
140
|
_getLessTf(tf) {
|
|
129
|
-
let i = lib.BSearch(this.barsInfoMap.sortedKeys, tf.index - 1,
|
|
141
|
+
let i = lib.BSearch(this.barsInfoMap.sortedKeys, tf.index - 1, common_1.E_MATCH.LESS_OR_EQUAL);
|
|
130
142
|
return (i >= 0) ? Bars_1.TF.all[this.barsInfoMap.sortedKeys[i]] : null;
|
|
131
143
|
}
|
|
132
144
|
_BuildNewBars(tf) {
|
|
@@ -324,7 +336,7 @@ class CQuotesHistoryMutable2 extends CQuotesHistory {
|
|
|
324
336
|
let srcBars = this._source?.Bars(tf);
|
|
325
337
|
if (!srcBars)
|
|
326
338
|
return null;
|
|
327
|
-
let istop = this._time ? srcBars.indexOf(this._time,
|
|
339
|
+
let istop = this._time ? srcBars.indexOf(this._time, common_1.E_MATCH.GREAT_OR_EQUAL) : srcBars.length;
|
|
328
340
|
let slicedBars = srcBars.data.slice(0, istop);
|
|
329
341
|
return new CBarsInternal(tf, slicedBars);
|
|
330
342
|
}
|
|
@@ -338,7 +350,7 @@ class CQuotesHistoryMutable2 extends CQuotesHistory {
|
|
|
338
350
|
let start = 0;
|
|
339
351
|
if (isUpdate && (endTime && this._time ? endTime >= this._time : endTime == this._time))
|
|
340
352
|
start = bars.data.length;
|
|
341
|
-
let stop = endTime ? srcBars.indexOf(endTime,
|
|
353
|
+
let stop = endTime ? srcBars.indexOf(endTime, common_1.E_MATCH.GREAT_OR_EQUAL) : srcBars.length;
|
|
342
354
|
let newbarsArr = srcBars.data.slice(start, stop);
|
|
343
355
|
let resultbarsArr = start > 0 ? [...bars.data, ...newbarsArr] : newbarsArr;
|
|
344
356
|
let resultBars = new Bars_1.CBars(bars.Tf, resultbarsArr, bars.tickSize);
|
|
@@ -353,5 +365,5 @@ class CQuotesHistoryMutable2 extends CQuotesHistory {
|
|
|
353
365
|
}
|
|
354
366
|
}
|
|
355
367
|
exports.CQuotesHistoryMutable2 = CQuotesHistoryMutable2;
|
|
356
|
-
var
|
|
357
|
-
Object.defineProperty(exports, "deepEqual", { enumerable: true, get: function () { return
|
|
368
|
+
var common_2 = require("../Common/common");
|
|
369
|
+
Object.defineProperty(exports, "deepEqual", { enumerable: true, get: function () { return common_2.deepEqual; } });
|
package/lib/client.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export * from "./Common/Time";
|
|
2
|
-
export * from "./Common/
|
|
2
|
+
export * from "./Common/common";
|
|
3
3
|
export * from "./Common/Color";
|
|
4
4
|
export * from "./Common/ListNodeAnd";
|
|
5
5
|
export * from "./Common/Math";
|
|
6
6
|
export * from "./Exchange/ConnectData/Binance";
|
|
7
7
|
export * as BaseTypes from "./Common/BaseTypes";
|
|
8
|
-
export * as Common from "./Common/
|
|
8
|
+
export * as Common from "./Common/common";
|
|
9
9
|
export * as Time from "./Common/Time";
|
|
10
10
|
export * as Color from "./Common/Color";
|
|
11
11
|
export * as ListNodeAnd from "./Common/ListNodeAnd";
|
package/lib/client.js
CHANGED
|
@@ -10,25 +10,37 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
29
|
exports.test = exports.LoadCandles = exports.List = exports.Math = exports.ListNodeAnd = exports.Color = exports.Time = exports.Common = exports.BaseTypes = void 0;
|
|
18
30
|
__exportStar(require("./Common/Time"), exports);
|
|
19
|
-
__exportStar(require("./Common/
|
|
31
|
+
__exportStar(require("./Common/common"), exports);
|
|
20
32
|
__exportStar(require("./Common/Color"), exports);
|
|
21
33
|
__exportStar(require("./Common/ListNodeAnd"), exports);
|
|
22
34
|
__exportStar(require("./Common/Math"), exports);
|
|
23
35
|
__exportStar(require("./Exchange/ConnectData/Binance"), exports);
|
|
24
|
-
exports.BaseTypes = require("./Common/BaseTypes");
|
|
25
|
-
exports.Common = require("./Common/
|
|
26
|
-
exports.Time = require("./Common/Time");
|
|
27
|
-
exports.Color = require("./Common/Color");
|
|
28
|
-
exports.ListNodeAnd = require("./Common/ListNodeAnd");
|
|
29
|
-
exports.Math = require("./Common/Math");
|
|
30
|
-
exports.List = require("./Common/List");
|
|
31
|
-
exports.LoadCandles = require("./Exchange/ConnectData/Binance");
|
|
36
|
+
exports.BaseTypes = __importStar(require("./Common/BaseTypes"));
|
|
37
|
+
exports.Common = __importStar(require("./Common/common"));
|
|
38
|
+
exports.Time = __importStar(require("./Common/Time"));
|
|
39
|
+
exports.Color = __importStar(require("./Common/Color"));
|
|
40
|
+
exports.ListNodeAnd = __importStar(require("./Common/ListNodeAnd"));
|
|
41
|
+
exports.Math = __importStar(require("./Common/Math"));
|
|
42
|
+
exports.List = __importStar(require("./Common/List"));
|
|
43
|
+
exports.LoadCandles = __importStar(require("./Exchange/ConnectData/Binance"));
|
|
32
44
|
const ListNodeAnd_1 = require("./Common/ListNodeAnd");
|
|
33
45
|
function test() {
|
|
34
46
|
const tt = new ListNodeAnd_1.CListNodeAnd();
|
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from "./Common/BaseTypes";
|
|
|
2
2
|
export * from "./Common/ByteStream";
|
|
3
3
|
export * from "./Common/Color";
|
|
4
4
|
export * from "./Common/Time";
|
|
5
|
-
export * from "./Common/
|
|
5
|
+
export * from "./Common/common";
|
|
6
6
|
export * from "./Common/commonsServer";
|
|
7
7
|
export * from "./Common/event";
|
|
8
8
|
export * from "./Common/funcTimeWait";
|
|
@@ -16,7 +16,7 @@ export * from "./Exchange/Bars";
|
|
|
16
16
|
export * from "./Exchange/LoadBase";
|
|
17
17
|
export * from "./Exchange/ConnectData/Binance";
|
|
18
18
|
export * as BaseTypes from "./Common/BaseTypes";
|
|
19
|
-
export * as Common from "./Common/
|
|
19
|
+
export * as Common from "./Common/common";
|
|
20
20
|
export * as Time from "./Common/Time";
|
|
21
21
|
export * as Color from "./Common/Color";
|
|
22
22
|
export * as ListNodeAnd from "./Common/ListNodeAnd";
|
package/lib/index.js
CHANGED
|
@@ -10,16 +10,28 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
13
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
20
|
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
29
|
exports.test = exports.LoadCandles = exports.Params = exports.List = exports.Math = exports.ListNodeAnd = exports.Color = exports.Time = exports.Common = exports.BaseTypes = void 0;
|
|
18
30
|
__exportStar(require("./Common/BaseTypes"), exports);
|
|
19
31
|
__exportStar(require("./Common/ByteStream"), exports);
|
|
20
32
|
__exportStar(require("./Common/Color"), exports);
|
|
21
33
|
__exportStar(require("./Common/Time"), exports);
|
|
22
|
-
__exportStar(require("./Common/
|
|
34
|
+
__exportStar(require("./Common/common"), exports);
|
|
23
35
|
__exportStar(require("./Common/commonsServer"), exports);
|
|
24
36
|
__exportStar(require("./Common/event"), exports);
|
|
25
37
|
__exportStar(require("./Common/funcTimeWait"), exports);
|
|
@@ -32,15 +44,15 @@ __exportStar(require("./Common/waitRun"), exports);
|
|
|
32
44
|
__exportStar(require("./Exchange/Bars"), exports);
|
|
33
45
|
__exportStar(require("./Exchange/LoadBase"), exports);
|
|
34
46
|
__exportStar(require("./Exchange/ConnectData/Binance"), exports);
|
|
35
|
-
exports.BaseTypes = require("./Common/BaseTypes");
|
|
36
|
-
exports.Common = require("./Common/
|
|
37
|
-
exports.Time = require("./Common/Time");
|
|
38
|
-
exports.Color = require("./Common/Color");
|
|
39
|
-
exports.ListNodeAnd = require("./Common/ListNodeAnd");
|
|
40
|
-
exports.Math = require("./Common/Math");
|
|
41
|
-
exports.List = require("./Common/List");
|
|
42
|
-
exports.Params = require("./Exchange/CParams");
|
|
43
|
-
exports.LoadCandles = require("./Exchange/ConnectData/Binance");
|
|
47
|
+
exports.BaseTypes = __importStar(require("./Common/BaseTypes"));
|
|
48
|
+
exports.Common = __importStar(require("./Common/common"));
|
|
49
|
+
exports.Time = __importStar(require("./Common/Time"));
|
|
50
|
+
exports.Color = __importStar(require("./Common/Color"));
|
|
51
|
+
exports.ListNodeAnd = __importStar(require("./Common/ListNodeAnd"));
|
|
52
|
+
exports.Math = __importStar(require("./Common/Math"));
|
|
53
|
+
exports.List = __importStar(require("./Common/List"));
|
|
54
|
+
exports.Params = __importStar(require("./Exchange/CParams"));
|
|
55
|
+
exports.LoadCandles = __importStar(require("./Exchange/ConnectData/Binance"));
|
|
44
56
|
const ListNodeAnd_1 = require("./Common/ListNodeAnd");
|
|
45
57
|
function test() {
|
|
46
58
|
const tt = new ListNodeAnd_1.CListNodeAnd();
|