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 CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  **[Türkçe](README.md) | [English](README.en.md)**
4
4
 
5
- > **TypeScript/JavaScript port of [borsapy](https://github.com/saidsurucu/borsapy)** - Inspired by the Python version.
6
-
7
- A TypeScript/JavaScript data library for Turkish financial markets. yfinance-like API for BIST stocks, forex, crypto, investment funds, and economic data.
5
+ A TypeScript/JavaScript data library for Turkey financial markets. yfinance-like API for BIST stocks, forex, crypto, investment funds, and economic data.
8
6
 
9
7
  ## Installation
10
8
 
@@ -15,32 +13,29 @@ npm install borsajs
15
13
  ## Quick Start
16
14
 
17
15
  ```typescript
18
- import { Ticker, FX, Crypto, Fund, Inflation, download } from 'borsajs';
16
+ import { Ticker, FX, Crypto, Fund, Inflation, symbols, cryptoSymbols } from 'borsajs';
19
17
 
20
18
  // Stock data
21
19
  const stock = new Ticker('THYAO');
22
20
  const info = await stock.getInfo();
23
- const history = await stock.getHistory({ period: '1mo' });
21
+ // { symbol: 'THYAO', last: 274.25, change: 5.75, changePercent: 2.14, ... }
24
22
 
25
23
  // Forex
26
24
  const usd = new FX('USD');
27
25
  const rate = await usd.getCurrent();
26
+ // → { symbol: 'USD', last: 43.02, updateTime: '2026-01-02T20:59:58.000Z' }
28
27
 
29
28
  // Crypto
30
29
  const btc = new Crypto('BTCTRY');
31
30
  const price = await btc.getCurrent();
31
+ // → { symbol: 'BTCTRY', last: 3839080, bid: 3839136, ask: 3840481, ... }
32
32
 
33
- // Investment fund
34
- const fund = new Fund('AAK');
35
- const fundInfo = await fund.getInfo();
36
-
37
- // Inflation
38
- const inflation = new Inflation();
39
- const latest = await inflation.getLatest();
40
- const calculation = await inflation.calculate(100000, '2020-01', '2024-01');
33
+ // Symbol lists
34
+ const stockList = symbols(); // → ['AKBNK', 'ARCLK', 'ASELS', ...] (80 stocks)
35
+ const cryptoList = await cryptoSymbols(); // → ['BTCTRY', 'ETHTRY', ...] (173 pairs)
41
36
  ```
42
37
 
43
- ## Modules
38
+ ## API Reference
44
39
 
45
40
  ### Ticker (Stocks)
46
41
 
@@ -48,62 +43,122 @@ const calculation = await inflation.calculate(100000, '2020-01', '2024-01');
48
43
  import { Ticker } from 'borsajs';
49
44
 
50
45
  const stock = new Ticker('THYAO');
51
-
52
- // Current info
53
46
  const info = await stock.getInfo();
54
- console.log(info.last); // Last price
55
- console.log(info.change); // Change
56
- console.log(info.changePercent); // Change %
57
-
58
- // Price history
59
- const daily = await stock.getHistory({ period: '1mo' });
60
- const hourly = await stock.getHistory({ period: '5d', interval: '1h' });
61
- const weekly = await stock.getHistory({ period: '1y', interval: '1wk' });
62
47
  ```
63
48
 
64
- ### Index
49
+ **Response:**
50
+ ```json
51
+ {
52
+ "symbol": "THYAO",
53
+ "last": 274.25,
54
+ "open": 271,
55
+ "high": 274.25,
56
+ "low": 269.75,
57
+ "close": 268.5,
58
+ "volume": 7853192164.25,
59
+ "change": 5.75,
60
+ "changePercent": 2.14,
61
+ "updateTime": "2026-01-01T21:00:00.000Z",
62
+ "type": "stock"
63
+ }
64
+ ```
65
65
 
66
+ **History:**
66
67
  ```typescript
67
- import { Index, indices } from 'borsajs';
68
-
69
- // Available indices
70
- console.log(indices()); // ['XU100', 'XU050', ...]
68
+ const history = await stock.getHistory({ period: '5d', interval: '1d' });
69
+ ```
71
70
 
72
- // Index data
73
- const xu100 = new Index('XU100');
74
- const info = await xu100.getInfo();
75
- const history = await xu100.getHistory({ period: '1mo' });
71
+ ```json
72
+ [
73
+ {
74
+ "date": "2026-01-01T21:00:00.000Z",
75
+ "open": 271,
76
+ "high": 274.25,
77
+ "low": 269.75,
78
+ "close": 274.25,
79
+ "volume": 7853192164.25
80
+ }
81
+ ]
76
82
  ```
77
83
 
78
84
  ### FX (Forex & Commodities)
79
85
 
80
86
  ```typescript
81
- import { FX } from 'borsajs';
87
+ import { FX, fxSymbols } from 'borsajs';
88
+
89
+ console.log(fxSymbols);
90
+ // → ['USD', 'EUR', 'GBP', 'JPY', 'CHF', 'CAD', 'AUD', 'gram-altin', 'ceyrek-altin', ...]
82
91
 
83
- // Exchange rates
84
92
  const usd = new FX('USD');
85
93
  const current = await usd.getCurrent();
86
- const history = await usd.getHistory({ period: '1mo' });
87
-
88
- // Gold
89
- const gold = new FX('gram-altin');
90
- const quarter = new FX('ceyrek-altin');
94
+ ```
91
95
 
92
- // Other: EUR, GBP, CHF, gumus (silver), BRENT, WTI
96
+ **Response:**
97
+ ```json
98
+ {
99
+ "symbol": "USD",
100
+ "last": 43.0237,
101
+ "open": 0,
102
+ "high": 0,
103
+ "low": 0,
104
+ "updateTime": "2026-01-02T20:59:58.000Z"
105
+ }
93
106
  ```
94
107
 
95
108
  ### Crypto
96
109
 
97
110
  ```typescript
98
- import { Crypto, cryptoPairs } from 'borsajs';
111
+ import { Crypto, cryptoSymbols } from 'borsajs';
99
112
 
100
- // Available pairs
101
- const pairs = await cryptoPairs(); // ['BTCTRY', 'ETHTRY', ...]
113
+ const pairs = await cryptoSymbols('TRY');
114
+ // ['BTCTRY', 'ETHTRY', 'XRPTRY', ...] (173 pairs)
102
115
 
103
- // Bitcoin/TRY
104
116
  const btc = new Crypto('BTCTRY');
105
117
  const current = await btc.getCurrent();
106
- const history = await btc.getHistory({ period: '1mo' });
118
+ ```
119
+
120
+ **Response:**
121
+ ```json
122
+ {
123
+ "symbol": "BTCTRY",
124
+ "last": 3839080,
125
+ "open": 3822360,
126
+ "high": 3891234,
127
+ "low": 3793804,
128
+ "bid": 3839136,
129
+ "ask": 3840481,
130
+ "volume": 36.22,
131
+ "change": 18121,
132
+ "changePercent": 0.44,
133
+ "timestamp": 1767432414317
134
+ }
135
+ ```
136
+
137
+ ### Index
138
+
139
+ ```typescript
140
+ import { Index, indexSymbols } from 'borsajs';
141
+
142
+ console.log(indexSymbols);
143
+ // → ['XU100', 'XU050', 'XU030', 'XBANK', 'XUSIN', ...]
144
+
145
+ const xu100 = new Index('XU100');
146
+ const info = await xu100.getInfo();
147
+ ```
148
+
149
+ **Response:**
150
+ ```json
151
+ {
152
+ "symbol": "XU100",
153
+ "last": 11498.38,
154
+ "open": 11296.52,
155
+ "high": 11498.38,
156
+ "low": 11296.52,
157
+ "change": 236.86,
158
+ "changePercent": 2.1,
159
+ "name": "BIST 100",
160
+ "type": "index"
161
+ }
107
162
  ```
108
163
 
109
164
  ### Fund (Investment Funds)
@@ -111,14 +166,22 @@ const history = await btc.getHistory({ period: '1mo' });
111
166
  ```typescript
112
167
  import { Fund, searchFunds } from 'borsajs';
113
168
 
114
- // Search funds
115
- const results = await searchFunds('bank');
116
-
117
- // Fund data
118
- const fund = new Fund('AAK');
169
+ const results = await searchFunds('ak', 3);
170
+ const fund = new Fund('AOY');
119
171
  const info = await fund.getInfo();
120
- const history = await fund.getHistory({ period: '1mo' });
121
- const performance = await fund.getPerformance();
172
+ ```
173
+
174
+ **Response:**
175
+ ```json
176
+ {
177
+ "fundCode": "AOY",
178
+ "name": "AK PORTFÖY ALTERNATİF ENERJİ YABANCI HİSSE SENEDİ FONU",
179
+ "price": 0.30568,
180
+ "fundSize": 785933047.54,
181
+ "investorCount": 34267,
182
+ "dailyReturn": -0.993,
183
+ "return1y": 77.59
184
+ }
122
185
  ```
123
186
 
124
187
  ### Inflation
@@ -127,48 +190,143 @@ const performance = await fund.getPerformance();
127
190
  import { Inflation } from 'borsajs';
128
191
 
129
192
  const inflation = new Inflation();
130
-
131
- // Latest CPI data
132
193
  const latest = await inflation.getLatest();
133
- const cpi = await inflation.getTufe({ limit: 12 });
194
+ const calc = await inflation.calculate(100000, '2020-01', '2024-01');
195
+ ```
196
+
197
+ **Response (Latest):**
198
+ ```json
199
+ {
200
+ "date": "2025-10-31",
201
+ "yearMonth": "11-2025",
202
+ "yearlyInflation": 31.07,
203
+ "monthlyInflation": 0.87,
204
+ "type": "TUFE"
205
+ }
206
+ ```
207
+
208
+ **Response (Calculate):**
209
+ ```json
210
+ {
211
+ "startDate": "2020-01",
212
+ "endDate": "2024-01",
213
+ "initialValue": 100000,
214
+ "finalValue": 444399.15,
215
+ "totalYears": 4,
216
+ "totalChange": 344.4,
217
+ "avgYearlyInflation": 45.19
218
+ }
219
+ ```
134
220
 
135
- // PPI data
136
- const ppi = await inflation.getUfe({ limit: 12 });
221
+ ### KAP (Public Disclosure Platform)
137
222
 
138
- // Inflation calculator
139
- const result = await inflation.calculate(100000, '2020-01', '2024-01');
140
- console.log(`100,000 TL -> ${result.finalValue.toLocaleString()} TL`);
223
+ ```typescript
224
+ import { getKapProvider } from 'borsajs';
225
+
226
+ const kap = getKapProvider();
227
+ const companies = await kap.getCompanies();
228
+ const search = await kap.search('türk hava');
141
229
  ```
142
230
 
143
- ### VIOP (Derivatives)
231
+ **Response (Companies):**
232
+ ```json
233
+ [
234
+ {
235
+ "ticker": "THYAO",
236
+ "name": "TÜRK HAVA YOLLARI A.O.",
237
+ "city": "İSTANBUL"
238
+ }
239
+ ]
240
+ ```
241
+
242
+ **Response (Search):**
243
+ ```json
244
+ [
245
+ {
246
+ "ticker": "THYAO",
247
+ "name": "TÜRK HAVA YOLLARI A.O.",
248
+ "city": "İSTANBUL"
249
+ }
250
+ ]
251
+ ```
144
252
 
253
+ **KAP Disclosures:**
145
254
  ```typescript
146
- import { VIOP } from 'borsajs';
255
+ const disclosures = await kap.getDisclosures('THYAO', 5);
256
+ ```
147
257
 
148
- const viop = new VIOP();
258
+ **Response (Disclosures):**
259
+ ```json
260
+ [
261
+ {
262
+ "date": "29.12.2025 19:21:18",
263
+ "title": "Haber ve Söylentilere İlişkin Açıklama",
264
+ "disclosureIndex": 1530826,
265
+ "url": "https://www.kap.org.tr/tr/Bildirim/1530826"
266
+ }
267
+ ]
268
+ ```
149
269
 
150
- // Futures
151
- const futures = await viop.getFutures();
152
- const stockFutures = await viop.getStockFutures();
153
- const indexFutures = await viop.getIndexFutures();
270
+ **Expected Disclosure Calendar:**
271
+ ```typescript
272
+ const calendar = await kap.getCalendar('THYAO');
273
+ ```
154
274
 
155
- // Options
156
- const options = await viop.getOptions();
275
+ **Response (Calendar):**
276
+ ```json
277
+ [
278
+ {
279
+ "startDate": "01.01.2026",
280
+ "endDate": "11.03.2026",
281
+ "subject": "Finansal Rapor",
282
+ "period": "Yıllık",
283
+ "year": "2025"
284
+ }
285
+ ]
286
+ ```
157
287
 
158
- // By symbol
159
- const thyaoDerivatives = await viop.getBySymbol('THYAO');
288
+ **Company Details:**
289
+ ```typescript
290
+ const details = await kap.getCompanyDetails('THYAO');
160
291
  ```
161
292
 
162
- ### Companies
293
+ **Response (Company Details):**
294
+ ```json
295
+ {
296
+ "sector": "ULAŞTIRMA VE DEPOLAMA",
297
+ "market": "YILDIZ PAZAR",
298
+ "website": "www.turkishairlines.com / http://investor.turkishairlines.com"
299
+ }
300
+ ```
301
+
302
+ ### Symbols
163
303
 
164
304
  ```typescript
165
- import { companies, searchCompanies } from 'borsajs';
305
+ import { symbols, searchSymbols, cryptoSymbols, fxSymbols, indexSymbols } from 'borsajs';
306
+
307
+ // Stock symbols
308
+ const stocks = symbols(); // → 80 stocks
309
+ const banks = searchSymbols('BNK'); // → ['AKBNK', 'YKBNK', 'SKBNK']
166
310
 
167
- // All companies
168
- const all = await companies();
311
+ // Crypto symbols
312
+ const crypto = await cryptoSymbols('TRY'); // → 173 pairs
169
313
 
170
- // Search companies
171
- const banks = await searchCompanies('bank');
314
+ // FX symbols
315
+ console.log(fxSymbols); // 19 currencies/commodities
316
+
317
+ // Index symbols
318
+ console.log(indexSymbols); // → 19 indices
319
+ ```
320
+
321
+ ### VIOP (Derivatives)
322
+
323
+ ```typescript
324
+ import { VIOP } from 'borsajs';
325
+
326
+ const viop = new VIOP();
327
+ const futures = await viop.getFutures();
328
+ const options = await viop.getOptions();
329
+ const thyao = await viop.getBySymbol('THYAO');
172
330
  ```
173
331
 
174
332
  ### Download (Multiple Tickers)
@@ -176,16 +334,8 @@ const banks = await searchCompanies('bank');
176
334
  ```typescript
177
335
  import { download, Tickers } from 'borsajs';
178
336
 
179
- // Download multiple tickers
180
337
  const data = await download(['THYAO', 'GARAN', 'AKBNK'], { period: '1mo' });
181
- console.log(data['THYAO']); // THYAO's OHLCV data
182
-
183
- // Tickers class
184
- const tickers = new Tickers('THYAO GARAN AKBNK');
185
- for (const [symbol, ticker] of tickers) {
186
- const info = await ticker.getInfo();
187
- console.log(`${symbol}: ${info.last}`);
188
- }
338
+ console.log(data['THYAO']); // THYAO's OHLCV data
189
339
  ```
190
340
 
191
341
  ## Data Sources
@@ -200,20 +350,15 @@ This library accesses publicly available data from the following sources:
200
350
  | Crypto | BtcTurk | [btcturk.com](https://www.btcturk.com/) | Cryptocurrency data |
201
351
  | Fund | TEFAS | [tefas.gov.tr](https://www.tefas.gov.tr/) | Investment fund data |
202
352
  | Inflation | TCMB | [tcmb.gov.tr](https://www.tcmb.gov.tr/) | Inflation data |
353
+ | KAP | KAP | [kap.org.tr](https://www.kap.org.tr/) | Company information |
203
354
  | VIOP | İş Yatırım | [isyatirim.com.tr](https://www.isyatirim.com.tr/) | Futures and options |
204
- | Companies | KAP | [kap.org.tr](https://www.kap.org.tr/) | Company information |
205
355
 
206
356
  ## ⚠️ Important Notices
207
357
 
208
- ### About Data Sources
209
- Data accessed through this library belongs to the third-party sources listed above. The data is subject to the respective terms of service of each provider.
210
-
211
358
  ### Commercial Use
212
359
  **This library is intended for personal and educational use only.**
213
360
 
214
- For commercial use:
215
- - You must obtain explicit permission from the respective data source providers
216
- - The authors of this library are not responsible for any unauthorized commercial use of data
361
+ For commercial use, you must obtain explicit permission from the respective data source providers.
217
362
 
218
363
  ### Reference Project
219
364
  This project is a TypeScript port of the [borsapy](https://github.com/saidsurucu/borsapy) Python library.