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/src/client/funds.ts
CHANGED
|
@@ -101,15 +101,20 @@ export interface FundHistoricalPrice {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
export class FundsClient extends Client {
|
|
104
|
-
async getFunds(region: Region,
|
|
104
|
+
async getFunds(region: Region, pageSize?: number, page?: number): Promise<Fund[]> {
|
|
105
|
+
const params = {
|
|
106
|
+
region,
|
|
107
|
+
...(pageSize != null && { pageSize }),
|
|
108
|
+
...(page != null && { page })
|
|
109
|
+
}
|
|
105
110
|
return this.sendRequest<Fund[]>({
|
|
106
111
|
method: "GET",
|
|
107
112
|
url: `/api/v1/fund`,
|
|
108
|
-
params:
|
|
113
|
+
params: params,
|
|
109
114
|
});
|
|
110
115
|
}
|
|
111
116
|
|
|
112
|
-
async getFundStats(symbol: string, region: Region) {
|
|
117
|
+
async getFundStats(symbol: string, region: Region): Promise<FundStats> {
|
|
113
118
|
return this.sendRequest<FundStats>({
|
|
114
119
|
method: "GET",
|
|
115
120
|
url: `/api/v1/fund/stats`,
|
|
@@ -117,7 +122,7 @@ export class FundsClient extends Client {
|
|
|
117
122
|
});
|
|
118
123
|
}
|
|
119
124
|
|
|
120
|
-
async getFundDistribution(symbol: string, region: Region) {
|
|
125
|
+
async getFundDistribution(symbol: string, region: Region): Promise<FundDistribution> {
|
|
121
126
|
return this.sendRequest<FundDistribution>({
|
|
122
127
|
method: "GET",
|
|
123
128
|
url: `/api/v1/fund/distribution`,
|
|
@@ -129,7 +134,7 @@ export class FundsClient extends Client {
|
|
|
129
134
|
symbol: string,
|
|
130
135
|
region: Region,
|
|
131
136
|
period: HistoricalFundPricePeriod
|
|
132
|
-
) {
|
|
137
|
+
): Promise<FundHistoricalPrice[]> {
|
|
133
138
|
return this.sendRequest<FundHistoricalPrice[]>({
|
|
134
139
|
method: "GET",
|
|
135
140
|
url: `/api/v1/fund/price`,
|
|
@@ -10,7 +10,7 @@ export class KeyInsightClient extends Client {
|
|
|
10
10
|
async getKeyInsights(symbol: string, region: Region) {
|
|
11
11
|
return this.sendRequest<KeyInsight>({
|
|
12
12
|
method: "GET",
|
|
13
|
-
url: "/api/v1/key-
|
|
13
|
+
url: "/api/v1/key-insights",
|
|
14
14
|
params: { symbol, region },
|
|
15
15
|
});
|
|
16
16
|
}
|
|
@@ -34,8 +34,10 @@ export enum LivePriceFeed {
|
|
|
34
34
|
LiveBist = "live_price_tr",
|
|
35
35
|
LiveUs = "live_price_us",
|
|
36
36
|
DelayedBist = "delayed_price_tr",
|
|
37
|
-
DelayedUs = "delayed_price_us",
|
|
38
37
|
DepthBist = "depth_tr",
|
|
38
|
+
Custom = "custom",
|
|
39
|
+
StateUs = "state_us",
|
|
40
|
+
LiveAskBidBist = "live_ask_bid_price_tr",
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
type StockLiveDataType<T extends LivePriceFeed> = T extends
|
package/src/client/live-price.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface BISTStockPriceData {
|
|
|
21
21
|
export interface USStockPriceData {
|
|
22
22
|
s: string; // Symbol
|
|
23
23
|
p: number; // Price
|
|
24
|
+
pc: number; // PercentChange
|
|
25
|
+
ac: number; // AmountChange
|
|
24
26
|
d: number; // Date
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -42,7 +44,7 @@ export interface OrderbookLevel {
|
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
export interface BISTBidAskData {
|
|
45
|
-
d:
|
|
47
|
+
d: number;
|
|
46
48
|
s: string;
|
|
47
49
|
ask: number;
|
|
48
50
|
bid: number;
|
|
@@ -76,26 +78,6 @@ interface WebSocketUsageResponse {
|
|
|
76
78
|
uniqueDeviceCount: number;
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
interface WebSocketUrlParams {
|
|
80
|
-
externalUserId: string;
|
|
81
|
-
feeds: LivePriceFeed[];
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export enum AccessorType {
|
|
85
|
-
User = "user",
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
interface UpdateUserDetailsParams {
|
|
89
|
-
externalUserID: string;
|
|
90
|
-
firstName?: string;
|
|
91
|
-
lastName?: string;
|
|
92
|
-
address?: string;
|
|
93
|
-
city?: string;
|
|
94
|
-
countryCode?: string;
|
|
95
|
-
accessorType?: AccessorType;
|
|
96
|
-
active: boolean;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
81
|
export interface SendWebsocketEventRequest {
|
|
100
82
|
externalUserID?: string;
|
|
101
83
|
event: Record<string, any>;
|
|
@@ -323,49 +305,41 @@ export class LivePriceClient extends Client {
|
|
|
323
305
|
externalUserId: string,
|
|
324
306
|
feeds: LivePriceFeed[]
|
|
325
307
|
): Promise<string> {
|
|
326
|
-
const url = new URL(`${this["baseUrl"]}/api/v2/ws/url`);
|
|
327
|
-
|
|
328
|
-
const params: WebSocketUrlParams = {
|
|
329
|
-
externalUserId,
|
|
330
|
-
feeds
|
|
331
|
-
};
|
|
332
|
-
|
|
333
308
|
const response = await this.sendRequest<WebSocketUrlResponse>({
|
|
334
309
|
method: "POST",
|
|
335
|
-
url: url
|
|
336
|
-
data:
|
|
310
|
+
url: "/api/v2/ws/url",
|
|
311
|
+
data: { externalUserId, feeds },
|
|
337
312
|
});
|
|
338
313
|
|
|
339
314
|
return response.url;
|
|
340
315
|
}
|
|
341
316
|
|
|
342
317
|
async getWebsocketUsageForMonth(
|
|
343
|
-
month:
|
|
344
|
-
year:
|
|
318
|
+
month: number,
|
|
319
|
+
year: number,
|
|
345
320
|
feedType: LivePriceFeed,
|
|
346
321
|
): Promise<WebSocketUsageResponse[]> {
|
|
347
|
-
|
|
348
|
-
url.searchParams.append("month", month);
|
|
349
|
-
url.searchParams.append("year", year);
|
|
350
|
-
url.searchParams.append("feedType", feedType);
|
|
351
|
-
|
|
352
|
-
const response = await this.sendRequest<WebSocketUsageResponse[]>({
|
|
322
|
+
return this.sendRequest<WebSocketUsageResponse[]>({
|
|
353
323
|
method: "GET",
|
|
354
|
-
url:
|
|
324
|
+
url: "/api/v1/ws/report",
|
|
325
|
+
params: { month, year, feedType },
|
|
355
326
|
});
|
|
356
|
-
|
|
357
|
-
return response;
|
|
358
327
|
}
|
|
359
328
|
|
|
360
329
|
async sendWebsocketEvent(
|
|
361
330
|
request: SendWebsocketEventRequest
|
|
362
331
|
): Promise<void> {
|
|
363
|
-
const url = new URL(`${this["baseUrl"]}/api/v1/ws/event`);
|
|
364
|
-
|
|
365
332
|
await this.sendRequest<void>({
|
|
366
333
|
method: "POST",
|
|
367
|
-
url:
|
|
334
|
+
url: "/api/v1/ws/event",
|
|
368
335
|
data: request,
|
|
369
336
|
});
|
|
370
337
|
}
|
|
338
|
+
|
|
339
|
+
async revokeWebsocketConnection(id: string): Promise<void> {
|
|
340
|
+
await this.sendRequest<void>({
|
|
341
|
+
method: "POST",
|
|
342
|
+
url: `/api/v1/ws/user/revoke/${id}`,
|
|
343
|
+
});
|
|
344
|
+
}
|
|
371
345
|
}
|
package/src/client/news.ts
CHANGED
|
@@ -42,7 +42,7 @@ export interface News {
|
|
|
42
42
|
|
|
43
43
|
export interface NewsPublisher {
|
|
44
44
|
name: string;
|
|
45
|
-
logoUrl
|
|
45
|
+
logoUrl: string | null;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export interface NewsTicker {
|
|
@@ -54,15 +54,15 @@ export interface NewsTicker {
|
|
|
54
54
|
export interface NewsCategories {
|
|
55
55
|
name: string;
|
|
56
56
|
newsCount: number;
|
|
57
|
-
categoryType?: string;
|
|
58
|
-
meanType?: number;
|
|
57
|
+
categoryType?: string | null;
|
|
58
|
+
meanType?: number | null;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export interface NewsSector {
|
|
62
62
|
name: string;
|
|
63
63
|
newsCount: number;
|
|
64
|
-
categoryType?: string;
|
|
65
|
-
meanType?: number;
|
|
64
|
+
categoryType?: string | null;
|
|
65
|
+
meanType?: number | null;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export interface NewsContent {
|
|
@@ -79,62 +79,46 @@ export interface NewsIndustry {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export class NewsClient extends Client {
|
|
82
|
-
async getHighlights(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
url.searchParams.append("region", region);
|
|
87
|
-
url.searchParams.append("locale", locale);
|
|
88
|
-
|
|
82
|
+
async getHighlights(
|
|
83
|
+
region: Region,
|
|
84
|
+
locale: Locale
|
|
85
|
+
): Promise<NewsHighlights> {
|
|
89
86
|
return this.sendRequest<NewsHighlights>({
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
method: "GET",
|
|
88
|
+
url: "/api/v1/news/highlights",
|
|
89
|
+
params: {
|
|
90
|
+
region,
|
|
91
|
+
locale,
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
94
96
|
|
|
95
97
|
async getNews(
|
|
96
98
|
region: Region,
|
|
97
99
|
locale: Locale,
|
|
98
|
-
newsType
|
|
99
|
-
page
|
|
100
|
-
size
|
|
101
|
-
orderBy
|
|
102
|
-
orderByDirection
|
|
103
|
-
extraFilters
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
url.searchParams.append("page", page.toString());
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (size) {
|
|
120
|
-
url.searchParams.append("size", size.toString());
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (orderBy) {
|
|
124
|
-
url.searchParams.append("orderBy", orderBy);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (orderByDirection) {
|
|
128
|
-
url.searchParams.append("orderByDirection", orderByDirection);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (extraFilters) {
|
|
132
|
-
url.searchParams.append("extraFilters", extraFilters);
|
|
133
|
-
}
|
|
134
|
-
|
|
100
|
+
newsType?: NewsType,
|
|
101
|
+
page?: number,
|
|
102
|
+
size?: number,
|
|
103
|
+
orderBy?: NewsOrderBy,
|
|
104
|
+
orderByDirection?: SortDirection,
|
|
105
|
+
extraFilters?: string
|
|
106
|
+
): Promise<PaginatedResponse<News>> {
|
|
107
|
+
const params = {
|
|
108
|
+
region,
|
|
109
|
+
locale,
|
|
110
|
+
...(newsType != null && { newsType }),
|
|
111
|
+
...(page != null && { page }),
|
|
112
|
+
...(size != null && { size }),
|
|
113
|
+
...(orderBy != null && { orderBy }),
|
|
114
|
+
...(orderByDirection != null && { orderByDirection }),
|
|
115
|
+
...(extraFilters != null && { extraFilters }),
|
|
116
|
+
};
|
|
117
|
+
|
|
135
118
|
return this.sendRequest<PaginatedResponse<News>>({
|
|
136
|
-
|
|
137
|
-
|
|
119
|
+
method: "GET",
|
|
120
|
+
url: "/api/v1/news",
|
|
121
|
+
params,
|
|
138
122
|
});
|
|
139
|
-
|
|
123
|
+
}
|
|
140
124
|
}
|
package/src/client/search.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface SearchResponseStock {
|
|
|
12
12
|
id: string;
|
|
13
13
|
name: string;
|
|
14
14
|
title: string;
|
|
15
|
-
region:
|
|
15
|
+
region: Region;
|
|
16
16
|
assetType: string;
|
|
17
17
|
type: string;
|
|
18
18
|
}
|
|
@@ -20,7 +20,7 @@ export interface SearchResponseStock {
|
|
|
20
20
|
export interface SearchResponseCollection {
|
|
21
21
|
id: string;
|
|
22
22
|
title: string;
|
|
23
|
-
region:
|
|
23
|
+
region: Region[];
|
|
24
24
|
assetClass: string;
|
|
25
25
|
imageUrl: string;
|
|
26
26
|
avatarUrl: string;
|
|
@@ -34,18 +34,22 @@ export interface SearchResponse {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export class SearchClient extends Client {
|
|
37
|
-
async search(query: string, types: SearchType[],
|
|
37
|
+
async search(query: string, types: SearchType[], locale: Locale, region?: Region, page?: number, size?: number): Promise<SearchResponse> {
|
|
38
38
|
const typesStr = types.join(',');
|
|
39
39
|
|
|
40
|
+
const params = {
|
|
41
|
+
filter: query,
|
|
42
|
+
types: typesStr,
|
|
43
|
+
locale,
|
|
44
|
+
...(region != null && { region }),
|
|
45
|
+
...(page != null && { page }),
|
|
46
|
+
...(size != null && { size })
|
|
47
|
+
}
|
|
48
|
+
|
|
40
49
|
return this.sendRequest<SearchResponse>({
|
|
41
50
|
method: 'GET',
|
|
42
51
|
url: '/api/v1/search',
|
|
43
|
-
params:
|
|
44
|
-
filter: query,
|
|
45
|
-
types: typesStr,
|
|
46
|
-
region,
|
|
47
|
-
locale,
|
|
48
|
-
},
|
|
52
|
+
params: params,
|
|
49
53
|
});
|
|
50
54
|
}
|
|
51
55
|
}
|
package/src/client/stocks.ts
CHANGED
|
@@ -13,8 +13,10 @@ export enum AssetType {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export enum AssetClass {
|
|
16
|
+
Adr = 'adr',
|
|
16
17
|
Equity = 'equity',
|
|
17
18
|
Crypto = 'crypto',
|
|
19
|
+
Etn = 'etn',
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export enum HistoricalPricePeriod {
|
|
@@ -81,10 +83,16 @@ export enum Market {
|
|
|
81
83
|
|
|
82
84
|
export interface PriceDataPoint {
|
|
83
85
|
d: number;
|
|
84
|
-
|
|
86
|
+
o: number;
|
|
87
|
+
uo?: number;
|
|
85
88
|
h: number;
|
|
89
|
+
uh?: number;
|
|
86
90
|
l: number;
|
|
87
|
-
|
|
91
|
+
ul?: number;
|
|
92
|
+
c: number;
|
|
93
|
+
uc?: number;
|
|
94
|
+
v?: number;
|
|
95
|
+
uv?: number;
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
export interface StockPriceGraph {
|
|
@@ -114,7 +122,7 @@ export interface TickRule {
|
|
|
114
122
|
additionalPrice: number;
|
|
115
123
|
lowerPriceLimit: number;
|
|
116
124
|
upperPriceLimit: number;
|
|
117
|
-
rules: TickSizeRule[]
|
|
125
|
+
rules: TickSizeRule[];
|
|
118
126
|
}
|
|
119
127
|
|
|
120
128
|
export interface TickSizeRule {
|
|
@@ -149,9 +157,22 @@ export interface MarketState {
|
|
|
149
157
|
stockSymbol?: string | null;
|
|
150
158
|
}
|
|
151
159
|
|
|
160
|
+
export enum ChartImagePeriod {
|
|
161
|
+
OneDay = '1D',
|
|
162
|
+
OneWeek = '1W',
|
|
163
|
+
OneMonth = '1M',
|
|
164
|
+
ThreeMonth = '3M',
|
|
165
|
+
SixMonth = '6M',
|
|
166
|
+
OneYear = '1Y',
|
|
167
|
+
TwoYear = '2Y',
|
|
168
|
+
ThreeYear = '3Y',
|
|
169
|
+
FiveYear = '5Y',
|
|
170
|
+
All = 'All',
|
|
171
|
+
}
|
|
172
|
+
|
|
152
173
|
export interface GenerateChartImageRequest {
|
|
153
174
|
symbol: string;
|
|
154
|
-
period?:
|
|
175
|
+
period?: ChartImagePeriod;
|
|
155
176
|
region: Region;
|
|
156
177
|
resolution?: HistoricalPriceInterval;
|
|
157
178
|
indicators?: string[];
|
|
@@ -159,14 +180,14 @@ export interface GenerateChartImageRequest {
|
|
|
159
180
|
}
|
|
160
181
|
|
|
161
182
|
export class StockClient extends Client {
|
|
162
|
-
async getAllStocks(region: Region, page
|
|
183
|
+
async getAllStocks(region: Region, page?: number, pageSize?: number): Promise<Stock[]> {
|
|
163
184
|
return this.sendRequest<Stock[]>({
|
|
164
185
|
method: 'GET',
|
|
165
186
|
url: '/api/v2/stock/all',
|
|
166
187
|
params: {
|
|
167
188
|
region,
|
|
168
|
-
...(page
|
|
169
|
-
...(pageSize
|
|
189
|
+
...(page != null ? { page } : {}),
|
|
190
|
+
...(pageSize != null ? { pageSize } : {}),
|
|
170
191
|
},
|
|
171
192
|
});
|
|
172
193
|
}
|
|
@@ -199,14 +220,24 @@ export class StockClient extends Client {
|
|
|
199
220
|
});
|
|
200
221
|
}
|
|
201
222
|
|
|
202
|
-
async getCustomHistoricalPrices(stock: string, region: Region, fromDate: string, toDate: string, interval: HistoricalPriceInterval, detail
|
|
223
|
+
async getCustomHistoricalPrices(stock: string, region: Region, fromDate: string, toDate: string, interval: HistoricalPriceInterval, detail?: boolean, numIntervals?: number): Promise<PriceDataPoint[]> {
|
|
203
224
|
this.validateCustomHistoricalPriceDate(fromDate);
|
|
204
225
|
this.validateCustomHistoricalPriceDate(toDate);
|
|
205
226
|
|
|
227
|
+
const params = {
|
|
228
|
+
stock,
|
|
229
|
+
region,
|
|
230
|
+
fromDate,
|
|
231
|
+
toDate,
|
|
232
|
+
interval,
|
|
233
|
+
...(detail != null && { detail }),
|
|
234
|
+
...(numIntervals != null && { numIntervals })
|
|
235
|
+
}
|
|
236
|
+
|
|
206
237
|
return this.sendRequest<PriceDataPoint[]>({
|
|
207
238
|
method: 'GET',
|
|
208
239
|
url: '/api/v1/stock/price/interval',
|
|
209
|
-
params:
|
|
240
|
+
params: params,
|
|
210
241
|
});
|
|
211
242
|
}
|
|
212
243
|
|
|
@@ -226,11 +257,10 @@ export class StockClient extends Client {
|
|
|
226
257
|
});
|
|
227
258
|
}
|
|
228
259
|
|
|
229
|
-
async getAllStockRestrictions(
|
|
260
|
+
async getAllStockRestrictions(): Promise<StockRestriction[]> {
|
|
230
261
|
return this.sendRequest<StockRestriction[]>({
|
|
231
262
|
method: 'GET',
|
|
232
|
-
url: '/api/v1/stock/restrictions/all'
|
|
233
|
-
params: { region },
|
|
263
|
+
url: '/api/v1/stock/restrictions/all'
|
|
234
264
|
});
|
|
235
265
|
}
|
|
236
266
|
|