laplace-api 3.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/client/broker.ts +76 -98
- 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 +83 -107
- 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
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Client } from "./client";
|
|
2
|
+
import { Region } from "./collections";
|
|
3
|
+
import { AssetType } from "./stocks";
|
|
4
|
+
|
|
5
|
+
export enum FundType {
|
|
6
|
+
STOCK_UMBRELLA_FUND = "STOCK_UMBRELLA_FUND",
|
|
7
|
+
VARIABLE_UMBRELLA_FUND = "VARIABLE_UMBRELLA_FUND",
|
|
8
|
+
PARTICIPATION_UMBRELLA_FUND = "PARTICIPATION_UMBRELLA_FUND",
|
|
9
|
+
FLEXIBLE_UMBRELLA_FUND = "FLEXIBLE_UMBRELLA_FUND",
|
|
10
|
+
FUND_BASKET_UMBRELLA_FUND = "FUND_BASKET_UMBRELLA_FUND",
|
|
11
|
+
MONEY_MARKET_UMBRELLA_FUND = "MONEY_MARKET_UMBRELLA_FUND",
|
|
12
|
+
PRECIOUS_METALS_UMBRELLA_FUND = "PRECIOUS_METALS_UMBRELLA_FUND",
|
|
13
|
+
DEBT_INSTRUMENTS_UMBRELLA_FUND = "DEBT_INSTRUMENTS_UMBRELLA_FUND",
|
|
14
|
+
MIXED_UMBRELLA_FUND = "MIXED_UMBRELLA_FUND",
|
|
15
|
+
UNKNOWN_FUND_TYPE = "UNKNOWN_FUND_TYPE",
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface Fund {
|
|
19
|
+
assetType: AssetType;
|
|
20
|
+
name: string;
|
|
21
|
+
symbol: string;
|
|
22
|
+
active: boolean;
|
|
23
|
+
managementFee: number;
|
|
24
|
+
riskLevel: number;
|
|
25
|
+
fundType: FundType;
|
|
26
|
+
ownerSymbol: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface FundStats {
|
|
30
|
+
yearBeta: number;
|
|
31
|
+
yearStdev: number;
|
|
32
|
+
ytdReturn: number;
|
|
33
|
+
yearMomentum: number;
|
|
34
|
+
yearlyReturn: number;
|
|
35
|
+
monthlyReturn: number;
|
|
36
|
+
fiveYearReturn: number;
|
|
37
|
+
sixMonthReturn: number;
|
|
38
|
+
threeYearReturn: number;
|
|
39
|
+
threeMonthReturn: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export enum FundContentType {
|
|
43
|
+
BIST_STOCK = "BIST_STOCK",
|
|
44
|
+
OTHER_STOCK = "OTHER_STOCK",
|
|
45
|
+
UNKNOWN = "UNKNOWN",
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export enum FundAssetCategory {
|
|
49
|
+
OTHER = "OTHER",
|
|
50
|
+
EQUITY = "EQUITY",
|
|
51
|
+
LIQUID_DEPOSIT = "LIQUID_DEPOSIT",
|
|
52
|
+
FUTURES_CASH_COLLATERAL = "FUTURES_CASH_COLLATERAL",
|
|
53
|
+
INVESTMENT_FUNDS = "INVESTMENT_FUNDS",
|
|
54
|
+
PARTICIPATION_ACCOUNT = "PARTICIPATION_ACCOUNT",
|
|
55
|
+
PRECIOUS_METALS = "PRECIOUS_METALS",
|
|
56
|
+
CORPORATE_BOND = "CORPORATE_BOND",
|
|
57
|
+
CURRENCY = "CURRENCY",
|
|
58
|
+
PUBLIC_EXTERNAL_DEBT_SECURITIES = "PUBLIC_EXTERNAL_DEBT_SECURITIES",
|
|
59
|
+
PRIVATE_SECTOR_EXTERNAL_DEBT_SECURITIES = "PRIVATE_SECTOR_EXTERNAL_DEBT_SECURITIES",
|
|
60
|
+
PUBLIC_LEASE_CERTIFICATES = "PUBLIC_LEASE_CERTIFICATES",
|
|
61
|
+
PRIVATE_SECTOR_LEASE_CERTIFICATES = "PRIVATE_SECTOR_LEASE_CERTIFICATES",
|
|
62
|
+
FOREIGN_EXCHANGE_TRADED_FUNDS = "FOREIGN_EXCHANGE_TRADED_FUNDS",
|
|
63
|
+
PUBLIC_LEASE_CERTIFICATES_CURRENCY = "PUBLIC_LEASE_CERTIFICATES_CURRENCY",
|
|
64
|
+
GOVERNMENT_BOND = "GOVERNMENT_BOND",
|
|
65
|
+
PRIVATE_SECTOR_LEASE_CERTIFICATES_CURRENCY = "PRIVATE_SECTOR_LEASE_CERTIFICATES_CURRENCY",
|
|
66
|
+
UNKNOWN = "UNKNOWN",
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface FundAsset {
|
|
70
|
+
type: FundContentType;
|
|
71
|
+
symbol: string;
|
|
72
|
+
wholePercentage: number;
|
|
73
|
+
categoryPercentage: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface FundDistribution {
|
|
77
|
+
categories: FundCategoryDistribution[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface FundCategoryDistribution {
|
|
81
|
+
category: FundAssetCategory;
|
|
82
|
+
percentage: number;
|
|
83
|
+
assets?: FundAsset[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export enum HistoricalFundPricePeriod {
|
|
87
|
+
OneWeek = "1H",
|
|
88
|
+
OneMonth = "1A",
|
|
89
|
+
ThreeMonth = "3A",
|
|
90
|
+
OneYear = "1Y",
|
|
91
|
+
ThreeYear = "3Y",
|
|
92
|
+
FiveYear = "5Y",
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface FundHistoricalPrice {
|
|
96
|
+
aum: number;
|
|
97
|
+
date: string;
|
|
98
|
+
price: number;
|
|
99
|
+
shareCount: number;
|
|
100
|
+
investorCount: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export class FundsClient extends Client {
|
|
104
|
+
async getFunds(region: Region, page: number, pageSize: number) {
|
|
105
|
+
return this.sendRequest<Fund[]>({
|
|
106
|
+
method: "GET",
|
|
107
|
+
url: `/api/v1/fund`,
|
|
108
|
+
params: { region, page, pageSize },
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async getFundStats(symbol: string, region: Region) {
|
|
113
|
+
return this.sendRequest<FundStats>({
|
|
114
|
+
method: "GET",
|
|
115
|
+
url: `/api/v1/fund/stats`,
|
|
116
|
+
params: { symbol, region },
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async getFundDistribution(symbol: string, region: Region) {
|
|
121
|
+
return this.sendRequest<FundDistribution>({
|
|
122
|
+
method: "GET",
|
|
123
|
+
url: `/api/v1/fund/distribution`,
|
|
124
|
+
params: { symbol, region },
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async getHistoricalFundPrices(
|
|
129
|
+
symbol: string,
|
|
130
|
+
region: Region,
|
|
131
|
+
period: HistoricalFundPricePeriod
|
|
132
|
+
) {
|
|
133
|
+
return this.sendRequest<FundHistoricalPrice[]>({
|
|
134
|
+
method: "GET",
|
|
135
|
+
url: `/api/v1/fund/price`,
|
|
136
|
+
params: { symbol, region, period },
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Client } from "./client";
|
|
2
|
+
import { Region } from "./collections";
|
|
3
|
+
|
|
4
|
+
export interface KeyInsight {
|
|
5
|
+
symbol: string;
|
|
6
|
+
insight: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class KeyInsightClient extends Client {
|
|
10
|
+
async getKeyInsights(symbol: string, region: Region) {
|
|
11
|
+
return this.sendRequest<KeyInsight>({
|
|
12
|
+
method: "GET",
|
|
13
|
+
url: "/api/v1/key-insight",
|
|
14
|
+
params: { symbol, region },
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
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',
|
package/src/test/broker.test.ts
CHANGED
|
@@ -3,13 +3,10 @@ import { Region } from "../client/collections";
|
|
|
3
3
|
import { LaplaceConfiguration } from "../utilities/configuration";
|
|
4
4
|
import "./client_test_suite";
|
|
5
5
|
import {
|
|
6
|
-
BaseBrokerStats,
|
|
7
6
|
BrokerClient,
|
|
8
7
|
BrokerSort,
|
|
8
|
+
SortDirection,
|
|
9
9
|
BrokerStats,
|
|
10
|
-
BrokerStockStats,
|
|
11
|
-
StockBrokerStats,
|
|
12
|
-
StockOverallStats,
|
|
13
10
|
} from "../client/broker";
|
|
14
11
|
|
|
15
12
|
describe("BrokerClient", () => {
|
|
@@ -35,9 +32,10 @@ describe("BrokerClient", () => {
|
|
|
35
32
|
test("getMarketBrokers returns valid and fully typed data", async () => {
|
|
36
33
|
const response = await brokerClient.getMarketBrokers(
|
|
37
34
|
Region.Tr,
|
|
35
|
+
BrokerSort.TotalVolume,
|
|
36
|
+
SortDirection.Desc,
|
|
38
37
|
"2025-05-27",
|
|
39
38
|
"2025-05-28",
|
|
40
|
-
BrokerSort.Volume,
|
|
41
39
|
0,
|
|
42
40
|
5
|
|
43
41
|
);
|
|
@@ -46,7 +44,7 @@ describe("BrokerClient", () => {
|
|
|
46
44
|
expect(typeof response.recordCount).toBe("number");
|
|
47
45
|
|
|
48
46
|
const stats = response.totalStats;
|
|
49
|
-
expect(stats).toMatchObject<
|
|
47
|
+
expect(stats).toMatchObject<BrokerStats>({
|
|
50
48
|
totalBuyAmount: expect.any(Number),
|
|
51
49
|
totalSellAmount: expect.any(Number),
|
|
52
50
|
netAmount: expect.any(Number),
|
|
@@ -68,44 +66,48 @@ describe("BrokerClient", () => {
|
|
|
68
66
|
totalSellVolume: expect.any(Number),
|
|
69
67
|
totalVolume: expect.any(Number),
|
|
70
68
|
totalAmount: expect.any(Number),
|
|
71
|
-
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (item.broker) {
|
|
72
|
+
expect(item.broker).toMatchObject({
|
|
72
73
|
id: expect.any(Number),
|
|
73
74
|
symbol: expect.any(String),
|
|
74
75
|
name: expect.any(String),
|
|
75
76
|
longName: expect.any(String),
|
|
76
77
|
logo: expect.any(String),
|
|
77
|
-
}
|
|
78
|
-
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
79
80
|
}
|
|
80
81
|
});
|
|
81
82
|
|
|
82
|
-
test("
|
|
83
|
-
const response = await brokerClient.
|
|
83
|
+
test("getMarketStocks returns valid stock data", async () => {
|
|
84
|
+
const response = await brokerClient.getMarketStocks(
|
|
84
85
|
region,
|
|
86
|
+
BrokerSort.TotalVolume,
|
|
87
|
+
SortDirection.Desc,
|
|
85
88
|
fromDate,
|
|
86
89
|
toDate,
|
|
87
|
-
|
|
90
|
+
0,
|
|
91
|
+
5
|
|
88
92
|
);
|
|
89
93
|
|
|
90
94
|
expect(response).toBeDefined();
|
|
95
|
+
expect(typeof response.recordCount).toBe("number");
|
|
91
96
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
expect(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
103
|
-
}
|
|
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
|
+
});
|
|
104
107
|
|
|
105
|
-
expect(Array.isArray(response.
|
|
106
|
-
expect(response.topItems.length).toBeGreaterThan(0);
|
|
108
|
+
expect(Array.isArray(response.items)).toBe(true);
|
|
107
109
|
|
|
108
|
-
for (const item of response.
|
|
110
|
+
for (const item of response.items) {
|
|
109
111
|
expect(item).toMatchObject<BrokerStats>({
|
|
110
112
|
totalBuyAmount: expect.any(Number),
|
|
111
113
|
totalSellAmount: expect.any(Number),
|
|
@@ -114,24 +116,28 @@ describe("BrokerClient", () => {
|
|
|
114
116
|
totalSellVolume: expect.any(Number),
|
|
115
117
|
totalVolume: expect.any(Number),
|
|
116
118
|
totalAmount: expect.any(Number),
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (item.stock) {
|
|
122
|
+
expect(item.stock).toMatchObject({
|
|
123
|
+
id: expect.any(String),
|
|
119
124
|
symbol: expect.any(String),
|
|
120
125
|
name: expect.any(String),
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
}
|
|
126
|
+
assetType: expect.any(String),
|
|
127
|
+
assetClass: expect.any(String),
|
|
128
|
+
});
|
|
129
|
+
}
|
|
125
130
|
}
|
|
126
131
|
});
|
|
127
132
|
|
|
128
|
-
test("
|
|
129
|
-
const response = await brokerClient.
|
|
133
|
+
test("getBrokersByStock returns brokers for specific stock", async () => {
|
|
134
|
+
const response = await brokerClient.getBrokersByStock(
|
|
135
|
+
"TUPRS",
|
|
130
136
|
region,
|
|
137
|
+
BrokerSort.TotalVolume,
|
|
138
|
+
SortDirection.Desc,
|
|
131
139
|
fromDate,
|
|
132
140
|
toDate,
|
|
133
|
-
BrokerSort.Volume,
|
|
134
|
-
"TUPRS",
|
|
135
141
|
0,
|
|
136
142
|
5
|
|
137
143
|
);
|
|
@@ -139,7 +145,8 @@ describe("BrokerClient", () => {
|
|
|
139
145
|
expect(response).toBeDefined();
|
|
140
146
|
expect(typeof response.recordCount).toBe("number");
|
|
141
147
|
|
|
142
|
-
|
|
148
|
+
const stats = response.totalStats;
|
|
149
|
+
expect(stats).toMatchObject<BrokerStats>({
|
|
143
150
|
totalBuyAmount: expect.any(Number),
|
|
144
151
|
totalSellAmount: expect.any(Number),
|
|
145
152
|
netAmount: expect.any(Number),
|
|
@@ -147,43 +154,12 @@ describe("BrokerClient", () => {
|
|
|
147
154
|
totalSellVolume: expect.any(Number),
|
|
148
155
|
totalVolume: expect.any(Number),
|
|
149
156
|
totalAmount: expect.any(Number),
|
|
150
|
-
averageCost: expect.any(Number),
|
|
151
157
|
});
|
|
152
158
|
|
|
153
|
-
|
|
154
|
-
expect(item).toMatchObject<StockBrokerStats>({
|
|
155
|
-
averageCost: expect.any(Number),
|
|
156
|
-
totalBuyAmount: expect.any(Number),
|
|
157
|
-
totalSellAmount: expect.any(Number),
|
|
158
|
-
netAmount: expect.any(Number),
|
|
159
|
-
totalBuyVolume: expect.any(Number),
|
|
160
|
-
totalSellVolume: expect.any(Number),
|
|
161
|
-
totalVolume: expect.any(Number),
|
|
162
|
-
totalAmount: expect.any(Number),
|
|
163
|
-
broker: {
|
|
164
|
-
id: expect.any(Number),
|
|
165
|
-
symbol: expect.any(String),
|
|
166
|
-
name: expect.any(String),
|
|
167
|
-
longName: expect.any(String),
|
|
168
|
-
logo: expect.any(String),
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
test("getTopStockBrokers returns fully typed top & rest stats with averageCost", async () => {
|
|
175
|
-
const response = await brokerClient.getTopStockBrokers(
|
|
176
|
-
region,
|
|
177
|
-
fromDate,
|
|
178
|
-
toDate,
|
|
179
|
-
BrokerSort.Volume,
|
|
180
|
-
"TUPRS"
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
expect(response).toBeDefined();
|
|
159
|
+
expect(Array.isArray(response.items)).toBe(true);
|
|
184
160
|
|
|
185
|
-
for (const
|
|
186
|
-
expect(
|
|
161
|
+
for (const item of response.items) {
|
|
162
|
+
expect(item).toMatchObject<BrokerStats>({
|
|
187
163
|
totalBuyAmount: expect.any(Number),
|
|
188
164
|
totalSellAmount: expect.any(Number),
|
|
189
165
|
netAmount: expect.any(Number),
|
|
@@ -191,44 +167,54 @@ describe("BrokerClient", () => {
|
|
|
191
167
|
totalSellVolume: expect.any(Number),
|
|
192
168
|
totalVolume: expect.any(Number),
|
|
193
169
|
totalAmount: expect.any(Number),
|
|
194
|
-
averageCost: expect.any(Number),
|
|
195
170
|
});
|
|
196
|
-
}
|
|
197
171
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
averageCost: expect.any(Number),
|
|
201
|
-
totalBuyAmount: expect.any(Number),
|
|
202
|
-
totalSellAmount: expect.any(Number),
|
|
203
|
-
netAmount: expect.any(Number),
|
|
204
|
-
totalBuyVolume: expect.any(Number),
|
|
205
|
-
totalSellVolume: expect.any(Number),
|
|
206
|
-
totalVolume: expect.any(Number),
|
|
207
|
-
totalAmount: expect.any(Number),
|
|
208
|
-
broker: {
|
|
172
|
+
if (item.broker) {
|
|
173
|
+
expect(item.broker).toMatchObject({
|
|
209
174
|
id: expect.any(Number),
|
|
210
175
|
symbol: expect.any(String),
|
|
211
176
|
name: expect.any(String),
|
|
212
177
|
longName: expect.any(String),
|
|
213
178
|
logo: expect.any(String),
|
|
214
|
-
}
|
|
215
|
-
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if ("averageCost" in item) {
|
|
183
|
+
expect(item.averageCost).toEqual(expect.any(Number));
|
|
184
|
+
}
|
|
216
185
|
}
|
|
217
186
|
});
|
|
218
187
|
|
|
219
|
-
test("
|
|
220
|
-
const response = await brokerClient.
|
|
188
|
+
test("getStocksByBroker returns stocks for specific broker", async () => {
|
|
189
|
+
const response = await brokerClient.getStocksByBroker(
|
|
190
|
+
"BIYKR",
|
|
221
191
|
region,
|
|
192
|
+
BrokerSort.TotalVolume,
|
|
193
|
+
SortDirection.Desc,
|
|
222
194
|
fromDate,
|
|
223
195
|
toDate,
|
|
224
|
-
|
|
225
|
-
|
|
196
|
+
0,
|
|
197
|
+
5
|
|
226
198
|
);
|
|
227
199
|
|
|
228
200
|
expect(response).toBeDefined();
|
|
201
|
+
expect(typeof response.recordCount).toBe("number");
|
|
229
202
|
|
|
230
|
-
|
|
231
|
-
|
|
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>({
|
|
232
218
|
totalBuyAmount: expect.any(Number),
|
|
233
219
|
totalSellAmount: expect.any(Number),
|
|
234
220
|
netAmount: expect.any(Number),
|
|
@@ -237,26 +223,16 @@ describe("BrokerClient", () => {
|
|
|
237
223
|
totalVolume: expect.any(Number),
|
|
238
224
|
totalAmount: expect.any(Number),
|
|
239
225
|
});
|
|
240
|
-
}
|
|
241
226
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
totalBuyAmount: expect.any(Number),
|
|
245
|
-
totalSellAmount: expect.any(Number),
|
|
246
|
-
netAmount: expect.any(Number),
|
|
247
|
-
totalBuyVolume: expect.any(Number),
|
|
248
|
-
totalSellVolume: expect.any(Number),
|
|
249
|
-
totalVolume: expect.any(Number),
|
|
250
|
-
totalAmount: expect.any(Number),
|
|
251
|
-
stock: {
|
|
227
|
+
if (item.stock) {
|
|
228
|
+
expect(item.stock).toMatchObject({
|
|
252
229
|
id: expect.any(String),
|
|
253
230
|
symbol: expect.any(String),
|
|
254
231
|
name: expect.any(String),
|
|
255
232
|
assetType: expect.any(String),
|
|
256
233
|
assetClass: expect.any(String),
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
});
|
|
234
|
+
});
|
|
235
|
+
}
|
|
260
236
|
}
|
|
261
237
|
});
|
|
262
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
|
+
}
|