laplace-api 4.8.0 → 5.1.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/package.json +1 -1
- package/src/client/broker.ts +17 -17
- package/src/client/capital_increase.ts +9 -10
- package/src/client/client.ts +40 -40
- package/src/client/collections.ts +26 -14
- package/src/client/custom_theme.ts +15 -14
- package/src/client/financial_fundamentals.ts +29 -27
- package/src/client/financial_ratios.ts +29 -47
- package/src/client/funds.ts +10 -5
- package/src/client/key-insights.ts +1 -1
- package/src/client/live-price-web-socket.ts +3 -1
- package/src/client/live-price.ts +18 -44
- package/src/client/news.ts +40 -56
- package/src/client/search.ts +13 -9
- package/src/client/stocks.ts +42 -12
- package/src/test/broker.test.ts +580 -453
- package/src/test/capital_increase.test.ts +131 -82
- package/src/test/collections.test.ts +489 -268
- package/src/test/custom_theme.test.ts +250 -144
- package/src/test/financial_fundamentals.test.ts +171 -202
- package/src/test/financial_ratios.test.ts +222 -170
- package/src/test/funds.test.ts +231 -162
- package/src/test/helpers.ts +23 -27
- package/src/test/key-insight.test.ts +71 -36
- package/src/test/live-price.test.ts +135 -1
- package/src/test/news.test.ts +320 -177
- package/src/test/politician.test.ts +176 -187
- package/src/test/readme.test.ts +12 -13
- package/src/test/search.test.ts +144 -170
- package/src/test/stocks.test.ts +306 -370
- package/src/utilities/test.env +0 -2
package/package.json
CHANGED
package/src/client/broker.ts
CHANGED
|
@@ -33,6 +33,8 @@ export interface BrokerStock {
|
|
|
33
33
|
id: string;
|
|
34
34
|
assetType: AssetType;
|
|
35
35
|
assetClass: AssetClass;
|
|
36
|
+
logoUrl?: string;
|
|
37
|
+
exchange?: string;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
export interface BrokerStats {
|
|
@@ -59,8 +61,8 @@ export class BrokerClient extends Client {
|
|
|
59
61
|
|
|
60
62
|
async getBrokers(
|
|
61
63
|
region: Region,
|
|
62
|
-
page: number,
|
|
63
64
|
size: number,
|
|
65
|
+
page?: number,
|
|
64
66
|
assetClass?: AssetClass
|
|
65
67
|
): Promise<PaginatedResponse<Broker>> {
|
|
66
68
|
return this.sendRequest<PaginatedResponse<Broker>>({
|
|
@@ -68,9 +70,9 @@ export class BrokerClient extends Client {
|
|
|
68
70
|
url: "/api/v1/brokers",
|
|
69
71
|
params: {
|
|
70
72
|
region,
|
|
71
|
-
page,
|
|
72
73
|
size,
|
|
73
|
-
|
|
74
|
+
...(page != null && { page }),
|
|
75
|
+
...(assetClass != null && { assetClass }),
|
|
74
76
|
},
|
|
75
77
|
});
|
|
76
78
|
}
|
|
@@ -81,8 +83,8 @@ export class BrokerClient extends Client {
|
|
|
81
83
|
sortDirection: SortDirection,
|
|
82
84
|
fromDate: string,
|
|
83
85
|
toDate: string,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
size: number,
|
|
87
|
+
page?: number,
|
|
86
88
|
): Promise<BrokerList> {
|
|
87
89
|
return this.sendRequest<BrokerList>({
|
|
88
90
|
method: "GET",
|
|
@@ -93,8 +95,8 @@ export class BrokerClient extends Client {
|
|
|
93
95
|
sortDirection,
|
|
94
96
|
fromDate,
|
|
95
97
|
toDate,
|
|
96
|
-
page,
|
|
97
98
|
size,
|
|
99
|
+
...(page != null && { page }),
|
|
98
100
|
},
|
|
99
101
|
});
|
|
100
102
|
}
|
|
@@ -105,8 +107,8 @@ export class BrokerClient extends Client {
|
|
|
105
107
|
sortDirection: SortDirection,
|
|
106
108
|
fromDate: string,
|
|
107
109
|
toDate: string,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
size: number,
|
|
111
|
+
page?: number,
|
|
110
112
|
): Promise<BrokerList> {
|
|
111
113
|
return this.sendRequest<BrokerList>({
|
|
112
114
|
method: "GET",
|
|
@@ -117,8 +119,8 @@ export class BrokerClient extends Client {
|
|
|
117
119
|
sortDirection,
|
|
118
120
|
fromDate,
|
|
119
121
|
toDate,
|
|
120
|
-
page,
|
|
121
122
|
size,
|
|
123
|
+
...(page != null && { page }),
|
|
122
124
|
},
|
|
123
125
|
});
|
|
124
126
|
}
|
|
@@ -130,21 +132,20 @@ export class BrokerClient extends Client {
|
|
|
130
132
|
sortDirection: SortDirection,
|
|
131
133
|
fromDate: string,
|
|
132
134
|
toDate: string,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
size: number,
|
|
136
|
+
page?: number,
|
|
135
137
|
): Promise<BrokerList> {
|
|
136
138
|
return this.sendRequest<BrokerList>({
|
|
137
139
|
method: "GET",
|
|
138
140
|
url: `/api/v1/brokers/${symbol}`,
|
|
139
141
|
params: {
|
|
140
|
-
symbol,
|
|
141
142
|
region,
|
|
142
143
|
sortBy,
|
|
143
144
|
sortDirection,
|
|
144
145
|
fromDate,
|
|
145
146
|
toDate,
|
|
146
|
-
page,
|
|
147
147
|
size,
|
|
148
|
+
...(page != null && { page }),
|
|
148
149
|
},
|
|
149
150
|
});
|
|
150
151
|
}
|
|
@@ -156,21 +157,20 @@ export class BrokerClient extends Client {
|
|
|
156
157
|
sortDirection: SortDirection,
|
|
157
158
|
fromDate: string,
|
|
158
159
|
toDate: string,
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
size: number,
|
|
161
|
+
page?: number,
|
|
161
162
|
): Promise<BrokerList> {
|
|
162
163
|
return this.sendRequest<BrokerList>({
|
|
163
164
|
method: "GET",
|
|
164
165
|
url: `/api/v1/brokers/stock/${symbol}`,
|
|
165
166
|
params: {
|
|
166
|
-
symbol,
|
|
167
167
|
region,
|
|
168
168
|
sortBy,
|
|
169
169
|
sortDirection,
|
|
170
170
|
fromDate,
|
|
171
171
|
toDate,
|
|
172
|
-
page,
|
|
173
172
|
size,
|
|
173
|
+
...(page != null && { page }),
|
|
174
174
|
},
|
|
175
175
|
});
|
|
176
176
|
}
|
|
@@ -8,7 +8,7 @@ export interface PaginatedResponse<T> {
|
|
|
8
8
|
|
|
9
9
|
export interface CapitalIncrease {
|
|
10
10
|
id: number;
|
|
11
|
-
boardDecisionDate: string;
|
|
11
|
+
boardDecisionDate: string | null;
|
|
12
12
|
registeredCapitalCeiling: string;
|
|
13
13
|
currentCapital: string;
|
|
14
14
|
targetCapital: string;
|
|
@@ -38,39 +38,38 @@ export interface CapitalIncrease {
|
|
|
38
38
|
|
|
39
39
|
export class CapitalIncreaseClient extends Client {
|
|
40
40
|
async getAllCapitalIncreases(
|
|
41
|
-
page: number,
|
|
42
41
|
size: number,
|
|
43
|
-
region: Region
|
|
42
|
+
region: Region,
|
|
43
|
+
page?: number,
|
|
44
44
|
): Promise<PaginatedResponse<CapitalIncrease>> {
|
|
45
45
|
return this.sendRequest<PaginatedResponse<CapitalIncrease>>({
|
|
46
46
|
method: "GET",
|
|
47
47
|
url: "/api/v1/capital-increase/all",
|
|
48
|
-
params: { region,
|
|
48
|
+
params: { region, size, ...(page != null && { page }) },
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
async getCapitalIncreasesForInstrument(
|
|
53
53
|
symbol: string,
|
|
54
|
-
page: number,
|
|
55
54
|
size: number,
|
|
56
|
-
region: Region
|
|
55
|
+
region: Region,
|
|
56
|
+
page?: number,
|
|
57
57
|
): Promise<PaginatedResponse<CapitalIncrease>> {
|
|
58
58
|
return this.sendRequest<PaginatedResponse<CapitalIncrease>>({
|
|
59
59
|
method: 'GET',
|
|
60
60
|
url: `/api/v1/capital-increase/${symbol}`,
|
|
61
|
-
params: { region,
|
|
61
|
+
params: { region, size, ...(page != null && { page }) },
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
async getActiveRightsForInstrument(
|
|
66
66
|
symbol: string,
|
|
67
|
-
date
|
|
68
|
-
region: Region
|
|
67
|
+
date?: string,
|
|
69
68
|
): Promise<CapitalIncrease[]> {
|
|
70
69
|
return this.sendRequest<CapitalIncrease[]>({
|
|
71
70
|
method: 'GET',
|
|
72
71
|
url: `/api/v1/rights/active/${symbol}`,
|
|
73
|
-
params: { date
|
|
72
|
+
params: { ...(date != null && { date }) },
|
|
74
73
|
});
|
|
75
74
|
}
|
|
76
75
|
}
|
package/src/client/client.ts
CHANGED
|
@@ -10,8 +10,8 @@ export class Client {
|
|
|
10
10
|
private apiKey: string;
|
|
11
11
|
private logger: Logger;
|
|
12
12
|
|
|
13
|
-
constructor(cfg: LaplaceConfiguration, logger: Logger) {
|
|
14
|
-
this.cli = axios.create();
|
|
13
|
+
constructor(cfg: LaplaceConfiguration, logger: Logger, cli?: AxiosInstance) {
|
|
14
|
+
this.cli = cli ?? axios.create();
|
|
15
15
|
this.baseUrl = cfg.baseURL;
|
|
16
16
|
this.apiKey = cfg.apiKey;
|
|
17
17
|
this.logger = logger;
|
|
@@ -41,54 +41,54 @@ export class Client {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
sendSSERequest<T>(url: string): { events: AsyncIterable<T>, cancel: () => void } {
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
sendSSERequest<T>(url: string): { events: AsyncIterable<T>, cancel: () => void } {
|
|
45
|
+
const source = axios.CancelToken.source();
|
|
46
|
+
const apiKey = this.apiKey;
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
const events: AsyncIterable<T> = {
|
|
49
|
+
async *[Symbol.asyncIterator]() {
|
|
50
|
+
try {
|
|
51
|
+
const response = await axios.get(url, {
|
|
52
|
+
headers: {
|
|
53
|
+
Authorization: `Bearer ${apiKey}`,
|
|
54
|
+
},
|
|
55
|
+
responseType: 'stream',
|
|
56
|
+
cancelToken: source.token,
|
|
57
|
+
});
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
const reader = response.data;
|
|
60
|
+
const decoder = new TextDecoder();
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
for await (const chunk of reader) {
|
|
63
|
+
const text = decoder.decode(chunk);
|
|
64
|
+
const lines = text.split('\n').filter(line => line.trim() !== '');
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
66
|
+
for (const line of lines) {
|
|
67
|
+
if (line.startsWith('data: ')) {
|
|
68
|
+
const data = line.slice(6);
|
|
69
|
+
try {
|
|
70
|
+
const parsedData = JSON.parse(data) as T;
|
|
71
|
+
yield parsedData;
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error(`Error parsing event data: ${error}`);
|
|
74
|
+
}
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
}
|
|
78
|
+
} catch (error) {
|
|
79
|
+
if (!axios.isCancel(error)) {
|
|
80
|
+
console.error(`SSE error: ${error}`);
|
|
81
|
+
}
|
|
77
82
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
console.error(`SSE error: ${error}`);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
};
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
const cancel = () => {
|
|
87
|
+
source.cancel('Request cancelled by user');
|
|
88
|
+
};
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
}
|
|
90
|
+
return { events, cancel };
|
|
91
|
+
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
export function createClient(cfg: LaplaceConfiguration, logger: Logger): Client {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client } from './client';
|
|
2
|
-
import {
|
|
2
|
+
import { PriceDataPoint, Stock } from './stocks';
|
|
3
3
|
|
|
4
4
|
export enum CollectionType {
|
|
5
5
|
Sector = 'sector',
|
|
@@ -23,11 +23,23 @@ export enum SortBy {
|
|
|
23
23
|
PriceChange = "price_change"
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
export enum AggregateGraphPeriod {
|
|
27
|
+
OneDay = '1G',
|
|
28
|
+
OneWeek = '1H',
|
|
29
|
+
OneMonth = '1A',
|
|
30
|
+
ThreeMonth = '3A',
|
|
31
|
+
OneYear = '1Y',
|
|
32
|
+
TwoYear = '2Y',
|
|
33
|
+
ThreeYear = '3Y',
|
|
34
|
+
FiveYear = '5Y',
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
export interface Collection {
|
|
27
38
|
id: string;
|
|
28
39
|
title: string;
|
|
29
40
|
description?: string;
|
|
30
|
-
region
|
|
41
|
+
region: Region[];
|
|
42
|
+
locale?: Locale;
|
|
31
43
|
assetClass?: string;
|
|
32
44
|
imageUrl: string;
|
|
33
45
|
avatarUrl: string;
|
|
@@ -80,39 +92,39 @@ export class CollectionClient extends Client {
|
|
|
80
92
|
});
|
|
81
93
|
}
|
|
82
94
|
|
|
83
|
-
async getSectorDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
|
|
95
|
+
async getSectorDetail(id: string, region: Region, locale: Locale, sortBy?: SortBy): Promise<CollectionDetail> {
|
|
84
96
|
return this.sendRequest<CollectionDetail>({
|
|
85
97
|
method: 'GET',
|
|
86
98
|
url: `/api/v1/sector/${id}`,
|
|
87
|
-
params: { region, locale },
|
|
99
|
+
params: { region, locale, ...(sortBy != null && { sortBy }) },
|
|
88
100
|
});
|
|
89
101
|
}
|
|
90
|
-
|
|
91
|
-
async getIndustryDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
|
|
102
|
+
|
|
103
|
+
async getIndustryDetail(id: string, region: Region, locale: Locale, sortBy?: SortBy): Promise<CollectionDetail> {
|
|
92
104
|
return this.sendRequest<CollectionDetail>({
|
|
93
105
|
method: 'GET',
|
|
94
106
|
url: `/api/v1/industry/${id}`,
|
|
95
|
-
params: { region, locale },
|
|
107
|
+
params: { region, locale, ...(sortBy != null && { sortBy }) },
|
|
96
108
|
});
|
|
97
109
|
}
|
|
98
|
-
|
|
99
|
-
async getThemeDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
|
|
110
|
+
|
|
111
|
+
async getThemeDetail(id: string, region: Region, locale: Locale, sortBy?: SortBy): Promise<CollectionDetail> {
|
|
100
112
|
return this.sendRequest<CollectionDetail>({
|
|
101
113
|
method: 'GET',
|
|
102
114
|
url: `/api/v1/theme/${id}`,
|
|
103
|
-
params: { region, locale },
|
|
115
|
+
params: { region, locale, ...(sortBy != null && { sortBy }) },
|
|
104
116
|
});
|
|
105
117
|
}
|
|
106
|
-
|
|
107
|
-
async getCollectionDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
|
|
118
|
+
|
|
119
|
+
async getCollectionDetail(id: string, region: Region, locale: Locale, sortBy?: SortBy): Promise<CollectionDetail> {
|
|
108
120
|
return this.sendRequest<CollectionDetail>({
|
|
109
121
|
method: 'GET',
|
|
110
122
|
url: `/api/v1/collection/${id}`,
|
|
111
|
-
params: { region, locale },
|
|
123
|
+
params: { region, locale, ...(sortBy != null && { sortBy }) },
|
|
112
124
|
});
|
|
113
125
|
}
|
|
114
126
|
|
|
115
|
-
async getAggregateGraph(period:
|
|
127
|
+
async getAggregateGraph(period: AggregateGraphPeriod, sectorId: string, industryId: string, collectionId: string, region: Region): Promise<CollectionPriceGraph> {
|
|
116
128
|
return this.sendRequest<CollectionPriceGraph>({
|
|
117
129
|
method: 'GET',
|
|
118
130
|
url: `/api/v1/aggregate/graph`,
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { Client } from './client';
|
|
2
2
|
import { Collection, CollectionDetail, CollectionType, Region, Locale, SortBy } from './collections';
|
|
3
|
+
import { LocaleString } from './stocks';
|
|
3
4
|
|
|
4
5
|
export enum CollectionStatus {
|
|
5
6
|
Active = 'active',
|
|
6
7
|
Inactive = 'inactive',
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export interface LocaleString {
|
|
10
|
-
[key: string]: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
10
|
export interface CreateCustomThemeParams {
|
|
14
11
|
title: LocaleString;
|
|
15
12
|
description?: LocaleString;
|
|
@@ -35,21 +32,25 @@ export interface UpdateCustomThemeParams {
|
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
export class CustomThemeClient extends Client {
|
|
38
|
-
private async getAllCollectionsPrivate(collectionType: CollectionType, locale: Locale): Promise<Collection[]> {
|
|
35
|
+
private async getAllCollectionsPrivate(collectionType: CollectionType, locale: Locale, region?: Region): Promise<Collection[]> {
|
|
36
|
+
const params = {
|
|
37
|
+
locale,
|
|
38
|
+
...(region != null && { region }),
|
|
39
|
+
};
|
|
40
|
+
|
|
39
41
|
return this.sendRequest<Collection[]>({
|
|
40
42
|
method: 'GET',
|
|
41
43
|
url: `/api/v1/${collectionType}`,
|
|
42
|
-
params:
|
|
44
|
+
params: params,
|
|
43
45
|
});
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
private async getCollectionDetailPrivate(id: string, collectionType: CollectionType, locale: Locale, sortBy: SortBy | null): Promise<CollectionDetail> {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}
|
|
49
|
+
const params = {
|
|
50
|
+
locale,
|
|
51
|
+
...(sortBy != null && { sortBy }),
|
|
52
|
+
};
|
|
53
|
+
|
|
53
54
|
return this.sendRequest<CollectionDetail>({
|
|
54
55
|
method: 'GET',
|
|
55
56
|
url: `/api/v1/${collectionType}/${id}`,
|
|
@@ -58,8 +59,8 @@ export class CustomThemeClient extends Client {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
|
|
61
|
-
async getAllCustomThemes(locale: Locale): Promise<Collection[]> {
|
|
62
|
-
return this.getAllCollectionsPrivate(CollectionType.CustomTheme, locale);
|
|
62
|
+
async getAllCustomThemes(locale: Locale, region?: Region): Promise<Collection[]> {
|
|
63
|
+
return this.getAllCollectionsPrivate(CollectionType.CustomTheme, locale, region);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
async getCustomThemeDetail(id: string, locale: Locale, sortBy: SortBy | null): Promise<CollectionDetail> {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Client } from './client';
|
|
2
2
|
import { Region } from './collections';
|
|
3
|
+
import { Currency } from './financial_ratios';
|
|
3
4
|
import { AssetClass, AssetType } from './stocks';
|
|
4
5
|
|
|
5
6
|
export interface StockDividend {
|
|
6
7
|
date: string;
|
|
8
|
+
currency: Currency;
|
|
7
9
|
netAmount: number;
|
|
8
10
|
netRatio: number;
|
|
9
11
|
grossAmount: number;
|
|
@@ -14,28 +16,28 @@ export interface StockDividend {
|
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export interface StockStats {
|
|
19
|
+
ytdReturn: number;
|
|
20
|
+
yearlyReturn: number;
|
|
21
|
+
"3YearReturn": number;
|
|
22
|
+
"5YearReturn": number;
|
|
23
|
+
"3MonthReturn": number;
|
|
24
|
+
monthlyReturn: number;
|
|
25
|
+
weeklyReturn: number;
|
|
26
|
+
symbol: string;
|
|
27
|
+
dailyChange: number;
|
|
17
28
|
previousClose?: number;
|
|
18
29
|
marketCap?: number;
|
|
19
30
|
peRatio?: number;
|
|
20
31
|
pbRatio?: number;
|
|
21
32
|
yearLow?: number;
|
|
22
33
|
yearHigh?: number;
|
|
23
|
-
weeklyReturn?: number;
|
|
24
|
-
monthlyReturn?: number;
|
|
25
|
-
"3MonthReturn"?: number;
|
|
26
|
-
ytdReturn?: number;
|
|
27
|
-
yearlyReturn?: number;
|
|
28
|
-
"3YearReturn"?: number;
|
|
29
|
-
"5YearReturn"?: number;
|
|
30
|
-
symbol: string;
|
|
31
34
|
latestPrice?: number;
|
|
32
|
-
dailyChange?: number;
|
|
33
|
-
dayLow?: number;
|
|
34
35
|
dayHigh?: number;
|
|
35
|
-
|
|
36
|
-
upperPriceLimit?: number;
|
|
36
|
+
dayLow?: number;
|
|
37
37
|
dayOpen?: number;
|
|
38
38
|
eps?: number;
|
|
39
|
+
lowerPriceLimit?: number;
|
|
40
|
+
upperPriceLimit?: number;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export enum StockStatsKey {
|
|
@@ -83,30 +85,30 @@ export class FinancialFundamentalsClient extends Client {
|
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
async getStockStats(symbols: string[], region: Region): Promise<StockStats[]> {
|
|
86
|
-
const url = new URL(`${this['baseUrl']}/api/v2/stock/stats`);
|
|
87
|
-
url.searchParams.append('symbols', symbols.join(','));
|
|
88
|
-
url.searchParams.append('region', region);
|
|
89
|
-
|
|
90
88
|
return this.sendRequest<StockStats[]>({
|
|
91
89
|
method: 'GET',
|
|
92
|
-
url:
|
|
90
|
+
url: '/api/v2/stock/stats',
|
|
91
|
+
params: {
|
|
92
|
+
symbols: symbols.join(','),
|
|
93
|
+
region,
|
|
94
|
+
},
|
|
93
95
|
});
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
async getTopMovers(region: Region,
|
|
98
|
+
async getTopMovers(region: Region, pageSize: number, direction: TopMoverDirection, page?: number, assetType?: AssetType,
|
|
97
99
|
assetClass?: AssetClass
|
|
98
100
|
): Promise<TopMover[]> {
|
|
99
|
-
const url = new URL(`${this['baseUrl']}/api/v2/stock/top-movers`);
|
|
100
|
-
url.searchParams.append('region', region);
|
|
101
|
-
url.searchParams.append('page', page.toString());
|
|
102
|
-
url.searchParams.append('pageSize', pageSize.toString());
|
|
103
|
-
url.searchParams.append('direction', direction);
|
|
104
|
-
if (assetType) url.searchParams.append('assetType', assetType);
|
|
105
|
-
if (assetClass) url.searchParams.append("assetClass", assetClass);
|
|
106
|
-
|
|
107
101
|
return this.sendRequest<TopMover[]>({
|
|
108
102
|
method: 'GET',
|
|
109
|
-
url:
|
|
103
|
+
url: '/api/v2/stock/top-movers',
|
|
104
|
+
params: {
|
|
105
|
+
region,
|
|
106
|
+
pageSize,
|
|
107
|
+
direction,
|
|
108
|
+
...(assetType != null && { assetType }),
|
|
109
|
+
...(assetClass != null && { assetClass }),
|
|
110
|
+
...(page != null && { page }),
|
|
111
|
+
},
|
|
110
112
|
});
|
|
111
113
|
}
|
|
112
114
|
}
|
|
@@ -121,13 +121,13 @@ export enum HistoricalRatiosKey {
|
|
|
121
121
|
export interface StockHistoricalRatiosDescription {
|
|
122
122
|
id: number;
|
|
123
123
|
format: string;
|
|
124
|
-
currency:
|
|
124
|
+
currency: Currency;
|
|
125
125
|
slug: string;
|
|
126
126
|
createdAt: string;
|
|
127
127
|
updatedAt: string;
|
|
128
128
|
name: string;
|
|
129
129
|
description: string;
|
|
130
|
-
locale:
|
|
130
|
+
locale: Locale;
|
|
131
131
|
isRealtime: boolean;
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -177,16 +177,10 @@ export class FinancialClient extends Client {
|
|
|
177
177
|
region: Region,
|
|
178
178
|
peerType: RatioComparisonPeerType
|
|
179
179
|
): Promise<StockPeerFinancialRatioComparison[]> {
|
|
180
|
-
const url = new URL(
|
|
181
|
-
`${this["baseUrl"]}/api/v2/stock/financial-ratio-comparison`
|
|
182
|
-
);
|
|
183
|
-
url.searchParams.append("symbol", symbol);
|
|
184
|
-
url.searchParams.append("region", region);
|
|
185
|
-
url.searchParams.append("peerType", peerType);
|
|
186
|
-
|
|
187
180
|
return this.sendRequest<StockPeerFinancialRatioComparison[]>({
|
|
188
181
|
method: "GET",
|
|
189
|
-
url:
|
|
182
|
+
url: "/api/v2/stock/financial-ratio-comparison",
|
|
183
|
+
params: { symbol, region, peerType },
|
|
190
184
|
});
|
|
191
185
|
}
|
|
192
186
|
|
|
@@ -194,17 +188,17 @@ export class FinancialClient extends Client {
|
|
|
194
188
|
symbol: string,
|
|
195
189
|
keys: HistoricalRatiosKey[],
|
|
196
190
|
region: Region,
|
|
197
|
-
locale
|
|
191
|
+
locale?: Locale
|
|
198
192
|
): Promise<StockHistoricalRatios[]> {
|
|
199
|
-
const url = new URL(`${this["baseUrl"]}/api/v2/stock/historical-ratios`);
|
|
200
|
-
url.searchParams.append("symbol", symbol);
|
|
201
|
-
url.searchParams.append("region", region);
|
|
202
|
-
url.searchParams.append("locale", locale);
|
|
203
|
-
url.searchParams.append("slugs", keys.join(","));
|
|
204
|
-
|
|
205
193
|
return this.sendRequest<StockHistoricalRatios[]>({
|
|
206
194
|
method: "GET",
|
|
207
|
-
url:
|
|
195
|
+
url: "/api/v2/stock/historical-ratios",
|
|
196
|
+
params: {
|
|
197
|
+
symbol,
|
|
198
|
+
region,
|
|
199
|
+
slugs: keys.join(","),
|
|
200
|
+
...(locale != null && { locale }),
|
|
201
|
+
},
|
|
208
202
|
});
|
|
209
203
|
}
|
|
210
204
|
|
|
@@ -212,15 +206,10 @@ export class FinancialClient extends Client {
|
|
|
212
206
|
locale: Locale,
|
|
213
207
|
region: Region
|
|
214
208
|
): Promise<StockHistoricalRatiosDescription[]> {
|
|
215
|
-
const url = new URL(
|
|
216
|
-
`${this["baseUrl"]}/api/v2/stock/historical-ratios/descriptions`
|
|
217
|
-
);
|
|
218
|
-
url.searchParams.append("locale", locale);
|
|
219
|
-
url.searchParams.append("region", region);
|
|
220
|
-
|
|
221
209
|
return this.sendRequest<StockHistoricalRatiosDescription[]>({
|
|
222
210
|
method: "GET",
|
|
223
|
-
url:
|
|
211
|
+
url: "/api/v2/stock/historical-ratios/descriptions",
|
|
212
|
+
params: { locale, region },
|
|
224
213
|
});
|
|
225
214
|
}
|
|
226
215
|
|
|
@@ -233,27 +222,6 @@ export class FinancialClient extends Client {
|
|
|
233
222
|
currency: Currency,
|
|
234
223
|
region: Region
|
|
235
224
|
): Promise<HistoricalFinancialSheets> {
|
|
236
|
-
const url = new URL(
|
|
237
|
-
`${this["baseUrl"]}/api/v3/stock/historical-financial-sheets`
|
|
238
|
-
);
|
|
239
|
-
url.searchParams.append("symbol", symbol);
|
|
240
|
-
url.searchParams.append(
|
|
241
|
-
"from",
|
|
242
|
-
`${from.year.toString().padStart(4, "0")}-${from.month
|
|
243
|
-
.toString()
|
|
244
|
-
.padStart(2, "0")}-${from.day.toString().padStart(2, "0")}`
|
|
245
|
-
);
|
|
246
|
-
url.searchParams.append(
|
|
247
|
-
"to",
|
|
248
|
-
`${to.year.toString().padStart(4, "0")}-${to.month
|
|
249
|
-
.toString()
|
|
250
|
-
.padStart(2, "0")}-${to.day.toString().padStart(2, "0")}`
|
|
251
|
-
);
|
|
252
|
-
url.searchParams.append("sheetType", sheetType);
|
|
253
|
-
url.searchParams.append("periodType", period);
|
|
254
|
-
url.searchParams.append("currency", currency);
|
|
255
|
-
url.searchParams.append("region", region);
|
|
256
|
-
|
|
257
225
|
if (
|
|
258
226
|
sheetType === FinancialSheetType.BalanceSheet &&
|
|
259
227
|
period !== FinancialSheetPeriod.Cumulative
|
|
@@ -261,9 +229,23 @@ export class FinancialClient extends Client {
|
|
|
261
229
|
throw new Error("balance sheet is only available for cumulative period");
|
|
262
230
|
}
|
|
263
231
|
|
|
232
|
+
const formatDate = (d: FinancialSheetDate) =>
|
|
233
|
+
`${d.year.toString().padStart(4, "0")}-${d.month
|
|
234
|
+
.toString()
|
|
235
|
+
.padStart(2, "0")}-${d.day.toString().padStart(2, "0")}`;
|
|
236
|
+
|
|
264
237
|
return this.sendRequest<HistoricalFinancialSheets>({
|
|
265
238
|
method: "GET",
|
|
266
|
-
url:
|
|
239
|
+
url: "/api/v3/stock/historical-financial-sheets",
|
|
240
|
+
params: {
|
|
241
|
+
symbol,
|
|
242
|
+
from: formatDate(from),
|
|
243
|
+
to: formatDate(to),
|
|
244
|
+
sheetType,
|
|
245
|
+
periodType: period,
|
|
246
|
+
currency,
|
|
247
|
+
region,
|
|
248
|
+
},
|
|
267
249
|
});
|
|
268
250
|
}
|
|
269
251
|
}
|