borsajs 0.1.1 β 0.1.4
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.en.md +239 -94
- package/README.md +250 -18
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/market.d.ts +33 -4
- package/dist/market.d.ts.map +1 -1
- package/dist/market.js +58 -3
- package/dist/market.js.map +1 -1
- package/dist/providers/kap.d.ts +24 -3
- package/dist/providers/kap.d.ts.map +1 -1
- package/dist/providers/kap.js +180 -7
- package/dist/providers/kap.js.map +1 -1
- package/package.json +7 -4
- package/src/index.ts +3 -2
- package/src/market.ts +73 -3
- package/src/providers/kap.ts +216 -7
- package/test/demo.ts +108 -35
package/test/demo.ts
CHANGED
|
@@ -4,95 +4,168 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Crypto, cryptoPairs } from '../src/crypto.js';
|
|
6
6
|
import { FX } from '../src/fx.js';
|
|
7
|
-
import { Ticker } from '../src/ticker.js';
|
|
8
|
-
import { Index, indices } from '../src/index-class.js';
|
|
9
7
|
import { Fund, searchFunds } from '../src/fund.js';
|
|
8
|
+
import { Index, indices } from '../src/index-class.js';
|
|
10
9
|
import { Inflation } from '../src/inflation.js';
|
|
10
|
+
import { Ticker } from '../src/ticker.js';
|
|
11
|
+
import { symbols, searchSymbols, cryptoSymbols, fxSymbols, indexSymbols } from '../src/market.js';
|
|
12
|
+
import { getKapProvider } from '../src/providers/kap.js';
|
|
11
13
|
|
|
12
14
|
async function testCrypto() {
|
|
13
|
-
console.log('\nπͺ
|
|
14
|
-
console.log('β'.repeat(
|
|
15
|
+
console.log('\nπͺ CRYPTO (BtcTurk)');
|
|
16
|
+
console.log('β'.repeat(60));
|
|
15
17
|
try {
|
|
16
18
|
const btc = new Crypto('BTCTRY');
|
|
17
19
|
const current = await btc.getCurrent();
|
|
18
|
-
console.log('BTC/TRY
|
|
20
|
+
console.log('BTC/TRY:', JSON.stringify(current, null, 2));
|
|
21
|
+
|
|
19
22
|
const pairs = await cryptoPairs('TRY');
|
|
20
|
-
console.log(`\nAvailable
|
|
21
|
-
} catch (error) { console.error('
|
|
23
|
+
console.log(`\nAvailable pairs: ${pairs.slice(0, 10).join(', ')}... (${pairs.length} total)`);
|
|
24
|
+
} catch (error) { console.error('Error:', error); }
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
async function testFX() {
|
|
25
|
-
console.log('\nπ±
|
|
26
|
-
console.log('β'.repeat(
|
|
28
|
+
console.log('\nπ± FX (doviz.com)');
|
|
29
|
+
console.log('β'.repeat(60));
|
|
27
30
|
try {
|
|
28
31
|
const usd = new FX('USD');
|
|
29
32
|
const current = await usd.getCurrent();
|
|
30
|
-
console.log('USD/TRY
|
|
33
|
+
console.log('USD/TRY:', JSON.stringify(current, null, 2));
|
|
34
|
+
|
|
31
35
|
const gold = new FX('gram-altin');
|
|
32
36
|
const goldCurrent = await gold.getCurrent();
|
|
33
|
-
console.log('\nGold (gram)
|
|
34
|
-
|
|
37
|
+
console.log('\nGold (gram):', JSON.stringify(goldCurrent, null, 2));
|
|
38
|
+
|
|
39
|
+
console.log(`\nFX Symbols: ${fxSymbols.slice(0, 10).join(', ')}...`);
|
|
40
|
+
} catch (error) { console.error('Error:', error); }
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
async function testTicker() {
|
|
38
|
-
console.log('\nπ
|
|
39
|
-
console.log('β'.repeat(
|
|
44
|
+
console.log('\nπ TICKER (Paratic)');
|
|
45
|
+
console.log('β'.repeat(60));
|
|
40
46
|
try {
|
|
41
47
|
const stock = new Ticker('THYAO');
|
|
42
48
|
const info = await stock.getInfo();
|
|
43
|
-
console.log('THYAO
|
|
44
|
-
|
|
49
|
+
console.log('THYAO:', JSON.stringify(info, null, 2));
|
|
50
|
+
|
|
51
|
+
const history = await stock.getHistory({ period: '5d', interval: '1d' });
|
|
52
|
+
console.log(`\nHistory (5d): ${history.length} records`);
|
|
53
|
+
if (history.length > 0) console.log('Last:', JSON.stringify(history[history.length - 1], null, 2));
|
|
54
|
+
} catch (error) { console.error('Error:', error); }
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
async function testIndex() {
|
|
48
|
-
console.log('\nπ
|
|
49
|
-
console.log('β'.repeat(
|
|
58
|
+
console.log('\nπ INDEX (Paratic)');
|
|
59
|
+
console.log('β'.repeat(60));
|
|
50
60
|
try {
|
|
51
|
-
console.log('
|
|
61
|
+
console.log('Index Symbols:', indexSymbols.slice(0, 10).join(', '));
|
|
62
|
+
|
|
52
63
|
const xu100 = new Index('XU100');
|
|
53
64
|
const info = await xu100.getInfo();
|
|
54
|
-
console.log('\nXU100
|
|
55
|
-
} catch (error) { console.error('
|
|
65
|
+
console.log('\nXU100:', JSON.stringify(info, null, 2));
|
|
66
|
+
} catch (error) { console.error('Error:', error); }
|
|
56
67
|
}
|
|
57
68
|
|
|
58
69
|
async function testFund() {
|
|
59
|
-
console.log('\nπ¦
|
|
60
|
-
console.log('β'.repeat(
|
|
70
|
+
console.log('\nπ¦ FUND (TEFAS)');
|
|
71
|
+
console.log('β'.repeat(60));
|
|
61
72
|
try {
|
|
62
|
-
const results = await searchFunds('ak',
|
|
73
|
+
const results = await searchFunds('ak', 3);
|
|
63
74
|
console.log('Search "ak":', JSON.stringify(results, null, 2));
|
|
75
|
+
|
|
64
76
|
if (results.length > 0) {
|
|
65
77
|
const fund = new Fund(results[0].fundCode);
|
|
66
78
|
const info = await fund.getInfo();
|
|
67
|
-
console.log(`\n${results[0].fundCode}
|
|
79
|
+
console.log(`\n${results[0].fundCode}:`, JSON.stringify(info, null, 2));
|
|
68
80
|
}
|
|
69
|
-
} catch (error) { console.error('
|
|
81
|
+
} catch (error) { console.error('Error:', error); }
|
|
70
82
|
}
|
|
71
83
|
|
|
72
84
|
async function testInflation() {
|
|
73
|
-
console.log('\nπ
|
|
74
|
-
console.log('β'.repeat(
|
|
85
|
+
console.log('\nπ INFLATION (TCMB)');
|
|
86
|
+
console.log('β'.repeat(60));
|
|
75
87
|
try {
|
|
76
88
|
const inflation = new Inflation();
|
|
77
89
|
const latest = await inflation.getLatest();
|
|
78
90
|
console.log('Latest CPI:', JSON.stringify(latest, null, 2));
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
91
|
+
|
|
92
|
+
const calc = await inflation.calculate(100000, '2020-01', '2024-01');
|
|
93
|
+
console.log('\nCalculation (100K TL, 2020-01 β 2024-01):', JSON.stringify(calc, null, 2));
|
|
94
|
+
} catch (error) { console.error('Error:', error); }
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function testSymbols() {
|
|
98
|
+
console.log('\nπ’ SYMBOLS');
|
|
99
|
+
console.log('β'.repeat(60));
|
|
100
|
+
try {
|
|
101
|
+
// Stock symbols
|
|
102
|
+
const stockSymbols = symbols();
|
|
103
|
+
console.log(`Stock Symbols: ${stockSymbols.slice(0, 15).join(', ')}... (${stockSymbols.length} total)`);
|
|
104
|
+
|
|
105
|
+
// Search stocks
|
|
106
|
+
const banks = searchSymbols('BNK');
|
|
107
|
+
console.log(`\nSearch "BNK": ${banks.join(', ')}`);
|
|
108
|
+
|
|
109
|
+
// Crypto symbols
|
|
110
|
+
const cryptoList = await cryptoSymbols('TRY');
|
|
111
|
+
console.log(`\nCrypto Symbols: ${cryptoList.slice(0, 10).join(', ')}... (${cryptoList.length} total)`);
|
|
112
|
+
|
|
113
|
+
// FX symbols
|
|
114
|
+
console.log(`\nFX Symbols: ${fxSymbols.join(', ')}`);
|
|
115
|
+
|
|
116
|
+
// Index symbols
|
|
117
|
+
console.log(`\nIndex Symbols: ${indexSymbols.join(', ')}`);
|
|
118
|
+
} catch (error) { console.error('Error:', error); }
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function testKap() {
|
|
122
|
+
console.log('\nποΈ KAP (Public Disclosure Platform)');
|
|
123
|
+
console.log('β'.repeat(60));
|
|
124
|
+
try {
|
|
125
|
+
const kap = getKapProvider();
|
|
126
|
+
const companies = await kap.getCompanies();
|
|
127
|
+
console.log(`Total Companies: ${companies.length}`);
|
|
128
|
+
console.log('Sample:', JSON.stringify(companies.slice(0, 3), null, 2));
|
|
129
|
+
|
|
130
|
+
const search = await kap.search('tΓΌrk hava');
|
|
131
|
+
console.log('\nSearch "tΓΌrk hava":', JSON.stringify(search, null, 2));
|
|
132
|
+
|
|
133
|
+
// Test disclosures
|
|
134
|
+
const disclosures = await kap.getDisclosures('THYAO', 5);
|
|
135
|
+
console.log(`\nRecent THYAO Disclosures (${disclosures.length}):`);
|
|
136
|
+
disclosures.forEach((d, i) => {
|
|
137
|
+
console.log(` ${i + 1}. [${d.date}] ${d.title}`);
|
|
138
|
+
console.log(` ${d.url}`);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
// Test calendar
|
|
142
|
+
const calendar = await kap.getCalendar('THYAO');
|
|
143
|
+
console.log(`\nTHYAO Expected Disclosures (${calendar.length}):`);
|
|
144
|
+
calendar.slice(0, 3).forEach((c, i) => {
|
|
145
|
+
console.log(` ${i + 1}. ${c.subject} (${c.period} ${c.year})`);
|
|
146
|
+
console.log(` ${c.startDate} - ${c.endDate}`);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// Test company details
|
|
150
|
+
const details = await kap.getCompanyDetails('THYAO');
|
|
151
|
+
console.log('\nTHYAO Company Details:', JSON.stringify(details, null, 2));
|
|
152
|
+
} catch (error) { console.error('Error:', error); }
|
|
84
153
|
}
|
|
85
154
|
|
|
86
155
|
async function main() {
|
|
87
156
|
console.log('π borsajs API Test');
|
|
88
|
-
console.log('β'.repeat(
|
|
157
|
+
console.log('β'.repeat(60));
|
|
158
|
+
|
|
89
159
|
await testCrypto();
|
|
90
160
|
await testFX();
|
|
91
161
|
await testTicker();
|
|
92
162
|
await testIndex();
|
|
93
163
|
await testFund();
|
|
94
164
|
await testInflation();
|
|
95
|
-
|
|
165
|
+
await testSymbols();
|
|
166
|
+
await testKap();
|
|
167
|
+
|
|
168
|
+
console.log('\n' + 'β'.repeat(60));
|
|
96
169
|
console.log('β
All tests completed!');
|
|
97
170
|
}
|
|
98
171
|
|