-
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathasset.ts
More file actions
49 lines (46 loc) · 1.17 KB
/
Copy pathasset.ts
File metadata and controls
49 lines (46 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2022-2026 The Indicator Authors. All rights reserved.
// https://github.com/cinar/indicatorts
/**
* Asset object.
*/
export interface Asset {
dates: Date[];
openings: number[];
closings: number[];
highs: number[];
lows: number[];
volumes: number[];
}
/**
* New asset with length.
*
* @param length asset length.
* @return asset object.
*/
export function newAssetWithLength(length: number): Asset {
return {
dates: new Array<Date>(length),
openings: new Array<number>(length),
closings: new Array<number>(length),
highs: new Array<number>(length),
lows: new Array<number>(length),
volumes: new Array<number>(length),
};
}
/**
* Concats the given assets.
*
* @param asset1 first asset.
* @param asset2 second asset.
* @return new asset.
*/
export function concatAssets(asset1: Asset, asset2: Asset): Asset {
return {
dates: [...asset1.dates, ...asset2.dates],
openings: [...asset1.openings, ...asset2.openings],
closings: [...asset1.closings, ...asset2.closings],
highs: [...asset1.highs, ...asset2.highs],
lows: [...asset1.lows, ...asset2.lows],
volumes: [...asset1.volumes, ...asset2.volumes],
};
}