laplace-api 1.0.11 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Client } from './client';
|
|
2
|
+
import { Region, Locale } from './collections';
|
|
3
|
+
|
|
4
|
+
// type PaginatedResponse[T any] struct {
|
|
5
|
+
// RecordCount int `json:"recordCount"`
|
|
6
|
+
// Items []T `json:"items"`
|
|
7
|
+
// }
|
|
8
|
+
|
|
9
|
+
export interface PaginatedResponse<T> {
|
|
10
|
+
recordCount: number;
|
|
11
|
+
items: T[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CapitalIncrease {
|
|
15
|
+
id: number;
|
|
16
|
+
boardDecisionDate: string;
|
|
17
|
+
registeredCapitalCeiling: string;
|
|
18
|
+
currentCapital: string;
|
|
19
|
+
targetCapital: string;
|
|
20
|
+
types: string[];
|
|
21
|
+
spkApplicationResult: string;
|
|
22
|
+
spkApplicationDate: string;
|
|
23
|
+
spkApprovalDate: string;
|
|
24
|
+
paymentDate: string;
|
|
25
|
+
registrationDate: string;
|
|
26
|
+
specifiedCurrency: string;
|
|
27
|
+
symbol: string;
|
|
28
|
+
relatedDisclosureIDs: number[];
|
|
29
|
+
rightsRate: string;
|
|
30
|
+
rightsPrice: string;
|
|
31
|
+
rightsTotalAmount: string;
|
|
32
|
+
rightsStartDate: string;
|
|
33
|
+
rightsEndDate: string;
|
|
34
|
+
bonusRate: string;
|
|
35
|
+
bonusTotalAmount: string;
|
|
36
|
+
bonusStartDate: string;
|
|
37
|
+
bonusDividendRate: string;
|
|
38
|
+
bonusDividendTotalAmount: string;
|
|
39
|
+
externalCapitalIncreaseAmount: string;
|
|
40
|
+
externalCapitalIncreaseRate: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class CapitalIncreaseClient extends Client {
|
|
44
|
+
async getAllCapitalIncreases(
|
|
45
|
+
page: number,
|
|
46
|
+
size: number,
|
|
47
|
+
region: Region
|
|
48
|
+
): Promise<PaginatedResponse<CapitalIncrease>> {
|
|
49
|
+
return this.sendRequest<PaginatedResponse<CapitalIncrease>>({
|
|
50
|
+
method: 'GET',
|
|
51
|
+
url: '/api/v1/capital-increase/all',
|
|
52
|
+
params: { region, page, size },
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async getCapitalIncreasesForInstrument(
|
|
57
|
+
symbol: string,
|
|
58
|
+
page: number,
|
|
59
|
+
size: number,
|
|
60
|
+
region: Region,
|
|
61
|
+
): Promise<PaginatedResponse<CapitalIncrease>> {
|
|
62
|
+
return this.sendRequest<PaginatedResponse<CapitalIncrease>>({
|
|
63
|
+
method: 'GET',
|
|
64
|
+
url: '/api/v1/capital-increase/' + symbol,
|
|
65
|
+
params: { region, page, size },
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async getActiveRightsForInstrument(
|
|
70
|
+
symbol: string,
|
|
71
|
+
date: string,
|
|
72
|
+
region: Region
|
|
73
|
+
): Promise<CapitalIncrease[]> {
|
|
74
|
+
return this.sendRequest<CapitalIncrease[]>({
|
|
75
|
+
method: 'GET',
|
|
76
|
+
url: '/api/v1/rights/active/' + symbol,
|
|
77
|
+
params: { date, region },
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/client/stocks.ts
CHANGED
|
@@ -25,6 +25,14 @@ export enum HistoricalPricePeriod {
|
|
|
25
25
|
FiveYear = '5Y',
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
export enum HistoricalPriceInterval {
|
|
29
|
+
OneMinute = "1m",
|
|
30
|
+
FiveMinute = "5m",
|
|
31
|
+
ThirtyMinute = "30m",
|
|
32
|
+
OneHour = "1h",
|
|
33
|
+
OneDay = "24h",
|
|
34
|
+
}
|
|
35
|
+
|
|
28
36
|
export interface Stock {
|
|
29
37
|
id: string;
|
|
30
38
|
assetType: AssetType;
|
|
@@ -34,6 +42,7 @@ export interface Stock {
|
|
|
34
42
|
industryId: string;
|
|
35
43
|
updatedDate: string;
|
|
36
44
|
dailyChange?: number;
|
|
45
|
+
active: boolean;
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
export interface LocaleString {
|
|
@@ -54,6 +63,19 @@ export interface StockDetail {
|
|
|
54
63
|
sectorId: string;
|
|
55
64
|
industryId: string;
|
|
56
65
|
updatedDate: string;
|
|
66
|
+
active: boolean;
|
|
67
|
+
markets: Market[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export enum Market {
|
|
71
|
+
Yildiz = "YILDIZ",
|
|
72
|
+
Ana = "ANA",
|
|
73
|
+
Alt = "ALT",
|
|
74
|
+
YakinIzleme = "YAKIN_IZLEME",
|
|
75
|
+
POIP = "POIP",
|
|
76
|
+
Fon = "FON",
|
|
77
|
+
Girisim = "GIRISIM",
|
|
78
|
+
Emtia = "EMTIA",
|
|
57
79
|
}
|
|
58
80
|
|
|
59
81
|
export interface PriceDataPoint {
|
|
@@ -76,6 +98,28 @@ export interface StockPriceGraph {
|
|
|
76
98
|
'5Y': PriceDataPoint[];
|
|
77
99
|
}
|
|
78
100
|
|
|
101
|
+
export interface StockRestriction {
|
|
102
|
+
id: number;
|
|
103
|
+
title: string;
|
|
104
|
+
description: string;
|
|
105
|
+
startDate: string;
|
|
106
|
+
endDate: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface TickRule {
|
|
110
|
+
basePrice: number;
|
|
111
|
+
additionalPrice: number;
|
|
112
|
+
lowerPriceLimit: number;
|
|
113
|
+
upperPriceLimit: number;
|
|
114
|
+
rules: TickSizeRule[];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface TickSizeRule {
|
|
118
|
+
priceFrom: number;
|
|
119
|
+
priceTo: number;
|
|
120
|
+
tickSize: number;
|
|
121
|
+
}
|
|
122
|
+
|
|
79
123
|
export class StockClient extends Client {
|
|
80
124
|
async getAllStocks(region: Region): Promise<Stock[]> {
|
|
81
125
|
return this.sendRequest<Stock[]>({
|
|
@@ -112,4 +156,39 @@ export class StockClient extends Client {
|
|
|
112
156
|
},
|
|
113
157
|
});
|
|
114
158
|
}
|
|
115
|
-
|
|
159
|
+
|
|
160
|
+
async getCustomHistoricalPrices(stock: string, region: Region, fromDate: string, toDate: string, interval: HistoricalPriceInterval, detail: boolean): Promise<PriceDataPoint[]> {
|
|
161
|
+
this.validateCustomHistoricalPriceDate(fromDate);
|
|
162
|
+
this.validateCustomHistoricalPriceDate(toDate);
|
|
163
|
+
|
|
164
|
+
return this.sendRequest<PriceDataPoint[]>({
|
|
165
|
+
method: 'GET',
|
|
166
|
+
url: '/api/v1/stock/price/interval',
|
|
167
|
+
params: { stock, region, fromDate, toDate, interval, detail },
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async validateCustomHistoricalPriceDate(date: string) {
|
|
172
|
+
const pattern = /^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?$/;
|
|
173
|
+
const matched = date.match(pattern);
|
|
174
|
+
if (!matched) {
|
|
175
|
+
throw new Error("Invalid date format, allowed formats: YYYY-MM-DD, YYYY-MM-DD HH:MM:SS");
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async getStockRestrictions(symbol: string, region: Region): Promise<StockRestriction[]> {
|
|
180
|
+
return this.sendRequest<StockRestriction[]>({
|
|
181
|
+
method: 'GET',
|
|
182
|
+
url: '/api/v1/stock/restrictions',
|
|
183
|
+
params: { symbol, region },
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async getTickRules(symbol: string, region: Region): Promise<TickRule> {
|
|
188
|
+
return this.sendRequest<TickRule>({
|
|
189
|
+
method: 'GET',
|
|
190
|
+
url: '/api/v1/stock/rules',
|
|
191
|
+
params: { symbol, region },
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Logger } from 'winston';
|
|
2
|
+
import { LaplaceConfiguration } from '../utilities/configuration';
|
|
3
|
+
import { CapitalIncreaseClient } from '../client/capital_increase';
|
|
4
|
+
import { Region } from '../client/collections';
|
|
5
|
+
import './client_test_suite';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
describe('Capital Increase', () => {
|
|
9
|
+
let client: CapitalIncreaseClient;
|
|
10
|
+
|
|
11
|
+
beforeAll(() => {
|
|
12
|
+
// Assuming global.testSuite is set up as in the previous example
|
|
13
|
+
const config = (global as any).testSuite.config as LaplaceConfiguration;
|
|
14
|
+
const logger: Logger = {
|
|
15
|
+
info: jest.fn(),
|
|
16
|
+
error: jest.fn(),
|
|
17
|
+
warn: jest.fn(),
|
|
18
|
+
debug: jest.fn(),
|
|
19
|
+
} as unknown as Logger;
|
|
20
|
+
|
|
21
|
+
client = new CapitalIncreaseClient(config, logger);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('GetAllCapitalIncreases', async () => {
|
|
25
|
+
await client.getAllCapitalIncreases(1, 10, Region.Tr, );
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('GetCapitalIncreasesForInstrument', async () => {
|
|
29
|
+
await client.getCapitalIncreasesForInstrument("TUPRS", 1, 10, Region.Tr);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('GetActiveRightsForInstrument', async () => {
|
|
33
|
+
await client.getActiveRightsForInstrument("TUPRS", "2024-01-01", Region.Tr);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
});
|
package/src/test/stocks.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Logger } from 'winston';
|
|
2
2
|
import { LaplaceConfiguration } from '../utilities/configuration';
|
|
3
|
-
import { StockClient, AssetClass, HistoricalPricePeriod } from '../client/stocks';
|
|
3
|
+
import { StockClient, AssetClass, HistoricalPricePeriod, HistoricalPriceInterval } from '../client/stocks';
|
|
4
4
|
import { Region, Locale } from '../client/collections';
|
|
5
5
|
import './client_test_suite';
|
|
6
6
|
|
|
@@ -48,4 +48,43 @@ describe('Stocks', () => {
|
|
|
48
48
|
expect(price).not.toBeEmpty();
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
-
|
|
51
|
+
|
|
52
|
+
test('GetCustomHistoricalPrices', async () => {
|
|
53
|
+
let resp = await client.getCustomHistoricalPrices(
|
|
54
|
+
"TUPRS",
|
|
55
|
+
Region.Tr,
|
|
56
|
+
"2024-01-01",
|
|
57
|
+
"2024-03-01",
|
|
58
|
+
HistoricalPriceInterval.OneDay,
|
|
59
|
+
false
|
|
60
|
+
);
|
|
61
|
+
expect(resp).not.toBeEmpty();
|
|
62
|
+
|
|
63
|
+
for (const price of resp) {
|
|
64
|
+
expect(price).not.toBeEmpty();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
resp = await client.getCustomHistoricalPrices(
|
|
68
|
+
"SASA",
|
|
69
|
+
Region.Tr,
|
|
70
|
+
"2024-01-01 10:00:00",
|
|
71
|
+
"2024-01-05 10:00:00",
|
|
72
|
+
HistoricalPriceInterval.OneHour,
|
|
73
|
+
true
|
|
74
|
+
);
|
|
75
|
+
expect(resp).not.toBeEmpty();
|
|
76
|
+
|
|
77
|
+
for (const price of resp) {
|
|
78
|
+
expect(price).not.toBeEmpty();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('GetStockRestrictions', async () => {
|
|
83
|
+
await client.getStockRestrictions("TUPRS", Region.Tr);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('GetTickRules', async () => {
|
|
87
|
+
const resp = await client.getTickRules("TUPRS", Region.Tr);
|
|
88
|
+
expect(resp).not.toBeEmpty();
|
|
89
|
+
});
|
|
90
|
+
});
|