@invezgo/sdk 1.3.2 → 2.0.1
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/README.md +318 -314
- package/dist/cache.d.ts +27 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/client.d.ts +15 -18
- package/dist/client.d.ts.map +1 -1
- package/dist/errors.d.ts +71 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/generated/resources.d.ts +3291 -0
- package/dist/generated/resources.d.ts.map +1 -0
- package/dist/generated/types.d.ts +3449 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/http.d.ts +66 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/index.d.ts +9 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +754 -1080
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +775 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +66 -63
- package/dist/endpoints/ai.d.ts +0 -98
- package/dist/endpoints/ai.d.ts.map +0 -1
- package/dist/endpoints/alerts.d.ts +0 -49
- package/dist/endpoints/alerts.d.ts.map +0 -1
- package/dist/endpoints/analysis.d.ts +0 -380
- package/dist/endpoints/analysis.d.ts.map +0 -1
- package/dist/endpoints/batch.d.ts +0 -40
- package/dist/endpoints/batch.d.ts.map +0 -1
- package/dist/endpoints/health.d.ts +0 -24
- package/dist/endpoints/health.d.ts.map +0 -1
- package/dist/endpoints/journals.d.ts +0 -49
- package/dist/endpoints/journals.d.ts.map +0 -1
- package/dist/endpoints/membership.d.ts +0 -35
- package/dist/endpoints/membership.d.ts.map +0 -1
- package/dist/endpoints/portfolios.d.ts +0 -14
- package/dist/endpoints/portfolios.d.ts.map +0 -1
- package/dist/endpoints/posts.d.ts +0 -42
- package/dist/endpoints/posts.d.ts.map +0 -1
- package/dist/endpoints/profile.d.ts +0 -34
- package/dist/endpoints/profile.d.ts.map +0 -1
- package/dist/endpoints/recommendation.d.ts +0 -10
- package/dist/endpoints/recommendation.d.ts.map +0 -1
- package/dist/endpoints/screener.d.ts +0 -45
- package/dist/endpoints/screener.d.ts.map +0 -1
- package/dist/endpoints/search.d.ts +0 -18
- package/dist/endpoints/search.d.ts.map +0 -1
- package/dist/endpoints/trades.d.ts +0 -31
- package/dist/endpoints/trades.d.ts.map +0 -1
- package/dist/endpoints/usage.d.ts +0 -11
- package/dist/endpoints/usage.d.ts.map +0 -1
- package/dist/endpoints/watchlists.d.ts +0 -64
- package/dist/endpoints/watchlists.d.ts.map +0 -1
- package/dist/index.esm.js +0 -1130
- package/dist/index.esm.js.map +0 -1
- package/dist/invezgo.d.ts +0 -42
- package/dist/invezgo.d.ts.map +0 -1
- package/dist/types.d.ts +0 -610
- package/dist/types.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,1130 +1,804 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.
|
|
9
|
-
Object.setPrototypeOf(this, InvezgoError.prototype);
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
class AnalysisResource {
|
|
6
|
+
transport;
|
|
7
|
+
constructor(transport) {
|
|
8
|
+
this.transport = transport;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
constructor(config) {
|
|
14
|
-
// Ensure baseURL doesn't have trailing slash since paths start with /
|
|
15
|
-
const baseURL = config.baseURL || 'https://api.invezgo.com';
|
|
16
|
-
this.baseURL = baseURL.endsWith('/') ? baseURL.slice(0, -1) : baseURL;
|
|
17
|
-
this.apiKey = config.apiKey;
|
|
18
|
-
this.timeout = config.timeout || 30000;
|
|
19
|
-
if (!this.apiKey) {
|
|
20
|
-
throw new Error('API Key is required');
|
|
21
|
-
}
|
|
10
|
+
getStockList(options) {
|
|
11
|
+
return this.transport.request({ method: 'GET', route: '/analysis/list/stock', cache: 'default' }, options);
|
|
22
12
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const controller = new AbortController();
|
|
26
|
-
const timeoutId = setTimeout(() => controller.abort(), options.timeout || this.timeout);
|
|
27
|
-
try {
|
|
28
|
-
const headers = {
|
|
29
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
30
|
-
'Content-Type': 'application/json',
|
|
31
|
-
'User-Agent': 'Invezgo JS SDK',
|
|
32
|
-
...options.headers,
|
|
33
|
-
};
|
|
34
|
-
const response = await fetch(url, {
|
|
35
|
-
method,
|
|
36
|
-
headers,
|
|
37
|
-
signal: controller.signal,
|
|
38
|
-
});
|
|
39
|
-
clearTimeout(timeoutId);
|
|
40
|
-
// Handle 204 No Content
|
|
41
|
-
if (response.status === 204) {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
const data = await response.json().catch(() => ({}));
|
|
45
|
-
// Handle error responses
|
|
46
|
-
if (!response.ok) {
|
|
47
|
-
throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
|
|
48
|
-
}
|
|
49
|
-
return data;
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
clearTimeout(timeoutId);
|
|
53
|
-
if (error.name === 'AbortError') {
|
|
54
|
-
throw new InvezgoError(408, 'Request timeout', 'Timeout');
|
|
55
|
-
}
|
|
56
|
-
if (error instanceof InvezgoError) {
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
|
|
60
|
-
}
|
|
13
|
+
getBrokerList(options) {
|
|
14
|
+
return this.transport.request({ method: 'GET', route: '/analysis/list/broker', cache: 'default' }, options);
|
|
61
15
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (params && Object.keys(params).length > 0) {
|
|
65
|
-
const searchParams = new URLSearchParams();
|
|
66
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
67
|
-
if (value !== undefined && value !== null) {
|
|
68
|
-
if (Array.isArray(value)) {
|
|
69
|
-
value.forEach(v => searchParams.append(key, String(v)));
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
searchParams.append(key, String(value));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
url = `${path}?${searchParams.toString()}`;
|
|
77
|
-
}
|
|
78
|
-
return this.request('GET', url, options);
|
|
79
|
-
}
|
|
80
|
-
async post(path, body, options) {
|
|
81
|
-
const requestOptions = {
|
|
82
|
-
...options,
|
|
83
|
-
headers: {
|
|
84
|
-
...options?.headers,
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
const controller = new AbortController();
|
|
88
|
-
const timeoutId = setTimeout(() => controller.abort(), requestOptions.timeout || this.timeout);
|
|
89
|
-
try {
|
|
90
|
-
const url = `${this.baseURL}${path}`;
|
|
91
|
-
const headers = {
|
|
92
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
93
|
-
'Content-Type': 'application/json',
|
|
94
|
-
'User-Agent': 'Invezgo JS SDK',
|
|
95
|
-
...requestOptions.headers,
|
|
96
|
-
};
|
|
97
|
-
const response = await fetch(url, {
|
|
98
|
-
method: 'POST',
|
|
99
|
-
headers,
|
|
100
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
101
|
-
signal: controller.signal,
|
|
102
|
-
});
|
|
103
|
-
clearTimeout(timeoutId);
|
|
104
|
-
if (response.status === 204) {
|
|
105
|
-
return {};
|
|
106
|
-
}
|
|
107
|
-
const data = await response.json().catch(() => ({}));
|
|
108
|
-
if (!response.ok) {
|
|
109
|
-
throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
|
|
110
|
-
}
|
|
111
|
-
return data;
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
clearTimeout(timeoutId);
|
|
115
|
-
if (error.name === 'AbortError') {
|
|
116
|
-
throw new InvezgoError(408, 'Request timeout', 'Timeout');
|
|
117
|
-
}
|
|
118
|
-
if (error instanceof InvezgoError) {
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
|
|
122
|
-
}
|
|
16
|
+
getIndexList(options) {
|
|
17
|
+
return this.transport.request({ method: 'GET', route: '/analysis/list/index', cache: 'default' }, options);
|
|
123
18
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const timeoutId = setTimeout(() => controller.abort(), options?.timeout || this.timeout);
|
|
127
|
-
try {
|
|
128
|
-
const url = `${this.baseURL}${path}`;
|
|
129
|
-
const headers = {
|
|
130
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
131
|
-
'Content-Type': 'application/json',
|
|
132
|
-
'User-Agent': 'Invezgo JS SDK',
|
|
133
|
-
...options?.headers,
|
|
134
|
-
};
|
|
135
|
-
const response = await fetch(url, {
|
|
136
|
-
method: 'PUT',
|
|
137
|
-
headers,
|
|
138
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
139
|
-
signal: controller.signal,
|
|
140
|
-
});
|
|
141
|
-
clearTimeout(timeoutId);
|
|
142
|
-
if (response.status === 204) {
|
|
143
|
-
return {};
|
|
144
|
-
}
|
|
145
|
-
const data = await response.json().catch(() => ({}));
|
|
146
|
-
if (!response.ok) {
|
|
147
|
-
throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
|
|
148
|
-
}
|
|
149
|
-
return data;
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
clearTimeout(timeoutId);
|
|
153
|
-
if (error.name === 'AbortError') {
|
|
154
|
-
throw new InvezgoError(408, 'Request timeout', 'Timeout');
|
|
155
|
-
}
|
|
156
|
-
if (error instanceof InvezgoError) {
|
|
157
|
-
throw error;
|
|
158
|
-
}
|
|
159
|
-
throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
|
|
160
|
-
}
|
|
19
|
+
getUma(params, options) {
|
|
20
|
+
return this.transport.request({ method: 'GET', route: '/analysis/uma', cache: 'default', query: params }, options);
|
|
161
21
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const timeoutId = setTimeout(() => controller.abort(), options?.timeout || this.timeout);
|
|
165
|
-
try {
|
|
166
|
-
const url = `${this.baseURL}${path}`;
|
|
167
|
-
const headers = {
|
|
168
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
169
|
-
'Content-Type': 'application/json',
|
|
170
|
-
'User-Agent': 'Invezgo JS SDK',
|
|
171
|
-
...options?.headers,
|
|
172
|
-
};
|
|
173
|
-
const response = await fetch(url, {
|
|
174
|
-
method: 'PATCH',
|
|
175
|
-
headers,
|
|
176
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
177
|
-
signal: controller.signal,
|
|
178
|
-
});
|
|
179
|
-
clearTimeout(timeoutId);
|
|
180
|
-
if (response.status === 204) {
|
|
181
|
-
return {};
|
|
182
|
-
}
|
|
183
|
-
const data = await response.json().catch(() => ({}));
|
|
184
|
-
if (!response.ok) {
|
|
185
|
-
throw new InvezgoError(response.status, data?.message || response.statusText, data?.error, data);
|
|
186
|
-
}
|
|
187
|
-
return data;
|
|
188
|
-
}
|
|
189
|
-
catch (error) {
|
|
190
|
-
clearTimeout(timeoutId);
|
|
191
|
-
if (error.name === 'AbortError') {
|
|
192
|
-
throw new InvezgoError(408, 'Request timeout', 'Timeout');
|
|
193
|
-
}
|
|
194
|
-
if (error instanceof InvezgoError) {
|
|
195
|
-
throw error;
|
|
196
|
-
}
|
|
197
|
-
throw new InvezgoError(500, error.message || 'Unknown error occurred', 'InternalError', error);
|
|
198
|
-
}
|
|
22
|
+
getSuspend(params, options) {
|
|
23
|
+
return this.transport.request({ method: 'GET', route: '/analysis/suspend', cache: 'default', query: params }, options);
|
|
199
24
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (params && Object.keys(params).length > 0) {
|
|
203
|
-
const searchParams = new URLSearchParams();
|
|
204
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
205
|
-
if (value !== undefined && value !== null) {
|
|
206
|
-
if (Array.isArray(value)) {
|
|
207
|
-
value.forEach(v => searchParams.append(key, String(v)));
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
searchParams.append(key, String(value));
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
url = `${path}?${searchParams.toString()}`;
|
|
215
|
-
}
|
|
216
|
-
return this.request('DELETE', url, options);
|
|
25
|
+
getNotation(options) {
|
|
26
|
+
return this.transport.request({ method: 'GET', route: '/analysis/notation', cache: 'default' }, options);
|
|
217
27
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
this.
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
return this.
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
return this.
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
return this.
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
return this.
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return this.
|
|
28
|
+
getInformation(code, options) {
|
|
29
|
+
return this.transport.request({ method: 'GET', route: '/analysis/information/{code}', cache: 'default', pathParams: { code } }, options);
|
|
30
|
+
}
|
|
31
|
+
getTopChange(params, options) {
|
|
32
|
+
return this.transport.request({ method: 'GET', route: '/analysis/top/change', cache: 'default', query: params }, options);
|
|
33
|
+
}
|
|
34
|
+
getTopForeign(params, options) {
|
|
35
|
+
return this.transport.request({ method: 'GET', route: '/analysis/top/foreign', cache: 'default', query: params }, options);
|
|
36
|
+
}
|
|
37
|
+
getTopAccumulation(params, options) {
|
|
38
|
+
return this.transport.request({ method: 'GET', route: '/analysis/top/accumulation', cache: 'default', query: params }, options);
|
|
39
|
+
}
|
|
40
|
+
getTopRitel(params, options) {
|
|
41
|
+
return this.transport.request({ method: 'GET', route: '/analysis/top/ritel', cache: 'default', query: params }, options);
|
|
42
|
+
}
|
|
43
|
+
getStockRunningTrade(code, params, options) {
|
|
44
|
+
return this.transport.request({ method: 'GET', route: '/analysis/running-trade/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
45
|
+
}
|
|
46
|
+
getIntradayChart(code, params, options) {
|
|
47
|
+
return this.transport.request({ method: 'GET', route: '/analysis/intraday/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
48
|
+
}
|
|
49
|
+
getOrderBook(code, params, options) {
|
|
50
|
+
return this.transport.request({ method: 'GET', route: '/analysis/order-book/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
51
|
+
}
|
|
52
|
+
getOrderQueue(code, params, options) {
|
|
53
|
+
return this.transport.request({ method: 'GET', route: '/analysis/queue/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
54
|
+
}
|
|
55
|
+
getIntradayData(code, params, options) {
|
|
56
|
+
return this.transport.request({ method: 'GET', route: '/analysis/intraday-data/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
57
|
+
}
|
|
58
|
+
getIntradayIndex(code, options) {
|
|
59
|
+
return this.transport.request({ method: 'GET', route: '/analysis/intraday-index/{code}', cache: 'realtime', pathParams: { code } }, options);
|
|
60
|
+
}
|
|
61
|
+
getAdvanceChart(code, params, options) {
|
|
62
|
+
return this.transport.request({ method: 'GET', route: '/analysis/chart/stock/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
63
|
+
}
|
|
64
|
+
getIndexChart(code, params, options) {
|
|
65
|
+
return this.transport.request({ method: 'GET', route: '/analysis/chart/index/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
66
|
+
}
|
|
67
|
+
getMultiTimeChart(code, params, options) {
|
|
68
|
+
return this.transport.request({ method: 'GET', route: '/analysis/chart/multi-time/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
69
|
+
}
|
|
70
|
+
getIndicatorChart(indicator, code, params, options) {
|
|
71
|
+
return this.transport.request({ method: 'GET', route: '/analysis/chart/stock/{indicator}/{code}', cache: 'default', pathParams: { indicator, code }, query: params }, options);
|
|
72
|
+
}
|
|
73
|
+
getShareholderDetail(params, options) {
|
|
74
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder-detail', cache: 'default', query: params }, options);
|
|
75
|
+
}
|
|
76
|
+
getShareholderOneDetail(params, options) {
|
|
77
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder-detail-one', cache: 'default', query: params }, options);
|
|
78
|
+
}
|
|
79
|
+
getShareholderHigh(options) {
|
|
80
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder/high', cache: 'default' }, options);
|
|
81
|
+
}
|
|
82
|
+
getShareholderNumber(code, options) {
|
|
83
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder/number/{code}', cache: 'default', pathParams: { code } }, options);
|
|
84
|
+
}
|
|
85
|
+
getShareholderRelation(params, options) {
|
|
86
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder/relation', cache: 'default', query: params }, options);
|
|
87
|
+
}
|
|
88
|
+
getShareholder(code, options) {
|
|
89
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder/{code}', cache: 'default', pathParams: { code } }, options);
|
|
90
|
+
}
|
|
91
|
+
getShareholderKSEI(code, params, options) {
|
|
92
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder/ksei/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
93
|
+
}
|
|
94
|
+
getShareholderClassification(code, params, options) {
|
|
95
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder/classification/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
96
|
+
}
|
|
97
|
+
getShareholderClassifyTable(code, options) {
|
|
98
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder/classify-table/{code}', cache: 'default', pathParams: { code } }, options);
|
|
99
|
+
}
|
|
100
|
+
getSummaryStock(code, params, options) {
|
|
101
|
+
return this.transport.request({ method: 'GET', route: '/analysis/summary/stock/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
102
|
+
}
|
|
103
|
+
getSummaryBroker(code, params, options) {
|
|
104
|
+
return this.transport.request({ method: 'GET', route: '/analysis/summary/broker/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
105
|
+
}
|
|
106
|
+
getSectorStalker(params, options) {
|
|
107
|
+
return this.transport.request({ method: 'GET', route: '/analysis/stalker/sector', cache: 'realtime', query: params }, options);
|
|
108
|
+
}
|
|
109
|
+
getSectorRotation(params, options) {
|
|
110
|
+
return this.transport.request({ method: 'GET', route: '/analysis/sector/rotation', cache: 'realtime', query: params }, options);
|
|
111
|
+
}
|
|
112
|
+
getBrokerStalker(broker, stock, params, options) {
|
|
113
|
+
return this.transport.request({ method: 'GET', route: '/analysis/stalker/broker/{broker}/{stock}', cache: 'default', pathParams: { broker, stock }, query: params }, options);
|
|
114
|
+
}
|
|
115
|
+
getBrokerStalkerList(code, params, options) {
|
|
116
|
+
return this.transport.request({ method: 'GET', route: '/analysis/stalker/list/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
117
|
+
}
|
|
118
|
+
getSummaryStockChart(code, params, options) {
|
|
119
|
+
return this.transport.request({ method: 'GET', route: '/analysis/summary-chart/stock/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
120
|
+
}
|
|
121
|
+
getSummaryBrokerChart(code, params, options) {
|
|
122
|
+
return this.transport.request({ method: 'GET', route: '/analysis/summary-chart/broker/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
123
|
+
}
|
|
124
|
+
getInventoryStockChart(code, params, options) {
|
|
125
|
+
return this.transport.request({ method: 'GET', route: '/analysis/inventory-chart/stock/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
126
|
+
}
|
|
127
|
+
getInventoryBrokerChart(code, params, options) {
|
|
128
|
+
return this.transport.request({ method: 'GET', route: '/analysis/inventory-chart/broker/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
129
|
+
}
|
|
130
|
+
getMomentumChart(code, params, options) {
|
|
131
|
+
return this.transport.request({ method: 'GET', route: '/analysis/momentum-chart/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
132
|
+
}
|
|
133
|
+
getIntradayInventoryChart(code, params, options) {
|
|
134
|
+
return this.transport.request({ method: 'GET', route: '/analysis/intraday-inventory-chart/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
135
|
+
}
|
|
136
|
+
getSankeyChart(code, params, options) {
|
|
137
|
+
return this.transport.request({ method: 'GET', route: '/analysis/sankey-chart/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
138
|
+
}
|
|
139
|
+
getPriceTable(code, params, options) {
|
|
140
|
+
return this.transport.request({ method: 'GET', route: '/analysis/price-table/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
141
|
+
}
|
|
142
|
+
getTimeTable(code, params, options) {
|
|
143
|
+
return this.transport.request({ method: 'GET', route: '/analysis/time-table/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
144
|
+
}
|
|
145
|
+
getPriceDiary(code, options) {
|
|
146
|
+
return this.transport.request({ method: 'GET', route: '/analysis/price-diary/{code}', cache: 'default', pathParams: { code } }, options);
|
|
147
|
+
}
|
|
148
|
+
getPriceSeasonality(code, params, options) {
|
|
149
|
+
return this.transport.request({ method: 'GET', route: '/analysis/price-seasonality/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
150
|
+
}
|
|
151
|
+
getShareholderAbove(params, options) {
|
|
152
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder-above', cache: 'default', query: params }, options);
|
|
153
|
+
}
|
|
154
|
+
getShareholderAboveChart(code, params, options) {
|
|
155
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder-above-chart/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
156
|
+
}
|
|
157
|
+
getShareholderOne(params, options) {
|
|
158
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder-one', cache: 'default', query: params }, options);
|
|
159
|
+
}
|
|
160
|
+
getShareholderOneChart(code, params, options) {
|
|
161
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder-one-chart/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
162
|
+
}
|
|
163
|
+
getInsider(params, options) {
|
|
164
|
+
return this.transport.request({ method: 'GET', route: '/analysis/shareholder-insider', cache: 'default', query: params }, options);
|
|
165
|
+
}
|
|
166
|
+
getInsiderChart(code, params, options) {
|
|
167
|
+
return this.transport.request({ method: 'GET', route: '/analysis/insider-chart/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
168
|
+
}
|
|
169
|
+
getFinancialStatement(code, params, options) {
|
|
170
|
+
return this.transport.request({ method: 'GET', route: '/analysis/financial-statement/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
171
|
+
}
|
|
172
|
+
getFinancialStatementChart(code, params, options) {
|
|
173
|
+
return this.transport.request({ method: 'GET', route: '/analysis/financial-statement-chart/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
174
|
+
}
|
|
175
|
+
getKeystat(code, params, options) {
|
|
176
|
+
return this.transport.request({ method: 'GET', route: '/analysis/keystat/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
177
|
+
}
|
|
178
|
+
getKeystatChart(code, params, options) {
|
|
179
|
+
return this.transport.request({ method: 'GET', route: '/analysis/keystat-chart/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
180
|
+
}
|
|
181
|
+
getCalendar(params, options) {
|
|
182
|
+
return this.transport.request({ method: 'GET', route: '/analysis/calendar', cache: 'default', query: params }, options);
|
|
183
|
+
}
|
|
184
|
+
getNews(params, options) {
|
|
185
|
+
return this.transport.request({ method: 'GET', route: '/analysis/news', cache: 'default', query: params }, options);
|
|
186
|
+
}
|
|
187
|
+
getDisclosure(params, options) {
|
|
188
|
+
return this.transport.request({ method: 'GET', route: '/analysis/disclosure', cache: 'default', query: params }, options);
|
|
253
189
|
}
|
|
254
190
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
constructor(
|
|
258
|
-
this.
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Get list of all stocks listed on BEI.
|
|
262
|
-
*/
|
|
263
|
-
async getStockList() {
|
|
264
|
-
return this.client.get('/analysis/list/stock');
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Get list of all brokers/securities on BEI.
|
|
268
|
-
*/
|
|
269
|
-
async getBrokerList() {
|
|
270
|
-
return this.client.get('/analysis/list/broker');
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Get list of all supported IDX indexes.
|
|
274
|
-
*/
|
|
275
|
-
async getIndexList() {
|
|
276
|
-
return this.client.get('/analysis/list/index');
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Get complete company information.
|
|
280
|
-
*/
|
|
281
|
-
async getInformation(code) {
|
|
282
|
-
return this.client.get(`/analysis/information/${code}`);
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Get top gainer and loser stocks for a specific date.
|
|
286
|
-
*/
|
|
287
|
-
async getTopChange(date) {
|
|
288
|
-
return this.client.get('/analysis/top/change', { date });
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Get top foreign accumulation and distribution.
|
|
292
|
-
*/
|
|
293
|
-
async getTopForeign(date) {
|
|
294
|
-
return this.client.get('/analysis/top/foreign', { date });
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Get top bandarmology accumulation and distribution.
|
|
298
|
-
*/
|
|
299
|
-
async getTopAccumulation(date) {
|
|
300
|
-
return this.client.get('/analysis/top/accumulation', { date });
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Get top retail accumulation and distribution.
|
|
304
|
-
*/
|
|
305
|
-
async getTopRitel(date) {
|
|
306
|
-
return this.client.get('/analysis/top/ritel', { date });
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Alias for getTopRitel.
|
|
310
|
-
*/
|
|
311
|
-
async getTopRetail(date) {
|
|
312
|
-
return this.getTopRitel(date);
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Get intraday chart data.
|
|
316
|
-
*/
|
|
317
|
-
async getIntradayChart(code, market = 'RG') {
|
|
318
|
-
return this.client.get(`/analysis/intraday/${code}`, { market });
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* Get intraday stock summary data.
|
|
322
|
-
*/
|
|
323
|
-
async getIntradayData(code, market = 'RG') {
|
|
324
|
-
return this.client.get(`/analysis/intraday-data/${code}`, { market });
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Get intraday index summary data.
|
|
328
|
-
*/
|
|
329
|
-
async getIntradayIndex(code, market = 'RG') {
|
|
330
|
-
return this.client.get(`/analysis/intraday-index/${code}`, { market });
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Get order book data.
|
|
334
|
-
*/
|
|
335
|
-
async getOrderBook(code, market = 'RG') {
|
|
336
|
-
return this.client.get(`/analysis/order-book/${code}`, { market });
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Get complete stock chart data.
|
|
340
|
-
*/
|
|
341
|
-
async getChart(code, params) {
|
|
342
|
-
return this.client.get(`/analysis/chart/stock/${code}`, params);
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Get historical index chart data.
|
|
346
|
-
*/
|
|
347
|
-
async getIndexChart(code, params) {
|
|
348
|
-
return this.client.get(`/analysis/chart/index/${code}`, params);
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Get stock chart with technical indicator.
|
|
352
|
-
*/
|
|
353
|
-
async getIndicatorChart(code, indicator, params) {
|
|
354
|
-
return this.client.get(`/analysis/chart/stock/${indicator}/${code}`, params);
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* Get shareholder detail above 5%.
|
|
358
|
-
*/
|
|
359
|
-
async getShareholderDetail(code) {
|
|
360
|
-
return this.client.get(`/analysis/shareholder-detail/${code}`);
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Get shareholder detail above 1% for a specific holder.
|
|
364
|
-
*/
|
|
365
|
-
async getShareholderDetailOne(params) {
|
|
366
|
-
return this.client.get('/analysis/shareholder-detail-one', params);
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Get number of shareholders.
|
|
370
|
-
*/
|
|
371
|
-
async getShareholderNumber(code) {
|
|
372
|
-
return this.client.get(`/analysis/shareholder/number/${code}`);
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Get shareholder relation graph.
|
|
376
|
-
*/
|
|
377
|
-
async getShareholderRelation(params) {
|
|
378
|
-
return this.client.get('/analysis/shareholder/relation', params);
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Get shareholder composition.
|
|
382
|
-
*/
|
|
383
|
-
async getShareholder(code) {
|
|
384
|
-
return this.client.get(`/analysis/shareholder/${code}`);
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Get KSEI shareholder data.
|
|
388
|
-
*/
|
|
389
|
-
async getShareholderKSEI(code, range) {
|
|
390
|
-
return this.client.get(`/analysis/shareholder/ksei/${code}`, {
|
|
391
|
-
range: Math.min(range, 12),
|
|
392
|
-
});
|
|
191
|
+
class BatchResource {
|
|
192
|
+
transport;
|
|
193
|
+
constructor(transport) {
|
|
194
|
+
this.transport = transport;
|
|
393
195
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
*/
|
|
397
|
-
async getBrokerSummaryStock(code, params) {
|
|
398
|
-
return this.client.get(`/analysis/summary/stock/${code}`, params);
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
|
-
* Get broker summary for a broker.
|
|
402
|
-
*/
|
|
403
|
-
async getBrokerSummaryBroker(code, params) {
|
|
404
|
-
return this.client.get(`/analysis/summary/broker/${code}`, params);
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Get sector stalker data.
|
|
408
|
-
*/
|
|
409
|
-
async getStalkerSector(params) {
|
|
410
|
-
return this.client.get('/analysis/stalker/sector', params);
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Get sector rotation chart.
|
|
414
|
-
*/
|
|
415
|
-
async getSectorRotation(params) {
|
|
416
|
-
return this.client.get('/analysis/sector/rotation', params);
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Get broker stalker data for a stock.
|
|
420
|
-
*/
|
|
421
|
-
async getBrokerStalker(broker, stock, params) {
|
|
422
|
-
return this.client.get(`/analysis/stalker/broker/${broker}/${stock}`, params);
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Get broker stalker list.
|
|
426
|
-
*/
|
|
427
|
-
async getBrokerStalkerList(code, params) {
|
|
428
|
-
return this.client.get(`/analysis/stalker/list/${code}`, params);
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Get broker summary chart for a stock.
|
|
432
|
-
*/
|
|
433
|
-
async getBrokerSummaryChartStock(code, params) {
|
|
434
|
-
return this.client.get(`/analysis/summary-chart/stock/${code}`, params);
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* Get broker summary chart for a broker.
|
|
438
|
-
*/
|
|
439
|
-
async getBrokerSummaryChartBroker(code, params) {
|
|
440
|
-
return this.client.get(`/analysis/summary-chart/broker/${code}`, params);
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Get inventory chart for a stock.
|
|
444
|
-
*/
|
|
445
|
-
async getInventoryChartStock(code, params) {
|
|
446
|
-
return this.client.get(`/analysis/inventory-chart/stock/${code}`, params);
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
* Get inventory chart for a broker.
|
|
450
|
-
*/
|
|
451
|
-
async getInventoryChartBroker(code, params) {
|
|
452
|
-
return this.client.get(`/analysis/inventory-chart/broker/${code}`, params);
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Get momentum chart.
|
|
456
|
-
*/
|
|
457
|
-
async getMomentumChart(code, params) {
|
|
458
|
-
return this.client.get(`/analysis/momentum-chart/${code}`, params);
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Get intraday inventory chart.
|
|
462
|
-
*/
|
|
463
|
-
async getIntradayInventoryChart(code, params) {
|
|
464
|
-
return this.client.get(`/analysis/intraday-inventory-chart/${code}`, params);
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Get distribution or crossing chart.
|
|
468
|
-
*/
|
|
469
|
-
async getSankeyChart(code, params) {
|
|
470
|
-
return this.client.get(`/analysis/sankey-chart/${code}`, params);
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* Get price table.
|
|
474
|
-
*/
|
|
475
|
-
async getPriceTable(code, date) {
|
|
476
|
-
return this.client.get(`/analysis/price-table/${code}`, { date });
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Get time table.
|
|
480
|
-
*/
|
|
481
|
-
async getTimeTable(code, params) {
|
|
482
|
-
return this.client.get(`/analysis/time-table/${code}`, params);
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* Get price diary.
|
|
486
|
-
*/
|
|
487
|
-
async getPriceDiary(code) {
|
|
488
|
-
return this.client.get(`/analysis/price-diary/${code}`);
|
|
489
|
-
}
|
|
490
|
-
/**
|
|
491
|
-
* Get price seasonality.
|
|
492
|
-
*/
|
|
493
|
-
async getPriceSeasonality(code, range) {
|
|
494
|
-
return this.client.get(`/analysis/price-seasonality/${code}`, {
|
|
495
|
-
range: Math.min(range, 60),
|
|
496
|
-
});
|
|
196
|
+
getOrderBook(code, params, options) {
|
|
197
|
+
return this.transport.request({ method: 'GET', route: '/batch/order-book/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
497
198
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
*/
|
|
501
|
-
async getShareholderAbove(params) {
|
|
502
|
-
return this.client.get('/analysis/shareholder-above', params);
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* Get shareholder above 5% chart.
|
|
506
|
-
*/
|
|
507
|
-
async getShareholderAboveChart(code, params) {
|
|
508
|
-
return this.client.get(`/analysis/shareholder-above-chart/${code}`, params);
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* Get shareholders above 1%.
|
|
512
|
-
*/
|
|
513
|
-
async getShareholderOne(params) {
|
|
514
|
-
return this.client.get('/analysis/shareholder-one', params);
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
* Get shareholder above 1% chart.
|
|
518
|
-
*/
|
|
519
|
-
async getShareholderOneChart(code, params) {
|
|
520
|
-
return this.client.get(`/analysis/shareholder-one-chart/${code}`, params);
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* Get insider trading data.
|
|
524
|
-
*/
|
|
525
|
-
async getInsiderTrading(params) {
|
|
526
|
-
return this.client.get('/analysis/shareholder-insider', params);
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* Get insider chart.
|
|
530
|
-
*/
|
|
531
|
-
async getInsiderChart(code, params) {
|
|
532
|
-
return this.client.get(`/analysis/insider-chart/${code}`, params);
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* Get financial statement.
|
|
536
|
-
*/
|
|
537
|
-
async getFinancialStatement(code, params) {
|
|
538
|
-
return this.client.get(`/analysis/financial-statement/${code}`, { ...params, limit: Math.min(params.limit, 20) });
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Get financial statement chart.
|
|
542
|
-
*/
|
|
543
|
-
async getFinancialStatementChart(code, params) {
|
|
544
|
-
return this.client.get(`/analysis/financial-statement-chart/${code}`, { ...params, limit: Math.min(params.limit, 20) });
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Get key statistics.
|
|
548
|
-
*/
|
|
549
|
-
async getKeyStat(code, params) {
|
|
550
|
-
return this.client.get(`/analysis/keystat/${code}`, {
|
|
551
|
-
...params,
|
|
552
|
-
limit: Math.min(params.limit, 20),
|
|
553
|
-
});
|
|
199
|
+
getIntradayData(code, params, options) {
|
|
200
|
+
return this.transport.request({ method: 'GET', route: '/batch/intraday-data/{code}', cache: 'realtime', pathParams: { code }, query: params }, options);
|
|
554
201
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
202
|
+
getIntradayIndex(code, options) {
|
|
203
|
+
return this.transport.request({ method: 'GET', route: '/batch/intraday-index/{code}', cache: 'realtime', pathParams: { code } }, options);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
class SearchResource {
|
|
207
|
+
transport;
|
|
208
|
+
constructor(transport) {
|
|
209
|
+
this.transport = transport;
|
|
563
210
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
return this.
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
*/
|
|
573
|
-
async getCorporateActionCalendar(params) {
|
|
574
|
-
return this.getCalendar(params);
|
|
575
|
-
}
|
|
576
|
-
/**
|
|
577
|
-
* Get multi-timeframe chart data for stocks or indexes.
|
|
578
|
-
*/
|
|
579
|
-
async getMultiTimeChart(code, params) {
|
|
580
|
-
return this.client.get(`/analysis/chart/multi-time/${code}`, params);
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* Get high concentration stock ownership data for all issuers.
|
|
584
|
-
*/
|
|
585
|
-
async getShareholderHigh() {
|
|
586
|
-
return this.client.get('/analysis/shareholder/high');
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* Get complete shareholder data with all investor classifications for a specific period.
|
|
590
|
-
*/
|
|
591
|
-
async getShareholderClassification(code, range) {
|
|
592
|
-
return this.client.get(`/analysis/shareholder/classification/${code}`, { range: Math.min(range, 36) });
|
|
593
|
-
}
|
|
594
|
-
/**
|
|
595
|
-
* Get latest shareholder data with investor classifications in table format.
|
|
596
|
-
*/
|
|
597
|
-
async getShareholderClassifyTable(code) {
|
|
598
|
-
return this.client.get(`/analysis/shareholder/classify-table/${code}`);
|
|
599
|
-
}
|
|
600
|
-
/**
|
|
601
|
-
* Get order queue (order tracking) for a stock at a specific price, side, page, and limit.
|
|
602
|
-
*/
|
|
603
|
-
async getOrderQueue(code, params) {
|
|
604
|
-
return this.client.get(`/analysis/queue/${code}`, params);
|
|
605
|
-
}
|
|
606
|
-
/**
|
|
607
|
-
* Get realtime/historical running trade transaction data for a specific stock code.
|
|
608
|
-
*
|
|
609
|
-
* @param code Stock code (e.g. 'BBCA')
|
|
610
|
-
* @param params Query parameters including date (YYYY-MM-DD), page, limit, type, orderby, etc.
|
|
611
|
-
*/
|
|
612
|
-
async getRunningTrade(code, params) {
|
|
613
|
-
return this.client.get(`/analysis/running-trade/${code}`, params);
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* Alias for getRunningTrade.
|
|
617
|
-
*/
|
|
618
|
-
async getStockRunningTrade(code, params) {
|
|
619
|
-
return this.getRunningTrade(code, params);
|
|
211
|
+
search(params, options) {
|
|
212
|
+
return this.transport.request({ method: 'GET', route: '/search', cache: 'default', query: params }, options);
|
|
213
|
+
}
|
|
214
|
+
searchStock(params, options) {
|
|
215
|
+
return this.transport.request({ method: 'GET', route: '/search/stock', cache: 'default', query: params }, options);
|
|
216
|
+
}
|
|
217
|
+
searchUser(params, options) {
|
|
218
|
+
return this.transport.request({ method: 'GET', route: '/search/user', cache: 'default', query: params }, options);
|
|
620
219
|
}
|
|
621
220
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
constructor(
|
|
625
|
-
this.
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
return this.
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
return this.
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
*
|
|
642
|
-
* The current OpenAPI spec does not describe delete filters,
|
|
643
|
-
* but the SDK keeps optional query params for batch deletion support.
|
|
644
|
-
*/
|
|
645
|
-
async delete(params) {
|
|
646
|
-
return this.client.delete('/watchlists', params);
|
|
647
|
-
}
|
|
648
|
-
/**
|
|
649
|
-
* Get list of watchlist groups.
|
|
650
|
-
*/
|
|
651
|
-
async listGroups() {
|
|
652
|
-
return this.client.get('/watchlists/group');
|
|
653
|
-
}
|
|
654
|
-
/**
|
|
655
|
-
* Add new watchlist group.
|
|
656
|
-
*/
|
|
657
|
-
async addGroup(dto) {
|
|
658
|
-
return this.client.post('/watchlists/group', dto);
|
|
659
|
-
}
|
|
660
|
-
/**
|
|
661
|
-
* Update watchlist group.
|
|
662
|
-
*/
|
|
663
|
-
async updateGroup(id, dto) {
|
|
664
|
-
return this.client.put(`/watchlists/group/${id}`, dto);
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* Delete watchlist group.
|
|
668
|
-
*/
|
|
669
|
-
async deleteGroup(id) {
|
|
670
|
-
return this.client.delete(`/watchlists/group/${id}`);
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* Update watchlist.
|
|
674
|
-
*/
|
|
675
|
-
async update(id, dto) {
|
|
676
|
-
return this.client.put(`/watchlists/${id}`, dto);
|
|
677
|
-
}
|
|
678
|
-
/**
|
|
679
|
-
* Update watchlist note.
|
|
680
|
-
*/
|
|
681
|
-
async updateNote(id, dto) {
|
|
682
|
-
return this.client.patch(`/watchlists/${id}`, dto);
|
|
221
|
+
class ScreenerResource {
|
|
222
|
+
transport;
|
|
223
|
+
constructor(transport) {
|
|
224
|
+
this.transport = transport;
|
|
225
|
+
}
|
|
226
|
+
screen(body, options) {
|
|
227
|
+
return this.transport.request({ method: 'POST', route: '/screener/screen', cache: 'none', body }, options);
|
|
228
|
+
}
|
|
229
|
+
list(options) {
|
|
230
|
+
return this.transport.request({ method: 'GET', route: '/screener', cache: 'default' }, options);
|
|
231
|
+
}
|
|
232
|
+
save(body, options) {
|
|
233
|
+
return this.transport.request({ method: 'POST', route: '/screener', cache: 'none', body }, options);
|
|
234
|
+
}
|
|
235
|
+
update(id, body, options) {
|
|
236
|
+
return this.transport.request({ method: 'PUT', route: '/screener/{id}', cache: 'none', pathParams: { id }, body }, options);
|
|
237
|
+
}
|
|
238
|
+
delete(id, options) {
|
|
239
|
+
return this.transport.request({ method: 'DELETE', route: '/screener/{id}', cache: 'none', pathParams: { id } }, options);
|
|
683
240
|
}
|
|
684
241
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
constructor(
|
|
688
|
-
this.
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
formData.append('file', file);
|
|
696
|
-
const url = `${this.client.baseURL}/journals/file`;
|
|
697
|
-
const response = await fetch(url, {
|
|
698
|
-
method: 'POST',
|
|
699
|
-
headers: {
|
|
700
|
-
Authorization: `Bearer ${this.client.apiKey}`,
|
|
701
|
-
},
|
|
702
|
-
body: formData,
|
|
703
|
-
});
|
|
704
|
-
if (!response.ok) {
|
|
705
|
-
const data = (await response.json().catch(() => ({})));
|
|
706
|
-
throw new InvezgoError(response.status, data.message || 'Failed to extract journal from file', data.error, data);
|
|
707
|
-
}
|
|
708
|
-
return response.json().catch(() => ({}));
|
|
709
|
-
}
|
|
710
|
-
/**
|
|
711
|
-
* Add new journal transaction.
|
|
712
|
-
*/
|
|
713
|
-
async add(dto) {
|
|
714
|
-
return this.client.post('/journals', dto);
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* List journal transactions.
|
|
718
|
-
*/
|
|
719
|
-
async list() {
|
|
720
|
-
return this.client.get('/journals');
|
|
721
|
-
}
|
|
722
|
-
/**
|
|
723
|
-
* Delete journal entries.
|
|
724
|
-
*
|
|
725
|
-
* The current OpenAPI spec does not describe delete filters,
|
|
726
|
-
* but the SDK keeps optional query params for batch deletion support.
|
|
727
|
-
*/
|
|
728
|
-
async delete(params) {
|
|
729
|
-
return this.client.delete('/journals', params);
|
|
730
|
-
}
|
|
731
|
-
/**
|
|
732
|
-
* Get journal transactions summary.
|
|
733
|
-
*/
|
|
734
|
-
async getSummary() {
|
|
735
|
-
return this.client.get('/journals/summary');
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Update journal transaction note.
|
|
739
|
-
*/
|
|
740
|
-
async updateNote(id, dto) {
|
|
741
|
-
return this.client.patch(`/journals/${id}`, dto);
|
|
242
|
+
class UsageResource {
|
|
243
|
+
transport;
|
|
244
|
+
constructor(transport) {
|
|
245
|
+
this.transport = transport;
|
|
246
|
+
}
|
|
247
|
+
getApiUsage(options) {
|
|
248
|
+
return this.transport.request({ method: 'GET', route: '/usage/api', cache: 'none' }, options);
|
|
249
|
+
}
|
|
250
|
+
getLogs(params, options) {
|
|
251
|
+
return this.transport.request({ method: 'GET', route: '/usage/logs', cache: 'none', query: params }, options);
|
|
742
252
|
}
|
|
743
253
|
}
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
constructor(
|
|
747
|
-
this.
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
return this.
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
return this.
|
|
254
|
+
class WatchlistsResource {
|
|
255
|
+
transport;
|
|
256
|
+
constructor(transport) {
|
|
257
|
+
this.transport = transport;
|
|
258
|
+
}
|
|
259
|
+
list(params, options) {
|
|
260
|
+
return this.transport.request({ method: 'GET', route: '/watchlists', cache: 'default', query: params }, options);
|
|
261
|
+
}
|
|
262
|
+
add(body, options) {
|
|
263
|
+
return this.transport.request({ method: 'POST', route: '/watchlists', cache: 'none', body }, options);
|
|
264
|
+
}
|
|
265
|
+
delete(body, options) {
|
|
266
|
+
return this.transport.request({ method: 'DELETE', route: '/watchlists', cache: 'none', body }, options);
|
|
267
|
+
}
|
|
268
|
+
listGroups(options) {
|
|
269
|
+
return this.transport.request({ method: 'GET', route: '/watchlists/group', cache: 'default' }, options);
|
|
270
|
+
}
|
|
271
|
+
addGroup(body, options) {
|
|
272
|
+
return this.transport.request({ method: 'POST', route: '/watchlists/group', cache: 'none', body }, options);
|
|
273
|
+
}
|
|
274
|
+
updateGroup(id, body, options) {
|
|
275
|
+
return this.transport.request({ method: 'PUT', route: '/watchlists/group/{id}', cache: 'none', pathParams: { id }, body }, options);
|
|
276
|
+
}
|
|
277
|
+
deleteGroup(id, options) {
|
|
278
|
+
return this.transport.request({ method: 'DELETE', route: '/watchlists/group/{id}', cache: 'none', pathParams: { id } }, options);
|
|
279
|
+
}
|
|
280
|
+
update(id, body, options) {
|
|
281
|
+
return this.transport.request({ method: 'PUT', route: '/watchlists/{id}', cache: 'none', pathParams: { id }, body }, options);
|
|
282
|
+
}
|
|
283
|
+
updateNote(id, body, options) {
|
|
284
|
+
return this.transport.request({ method: 'PATCH', route: '/watchlists/{id}', cache: 'none', pathParams: { id }, body }, options);
|
|
760
285
|
}
|
|
761
286
|
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
constructor(
|
|
765
|
-
this.
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
return this.
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
return this.
|
|
778
|
-
}
|
|
779
|
-
/**
|
|
780
|
-
* Search for users
|
|
781
|
-
*/
|
|
782
|
-
async searchUser(query, cursor) {
|
|
783
|
-
return this.client.get('/search/user', { query, cursor });
|
|
287
|
+
class JournalsResource {
|
|
288
|
+
transport;
|
|
289
|
+
constructor(transport) {
|
|
290
|
+
this.transport = transport;
|
|
291
|
+
}
|
|
292
|
+
add(body, options) {
|
|
293
|
+
return this.transport.request({ method: 'POST', route: '/journals', cache: 'none', body }, options);
|
|
294
|
+
}
|
|
295
|
+
list(params, options) {
|
|
296
|
+
return this.transport.request({ method: 'GET', route: '/journals', cache: 'default', query: params }, options);
|
|
297
|
+
}
|
|
298
|
+
delete(body, options) {
|
|
299
|
+
return this.transport.request({ method: 'DELETE', route: '/journals', cache: 'none', body }, options);
|
|
300
|
+
}
|
|
301
|
+
getSummary(params, options) {
|
|
302
|
+
return this.transport.request({ method: 'GET', route: '/journals/summary', cache: 'default', query: params }, options);
|
|
784
303
|
}
|
|
785
304
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
constructor(
|
|
789
|
-
this.
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
return this.
|
|
796
|
-
}
|
|
797
|
-
/**
|
|
798
|
-
* Get user posts
|
|
799
|
-
*/
|
|
800
|
-
async getUserPosts(username, page, limit) {
|
|
801
|
-
return this.client.get(`/profile/posts/${username}`, { page, limit });
|
|
802
|
-
}
|
|
803
|
-
/**
|
|
804
|
-
* Get user posts by category
|
|
805
|
-
*/
|
|
806
|
-
async getCategoryPosts(username, category, page, limit) {
|
|
807
|
-
return this.client.get(`/profile/posts/${username}/${category}`, { page, limit });
|
|
808
|
-
}
|
|
809
|
-
/**
|
|
810
|
-
* Get user watchlist
|
|
811
|
-
*/
|
|
812
|
-
async getUserWatchlist(username) {
|
|
813
|
-
return this.client.get(`/profile/watchlist/${username}`);
|
|
814
|
-
}
|
|
815
|
-
/**
|
|
816
|
-
* Get user followers
|
|
817
|
-
*/
|
|
818
|
-
async getFollowers(username) {
|
|
819
|
-
return this.client.get(`/profile/follow/${username}`);
|
|
820
|
-
}
|
|
821
|
-
/**
|
|
822
|
-
* Get users being followed
|
|
823
|
-
*/
|
|
824
|
-
async getFollowing(username) {
|
|
825
|
-
return this.client.get(`/profile/following/${username}`);
|
|
826
|
-
}
|
|
827
|
-
/**
|
|
828
|
-
* Get user memberships
|
|
829
|
-
*/
|
|
830
|
-
async getMemberships(username) {
|
|
831
|
-
return this.client.get(`/profile/membership/${username}`);
|
|
305
|
+
class PortfoliosResource {
|
|
306
|
+
transport;
|
|
307
|
+
constructor(transport) {
|
|
308
|
+
this.transport = transport;
|
|
309
|
+
}
|
|
310
|
+
list(options) {
|
|
311
|
+
return this.transport.request({ method: 'GET', route: '/portfolios', cache: 'default' }, options);
|
|
312
|
+
}
|
|
313
|
+
getSummary(options) {
|
|
314
|
+
return this.transport.request({ method: 'GET', route: '/portfolios/summary', cache: 'default' }, options);
|
|
832
315
|
}
|
|
833
316
|
}
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
constructor(
|
|
837
|
-
this.
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
return this.
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
return this.
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
*/
|
|
854
|
-
async getScope() {
|
|
855
|
-
return this.client.get('/membership/scope');
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* Get membership transactions.
|
|
859
|
-
*/
|
|
860
|
-
async getTransactions() {
|
|
861
|
-
return this.client.get('/membership/list');
|
|
862
|
-
}
|
|
863
|
-
/**
|
|
864
|
-
* Update membership.
|
|
865
|
-
*/
|
|
866
|
-
async update(id, dto) {
|
|
867
|
-
return this.client.put(`/membership/${id}`, dto);
|
|
868
|
-
}
|
|
869
|
-
/**
|
|
870
|
-
* Delete membership.
|
|
871
|
-
*/
|
|
872
|
-
async delete(id) {
|
|
873
|
-
return this.client.delete(`/membership/${id}`);
|
|
317
|
+
class AlertsResource {
|
|
318
|
+
transport;
|
|
319
|
+
constructor(transport) {
|
|
320
|
+
this.transport = transport;
|
|
321
|
+
}
|
|
322
|
+
create(body, options) {
|
|
323
|
+
return this.transport.request({ method: 'POST', route: '/alerts', cache: 'none', body }, options);
|
|
324
|
+
}
|
|
325
|
+
list(options) {
|
|
326
|
+
return this.transport.request({ method: 'GET', route: '/alerts', cache: 'default' }, options);
|
|
327
|
+
}
|
|
328
|
+
test(body, options) {
|
|
329
|
+
return this.transport.request({ method: 'POST', route: '/alerts/test', cache: 'none', body }, options);
|
|
330
|
+
}
|
|
331
|
+
update(id, body, options) {
|
|
332
|
+
return this.transport.request({ method: 'PUT', route: '/alerts/{id}', cache: 'none', pathParams: { id }, body }, options);
|
|
333
|
+
}
|
|
334
|
+
delete(id, options) {
|
|
335
|
+
return this.transport.request({ method: 'DELETE', route: '/alerts/{id}', cache: 'none', pathParams: { id } }, options);
|
|
874
336
|
}
|
|
875
337
|
}
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
constructor(
|
|
879
|
-
this.
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
return this.
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
return this.
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
return this.
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
return this.
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
*/
|
|
908
|
-
async getPostById(id) {
|
|
909
|
-
return this.client.get(`/posts/detail/${id}`);
|
|
910
|
-
}
|
|
911
|
-
/**
|
|
912
|
-
* Get post comments
|
|
913
|
-
*/
|
|
914
|
-
async getComments(id) {
|
|
915
|
-
return this.client.get(`/posts/comment/${id}`);
|
|
916
|
-
}
|
|
917
|
-
/**
|
|
918
|
-
* Get liked posts
|
|
919
|
-
*/
|
|
920
|
-
async getLiked() {
|
|
921
|
-
return this.client.get('/posts/like');
|
|
922
|
-
}
|
|
923
|
-
/**
|
|
924
|
-
* Get favorite posts
|
|
925
|
-
*/
|
|
926
|
-
async getFavorites() {
|
|
927
|
-
return this.client.get('/posts/favorite');
|
|
928
|
-
}
|
|
929
|
-
/**
|
|
930
|
-
* Get post voters
|
|
931
|
-
*/
|
|
932
|
-
async getVoters(id) {
|
|
933
|
-
return this.client.get(`/posts/vote/${id}`);
|
|
338
|
+
class PostsResource {
|
|
339
|
+
transport;
|
|
340
|
+
constructor(transport) {
|
|
341
|
+
this.transport = transport;
|
|
342
|
+
}
|
|
343
|
+
list(params, options) {
|
|
344
|
+
return this.transport.request({ method: 'GET', route: '/posts', cache: 'default', query: params }, options);
|
|
345
|
+
}
|
|
346
|
+
listByCategory(category, params, options) {
|
|
347
|
+
return this.transport.request({ method: 'GET', route: '/posts/category/{category}', cache: 'default', pathParams: { category }, query: params }, options);
|
|
348
|
+
}
|
|
349
|
+
listByStock(code, params, options) {
|
|
350
|
+
return this.transport.request({ method: 'GET', route: '/posts/space/{code}', cache: 'default', pathParams: { code }, query: params }, options);
|
|
351
|
+
}
|
|
352
|
+
listByStockCategory(code, category, params, options) {
|
|
353
|
+
return this.transport.request({ method: 'GET', route: '/posts/space/category/{code}/{category}', cache: 'default', pathParams: { code, category }, query: params }, options);
|
|
354
|
+
}
|
|
355
|
+
get(id, options) {
|
|
356
|
+
return this.transport.request({ method: 'GET', route: '/posts/detail/{id}', cache: 'default', pathParams: { id } }, options);
|
|
357
|
+
}
|
|
358
|
+
getComments(id, params, options) {
|
|
359
|
+
return this.transport.request({ method: 'GET', route: '/posts/comment/{id}', cache: 'default', pathParams: { id }, query: params }, options);
|
|
360
|
+
}
|
|
361
|
+
getLikes(params, options) {
|
|
362
|
+
return this.transport.request({ method: 'GET', route: '/posts/like', cache: 'default', query: params }, options);
|
|
363
|
+
}
|
|
364
|
+
getFavorites(params, options) {
|
|
365
|
+
return this.transport.request({ method: 'GET', route: '/posts/favorite', cache: 'default', query: params }, options);
|
|
366
|
+
}
|
|
367
|
+
getVoters(id, options) {
|
|
368
|
+
return this.transport.request({ method: 'GET', route: '/posts/vote/{id}', cache: 'default', pathParams: { id } }, options);
|
|
934
369
|
}
|
|
935
370
|
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
constructor(
|
|
939
|
-
this.
|
|
371
|
+
class TradesResource {
|
|
372
|
+
transport;
|
|
373
|
+
constructor(transport) {
|
|
374
|
+
this.transport = transport;
|
|
375
|
+
}
|
|
376
|
+
list(params, options) {
|
|
377
|
+
return this.transport.request({ method: 'GET', route: '/trades', cache: 'default', query: params }, options);
|
|
378
|
+
}
|
|
379
|
+
delete(body, options) {
|
|
380
|
+
return this.transport.request({ method: 'DELETE', route: '/trades', cache: 'none', body }, options);
|
|
940
381
|
}
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
return this.
|
|
382
|
+
getSummary(params, options) {
|
|
383
|
+
return this.transport.request({ method: 'GET', route: '/trades/summary', cache: 'default', query: params }, options);
|
|
384
|
+
}
|
|
385
|
+
getSummaryChart(params, options) {
|
|
386
|
+
return this.transport.request({ method: 'GET', route: '/trades/summary-chart', cache: 'default', query: params }, options);
|
|
387
|
+
}
|
|
388
|
+
updateNote(id, body, options) {
|
|
389
|
+
return this.transport.request({ method: 'PATCH', route: '/trades/{id}', cache: 'none', pathParams: { id }, body }, options);
|
|
946
390
|
}
|
|
947
391
|
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
* Get trades summary chart
|
|
973
|
-
*/
|
|
974
|
-
async getSummaryChart() {
|
|
975
|
-
return this.client.get('/trades/summary-chart');
|
|
976
|
-
}
|
|
977
|
-
/**
|
|
978
|
-
* Update trade note
|
|
979
|
-
*/
|
|
980
|
-
async updateNote(id, dto) {
|
|
981
|
-
return this.client.patch(`/trades/${id}`, dto);
|
|
392
|
+
class InvezgoResources {
|
|
393
|
+
analysis;
|
|
394
|
+
batch;
|
|
395
|
+
search;
|
|
396
|
+
screener;
|
|
397
|
+
usage;
|
|
398
|
+
watchlists;
|
|
399
|
+
journals;
|
|
400
|
+
portfolios;
|
|
401
|
+
alerts;
|
|
402
|
+
posts;
|
|
403
|
+
trades;
|
|
404
|
+
constructor(transport) {
|
|
405
|
+
this.analysis = new AnalysisResource(transport);
|
|
406
|
+
this.batch = new BatchResource(transport);
|
|
407
|
+
this.search = new SearchResource(transport);
|
|
408
|
+
this.screener = new ScreenerResource(transport);
|
|
409
|
+
this.usage = new UsageResource(transport);
|
|
410
|
+
this.watchlists = new WatchlistsResource(transport);
|
|
411
|
+
this.journals = new JournalsResource(transport);
|
|
412
|
+
this.portfolios = new PortfoliosResource(transport);
|
|
413
|
+
this.alerts = new AlertsResource(transport);
|
|
414
|
+
this.posts = new PostsResource(transport);
|
|
415
|
+
this.trades = new TradesResource(transport);
|
|
982
416
|
}
|
|
983
417
|
}
|
|
984
418
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
419
|
+
const encoder = new TextEncoder();
|
|
420
|
+
class LruCache {
|
|
421
|
+
maxEntries;
|
|
422
|
+
maxBytes;
|
|
423
|
+
now;
|
|
424
|
+
map = new Map();
|
|
425
|
+
totalBytes = 0;
|
|
426
|
+
constructor(maxEntries, maxBytes, now = () => performance.now()) {
|
|
427
|
+
this.maxEntries = maxEntries;
|
|
428
|
+
this.maxBytes = maxBytes;
|
|
429
|
+
this.now = now;
|
|
430
|
+
}
|
|
431
|
+
get size() {
|
|
432
|
+
return this.map.size;
|
|
433
|
+
}
|
|
434
|
+
get bytes() {
|
|
435
|
+
return this.totalBytes;
|
|
436
|
+
}
|
|
437
|
+
get(key) {
|
|
438
|
+
const entry = this.map.get(key);
|
|
439
|
+
if (!entry)
|
|
440
|
+
return undefined;
|
|
441
|
+
this.map.delete(key);
|
|
442
|
+
if (entry.expiresAt <= this.now()) {
|
|
443
|
+
this.totalBytes -= entry.size;
|
|
444
|
+
return undefined;
|
|
445
|
+
}
|
|
446
|
+
this.map.set(key, entry);
|
|
447
|
+
return entry.body;
|
|
448
|
+
}
|
|
449
|
+
set(key, body, ttlMs) {
|
|
450
|
+
const size = encoder.encode(body).length;
|
|
451
|
+
this.delete(key);
|
|
452
|
+
if (ttlMs <= 0 || size > this.maxBytes || this.maxEntries <= 0)
|
|
453
|
+
return;
|
|
454
|
+
this.map.set(key, { body, size, expiresAt: this.now() + ttlMs });
|
|
455
|
+
this.totalBytes += size;
|
|
456
|
+
for (const [oldest, entry] of this.map) {
|
|
457
|
+
if (this.map.size <= this.maxEntries && this.totalBytes <= this.maxBytes)
|
|
458
|
+
break;
|
|
459
|
+
this.map.delete(oldest);
|
|
460
|
+
this.totalBytes -= entry.size;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
delete(key) {
|
|
464
|
+
const entry = this.map.get(key);
|
|
465
|
+
if (entry) {
|
|
466
|
+
this.map.delete(key);
|
|
467
|
+
this.totalBytes -= entry.size;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
deleteWhere(predicate) {
|
|
471
|
+
for (const key of [...this.map.keys()])
|
|
472
|
+
if (predicate(key))
|
|
473
|
+
this.delete(key);
|
|
474
|
+
}
|
|
475
|
+
clear() {
|
|
476
|
+
this.map.clear();
|
|
477
|
+
this.totalBytes = 0;
|
|
1018
478
|
}
|
|
1019
479
|
}
|
|
1020
480
|
|
|
1021
|
-
class
|
|
1022
|
-
|
|
1023
|
-
|
|
481
|
+
class InvezgoError extends Error {
|
|
482
|
+
status;
|
|
483
|
+
error;
|
|
484
|
+
requestId;
|
|
485
|
+
path;
|
|
486
|
+
body;
|
|
487
|
+
constructor(init) {
|
|
488
|
+
super(init.message, init.cause === undefined ? undefined : { cause: init.cause });
|
|
489
|
+
this.name = new.target.name;
|
|
490
|
+
this.status = init.status;
|
|
491
|
+
this.error = init.error;
|
|
492
|
+
this.requestId = init.requestId;
|
|
493
|
+
this.path = init.path;
|
|
494
|
+
this.body = init.body;
|
|
1024
495
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
496
|
+
}
|
|
497
|
+
class ValidationError extends InvezgoError {
|
|
498
|
+
}
|
|
499
|
+
class AuthenticationError extends InvezgoError {
|
|
500
|
+
}
|
|
501
|
+
class PaymentRequiredError extends InvezgoError {
|
|
502
|
+
}
|
|
503
|
+
class NotFoundError extends InvezgoError {
|
|
504
|
+
}
|
|
505
|
+
class ServerError extends InvezgoError {
|
|
506
|
+
}
|
|
507
|
+
class RateLimitError extends InvezgoError {
|
|
508
|
+
retryAfter;
|
|
509
|
+
limit;
|
|
510
|
+
remaining;
|
|
511
|
+
reset;
|
|
512
|
+
quotaExceeded;
|
|
513
|
+
constructor(init) {
|
|
514
|
+
super(init);
|
|
515
|
+
this.retryAfter = init.retryAfter;
|
|
516
|
+
this.limit = init.limit;
|
|
517
|
+
this.remaining = init.remaining;
|
|
518
|
+
this.reset = init.reset;
|
|
519
|
+
this.quotaExceeded = init.quotaExceeded;
|
|
1030
520
|
}
|
|
1031
521
|
}
|
|
522
|
+
class ConnectionError extends InvezgoError {
|
|
523
|
+
}
|
|
524
|
+
class TimeoutError extends ConnectionError {
|
|
525
|
+
}
|
|
526
|
+
function errorClassFor(status) {
|
|
527
|
+
if (status === 400 || status === 422)
|
|
528
|
+
return ValidationError;
|
|
529
|
+
if (status === 401)
|
|
530
|
+
return AuthenticationError;
|
|
531
|
+
if (status === 402)
|
|
532
|
+
return PaymentRequiredError;
|
|
533
|
+
if (status === 404)
|
|
534
|
+
return NotFoundError;
|
|
535
|
+
if (status >= 500)
|
|
536
|
+
return ServerError;
|
|
537
|
+
return InvezgoError;
|
|
538
|
+
}
|
|
1032
539
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
540
|
+
const VERSION = '2.0.0';
|
|
541
|
+
const DEFAULT_BASE_URL = 'https://api.invezgo.com';
|
|
542
|
+
const PERSONAL_SEGMENTS = new Set(['watchlists', 'journals', 'portfolios', 'trades', 'alerts', 'screener']);
|
|
543
|
+
const QUOTA_MESSAGE = /quota|kuota|monthly|bulanan/i;
|
|
544
|
+
class Transport {
|
|
545
|
+
keys;
|
|
546
|
+
baseUrl;
|
|
547
|
+
timeout;
|
|
548
|
+
fetchImpl;
|
|
549
|
+
cache;
|
|
550
|
+
ttlMs = 0;
|
|
551
|
+
realtimeTtlMs = 0;
|
|
552
|
+
blocks = new Map();
|
|
553
|
+
constructor(config) {
|
|
554
|
+
if (!config || typeof config.apiKey !== 'string' || !config.apiKey.trim()) {
|
|
555
|
+
throw new TypeError('Invezgo: `apiKey` is required');
|
|
556
|
+
}
|
|
557
|
+
this.keys = [...new Set([config.apiKey, ...(config.additionalApiKeys ?? [])].filter((k) => !!k && !!k.trim()))];
|
|
558
|
+
this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
|
|
559
|
+
this.timeout = config.timeout ?? 30_000;
|
|
560
|
+
const f = config.fetch ?? globalThis.fetch;
|
|
561
|
+
if (typeof f !== 'function')
|
|
562
|
+
throw new TypeError('Invezgo: global fetch is unavailable; pass `fetch` in the config (Node >= 18)');
|
|
563
|
+
this.fetchImpl = f;
|
|
564
|
+
if (config.cache !== false) {
|
|
565
|
+
const o = config.cache === true || config.cache === undefined ? {} : config.cache;
|
|
566
|
+
this.cache = new LruCache(o.maxEntries ?? 1000, o.maxBytes ?? 32 * 1024 * 1024);
|
|
567
|
+
this.ttlMs = (o.ttl ?? 60) * 1000;
|
|
568
|
+
this.realtimeTtlMs = (o.realtimeTtl ?? 5) * 1000;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
clearCache() {
|
|
572
|
+
this.cache?.clear();
|
|
573
|
+
}
|
|
574
|
+
async request(spec, options) {
|
|
575
|
+
const path = spec.route.replace(/\{(\w+)\}/g, (_, name) => {
|
|
576
|
+
const value = spec.pathParams?.[name];
|
|
577
|
+
if (value === undefined || value === null || value === '')
|
|
578
|
+
throw new TypeError(`Invezgo: path parameter \`${name}\` is required`);
|
|
579
|
+
return encodeURIComponent(String(value));
|
|
580
|
+
});
|
|
581
|
+
const qs = canonicalQuery(spec.query);
|
|
582
|
+
const target = qs ? `${path}?${qs}` : path;
|
|
583
|
+
const ttl = spec.method !== 'GET' ? 0 : spec.cache === 'realtime' ? this.realtimeTtlMs : spec.cache === 'default' ? this.ttlMs : 0;
|
|
584
|
+
if (this.cache && ttl > 0) {
|
|
585
|
+
const hit = this.cache.get(target);
|
|
586
|
+
if (hit !== undefined)
|
|
587
|
+
return parseBody(hit);
|
|
588
|
+
}
|
|
589
|
+
const tried = new Set();
|
|
590
|
+
let last;
|
|
591
|
+
for (;;) {
|
|
592
|
+
const index = this.pickKey(spec.route, tried);
|
|
593
|
+
if (index < 0)
|
|
594
|
+
throw this.allKeysBlocked(spec.route, last);
|
|
595
|
+
tried.add(index);
|
|
596
|
+
const res = await this.send(index, spec, target, options);
|
|
597
|
+
const text = await res.text();
|
|
598
|
+
if (res.status === 429) {
|
|
599
|
+
last = this.rateLimited(index, spec.route, res, text);
|
|
600
|
+
continue;
|
|
601
|
+
}
|
|
602
|
+
if (!res.ok)
|
|
603
|
+
throw buildError(res, text);
|
|
604
|
+
let data;
|
|
605
|
+
try {
|
|
606
|
+
data = parseBody(text);
|
|
607
|
+
}
|
|
608
|
+
catch (cause) {
|
|
609
|
+
throw new InvezgoError({ status: res.status, message: 'Invezgo: response is not valid JSON', body: text, path, cause });
|
|
610
|
+
}
|
|
611
|
+
if (this.cache) {
|
|
612
|
+
if (ttl > 0)
|
|
613
|
+
this.cache.set(target, text, ttl);
|
|
614
|
+
else if (spec.method !== 'GET')
|
|
615
|
+
this.cache.deleteWhere((key) => PERSONAL_SEGMENTS.has(key.split(/[/?]/)[1]));
|
|
616
|
+
}
|
|
617
|
+
return data;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
async send(index, spec, target, options) {
|
|
621
|
+
const headers = {
|
|
622
|
+
Authorization: `Bearer ${this.keys[index]}`,
|
|
623
|
+
Accept: 'application/json',
|
|
624
|
+
'User-Agent': `invezgo-js-sdk/${VERSION}`,
|
|
625
|
+
};
|
|
626
|
+
let body;
|
|
627
|
+
if (spec.body !== undefined) {
|
|
628
|
+
headers['Content-Type'] = 'application/json';
|
|
629
|
+
body = JSON.stringify(spec.body);
|
|
630
|
+
}
|
|
631
|
+
const controller = new AbortController();
|
|
632
|
+
let timedOut = false;
|
|
633
|
+
const timer = setTimeout(() => {
|
|
634
|
+
timedOut = true;
|
|
635
|
+
controller.abort();
|
|
636
|
+
}, this.timeout);
|
|
637
|
+
const signal = options?.signal;
|
|
638
|
+
const onAbort = () => controller.abort(signal?.reason);
|
|
639
|
+
if (signal?.aborted)
|
|
640
|
+
onAbort();
|
|
641
|
+
else
|
|
642
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
643
|
+
try {
|
|
644
|
+
return await this.fetchImpl(this.baseUrl + target, { method: spec.method, headers, body, signal: controller.signal });
|
|
645
|
+
}
|
|
646
|
+
catch (cause) {
|
|
647
|
+
if (signal?.aborted)
|
|
648
|
+
throw cause;
|
|
649
|
+
if (timedOut)
|
|
650
|
+
throw new TimeoutError({ status: 0, message: `Invezgo: request timed out after ${this.timeout} ms`, path: target, cause });
|
|
651
|
+
throw new ConnectionError({ status: 0, message: `Invezgo: network error: ${cause?.message ?? cause}`, path: target, cause });
|
|
652
|
+
}
|
|
653
|
+
finally {
|
|
654
|
+
clearTimeout(timer);
|
|
655
|
+
signal?.removeEventListener('abort', onAbort);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
blockedFor(index, route, now) {
|
|
659
|
+
let ms = 0;
|
|
660
|
+
let quota = false;
|
|
661
|
+
for (const [id, isQuota] of [[`${index}`, true], [`${index} ${route}`, false]]) {
|
|
662
|
+
const b = this.blocks.get(id);
|
|
663
|
+
if (!b)
|
|
664
|
+
continue;
|
|
665
|
+
if (b.until <= now)
|
|
666
|
+
this.blocks.delete(id);
|
|
667
|
+
else if (b.until - now > ms) {
|
|
668
|
+
ms = b.until - now;
|
|
669
|
+
quota = isQuota;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
return { ms, quota };
|
|
673
|
+
}
|
|
674
|
+
pickKey(route, tried) {
|
|
675
|
+
const now = performance.now();
|
|
676
|
+
for (let i = 0; i < this.keys.length; i++) {
|
|
677
|
+
if (!tried.has(i) && this.blockedFor(i, route, now).ms === 0)
|
|
678
|
+
return i;
|
|
679
|
+
}
|
|
680
|
+
return -1;
|
|
681
|
+
}
|
|
682
|
+
rateLimited(index, route, res, text) {
|
|
683
|
+
const err = buildError(res, text);
|
|
684
|
+
const retryAfter = num(res.headers.get('retry-after'));
|
|
685
|
+
const reset = num(res.headers.get('x-ratelimit-reset'));
|
|
686
|
+
let wait = 60;
|
|
687
|
+
if (retryAfter !== undefined && retryAfter > 0)
|
|
688
|
+
wait = retryAfter;
|
|
689
|
+
else if (reset !== undefined && reset - Date.now() / 1000 > 0)
|
|
690
|
+
wait = reset - Date.now() / 1000;
|
|
691
|
+
const quota = QUOTA_MESSAGE.test(err.message);
|
|
692
|
+
this.blocks.set(quota ? `${index}` : `${index} ${route}`, { until: performance.now() + wait * 1000, quota });
|
|
693
|
+
return new RateLimitError({
|
|
694
|
+
status: 429,
|
|
695
|
+
message: err.message,
|
|
696
|
+
error: err.error,
|
|
697
|
+
requestId: err.requestId,
|
|
698
|
+
path: err.path,
|
|
699
|
+
body: err.body,
|
|
700
|
+
retryAfter: Math.ceil(wait),
|
|
701
|
+
limit: num(res.headers.get('x-ratelimit-limit')),
|
|
702
|
+
remaining: num(res.headers.get('x-ratelimit-remaining')),
|
|
703
|
+
reset,
|
|
704
|
+
quotaExceeded: quota,
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
allKeysBlocked(route, last) {
|
|
708
|
+
const now = performance.now();
|
|
709
|
+
let min = Infinity;
|
|
710
|
+
let allQuota = true;
|
|
711
|
+
for (let i = 0; i < this.keys.length; i++) {
|
|
712
|
+
const b = this.blockedFor(i, route, now);
|
|
713
|
+
min = Math.min(min, b.ms);
|
|
714
|
+
allQuota &&= b.quota;
|
|
715
|
+
}
|
|
716
|
+
const retryAfter = Math.max(0, Math.ceil((Number.isFinite(min) ? min : 0) / 1000));
|
|
717
|
+
if (last) {
|
|
718
|
+
return new RateLimitError({ ...last, message: last.message, retryAfter, quotaExceeded: last.quotaExceeded });
|
|
719
|
+
}
|
|
720
|
+
return new RateLimitError({
|
|
721
|
+
status: 429,
|
|
722
|
+
message: `Invezgo: all API keys are rate limited; retry in ${retryAfter}s`,
|
|
723
|
+
retryAfter,
|
|
724
|
+
quotaExceeded: allQuota,
|
|
725
|
+
});
|
|
1086
726
|
}
|
|
1087
727
|
}
|
|
728
|
+
function canonicalQuery(query) {
|
|
729
|
+
if (!query)
|
|
730
|
+
return '';
|
|
731
|
+
const entries = Object.entries(query)
|
|
732
|
+
.filter(([, v]) => v !== undefined && v !== null)
|
|
733
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
734
|
+
.map(([k, v]) => [k, String(v)]);
|
|
735
|
+
return new URLSearchParams(entries).toString();
|
|
736
|
+
}
|
|
737
|
+
function parseBody(text) {
|
|
738
|
+
return text.trim() === '' ? null : JSON.parse(text);
|
|
739
|
+
}
|
|
740
|
+
function num(value) {
|
|
741
|
+
if (value === null || value.trim() === '')
|
|
742
|
+
return undefined;
|
|
743
|
+
const n = Number(value);
|
|
744
|
+
return Number.isFinite(n) ? n : undefined;
|
|
745
|
+
}
|
|
746
|
+
function buildError(res, text) {
|
|
747
|
+
let body = text;
|
|
748
|
+
try {
|
|
749
|
+
body = text ? JSON.parse(text) : undefined;
|
|
750
|
+
}
|
|
751
|
+
catch {
|
|
752
|
+
}
|
|
753
|
+
const b = (typeof body === 'object' && body !== null ? body : {});
|
|
754
|
+
const msg = Array.isArray(b.message) ? b.message.join('; ') : typeof b.message === 'string' ? b.message : '';
|
|
755
|
+
const Cls = errorClassFor(res.status);
|
|
756
|
+
return new Cls({
|
|
757
|
+
status: res.status,
|
|
758
|
+
message: msg || res.statusText || `HTTP ${res.status}`,
|
|
759
|
+
error: typeof b.error === 'string' ? b.error : undefined,
|
|
760
|
+
requestId: typeof b.requestId === 'string' ? b.requestId : (res.headers.get('request-id') ?? undefined),
|
|
761
|
+
path: typeof b.path === 'string' ? b.path : undefined,
|
|
762
|
+
body,
|
|
763
|
+
});
|
|
764
|
+
}
|
|
1088
765
|
|
|
1089
|
-
class Invezgo {
|
|
766
|
+
class Invezgo extends InvezgoResources {
|
|
767
|
+
#transport;
|
|
1090
768
|
constructor(config) {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
this
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
this.
|
|
1097
|
-
this.search = new SearchEndpoints(this.client);
|
|
1098
|
-
this.profile = new ProfileEndpoints(this.client);
|
|
1099
|
-
this.membership = new MembershipEndpoints(this.client);
|
|
1100
|
-
this.posts = new PostsEndpoints(this.client);
|
|
1101
|
-
this.recommendation = new RecommendationEndpoints(this.client);
|
|
1102
|
-
this.trades = new TradesEndpoints(this.client);
|
|
1103
|
-
this.screener = new ScreenerEndpoints(this.client);
|
|
1104
|
-
this.usage = new UsageEndpoints(this.client);
|
|
1105
|
-
this.batch = new BatchEndpoints(this.client);
|
|
1106
|
-
}
|
|
1107
|
-
/**
|
|
1108
|
-
* Update API key.
|
|
1109
|
-
*/
|
|
1110
|
-
setApiKey(apiKey) {
|
|
1111
|
-
this.client.apiKey = apiKey;
|
|
1112
|
-
}
|
|
1113
|
-
/**
|
|
1114
|
-
* Check whether an API key is currently configured.
|
|
1115
|
-
*/
|
|
1116
|
-
hasApiKey() {
|
|
1117
|
-
return !!this.client.apiKey;
|
|
769
|
+
const transport = new Transport(config);
|
|
770
|
+
super(transport);
|
|
771
|
+
this.#transport = transport;
|
|
772
|
+
}
|
|
773
|
+
clearCache() {
|
|
774
|
+
this.#transport.clearCache();
|
|
1118
775
|
}
|
|
1119
776
|
}
|
|
1120
777
|
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
778
|
+
exports.AlertsResource = AlertsResource;
|
|
779
|
+
exports.AnalysisResource = AnalysisResource;
|
|
780
|
+
exports.AuthenticationError = AuthenticationError;
|
|
781
|
+
exports.BatchResource = BatchResource;
|
|
782
|
+
exports.ConnectionError = ConnectionError;
|
|
783
|
+
exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL;
|
|
784
|
+
exports.Invezgo = Invezgo;
|
|
785
|
+
exports.InvezgoClient = Invezgo;
|
|
786
|
+
exports.InvezgoError = InvezgoError;
|
|
787
|
+
exports.InvezgoResources = InvezgoResources;
|
|
788
|
+
exports.JournalsResource = JournalsResource;
|
|
789
|
+
exports.NotFoundError = NotFoundError;
|
|
790
|
+
exports.PaymentRequiredError = PaymentRequiredError;
|
|
791
|
+
exports.PortfoliosResource = PortfoliosResource;
|
|
792
|
+
exports.PostsResource = PostsResource;
|
|
793
|
+
exports.RateLimitError = RateLimitError;
|
|
794
|
+
exports.ScreenerResource = ScreenerResource;
|
|
795
|
+
exports.SearchResource = SearchResource;
|
|
796
|
+
exports.ServerError = ServerError;
|
|
797
|
+
exports.TimeoutError = TimeoutError;
|
|
798
|
+
exports.TradesResource = TradesResource;
|
|
799
|
+
exports.UsageResource = UsageResource;
|
|
800
|
+
exports.VERSION = VERSION;
|
|
801
|
+
exports.ValidationError = ValidationError;
|
|
802
|
+
exports.WatchlistsResource = WatchlistsResource;
|
|
803
|
+
exports.default = Invezgo;
|
|
1130
804
|
//# sourceMappingURL=index.js.map
|