laplace-api 3.1.0 → 4.0.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laplace-api",
3
- "version": "3.1.0",
3
+ "version": "4.0.0",
4
4
  "description": "Client library for Laplace API for the US stock market and BIST (Istanbul stock market) fundamental financial data.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,11 +1,21 @@
1
+ import { PaginatedResponse } from "./capital_increase";
1
2
  import { Client } from "./client";
2
3
  import { Region } from "./collections";
3
4
  import { AssetClass, AssetType } from "./stocks";
4
5
 
5
6
  export enum BrokerSort {
6
- NetBuy = "netBuy",
7
- NetSell = "netSell",
8
- Volume = "volume",
7
+ NetAmount = "netAmount",
8
+ TotalAmount = "totalAmount",
9
+ TotalVolume = "totalVolume",
10
+ TotalBuyAmount = "totalBuyAmount",
11
+ TotalBuyVolume = "totalBuyVolume",
12
+ TotalSellAmount = "totalSellAmount",
13
+ TotalSellVolume = "totalSellVolume",
14
+ }
15
+
16
+ export enum SortDirection {
17
+ Desc = "desc",
18
+ Asc = "asc",
9
19
  }
10
20
 
11
21
  export interface Broker {
@@ -22,10 +32,9 @@ export interface BrokerStock {
22
32
  id: string;
23
33
  assetType: AssetType;
24
34
  assetClass: AssetClass;
25
- region: Region;
26
35
  }
27
36
 
28
- export interface BaseBrokerStats {
37
+ export interface BrokerStats {
29
38
  totalBuyAmount: number;
30
39
  totalSellAmount: number;
31
40
  netAmount: number;
@@ -33,164 +42,133 @@ export interface BaseBrokerStats {
33
42
  totalSellVolume: number;
34
43
  totalVolume: number;
35
44
  totalAmount: number;
45
+ averageCost?: number;
36
46
  }
37
47
 
38
- export interface BrokerStats extends BaseBrokerStats {
39
- broker: Broker;
40
- }
41
-
42
- export interface MarketBrokersResponse {
43
- recordCount: number;
44
- totalStats: BaseBrokerStats;
45
- items: BrokerStats[];
46
- }
47
-
48
- export interface TopBrokersResponse {
49
- topStats: BaseBrokerStats;
50
- restStats: BaseBrokerStats;
51
- topItems: BrokerStats[];
52
- }
53
-
54
- export interface StockBrokerStats extends BaseBrokerStats {
55
- averageCost: number;
56
- broker: Broker;
57
- }
58
-
59
- export interface StockOverallStats extends BaseBrokerStats {
60
- averageCost: number;
61
- }
62
-
63
- export interface StockBrokersResponse {
64
- recordCount: number;
65
- totalStats: StockOverallStats;
66
- items: StockBrokerStats[];
67
- }
68
-
69
- export interface TopStockBrokersResponse {
70
- topStats: StockOverallStats;
71
- restStats: StockOverallStats;
72
- topItems: StockBrokerStats[];
48
+ export interface BrokerItem extends BrokerStats {
49
+ broker?: Broker;
50
+ stock?: BrokerStock;
73
51
  }
74
52
 
75
- export interface BrokerStockStats extends BaseBrokerStats {
76
- stock: BrokerStock;
77
- }
78
-
79
- export interface TopStocksForBrokerResponse {
80
- topStats: BaseBrokerStats;
81
- restStats: BaseBrokerStats;
82
- topItems: BrokerStockStats[];
53
+ export interface BrokerList extends PaginatedResponse<BrokerItem> {
54
+ totalStats: BrokerStats;
83
55
  }
84
56
 
85
57
  export class BrokerClient extends Client {
86
58
  private static readonly BASE = "/api/v1/brokers";
87
59
 
88
- async getMarketBrokers(
60
+ async getBrokers(
89
61
  region: Region,
90
- fromDate: string,
91
- toDate: string,
92
- sortBy: BrokerSort,
93
- page: number = 0,
94
- size: number = 10
95
- ): Promise<MarketBrokersResponse> {
96
- return this.sendRequest<MarketBrokersResponse>({
62
+ page: number,
63
+ size: number
64
+ ): Promise<PaginatedResponse<Broker>> {
65
+ return this.sendRequest<PaginatedResponse<Broker>>({
97
66
  method: "GET",
98
- url: BrokerClient.BASE + "/market",
67
+ url: BrokerClient.BASE,
99
68
  params: {
100
69
  region,
101
- fromDate,
102
- toDate,
103
- sortBy,
104
70
  page,
105
71
  size,
106
72
  },
107
73
  });
108
74
  }
109
75
 
110
- async getTopMarketBrokers(
76
+ async getMarketStocks(
111
77
  region: Region,
78
+ sortBy: BrokerSort,
79
+ sortDirection: SortDirection,
112
80
  fromDate: string,
113
81
  toDate: string,
114
- sortBy: BrokerSort,
115
- top: number = 5
116
- ): Promise<TopBrokersResponse> {
117
- return this.sendRequest<TopBrokersResponse>({
82
+ page: number,
83
+ size: number
84
+ ): Promise<BrokerList> {
85
+ return this.sendRequest<BrokerList>({
118
86
  method: "GET",
119
- url: BrokerClient.BASE + "/market/top",
87
+ url: BrokerClient.BASE + "/market/stock",
120
88
  params: {
121
89
  region,
90
+ sortBy,
91
+ sortDirection,
122
92
  fromDate,
123
93
  toDate,
124
- sortBy,
125
- top,
94
+ page,
95
+ size,
126
96
  },
127
97
  });
128
98
  }
129
99
 
130
- async getStockBrokers(
100
+ async getMarketBrokers(
131
101
  region: Region,
102
+ sortBy: BrokerSort,
103
+ sortDirection: SortDirection,
132
104
  fromDate: string,
133
105
  toDate: string,
134
- sortBy: BrokerSort,
135
- symbol: string,
136
- page: number = 0,
137
- size: number = 10
138
- ): Promise<StockBrokersResponse> {
139
- return this.sendRequest<StockBrokersResponse>({
106
+ page: number,
107
+ size: number
108
+ ): Promise<BrokerList> {
109
+ return this.sendRequest<BrokerList>({
140
110
  method: "GET",
141
- url: BrokerClient.BASE + "/stock",
111
+ url: BrokerClient.BASE + "/market",
142
112
  params: {
143
113
  region,
114
+ sortBy,
115
+ sortDirection,
144
116
  fromDate,
145
117
  toDate,
146
- sortBy,
147
118
  page,
148
119
  size,
149
- symbol,
150
120
  },
151
121
  });
152
122
  }
153
123
 
154
- async getTopStockBrokers(
124
+ async getBrokersByStock(
125
+ symbol: string,
155
126
  region: Region,
127
+ sortBy: BrokerSort,
128
+ sortDirection: SortDirection,
156
129
  fromDate: string,
157
130
  toDate: string,
158
- sortBy: BrokerSort,
159
- symbol: string,
160
- top: number = 5
161
- ): Promise<TopStockBrokersResponse> {
162
- return this.sendRequest<TopStockBrokersResponse>({
131
+ page: number,
132
+ size: number
133
+ ): Promise<BrokerList> {
134
+ return this.sendRequest<BrokerList>({
163
135
  method: "GET",
164
- url: BrokerClient.BASE + "/stock/top",
136
+ url: BrokerClient.BASE + "/" + symbol,
165
137
  params: {
138
+ symbol,
166
139
  region,
140
+ sortBy,
141
+ sortDirection,
167
142
  fromDate,
168
143
  toDate,
169
- sortBy,
170
- top,
171
- symbol,
144
+ page,
145
+ size,
172
146
  },
173
147
  });
174
148
  }
175
149
 
176
- async getTopStocksForBroker(
150
+ async getStocksByBroker(
151
+ symbol: string,
177
152
  region: Region,
153
+ sortBy: BrokerSort,
154
+ sortDirection: SortDirection,
178
155
  fromDate: string,
179
156
  toDate: string,
180
- sortBy: BrokerSort,
181
- brokerSymbol: string,
182
- top: number = 5
183
- ): Promise<TopStocksForBrokerResponse> {
184
- return this.sendRequest<TopStocksForBrokerResponse>({
157
+ page: number,
158
+ size: number
159
+ ): Promise<BrokerList> {
160
+ return this.sendRequest<BrokerList>({
185
161
  method: "GET",
186
- url: BrokerClient.BASE + "/top",
162
+ url: BrokerClient.BASE + "/stock/" + symbol,
187
163
  params: {
164
+ symbol,
188
165
  region,
166
+ sortBy,
167
+ sortDirection,
189
168
  fromDate,
190
169
  toDate,
191
- sortBy,
192
- top,
193
- brokerSymbol,
170
+ page,
171
+ size,
194
172
  },
195
173
  });
196
174
  }
@@ -1,5 +1,5 @@
1
1
  import { Client } from './client';
2
- import { Region, Locale } from './collections';
2
+ import { Region } from './collections';
3
3
 
4
4
  // type PaginatedResponse[T any] struct {
5
5
  // RecordCount int `json:"recordCount"`
@@ -18,23 +18,23 @@ export interface CapitalIncrease {
18
18
  currentCapital: string;
19
19
  targetCapital: string;
20
20
  types: string[];
21
- spkApplicationResult: string;
22
- spkApplicationDate: string;
23
- spkApprovalDate: string;
24
- paymentDate: string;
25
- registrationDate: string;
21
+ spkApplicationResult: string | null;
22
+ spkApplicationDate: string | null;
23
+ spkApprovalDate: string | null;
24
+ paymentDate: string | null;
25
+ registrationDate: string | null;
26
26
  specifiedCurrency: string;
27
27
  symbol: string;
28
- relatedDisclosureIDs: number[];
28
+ relatedDisclosureIds: number[];
29
29
  rightsRate: string;
30
30
  rightsPrice: string;
31
31
  rightsTotalAmount: string;
32
- rightsStartDate: string;
33
- rightsEndDate: string;
34
- rightsLastSellDate: string;
32
+ rightsStartDate: string | null;
33
+ rightsEndDate: string | null;
34
+ rightsLastSellDate: string | null;
35
35
  bonusRate: string;
36
36
  bonusTotalAmount: string;
37
- bonusStartDate: string;
37
+ bonusStartDate: string | null;
38
38
  bonusDividendRate: string;
39
39
  bonusDividendTotalAmount: string;
40
40
  externalCapitalIncreaseAmount: string;
@@ -26,14 +26,14 @@ export enum SortBy {
26
26
  export interface Collection {
27
27
  id: string;
28
28
  title: string;
29
- description: string;
30
- region: Region[];
31
- assetClass: string;
29
+ description?: string;
30
+ region?: Region[];
31
+ assetClass?: string;
32
32
  imageUrl: string;
33
33
  avatarUrl: string;
34
34
  numStocks: number;
35
- image: string;
36
- order: number;
35
+ image?: string;
36
+ order?: number;
37
37
  status?: string;
38
38
  metaData?: Record<string, any>;
39
39
  }
@@ -71,10 +71,6 @@ export class CollectionClient extends Client {
71
71
  return this.getAllCollectionsPrivate(CollectionType.Theme, region, locale);
72
72
  }
73
73
 
74
- async getAllCustomThemes(region: Region, locale: Locale): Promise<Collection[]> {
75
- return this.getAllCollectionsPrivate(CollectionType.CustomTheme, region, locale);
76
- }
77
-
78
74
  async getAllCollections(region: Region, locale: Locale): Promise<Collection[]> {
79
75
  return this.getAllCollectionsPrivate(CollectionType.Collection, region, locale);
80
76
  }
@@ -91,10 +87,6 @@ export class CollectionClient extends Client {
91
87
  return this.getCollectionDetailPrivate(id, CollectionType.Theme, region, locale);
92
88
  }
93
89
 
94
- async getCustomThemeDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
95
- return this.getCollectionDetailPrivate(id, CollectionType.CustomTheme, region, locale);
96
- }
97
-
98
90
  async getCollectionDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
99
91
  return this.getCollectionDetailPrivate(id, CollectionType.Collection, region, locale);
100
92
  }
@@ -3,37 +3,39 @@ import { Region } from './collections';
3
3
  import { AssetClass, AssetType } from './stocks';
4
4
 
5
5
  export interface StockDividend {
6
- date: Date;
7
- dividendAmount: number;
8
- dividendRatio: number;
9
- netDividendAmount: number;
10
- netDividendRatio: number;
6
+ date: string;
7
+ netAmount: number;
8
+ netRatio: number;
9
+ grossAmount: number;
10
+ grossRatio: number;
11
11
  priceThen: number;
12
+ stoppageRatio: number;
13
+ stoppageAmount: number;
12
14
  }
13
15
 
14
16
  export interface StockStats {
15
- previousClose: number;
16
- marketCap: number;
17
- peRatio: number;
18
- pbRatio: number;
19
- yearLow: number;
20
- yearHigh: number;
21
- weeklyReturn: number;
22
- monthlyReturn: number;
23
- '3MonthReturn': number;
24
- ytdReturn: number;
25
- yearlyReturn: number;
26
- '3YearReturn': number;
27
- '5YearReturn': number;
17
+ previousClose?: number;
18
+ marketCap?: number;
19
+ peRatio?: number;
20
+ pbRatio?: number;
21
+ yearLow?: number;
22
+ yearHigh?: number;
23
+ weeklyReturn?: number;
24
+ monthlyReturn?: number;
25
+ "3MonthReturn"?: number;
26
+ ytdReturn?: number;
27
+ yearlyReturn?: number;
28
+ "3YearReturn"?: number;
29
+ "5YearReturn"?: number;
28
30
  symbol: string;
29
- latestPrice: number;
30
- dailyChange: number;
31
- dayLow: number;
32
- dayHigh: number;
33
- lowerPriceLimit: number;
34
- upperPriceLimit: number;
35
- dayOpen: number;
36
- eps: number;
31
+ latestPrice?: number;
32
+ dailyChange?: number;
33
+ dayLow?: number;
34
+ dayHigh?: number;
35
+ lowerPriceLimit?: number;
36
+ upperPriceLimit?: number;
37
+ dayOpen?: number;
38
+ eps?: number;
37
39
  }
38
40
 
39
41
  export enum StockStatsKey {
@@ -59,8 +61,8 @@ export enum StockStatsKey {
59
61
  export interface TopMover {
60
62
  symbol: string;
61
63
  change: number;
62
- assetClass: AssetClass;
63
- assetType: AssetType
64
+ assetClass?: AssetClass;
65
+ assetType?: AssetType;
64
66
  }
65
67
 
66
68
  export enum TopMoverDirection {
@@ -69,10 +71,13 @@ export enum TopMoverDirection {
69
71
  }
70
72
 
71
73
  export class FinancialFundamentalsClient extends Client {
72
- async getStockDividends(symbol: string, region: Region): Promise<StockDividend[]> {
73
- const url = new URL(`${this['baseUrl']}/api/v1/stock/dividends`);
74
- url.searchParams.append('symbol', symbol);
75
- url.searchParams.append('region', region);
74
+ async getStockDividends(
75
+ symbol: string,
76
+ region: Region
77
+ ): Promise<StockDividend[]> {
78
+ const url = new URL(`${this["baseUrl"]}/api/v2/stock/dividends`);
79
+ url.searchParams.append("symbol", symbol);
80
+ url.searchParams.append("region", region);
76
81
 
77
82
  return this.sendRequest<StockDividend[]>({
78
83
  method: 'GET',
@@ -91,13 +96,16 @@ export class FinancialFundamentalsClient extends Client {
91
96
  });
92
97
  }
93
98
 
94
- async getTopMovers(region: Region, page: number, pageSize: number, direction: TopMoverDirection, assetType?: AssetType): Promise<TopMover[]> {
99
+ async getTopMovers(region: Region, page: number, pageSize: number, direction: TopMoverDirection, assetType?: AssetType,
100
+ assetClass?: AssetClass
101
+ ): Promise<TopMover[]> {
95
102
  const url = new URL(`${this['baseUrl']}/api/v2/stock/top-movers`);
96
103
  url.searchParams.append('region', region);
97
104
  url.searchParams.append('page', page.toString());
98
105
  url.searchParams.append('pageSize', pageSize.toString());
99
106
  url.searchParams.append('direction', direction);
100
107
  if (assetType) url.searchParams.append('assetType', assetType);
108
+ if (assetClass) url.searchParams.append("assetClass", assetClass);
101
109
 
102
110
  return this.sendRequest<TopMover[]>({
103
111
  method: 'GET',
@@ -1,16 +1,21 @@
1
- import { Client } from './client';
2
- import { Region, Locale } from './collections';
1
+ import { Client } from "./client";
2
+ import { Region, Locale } from "./collections";
3
3
 
4
- export interface StockSectorFinancialRatioComparison {
5
- metric_name: string;
4
+ export enum RatioComparisonPeerType {
5
+ Industry = "industry",
6
+ Sector = "sector"
7
+ }
8
+
9
+ export interface StockPeerFinancialRatioComparison {
10
+ metricName: string;
6
11
  normalizedValue: number;
7
- details: StockSectorFinancialRatioComparisonDetail[];
12
+ data: StockPeerFinancialRatioComparisonData[];
8
13
  }
9
14
 
10
- export interface StockSectorFinancialRatioComparisonDetail {
15
+ export interface StockPeerFinancialRatioComparisonData {
11
16
  slug: string;
12
17
  value: number;
13
- sectorAverage: number;
18
+ average: number;
14
19
  }
15
20
 
16
21
  export interface StockHistoricalRatios {
@@ -22,7 +27,7 @@ export interface StockHistoricalRatios {
22
27
  currency: Currency;
23
28
  format: HistoricalRatiosFormat;
24
29
  name: string;
25
- items: StockHistoricalRatiosData[]
30
+ items: StockHistoricalRatiosData[];
26
31
  }
27
32
 
28
33
  export interface StockHistoricalRatiosData {
@@ -34,7 +39,7 @@ export interface StockHistoricalRatiosData {
34
39
  export enum HistoricalRatiosFormat {
35
40
  CURRENCY = "currency",
36
41
  PERCENTAGE = "percentage",
37
- DECIMAL = "decimal"
42
+ DECIMAL = "decimal",
38
43
  }
39
44
 
40
45
  export enum HistoricalRatiosKey {
@@ -114,15 +119,16 @@ export enum HistoricalRatiosKey {
114
119
  }
115
120
 
116
121
  export interface StockHistoricalRatiosDescription {
122
+ id: number;
123
+ format: string;
124
+ currency: string;
117
125
  slug: string;
126
+ createdAt: string;
127
+ updatedAt: string;
118
128
  name: string;
119
- suffix: string;
120
- prefix: string;
121
- display: boolean;
122
- precision: number;
123
- multiplier: number;
124
129
  description: string;
125
- interval: string;
130
+ locale: string;
131
+ isRealtime: boolean;
126
132
  }
127
133
 
128
134
  export interface HistoricalFinancialSheets {
@@ -139,8 +145,6 @@ export interface HistoricalFinancialSheetRow {
139
145
  value: number;
140
146
  lineCodeId: number;
141
147
  indentLevel: number;
142
- firstAncestorLineCodeId: number;
143
- sectionLineCodeId: number;
144
148
  }
145
149
 
146
150
  export enum FinancialSheetType {
@@ -167,24 +171,36 @@ export interface FinancialSheetDate {
167
171
  year: number;
168
172
  }
169
173
 
170
- export class FinancialClient extends Client {
171
- async getFinancialRatioComparison(symbol: string, region: Region): Promise<StockSectorFinancialRatioComparison[]> {
172
- const url = new URL(`${this['baseUrl']}/api/v1/stock/financial-ratio-comparison`);
173
- url.searchParams.append('symbol', symbol);
174
- url.searchParams.append('region', region);
175
-
176
- return this.sendRequest<StockSectorFinancialRatioComparison[]>({
177
- method: 'GET',
174
+ export class FinancialClient extends Client {
175
+ async getFinancialRatioComparison(
176
+ symbol: string,
177
+ region: Region,
178
+ peerType: RatioComparisonPeerType
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
+ return this.sendRequest<StockPeerFinancialRatioComparison[]>({
188
+ method: "GET",
178
189
  url: url.toString(),
179
190
  });
180
191
  }
181
192
 
182
- async getHistoricalRatios(symbol: string, keys: HistoricalRatiosKey[], region: Region, locale: Locale): Promise<StockHistoricalRatios[]> {
183
- const url = new URL(`${this['baseUrl']}/api/v2/stock/historical-ratios`);
184
- url.searchParams.append('symbol', symbol);
185
- url.searchParams.append('region', region);
186
- url.searchParams.append('locale', locale);
187
- url.searchParams.append('slugs', keys.join(','));
193
+ async getHistoricalRatios(
194
+ symbol: string,
195
+ keys: HistoricalRatiosKey[],
196
+ region: Region,
197
+ locale: Locale
198
+ ): 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(","));
188
204
 
189
205
  return this.sendRequest<StockHistoricalRatios[]>({
190
206
  method: 'GET',
@@ -192,10 +208,15 @@ export class FinancialClient extends Client {
192
208
  });
193
209
  }
194
210
 
195
- async getHistoricalRatiosDescriptions(locale: Locale, region: Region): Promise<StockHistoricalRatiosDescription[]> {
196
- const url = new URL(`${this['baseUrl']}/api/v1/stock/historical-ratios/descriptions`);
197
- url.searchParams.append('locale', locale);
198
- url.searchParams.append('region', region);
211
+ async getHistoricalRatiosDescriptions(
212
+ locale: Locale,
213
+ region: Region
214
+ ): 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);
199
220
 
200
221
  return this.sendRequest<StockHistoricalRatiosDescription[]>({
201
222
  method: 'GET',