laplace-api 3.0.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client/broker.ts +175 -0
- package/src/client/capital_increase.ts +11 -11
- package/src/client/collections.ts +5 -13
- package/src/client/financial_fundamentals.ts +41 -33
- package/src/client/financial_ratios.ts +56 -35
- package/src/client/funds.ts +139 -0
- package/src/client/key-insights.ts +17 -0
- package/src/client/live-price.ts +25 -0
- package/src/client/stocks.ts +12 -2
- package/src/test/broker.test.ts +238 -0
- package/src/test/capital_increase.test.ts +119 -15
- package/src/test/collections.test.ts +69 -11
- package/src/test/custom_theme.test.ts +18 -9
- package/src/test/financial_fundamentals.test.ts +23 -8
- package/src/test/financial_ratios.test.ts +67 -37
- package/src/test/funds.test.ts +110 -0
- package/src/test/helpers.ts +58 -0
- package/src/test/key-insight.test.ts +48 -0
- package/src/test/live-price.test.ts +4 -5
- package/src/test/search.test.ts +71 -22
- package/src/test/stocks.test.ts +185 -67
package/src/client/live-price.ts
CHANGED
|
@@ -24,6 +24,21 @@ export interface USStockLiveData {
|
|
|
24
24
|
ap: number; // AskPrice
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
export enum AccessorType {
|
|
28
|
+
User = "user"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface UpdateUserDetailsParams {
|
|
32
|
+
externalUserID: string;
|
|
33
|
+
firstName?: string;
|
|
34
|
+
lastName?: string;
|
|
35
|
+
address?: string;
|
|
36
|
+
city?: string;
|
|
37
|
+
countryCode?: string;
|
|
38
|
+
accessorType?: AccessorType;
|
|
39
|
+
active: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
27
42
|
function getSSELivePrice<T>(
|
|
28
43
|
client: Client,
|
|
29
44
|
symbols: string[],
|
|
@@ -59,6 +74,16 @@ export class LivePriceClient extends Client {
|
|
|
59
74
|
return response.url;
|
|
60
75
|
}
|
|
61
76
|
|
|
77
|
+
async updateUserDetails(params: UpdateUserDetailsParams): Promise<void> {
|
|
78
|
+
const url = new URL(`${this["baseUrl"]}/api/v1/ws/user`);
|
|
79
|
+
|
|
80
|
+
await this.sendRequest<void>({
|
|
81
|
+
method: "PUT",
|
|
82
|
+
url: url.toString(),
|
|
83
|
+
data: params,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
|
|
62
87
|
getLivePriceForBIST(
|
|
63
88
|
symbols: string[],
|
|
64
89
|
region: Region,
|
package/src/client/stocks.ts
CHANGED
|
@@ -64,7 +64,7 @@ export interface StockDetail extends Stock {
|
|
|
64
64
|
shortDescription: string;
|
|
65
65
|
localizedShortDescription: LocaleString;
|
|
66
66
|
region: string;
|
|
67
|
-
markets
|
|
67
|
+
markets?: Market[];
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
export enum Market {
|
|
@@ -102,8 +102,10 @@ export interface StockRestriction {
|
|
|
102
102
|
id: number;
|
|
103
103
|
title: string;
|
|
104
104
|
description: string;
|
|
105
|
+
symbol?: string;
|
|
105
106
|
startDate: string;
|
|
106
107
|
endDate: string;
|
|
108
|
+
market?: string;
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
export interface TickRule {
|
|
@@ -111,7 +113,7 @@ export interface TickRule {
|
|
|
111
113
|
additionalPrice: number;
|
|
112
114
|
lowerPriceLimit: number;
|
|
113
115
|
upperPriceLimit: number;
|
|
114
|
-
rules: TickSizeRule[];
|
|
116
|
+
rules: TickSizeRule[] | null;
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
export interface TickSizeRule {
|
|
@@ -188,6 +190,14 @@ export class StockClient extends Client {
|
|
|
188
190
|
});
|
|
189
191
|
}
|
|
190
192
|
|
|
193
|
+
async getAllStockRestrictions(region: Region): Promise<StockRestriction[]> {
|
|
194
|
+
return this.sendRequest<StockRestriction[]>({
|
|
195
|
+
method: 'GET',
|
|
196
|
+
url: '/api/v1/stock/restrictions/all',
|
|
197
|
+
params: { region },
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
191
201
|
async getTickRules(symbol: string, region: Region): Promise<TickRule> {
|
|
192
202
|
return this.sendRequest<TickRule>({
|
|
193
203
|
method: 'GET',
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { Logger } from "winston";
|
|
2
|
+
import { Region } from "../client/collections";
|
|
3
|
+
import { LaplaceConfiguration } from "../utilities/configuration";
|
|
4
|
+
import "./client_test_suite";
|
|
5
|
+
import {
|
|
6
|
+
BrokerClient,
|
|
7
|
+
BrokerSort,
|
|
8
|
+
SortDirection,
|
|
9
|
+
BrokerStats,
|
|
10
|
+
} from "../client/broker";
|
|
11
|
+
|
|
12
|
+
describe("BrokerClient", () => {
|
|
13
|
+
let brokerClient: BrokerClient;
|
|
14
|
+
|
|
15
|
+
beforeAll(() => {
|
|
16
|
+
const config = (global as any).testSuite.config as LaplaceConfiguration;
|
|
17
|
+
|
|
18
|
+
const logger: Logger = {
|
|
19
|
+
info: jest.fn(),
|
|
20
|
+
error: jest.fn(),
|
|
21
|
+
warn: jest.fn(),
|
|
22
|
+
debug: jest.fn(),
|
|
23
|
+
} as unknown as Logger;
|
|
24
|
+
|
|
25
|
+
brokerClient = new BrokerClient(config, logger);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const region = Region.Tr;
|
|
29
|
+
const fromDate = "2025-05-20";
|
|
30
|
+
const toDate = "2025-05-28";
|
|
31
|
+
|
|
32
|
+
test("getMarketBrokers returns valid and fully typed data", async () => {
|
|
33
|
+
const response = await brokerClient.getMarketBrokers(
|
|
34
|
+
Region.Tr,
|
|
35
|
+
BrokerSort.TotalVolume,
|
|
36
|
+
SortDirection.Desc,
|
|
37
|
+
"2025-05-27",
|
|
38
|
+
"2025-05-28",
|
|
39
|
+
0,
|
|
40
|
+
5
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
expect(response).toBeDefined();
|
|
44
|
+
expect(typeof response.recordCount).toBe("number");
|
|
45
|
+
|
|
46
|
+
const stats = response.totalStats;
|
|
47
|
+
expect(stats).toMatchObject<BrokerStats>({
|
|
48
|
+
totalBuyAmount: expect.any(Number),
|
|
49
|
+
totalSellAmount: expect.any(Number),
|
|
50
|
+
netAmount: expect.any(Number),
|
|
51
|
+
totalBuyVolume: expect.any(Number),
|
|
52
|
+
totalSellVolume: expect.any(Number),
|
|
53
|
+
totalVolume: expect.any(Number),
|
|
54
|
+
totalAmount: expect.any(Number),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(Array.isArray(response.items)).toBe(true);
|
|
58
|
+
expect(response.items.length).toBeGreaterThan(0);
|
|
59
|
+
|
|
60
|
+
for (const item of response.items) {
|
|
61
|
+
expect(item).toMatchObject<BrokerStats>({
|
|
62
|
+
totalBuyAmount: expect.any(Number),
|
|
63
|
+
totalSellAmount: expect.any(Number),
|
|
64
|
+
netAmount: expect.any(Number),
|
|
65
|
+
totalBuyVolume: expect.any(Number),
|
|
66
|
+
totalSellVolume: expect.any(Number),
|
|
67
|
+
totalVolume: expect.any(Number),
|
|
68
|
+
totalAmount: expect.any(Number),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (item.broker) {
|
|
72
|
+
expect(item.broker).toMatchObject({
|
|
73
|
+
id: expect.any(Number),
|
|
74
|
+
symbol: expect.any(String),
|
|
75
|
+
name: expect.any(String),
|
|
76
|
+
longName: expect.any(String),
|
|
77
|
+
logo: expect.any(String),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("getMarketStocks returns valid stock data", async () => {
|
|
84
|
+
const response = await brokerClient.getMarketStocks(
|
|
85
|
+
region,
|
|
86
|
+
BrokerSort.TotalVolume,
|
|
87
|
+
SortDirection.Desc,
|
|
88
|
+
fromDate,
|
|
89
|
+
toDate,
|
|
90
|
+
0,
|
|
91
|
+
5
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
expect(response).toBeDefined();
|
|
95
|
+
expect(typeof response.recordCount).toBe("number");
|
|
96
|
+
|
|
97
|
+
const stats = response.totalStats;
|
|
98
|
+
expect(stats).toMatchObject<BrokerStats>({
|
|
99
|
+
totalBuyAmount: expect.any(Number),
|
|
100
|
+
totalSellAmount: expect.any(Number),
|
|
101
|
+
netAmount: expect.any(Number),
|
|
102
|
+
totalBuyVolume: expect.any(Number),
|
|
103
|
+
totalSellVolume: expect.any(Number),
|
|
104
|
+
totalVolume: expect.any(Number),
|
|
105
|
+
totalAmount: expect.any(Number),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(Array.isArray(response.items)).toBe(true);
|
|
109
|
+
|
|
110
|
+
for (const item of response.items) {
|
|
111
|
+
expect(item).toMatchObject<BrokerStats>({
|
|
112
|
+
totalBuyAmount: expect.any(Number),
|
|
113
|
+
totalSellAmount: expect.any(Number),
|
|
114
|
+
netAmount: expect.any(Number),
|
|
115
|
+
totalBuyVolume: expect.any(Number),
|
|
116
|
+
totalSellVolume: expect.any(Number),
|
|
117
|
+
totalVolume: expect.any(Number),
|
|
118
|
+
totalAmount: expect.any(Number),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (item.stock) {
|
|
122
|
+
expect(item.stock).toMatchObject({
|
|
123
|
+
id: expect.any(String),
|
|
124
|
+
symbol: expect.any(String),
|
|
125
|
+
name: expect.any(String),
|
|
126
|
+
assetType: expect.any(String),
|
|
127
|
+
assetClass: expect.any(String),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("getBrokersByStock returns brokers for specific stock", async () => {
|
|
134
|
+
const response = await brokerClient.getBrokersByStock(
|
|
135
|
+
"TUPRS",
|
|
136
|
+
region,
|
|
137
|
+
BrokerSort.TotalVolume,
|
|
138
|
+
SortDirection.Desc,
|
|
139
|
+
fromDate,
|
|
140
|
+
toDate,
|
|
141
|
+
0,
|
|
142
|
+
5
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
expect(response).toBeDefined();
|
|
146
|
+
expect(typeof response.recordCount).toBe("number");
|
|
147
|
+
|
|
148
|
+
const stats = response.totalStats;
|
|
149
|
+
expect(stats).toMatchObject<BrokerStats>({
|
|
150
|
+
totalBuyAmount: expect.any(Number),
|
|
151
|
+
totalSellAmount: expect.any(Number),
|
|
152
|
+
netAmount: expect.any(Number),
|
|
153
|
+
totalBuyVolume: expect.any(Number),
|
|
154
|
+
totalSellVolume: expect.any(Number),
|
|
155
|
+
totalVolume: expect.any(Number),
|
|
156
|
+
totalAmount: expect.any(Number),
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
expect(Array.isArray(response.items)).toBe(true);
|
|
160
|
+
|
|
161
|
+
for (const item of response.items) {
|
|
162
|
+
expect(item).toMatchObject<BrokerStats>({
|
|
163
|
+
totalBuyAmount: expect.any(Number),
|
|
164
|
+
totalSellAmount: expect.any(Number),
|
|
165
|
+
netAmount: expect.any(Number),
|
|
166
|
+
totalBuyVolume: expect.any(Number),
|
|
167
|
+
totalSellVolume: expect.any(Number),
|
|
168
|
+
totalVolume: expect.any(Number),
|
|
169
|
+
totalAmount: expect.any(Number),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
if (item.broker) {
|
|
173
|
+
expect(item.broker).toMatchObject({
|
|
174
|
+
id: expect.any(Number),
|
|
175
|
+
symbol: expect.any(String),
|
|
176
|
+
name: expect.any(String),
|
|
177
|
+
longName: expect.any(String),
|
|
178
|
+
logo: expect.any(String),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if ("averageCost" in item) {
|
|
183
|
+
expect(item.averageCost).toEqual(expect.any(Number));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test("getStocksByBroker returns stocks for specific broker", async () => {
|
|
189
|
+
const response = await brokerClient.getStocksByBroker(
|
|
190
|
+
"BIYKR",
|
|
191
|
+
region,
|
|
192
|
+
BrokerSort.TotalVolume,
|
|
193
|
+
SortDirection.Desc,
|
|
194
|
+
fromDate,
|
|
195
|
+
toDate,
|
|
196
|
+
0,
|
|
197
|
+
5
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
expect(response).toBeDefined();
|
|
201
|
+
expect(typeof response.recordCount).toBe("number");
|
|
202
|
+
|
|
203
|
+
const stats = response.totalStats;
|
|
204
|
+
expect(stats).toMatchObject<BrokerStats>({
|
|
205
|
+
totalBuyAmount: expect.any(Number),
|
|
206
|
+
totalSellAmount: expect.any(Number),
|
|
207
|
+
netAmount: expect.any(Number),
|
|
208
|
+
totalBuyVolume: expect.any(Number),
|
|
209
|
+
totalSellVolume: expect.any(Number),
|
|
210
|
+
totalVolume: expect.any(Number),
|
|
211
|
+
totalAmount: expect.any(Number),
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
expect(Array.isArray(response.items)).toBe(true);
|
|
215
|
+
|
|
216
|
+
for (const item of response.items) {
|
|
217
|
+
expect(item).toMatchObject<BrokerStats>({
|
|
218
|
+
totalBuyAmount: expect.any(Number),
|
|
219
|
+
totalSellAmount: expect.any(Number),
|
|
220
|
+
netAmount: expect.any(Number),
|
|
221
|
+
totalBuyVolume: expect.any(Number),
|
|
222
|
+
totalSellVolume: expect.any(Number),
|
|
223
|
+
totalVolume: expect.any(Number),
|
|
224
|
+
totalAmount: expect.any(Number),
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
if (item.stock) {
|
|
228
|
+
expect(item.stock).toMatchObject({
|
|
229
|
+
id: expect.any(String),
|
|
230
|
+
symbol: expect.any(String),
|
|
231
|
+
name: expect.any(String),
|
|
232
|
+
assetType: expect.any(String),
|
|
233
|
+
assetClass: expect.any(String),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
});
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { Logger } from
|
|
2
|
-
import { LaplaceConfiguration } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Logger } from "winston";
|
|
2
|
+
import { LaplaceConfiguration } from "../utilities/configuration";
|
|
3
|
+
import {
|
|
4
|
+
CapitalIncrease,
|
|
5
|
+
CapitalIncreaseClient,
|
|
6
|
+
} from "../client/capital_increase";
|
|
7
|
+
import "./client_test_suite";
|
|
8
|
+
import { Region } from "../client/collections";
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
describe('Capital Increase', () => {
|
|
10
|
+
describe("Capital Increase", () => {
|
|
9
11
|
let client: CapitalIncreaseClient;
|
|
10
12
|
|
|
11
13
|
beforeAll(() => {
|
|
12
|
-
// Assuming global.testSuite is set up as in the previous example
|
|
13
14
|
const config = (global as any).testSuite.config as LaplaceConfiguration;
|
|
14
15
|
const logger: Logger = {
|
|
15
16
|
info: jest.fn(),
|
|
@@ -21,16 +22,119 @@ describe('Capital Increase', () => {
|
|
|
21
22
|
client = new CapitalIncreaseClient(config, logger);
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
test(
|
|
25
|
-
await client.getAllCapitalIncreases(1, 10, Region.Tr
|
|
26
|
-
|
|
25
|
+
test("GetAllCapitalIncreases", async () => {
|
|
26
|
+
const resp = await client.getAllCapitalIncreases(1, 10, Region.Tr);
|
|
27
|
+
|
|
28
|
+
expect(resp).toBeDefined();
|
|
29
|
+
expect(typeof resp.recordCount).toBe("number");
|
|
30
|
+
expect(Array.isArray(resp.items)).toBe(true);
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
if (resp.items.length > 0) {
|
|
33
|
+
const firstItem = resp.items[0];
|
|
34
|
+
validateCapitalIncrease(firstItem);
|
|
35
|
+
}
|
|
30
36
|
});
|
|
31
37
|
|
|
32
|
-
test(
|
|
33
|
-
|
|
38
|
+
test("GetCapitalIncreasesForInstrument", async () => {
|
|
39
|
+
const resp = await client.getCapitalIncreasesForInstrument(
|
|
40
|
+
"TUPRS",
|
|
41
|
+
1,
|
|
42
|
+
10,
|
|
43
|
+
Region.Tr
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
expect(resp).toBeDefined();
|
|
47
|
+
expect(typeof resp.recordCount).toBe("number");
|
|
48
|
+
expect(Array.isArray(resp.items)).toBe(true);
|
|
49
|
+
|
|
50
|
+
if (resp.items.length > 0) {
|
|
51
|
+
const firstItem = resp.items[0];
|
|
52
|
+
validateCapitalIncrease(firstItem);
|
|
53
|
+
expect(firstItem.symbol).toBe("TUPRS");
|
|
54
|
+
}
|
|
34
55
|
});
|
|
35
56
|
|
|
57
|
+
test("GetActiveRightsForInstrument", async () => {
|
|
58
|
+
const resp = await client.getActiveRightsForInstrument(
|
|
59
|
+
"TUPRS",
|
|
60
|
+
"2024-01-01",
|
|
61
|
+
Region.Tr
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
expect(Array.isArray(resp)).toBe(true);
|
|
65
|
+
|
|
66
|
+
if (resp.length > 0) {
|
|
67
|
+
const firstItem = resp[0];
|
|
68
|
+
validateCapitalIncrease(firstItem);
|
|
69
|
+
expect(firstItem.symbol).toBe("TUPRS");
|
|
70
|
+
}
|
|
71
|
+
});
|
|
36
72
|
});
|
|
73
|
+
|
|
74
|
+
function validateCapitalIncrease(item: CapitalIncrease) {
|
|
75
|
+
expect(typeof item.id).toBe("number");
|
|
76
|
+
expect(typeof item.boardDecisionDate).toBe("string");
|
|
77
|
+
expect(typeof item.registeredCapitalCeiling).toBe("string");
|
|
78
|
+
expect(typeof item.currentCapital).toBe("string");
|
|
79
|
+
expect(typeof item.targetCapital).toBe("string");
|
|
80
|
+
expect(Array.isArray(item.types)).toBe(true);
|
|
81
|
+
|
|
82
|
+
if (item.spkApplicationResult !== null) {
|
|
83
|
+
expect(typeof item.spkApplicationResult).toBe("string");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (item.spkApplicationDate !== null) {
|
|
87
|
+
expect(typeof item.spkApplicationDate).toBe("string");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (item.spkApprovalDate !== null) {
|
|
91
|
+
expect(typeof item.spkApprovalDate).toBe("string");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (item.paymentDate !== null) {
|
|
95
|
+
expect(typeof item.paymentDate).toBe("string");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (item.registrationDate !== null) {
|
|
99
|
+
expect(typeof item.registrationDate).toBe("string");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
expect(typeof item.specifiedCurrency).toBe("string");
|
|
103
|
+
expect(typeof item.symbol).toBe("string");
|
|
104
|
+
expect(Array.isArray(item.relatedDisclosureIds)).toBe(true);
|
|
105
|
+
expect(typeof item.rightsRate).toBe("string");
|
|
106
|
+
expect(typeof item.rightsPrice).toBe("string");
|
|
107
|
+
expect(typeof item.rightsTotalAmount).toBe("string");
|
|
108
|
+
|
|
109
|
+
if (item.rightsStartDate !== null) {
|
|
110
|
+
expect(typeof item.rightsStartDate).toBe("string");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (item.rightsEndDate !== null) {
|
|
114
|
+
expect(typeof item.rightsEndDate).toBe("string");
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (item.rightsLastSellDate !== null) {
|
|
118
|
+
expect(typeof item.rightsLastSellDate).toBe("string");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
expect(typeof item.bonusRate).toBe("string");
|
|
122
|
+
expect(typeof item.bonusTotalAmount).toBe("string");
|
|
123
|
+
|
|
124
|
+
if (item.bonusStartDate !== null) {
|
|
125
|
+
expect(typeof item.bonusStartDate).toBe("string");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
expect(typeof item.bonusDividendRate).toBe("string");
|
|
129
|
+
expect(typeof item.bonusDividendTotalAmount).toBe("string");
|
|
130
|
+
expect(typeof item.externalCapitalIncreaseAmount).toBe("string");
|
|
131
|
+
expect(typeof item.externalCapitalIncreaseRate).toBe("string");
|
|
132
|
+
|
|
133
|
+
item.types.forEach(type => {
|
|
134
|
+
expect(typeof type).toBe("string");
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
item.relatedDisclosureIds.forEach(id => {
|
|
138
|
+
expect(typeof id).toBe("number");
|
|
139
|
+
});
|
|
140
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { Logger } from
|
|
2
|
-
import { LaplaceConfiguration } from
|
|
3
|
-
import { CollectionClient,
|
|
4
|
-
import
|
|
1
|
+
import { Logger } from "winston";
|
|
2
|
+
import { LaplaceConfiguration } from "../utilities/configuration";
|
|
3
|
+
import { CollectionClient, Locale, Region } from "../client/collections";
|
|
4
|
+
import "./client_test_suite";
|
|
5
|
+
import { validateCollection, validateCollectionDetail } from "./helpers";
|
|
5
6
|
|
|
6
|
-
describe(
|
|
7
|
+
describe("Collections", () => {
|
|
7
8
|
let client: CollectionClient;
|
|
8
9
|
|
|
9
10
|
beforeAll(() => {
|
|
@@ -19,18 +20,75 @@ describe('Collections', () => {
|
|
|
19
20
|
client = new CollectionClient(config, logger);
|
|
20
21
|
});
|
|
21
22
|
|
|
22
|
-
test(
|
|
23
|
+
test("GetAllIndustries", async () => {
|
|
23
24
|
const resp = await client.getAllIndustries(Region.Tr, Locale.Tr);
|
|
24
25
|
expect(resp).not.toBeEmpty();
|
|
26
|
+
|
|
27
|
+
const firstIndustry = resp[0];
|
|
28
|
+
validateCollection(firstIndustry);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("GetAllSectors", async () => {
|
|
32
|
+
const resp = await client.getAllSectors(Region.Tr, Locale.Tr);
|
|
33
|
+
expect(resp).not.toBeEmpty();
|
|
34
|
+
|
|
35
|
+
const firstSector = resp[0];
|
|
36
|
+
validateCollection(firstSector);
|
|
25
37
|
});
|
|
26
38
|
|
|
27
|
-
test(
|
|
28
|
-
const resp = await client.getIndustryDetail(
|
|
39
|
+
test("GetIndustryDetails", async () => {
|
|
40
|
+
const resp = await client.getIndustryDetail(
|
|
41
|
+
"65533e441fa5c7b58afa0944",
|
|
42
|
+
Region.Tr,
|
|
43
|
+
Locale.Tr
|
|
44
|
+
);
|
|
29
45
|
expect(resp).not.toBeEmpty();
|
|
46
|
+
validateCollectionDetail(resp);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("GetSectorDetails", async () => {
|
|
50
|
+
const resp = await client.getSectorDetail(
|
|
51
|
+
"65533e047844ee7afe9941b9",
|
|
52
|
+
Region.Tr,
|
|
53
|
+
Locale.Tr
|
|
54
|
+
);
|
|
55
|
+
expect(resp).not.toBeEmpty();
|
|
56
|
+
validateCollectionDetail(resp);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("GetAllThemes", async () => {
|
|
60
|
+
const resp = await client.getAllThemes(Region.Tr, Locale.Tr);
|
|
61
|
+
expect(resp).not.toBeEmpty();
|
|
62
|
+
|
|
63
|
+
const firstTheme = resp[0];
|
|
64
|
+
validateCollection(firstTheme);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test("GetThemeDetails", async () => {
|
|
68
|
+
const resp = await client.getThemeDetail(
|
|
69
|
+
"6256b0647d0bb100123effa7",
|
|
70
|
+
Region.Tr,
|
|
71
|
+
Locale.Tr
|
|
72
|
+
);
|
|
73
|
+
expect(resp).not.toBeEmpty();
|
|
74
|
+
validateCollectionDetail(resp);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("GetAllCollections", async () => {
|
|
78
|
+
const resp = await client.getAllCollections(Region.Tr, Locale.Tr);
|
|
79
|
+
expect(resp).not.toBeEmpty();
|
|
80
|
+
|
|
81
|
+
const firstCollection = resp[0];
|
|
82
|
+
validateCollection(firstCollection);
|
|
30
83
|
});
|
|
31
84
|
|
|
32
|
-
test(
|
|
33
|
-
const resp = await client.
|
|
85
|
+
test("GetCollectionDetails", async () => {
|
|
86
|
+
const resp = await client.getThemeDetail(
|
|
87
|
+
"620f455a0187ade00bb0d55f",
|
|
88
|
+
Region.Tr,
|
|
89
|
+
Locale.Tr
|
|
90
|
+
);
|
|
34
91
|
expect(resp).not.toBeEmpty();
|
|
92
|
+
validateCollectionDetail(resp);
|
|
35
93
|
});
|
|
36
|
-
});
|
|
94
|
+
});
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import { Logger } from
|
|
2
|
-
import { LaplaceConfiguration } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { Logger } from "winston";
|
|
2
|
+
import { LaplaceConfiguration } from "../utilities/configuration";
|
|
3
|
+
import {
|
|
4
|
+
CustomThemeClient,
|
|
5
|
+
CollectionStatus,
|
|
6
|
+
CreateCustomThemeParams,
|
|
7
|
+
UpdateCustomThemeParams,
|
|
8
|
+
} from "../client/custom_theme";
|
|
9
|
+
import { Stock, StockClient } from "../client/stocks";
|
|
10
|
+
import "./client_test_suite";
|
|
11
|
+
import { validateCollection } from "./helpers";
|
|
12
|
+
import { Locale, Region, SortBy } from "../client/collections";
|
|
13
|
+
|
|
14
|
+
describe("CustomTheme", () => {
|
|
9
15
|
let client: CustomThemeClient;
|
|
10
16
|
let stocksClient: StockClient;
|
|
11
17
|
|
|
@@ -22,9 +28,12 @@ describe('CustomTheme', () => {
|
|
|
22
28
|
stocksClient = new StockClient(config, logger);
|
|
23
29
|
});
|
|
24
30
|
|
|
25
|
-
test(
|
|
31
|
+
test("GetAllCustomThemes", async () => {
|
|
26
32
|
const resp = await client.getAllCustomThemes(Locale.Tr);
|
|
27
33
|
expect(resp).not.toBeEmpty();
|
|
34
|
+
|
|
35
|
+
const firstTheme = resp[0];
|
|
36
|
+
validateCollection(firstTheme);
|
|
28
37
|
});
|
|
29
38
|
|
|
30
39
|
test('CreateUpdateDeleteCustomTheme', async () => {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Logger } from 'winston';
|
|
2
2
|
import { LaplaceConfiguration } from '../utilities/configuration';
|
|
3
|
-
import { Client } from '../client/client';
|
|
4
3
|
import { FinancialFundamentalsClient, TopMoverDirection } from '../client/financial_fundamentals';
|
|
5
|
-
import { Region } from '../client/collections';
|
|
6
4
|
import './client_test_suite';
|
|
7
|
-
import {
|
|
5
|
+
import { Region } from '../client/collections';
|
|
6
|
+
import { AssetType, AssetClass } from '../client/stocks';
|
|
8
7
|
|
|
9
8
|
describe('FinancialFundamentals', () => {
|
|
10
|
-
let client: Client;
|
|
11
9
|
let stockClient: FinancialFundamentalsClient;
|
|
12
10
|
|
|
13
11
|
beforeAll(() => {
|
|
@@ -22,10 +20,23 @@ describe('FinancialFundamentals', () => {
|
|
|
22
20
|
stockClient = new FinancialFundamentalsClient(config, logger);
|
|
23
21
|
});
|
|
24
22
|
|
|
25
|
-
test(
|
|
26
|
-
const resp = await stockClient.getStockDividends(
|
|
23
|
+
test("GetStockDividend", async () => {
|
|
24
|
+
const resp = await stockClient.getStockDividends("TUPRS", Region.Tr);
|
|
27
25
|
expect(resp).not.toBeEmpty();
|
|
28
|
-
|
|
26
|
+
|
|
27
|
+
const firstDividend = resp[0];
|
|
28
|
+
expect(typeof firstDividend.date).toBe("string");
|
|
29
|
+
expect(() => new Date(firstDividend.date)).not.toThrow();
|
|
30
|
+
expect(new Date(firstDividend.date).getTime()).not.toBeNaN();
|
|
31
|
+
|
|
32
|
+
expect(typeof firstDividend.netAmount).toBe("number");
|
|
33
|
+
expect(typeof firstDividend.netRatio).toBe("number");
|
|
34
|
+
expect(typeof firstDividend.grossAmount).toBe("number");
|
|
35
|
+
expect(typeof firstDividend.grossRatio).toBe("number");
|
|
36
|
+
expect(typeof firstDividend.priceThen).toBe("number");
|
|
37
|
+
expect(typeof firstDividend.stoppageRatio).toBe("number");
|
|
38
|
+
expect(typeof firstDividend.stoppageAmount).toBe("number");
|
|
39
|
+
});
|
|
29
40
|
|
|
30
41
|
test('GetStockStats', async () => {
|
|
31
42
|
const resp = await stockClient.getStockStats(['TUPRS'], Region.Tr);
|
|
@@ -65,7 +76,7 @@ describe('FinancialFundamentals', () => {
|
|
|
65
76
|
const pageSize = 20;
|
|
66
77
|
|
|
67
78
|
async function testTopMovers(direction: TopMoverDirection, shouldBePositive: boolean) {
|
|
68
|
-
const result = await stockClient.getTopMovers(region, page, pageSize, direction, AssetType.Stock);
|
|
79
|
+
const result = await stockClient.getTopMovers(region, page, pageSize, direction, AssetType.Stock, AssetClass.Equity);
|
|
69
80
|
|
|
70
81
|
expect(Array.isArray(result)).toBe(true);
|
|
71
82
|
expect(result.length).toBeGreaterThan(0);
|
|
@@ -85,6 +96,10 @@ describe('FinancialFundamentals', () => {
|
|
|
85
96
|
const assetTypeCheck = result.every(mover => mover.assetType === AssetType.Stock)
|
|
86
97
|
|
|
87
98
|
expect(assetTypeCheck).toBe(true);
|
|
99
|
+
|
|
100
|
+
const assetClassCheck = result.every(mover => mover.assetClass === AssetClass.Equity)
|
|
101
|
+
|
|
102
|
+
expect(assetClassCheck).toBe(true);
|
|
88
103
|
|
|
89
104
|
expect(result.length).toBeLessThanOrEqual(pageSize);
|
|
90
105
|
}
|