laplace-api 3.1.0 → 4.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.
@@ -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 {
@@ -14,6 +24,7 @@ export interface Broker {
14
24
  name: string;
15
25
  longName: string;
16
26
  logo: string;
27
+ supportedAssetClasses?: AssetClass[]
17
28
  }
18
29
 
19
30
  export interface BrokerStock {
@@ -22,10 +33,9 @@ export interface BrokerStock {
22
33
  id: string;
23
34
  assetType: AssetType;
24
35
  assetClass: AssetClass;
25
- region: Region;
26
36
  }
27
37
 
28
- export interface BaseBrokerStats {
38
+ export interface BrokerStats {
29
39
  totalBuyAmount: number;
30
40
  totalSellAmount: number;
31
41
  netAmount: number;
@@ -33,164 +43,134 @@ export interface BaseBrokerStats {
33
43
  totalSellVolume: number;
34
44
  totalVolume: number;
35
45
  totalAmount: number;
46
+ averageCost?: number;
36
47
  }
37
48
 
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[];
49
+ export interface BrokerItem extends BrokerStats {
50
+ broker?: Broker;
51
+ stock?: BrokerStock;
73
52
  }
74
53
 
75
- export interface BrokerStockStats extends BaseBrokerStats {
76
- stock: BrokerStock;
77
- }
78
-
79
- export interface TopStocksForBrokerResponse {
80
- topStats: BaseBrokerStats;
81
- restStats: BaseBrokerStats;
82
- topItems: BrokerStockStats[];
54
+ export interface BrokerList extends PaginatedResponse<BrokerItem> {
55
+ totalStats: BrokerStats;
83
56
  }
84
57
 
85
58
  export class BrokerClient extends Client {
86
- 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
+ assetClass?: AssetClass
65
+ ): Promise<PaginatedResponse<Broker>> {
66
+ return this.sendRequest<PaginatedResponse<Broker>>({
97
67
  method: "GET",
98
- url: BrokerClient.BASE + "/market",
68
+ url: "/api/v1/brokers",
99
69
  params: {
100
70
  region,
101
- fromDate,
102
- toDate,
103
- sortBy,
104
71
  page,
105
72
  size,
73
+ assetClass
106
74
  },
107
75
  });
108
76
  }
109
77
 
110
- async getTopMarketBrokers(
78
+ async getMarketStocks(
111
79
  region: Region,
80
+ sortBy: BrokerSort,
81
+ sortDirection: SortDirection,
112
82
  fromDate: string,
113
83
  toDate: string,
114
- sortBy: BrokerSort,
115
- top: number = 5
116
- ): Promise<TopBrokersResponse> {
117
- return this.sendRequest<TopBrokersResponse>({
84
+ page: number,
85
+ size: number
86
+ ): Promise<BrokerList> {
87
+ return this.sendRequest<BrokerList>({
118
88
  method: "GET",
119
- url: BrokerClient.BASE + "/market/top",
89
+ url: "/api/v1/brokers/market/stock",
120
90
  params: {
121
91
  region,
92
+ sortBy,
93
+ sortDirection,
122
94
  fromDate,
123
95
  toDate,
124
- sortBy,
125
- top,
96
+ page,
97
+ size,
126
98
  },
127
99
  });
128
100
  }
129
101
 
130
- async getStockBrokers(
102
+ async getMarketBrokers(
131
103
  region: Region,
104
+ sortBy: BrokerSort,
105
+ sortDirection: SortDirection,
132
106
  fromDate: string,
133
107
  toDate: string,
134
- sortBy: BrokerSort,
135
- symbol: string,
136
- page: number = 0,
137
- size: number = 10
138
- ): Promise<StockBrokersResponse> {
139
- return this.sendRequest<StockBrokersResponse>({
108
+ page: number,
109
+ size: number
110
+ ): Promise<BrokerList> {
111
+ return this.sendRequest<BrokerList>({
140
112
  method: "GET",
141
- url: BrokerClient.BASE + "/stock",
113
+ url: "/api/v1/brokers/market",
142
114
  params: {
143
115
  region,
116
+ sortBy,
117
+ sortDirection,
144
118
  fromDate,
145
119
  toDate,
146
- sortBy,
147
120
  page,
148
121
  size,
149
- symbol,
150
122
  },
151
123
  });
152
124
  }
153
125
 
154
- async getTopStockBrokers(
126
+ async getBrokersByStock(
127
+ symbol: string,
155
128
  region: Region,
129
+ sortBy: BrokerSort,
130
+ sortDirection: SortDirection,
156
131
  fromDate: string,
157
132
  toDate: string,
158
- sortBy: BrokerSort,
159
- symbol: string,
160
- top: number = 5
161
- ): Promise<TopStockBrokersResponse> {
162
- return this.sendRequest<TopStockBrokersResponse>({
133
+ page: number,
134
+ size: number
135
+ ): Promise<BrokerList> {
136
+ return this.sendRequest<BrokerList>({
163
137
  method: "GET",
164
- url: BrokerClient.BASE + "/stock/top",
138
+ url: `/api/v1/brokers/${symbol}`,
165
139
  params: {
140
+ symbol,
166
141
  region,
142
+ sortBy,
143
+ sortDirection,
167
144
  fromDate,
168
145
  toDate,
169
- sortBy,
170
- top,
171
- symbol,
146
+ page,
147
+ size,
172
148
  },
173
149
  });
174
150
  }
175
151
 
176
- async getTopStocksForBroker(
152
+ async getStocksByBroker(
153
+ symbol: string,
177
154
  region: Region,
155
+ sortBy: BrokerSort,
156
+ sortDirection: SortDirection,
178
157
  fromDate: string,
179
158
  toDate: string,
180
- sortBy: BrokerSort,
181
- brokerSymbol: string,
182
- top: number = 5
183
- ): Promise<TopStocksForBrokerResponse> {
184
- return this.sendRequest<TopStocksForBrokerResponse>({
159
+ page: number,
160
+ size: number
161
+ ): Promise<BrokerList> {
162
+ return this.sendRequest<BrokerList>({
185
163
  method: "GET",
186
- url: BrokerClient.BASE + "/top",
164
+ url: `/api/v1/brokers/stock/${symbol}`,
187
165
  params: {
166
+ symbol,
188
167
  region,
168
+ sortBy,
169
+ sortDirection,
189
170
  fromDate,
190
171
  toDate,
191
- sortBy,
192
- top,
193
- brokerSymbol,
172
+ page,
173
+ size,
194
174
  },
195
175
  });
196
176
  }
@@ -1,10 +1,5 @@
1
- import { Client } from './client';
2
- import { Region, Locale } from './collections';
3
-
4
- // type PaginatedResponse[T any] struct {
5
- // RecordCount int `json:"recordCount"`
6
- // Items []T `json:"items"`
7
- // }
1
+ import { Client } from "./client";
2
+ import { Region } from "./collections";
8
3
 
9
4
  export interface PaginatedResponse<T> {
10
5
  recordCount: number;
@@ -18,23 +13,23 @@ export interface CapitalIncrease {
18
13
  currentCapital: string;
19
14
  targetCapital: string;
20
15
  types: string[];
21
- spkApplicationResult: string;
22
- spkApplicationDate: string;
23
- spkApprovalDate: string;
24
- paymentDate: string;
25
- registrationDate: string;
16
+ spkApplicationResult: string | null;
17
+ spkApplicationDate: string | null;
18
+ spkApprovalDate: string | null;
19
+ paymentDate: string | null;
20
+ registrationDate: string | null;
26
21
  specifiedCurrency: string;
27
22
  symbol: string;
28
- relatedDisclosureIDs: number[];
23
+ relatedDisclosureIds: number[];
29
24
  rightsRate: string;
30
25
  rightsPrice: string;
31
26
  rightsTotalAmount: string;
32
- rightsStartDate: string;
33
- rightsEndDate: string;
34
- rightsLastSellDate: string;
27
+ rightsStartDate: string | null;
28
+ rightsEndDate: string | null;
29
+ rightsLastSellDate: string | null;
35
30
  bonusRate: string;
36
31
  bonusTotalAmount: string;
37
- bonusStartDate: string;
32
+ bonusStartDate: string | null;
38
33
  bonusDividendRate: string;
39
34
  bonusDividendTotalAmount: string;
40
35
  externalCapitalIncreaseAmount: string;
@@ -48,8 +43,8 @@ export class CapitalIncreaseClient extends Client {
48
43
  region: Region
49
44
  ): Promise<PaginatedResponse<CapitalIncrease>> {
50
45
  return this.sendRequest<PaginatedResponse<CapitalIncrease>>({
51
- method: 'GET',
52
- url: '/api/v1/capital-increase/all',
46
+ method: "GET",
47
+ url: "/api/v1/capital-increase/all",
53
48
  params: { region, page, size },
54
49
  });
55
50
  }
@@ -58,11 +53,11 @@ export class CapitalIncreaseClient extends Client {
58
53
  symbol: string,
59
54
  page: number,
60
55
  size: number,
61
- region: Region,
56
+ region: Region
62
57
  ): Promise<PaginatedResponse<CapitalIncrease>> {
63
58
  return this.sendRequest<PaginatedResponse<CapitalIncrease>>({
64
59
  method: 'GET',
65
- url: '/api/v1/capital-increase/' + symbol,
60
+ url: `/api/v1/capital-increase/${symbol}`,
66
61
  params: { region, page, size },
67
62
  });
68
63
  }
@@ -74,7 +69,7 @@ export class CapitalIncreaseClient extends Client {
74
69
  ): Promise<CapitalIncrease[]> {
75
70
  return this.sendRequest<CapitalIncrease[]>({
76
71
  method: 'GET',
77
- url: '/api/v1/rights/active/' + symbol,
72
+ url: `/api/v1/rights/active/${symbol}`,
78
73
  params: { date, region },
79
74
  });
80
75
  }
@@ -1,5 +1,5 @@
1
1
  import { Client } from './client';
2
- import { Stock } from './stocks';
2
+ import { HistoricalPricePeriod, PriceDataPoint, Stock } from './stocks';
3
3
 
4
4
  export enum CollectionType {
5
5
  Sector = 'sector',
@@ -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
  }
@@ -42,60 +42,81 @@ export interface CollectionDetail extends Collection {
42
42
  stocks: Stock[];
43
43
  }
44
44
 
45
+ export interface CollectionPriceGraph {
46
+ previous_close: number;
47
+ graph: PriceDataPoint[];
48
+ }
49
+
45
50
  export class CollectionClient extends Client {
46
- private async getAllCollectionsPrivate(collectionType: CollectionType, region: Region, locale: Locale): Promise<Collection[]> {
51
+ async getAllSectors(region: Region, locale: Locale): Promise<Collection[]> {
47
52
  return this.sendRequest<Collection[]>({
48
53
  method: 'GET',
49
- url: `/api/v1/${collectionType}`,
54
+ url: `/api/v1/sector`,
50
55
  params: { region, locale },
51
56
  });
52
57
  }
53
-
54
- private async getCollectionDetailPrivate(id: string, collectionType: CollectionType, region: Region, locale: Locale): Promise<CollectionDetail> {
55
- return this.sendRequest<CollectionDetail>({
58
+
59
+ async getAllIndustries(region: Region, locale: Locale): Promise<Collection[]> {
60
+ return this.sendRequest<Collection[]>({
56
61
  method: 'GET',
57
- url: `/api/v1/${collectionType}/${id}`,
62
+ url: `/api/v1/industry`,
58
63
  params: { region, locale },
59
64
  });
60
65
  }
61
-
62
- async getAllSectors(region: Region, locale: Locale): Promise<Collection[]> {
63
- return this.getAllCollectionsPrivate(CollectionType.Sector, region, locale);
64
- }
65
-
66
- async getAllIndustries(region: Region, locale: Locale): Promise<Collection[]> {
67
- return this.getAllCollectionsPrivate(CollectionType.Industry, region, locale);
68
- }
69
-
66
+
70
67
  async getAllThemes(region: Region, locale: Locale): Promise<Collection[]> {
71
- return this.getAllCollectionsPrivate(CollectionType.Theme, region, locale);
72
- }
73
-
74
- async getAllCustomThemes(region: Region, locale: Locale): Promise<Collection[]> {
75
- return this.getAllCollectionsPrivate(CollectionType.CustomTheme, region, locale);
68
+ return this.sendRequest<Collection[]>({
69
+ method: 'GET',
70
+ url: `/api/v1/theme`,
71
+ params: { region, locale },
72
+ });
76
73
  }
77
-
74
+
78
75
  async getAllCollections(region: Region, locale: Locale): Promise<Collection[]> {
79
- return this.getAllCollectionsPrivate(CollectionType.Collection, region, locale);
76
+ return this.sendRequest<Collection[]>({
77
+ method: 'GET',
78
+ url: `/api/v1/collection`,
79
+ params: { region, locale },
80
+ });
80
81
  }
81
-
82
+
82
83
  async getSectorDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
83
- return this.getCollectionDetailPrivate(id, CollectionType.Sector, region, locale);
84
+ return this.sendRequest<CollectionDetail>({
85
+ method: 'GET',
86
+ url: `/api/v1/sector/${id}`,
87
+ params: { region, locale },
88
+ });
84
89
  }
85
-
90
+
86
91
  async getIndustryDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
87
- return this.getCollectionDetailPrivate(id, CollectionType.Industry, region, locale);
92
+ return this.sendRequest<CollectionDetail>({
93
+ method: 'GET',
94
+ url: `/api/v1/industry/${id}`,
95
+ params: { region, locale },
96
+ });
88
97
  }
89
-
98
+
90
99
  async getThemeDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
91
- return this.getCollectionDetailPrivate(id, CollectionType.Theme, region, locale);
100
+ return this.sendRequest<CollectionDetail>({
101
+ method: 'GET',
102
+ url: `/api/v1/theme/${id}`,
103
+ params: { region, locale },
104
+ });
92
105
  }
93
-
94
- async getCustomThemeDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
95
- return this.getCollectionDetailPrivate(id, CollectionType.CustomTheme, region, locale);
106
+
107
+ async getCollectionDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
108
+ return this.sendRequest<CollectionDetail>({
109
+ method: 'GET',
110
+ url: `/api/v1/collection/${id}`,
111
+ params: { region, locale },
112
+ });
96
113
  }
97
114
 
98
- async getCollectionDetail(id: string, region: Region, locale: Locale): Promise<CollectionDetail> {
99
- return this.getCollectionDetailPrivate(id, CollectionType.Collection, region, locale);
115
+ async getAggregateGraph(period: HistoricalPricePeriod, sectorId: string, industryId: string, collectionId: string, region: Region): Promise<CollectionPriceGraph> {
116
+ return this.sendRequest<CollectionPriceGraph>({
117
+ method: 'GET',
118
+ url: `/api/v1/aggregate/graph`,
119
+ params: { period, sectorId, industryId, collectionId, region },
120
+ });
100
121
  }
101
- }
122
+ }
@@ -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,14 +71,14 @@ 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);
76
-
74
+ async getStockDividends(
75
+ symbol: string,
76
+ region: Region
77
+ ): Promise<StockDividend[]> {
77
78
  return this.sendRequest<StockDividend[]>({
78
79
  method: 'GET',
79
- url: url.toString(),
80
+ url: "/api/v2/stock/dividends",
81
+ params: { symbol, region }
80
82
  });
81
83
  }
82
84
 
@@ -91,13 +93,16 @@ export class FinancialFundamentalsClient extends Client {
91
93
  });
92
94
  }
93
95
 
94
- async getTopMovers(region: Region, page: number, pageSize: number, direction: TopMoverDirection, assetType?: AssetType): Promise<TopMover[]> {
96
+ async getTopMovers(region: Region, page: number, pageSize: number, direction: TopMoverDirection, assetType?: AssetType,
97
+ assetClass?: AssetClass
98
+ ): Promise<TopMover[]> {
95
99
  const url = new URL(`${this['baseUrl']}/api/v2/stock/top-movers`);
96
100
  url.searchParams.append('region', region);
97
101
  url.searchParams.append('page', page.toString());
98
102
  url.searchParams.append('pageSize', pageSize.toString());
99
103
  url.searchParams.append('direction', direction);
100
104
  if (assetType) url.searchParams.append('assetType', assetType);
105
+ if (assetClass) url.searchParams.append("assetClass", assetClass);
101
106
 
102
107
  return this.sendRequest<TopMover[]>({
103
108
  method: 'GET',