laplace-api 4.7.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.
@@ -101,15 +101,20 @@ export interface FundHistoricalPrice {
101
101
  }
102
102
 
103
103
  export class FundsClient extends Client {
104
- async getFunds(region: Region, page: number, pageSize: number) {
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: { region, page, pageSize },
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-insight",
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
@@ -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: string;
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.toString(),
336
- data: params,
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: string,
344
- year: string,
318
+ month: number,
319
+ year: number,
345
320
  feedType: LivePriceFeed,
346
321
  ): Promise<WebSocketUsageResponse[]> {
347
- const url = new URL(`${this["baseUrl"]}/api/v1/ws/report`);
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: url.toString(),
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: url.toString(),
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
  }
@@ -34,27 +34,15 @@ export interface News {
34
34
  qualityScore: number;
35
35
  createdAt: string;
36
36
  tickers?: NewsTicker[];
37
- translations?: NewsTranslation;
38
37
  categories?: NewsCategories;
39
38
  sectors?: NewsSector;
40
39
  content?: NewsContent;
41
40
  industries?: NewsIndustry;
42
41
  }
43
42
 
44
- export interface NewsTranslation {
45
- title: string;
46
- description: string;
47
- content: string;
48
- summary: string;
49
- summaryParsed: string[];
50
- investorInsight: string;
51
- language: string;
52
- originalLanguage: boolean;
53
- }
54
-
55
43
  export interface NewsPublisher {
56
44
  name: string;
57
- logoUrl?: string;
45
+ logoUrl: string | null;
58
46
  }
59
47
 
60
48
  export interface NewsTicker {
@@ -66,15 +54,15 @@ export interface NewsTicker {
66
54
  export interface NewsCategories {
67
55
  name: string;
68
56
  newsCount: number;
69
- categoryType?: string;
70
- meanType?: number;
57
+ categoryType?: string | null;
58
+ meanType?: number | null;
71
59
  }
72
60
 
73
61
  export interface NewsSector {
74
62
  name: string;
75
63
  newsCount: number;
76
- categoryType?: string;
77
- meanType?: number;
64
+ categoryType?: string | null;
65
+ meanType?: number | null;
78
66
  }
79
67
 
80
68
  export interface NewsContent {
@@ -91,62 +79,46 @@ export interface NewsIndustry {
91
79
  }
92
80
 
93
81
  export class NewsClient extends Client {
94
- async getHighlights(region: Region, locale: Locale): Promise<NewsHighlights> {
95
- const url = new URL(
96
- `${this["baseUrl"]}/api/v1/news/highlights`,
97
- );
98
- url.searchParams.append("region", region);
99
- url.searchParams.append("locale", locale);
100
-
82
+ async getHighlights(
83
+ region: Region,
84
+ locale: Locale
85
+ ): Promise<NewsHighlights> {
101
86
  return this.sendRequest<NewsHighlights>({
102
- method: "GET",
103
- url: url.toString(),
104
- })
105
- }
87
+ method: "GET",
88
+ url: "/api/v1/news/highlights",
89
+ params: {
90
+ region,
91
+ locale,
92
+ },
93
+ });
94
+ }
95
+
106
96
 
107
97
  async getNews(
108
98
  region: Region,
109
99
  locale: Locale,
110
- newsType: NewsType | null,
111
- page: number | null,
112
- size: number | null,
113
- orderBy: NewsOrderBy | null,
114
- orderByDirection: SortDirection | null,
115
- extraFilters: string | null,
116
- ): Promise<PaginatedResponse<News>> {
117
- const url = new URL(
118
- `${this["baseUrl"]}/api/v1/news`,
119
- );
120
- url.searchParams.append("region", region);
121
- url.searchParams.append("locale", locale);
122
-
123
- if (newsType) {
124
- url.searchParams.append("newsType", newsType);
125
- }
126
-
127
- if (page) {
128
- url.searchParams.append("page", page.toString());
129
- }
130
-
131
- if (size) {
132
- url.searchParams.append("size", size.toString());
133
- }
134
-
135
- if (orderBy) {
136
- url.searchParams.append("orderBy", orderBy);
137
- }
138
-
139
- if (orderByDirection) {
140
- url.searchParams.append("orderByDirection", orderByDirection);
141
- }
142
-
143
- if (extraFilters) {
144
- url.searchParams.append("extraFilters", extraFilters);
145
- }
146
-
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
+
147
118
  return this.sendRequest<PaginatedResponse<News>>({
148
- method: "GET",
149
- url: url.toString(),
119
+ method: "GET",
120
+ url: "/api/v1/news",
121
+ params,
150
122
  });
151
- }
123
+ }
152
124
  }
@@ -12,7 +12,7 @@ export interface SearchResponseStock {
12
12
  id: string;
13
13
  name: string;
14
14
  title: string;
15
- region: string;
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: string[];
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[], region: Region, locale: Locale): Promise<SearchResponse> {
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
  }
@@ -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
- c: number;
86
+ o: number;
87
+ uo?: number;
85
88
  h: number;
89
+ uh?: number;
86
90
  l: number;
87
- o: number;
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[] | null;
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?: HistoricalPricePeriod;
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: number|null = null, pageSize: number|null = null): Promise<Stock[]> {
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 !== null ? { page } : {}),
169
- ...(pageSize !== null ? { 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: boolean): Promise<PriceDataPoint[]> {
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: { stock, region, fromDate, toDate, interval, detail },
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(region: Region): Promise<StockRestriction[]> {
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