@muhammedaksam/borsats 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Muhammed Mustafa AKŞAM
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,304 @@
1
+ # BorsaTS
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@muhammedaksam/borsats)](https://www.npmjs.com/package/@muhammedaksam/borsats)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
6
+ [![CI](https://github.com/muhammedaksam/borsats/workflows/CI/badge.svg)](https://github.com/muhammedaksam/borsats/actions)
7
+ [![codecov](https://codecov.io/gh/muhammedaksam/borsats/branch/main/graph/badge.svg)](https://codecov.io/gh/muhammedaksam/borsats)
8
+ [![Node.js](https://img.shields.io/badge/Node.js-20%2B-green.svg)](https://nodejs.org/)
9
+
10
+ > **Disclaimer**
11
+ >
12
+ > This library is for personal and educational use only. It cannot be used for developing commercial software products, commercial services, or any commercial purposes. For commercial use, you must contact Borsa Istanbul to purchase an appropriate license.
13
+
14
+ Turkish financial markets data library for TypeScript/JavaScript. A yfinance-like API for BIST stocks, forex, crypto, investment funds, and economic data.
15
+
16
+ **Inspired by [borsapy](https://github.com/saidsurucu/borsapy/)** - bringing the same powerful functionality to the TypeScript ecosystem.
17
+
18
+ ## Features
19
+
20
+ - 📈 **BIST Stocks** - Real-time quotes, financial statements, dividends
21
+ - 💱 **65+ Currencies** - Forex rates, bank rates, precious metals
22
+ - 🪙 **Cryptocurrencies** - BTC, ETH, and more via BTCTurk
23
+ - 🏦 **Investment Funds** - TEFAS fund data, performance, allocation
24
+ - 📊 **79 BIST Indices** - XU100, XU030, XKTUM, and more
25
+ - 📉 **Technical Indicators** - RSI, MACD, Bollinger Bands, and more
26
+ - 💼 **Portfolio Management** - Track performance, calculate risk metrics
27
+ - 🔍 **Stock Screener** - Filter by fundamentals
28
+ - 🌐 **Works in Node.js and Browser**
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ npm install @muhammedaksam/borsats
34
+ ```
35
+
36
+ ```bash
37
+ yarn add @muhammedaksam/borsats
38
+ ```
39
+
40
+ ```bash
41
+ pnpm add @muhammedaksam/borsats
42
+ ```
43
+
44
+ ## Quick Start
45
+
46
+ ```typescript
47
+ import { Crypto, Fund, FX, Ticker } from "@muhammedaksam/borsats";
48
+
49
+ // Stock data
50
+ const stock = new Ticker("THYAO");
51
+ console.log(await stock.info); // Real-time quote
52
+ console.log(await stock.history({ period: "1mo" })); // OHLCV data
53
+ console.log(await stock.balanceSheet); // Financial statements
54
+
55
+ // Forex
56
+ const usd = new FX("USD");
57
+ console.log(await usd.current); // Current rate
58
+ console.log(await usd.history({ period: "1mo" })); // Historical data
59
+ console.log(await usd.bankRates); // All bank rates
60
+
61
+ // Cryptocurrency
62
+ const btc = new Crypto("BTCTRY");
63
+ console.log(await btc.current); // Current price
64
+ console.log(await btc.history({ period: "1mo" })); // Historical OHLCV
65
+
66
+ // Investment Fund
67
+ const fund = new Fund("AAK");
68
+ console.log(await fund.info); // Fund details
69
+ console.log(await fund.performance); // Performance metrics
70
+ ```
71
+
72
+ ## Documentation
73
+
74
+ ### Ticker (BIST Stocks)
75
+
76
+ ```typescript
77
+ import { Ticker } from "@muhammedaksam/borsats";
78
+
79
+ const stock = new Ticker("THYAO");
80
+
81
+ // Fast info (cached, no API call)
82
+ const fastInfo = await stock.fastInfo;
83
+ console.log(fastInfo.lastPrice);
84
+ console.log(fastInfo.marketCap);
85
+ console.log(fastInfo.peRatio);
86
+
87
+ // Detailed info
88
+ const info = await stock.info;
89
+ console.log(info.last);
90
+ console.log(info.trailingPE);
91
+ console.log(info.dividendYield);
92
+
93
+ // Historical data
94
+ const history = await stock.history({
95
+ period: "1y",
96
+ interval: "1d",
97
+ actions: true, // Include dividends/splits
98
+ });
99
+
100
+ // Financial statements
101
+ const balanceSheet = await stock.balanceSheet;
102
+ const incomeStmt = await stock.incomeStmt;
103
+ const cashflow = await stock.cashflow;
104
+
105
+ // Quarterly statements
106
+ const qBalanceSheet = await stock.quarterlyBalanceSheet;
107
+ const qIncomeStmt = await stock.quarterlyIncomeStmt;
108
+
109
+ // Corporate actions
110
+ const dividends = await stock.dividends;
111
+ const splits = await stock.splits;
112
+
113
+ // Company info
114
+ const holders = await stock.majorHolders;
115
+ const news = await stock.news;
116
+ ```
117
+
118
+ ### FX (Forex and Commodities)
119
+
120
+ ```typescript
121
+ import { banks, FX } from "@muhammedaksam/borsats";
122
+
123
+ const usd = new FX("USD");
124
+
125
+ // Current rate
126
+ console.log(await usd.current);
127
+
128
+ // Historical data
129
+ console.log(await usd.history({ period: "1mo" }));
130
+
131
+ // Intraday data (for supported pairs)
132
+ console.log(await usd.history({ period: "1d", interval: "1m" }));
133
+
134
+ // Bank rates
135
+ console.log(await usd.bankRates); // All banks
136
+ console.log(await usd.bankRate("akbank")); // Specific bank
137
+
138
+ // Supported banks
139
+ console.log(banks());
140
+
141
+ // Precious metals
142
+ const gold = new FX("gram-altin");
143
+ console.log(await gold.current);
144
+ console.log(await gold.institutionRates); // All dealers
145
+ console.log(await gold.institutionRate("kapalicarsi")); // Specific dealer
146
+
147
+ // Commodities
148
+ const brent = new FX("BRENT");
149
+ const silver = new FX("XAG-USD");
150
+ ```
151
+
152
+ ### Index (BIST Indices)
153
+
154
+ ```typescript
155
+ import { allIndices, Index, indices } from "@muhammedaksam/borsats";
156
+
157
+ // List indices
158
+ console.log(indices()); // Popular indices
159
+ console.log(allIndices()); // All 79 indices
160
+
161
+ // Index data
162
+ const xu100 = new Index("XU100");
163
+ console.log(await xu100.info); // Current value
164
+ console.log(await xu100.history({ period: "1y" })); // Historical data
165
+
166
+ // Components
167
+ console.log(await xu100.components); // All stocks with details
168
+ console.log(await xu100.componentSymbols); // Just symbols
169
+ ```
170
+
171
+ ### Crypto (Cryptocurrency)
172
+
173
+ ```typescript
174
+ import { Crypto, cryptoPairs } from "@muhammedaksam/borsats";
175
+
176
+ // List available pairs
177
+ console.log(await cryptoPairs());
178
+
179
+ // Crypto data
180
+ const btc = new Crypto("BTCTRY");
181
+ console.log(await btc.current); // Current price
182
+ console.log(await btc.history({ period: "1mo" })); // OHLCV data
183
+ ```
184
+
185
+ ### Fund (Investment Funds)
186
+
187
+ ```typescript
188
+ import { Fund, screenFunds, searchFunds } from "@muhammedaksam/borsats";
189
+
190
+ // Search funds
191
+ console.log(await searchFunds("banka"));
192
+
193
+ // Screen funds
194
+ console.log(
195
+ await screenFunds({
196
+ fundType: "YAT",
197
+ minReturn1y: 50,
198
+ }),
199
+ );
200
+
201
+ // Fund data
202
+ const fund = new Fund("AAK");
203
+ console.log(await fund.info); // Fund details
204
+ console.log(await fund.history({ period: "1y" })); // NAV history
205
+ console.log(await fund.performance); // Performance metrics
206
+ console.log(await fund.allocation); // Asset allocation
207
+ console.log(await fund.riskMetrics({ period: "1y" })); // Sharpe, Sortino, etc.
208
+ ```
209
+
210
+ ### Portfolio Management
211
+
212
+ ```typescript
213
+ import { Portfolio } from "@muhammedaksam/borsats";
214
+
215
+ const portfolio = new Portfolio();
216
+
217
+ // Add holdings
218
+ portfolio
219
+ .add("THYAO", { shares: 100, cost: 280 })
220
+ .add("GARAN", { shares: 200, cost: 50 })
221
+ .add("USD", { shares: 1000, assetType: "fx" })
222
+ .add("gram-altin", { shares: 10, assetType: "fx" })
223
+ .add("BTCTRY", { shares: 0.5 })
224
+ .add("AAK", { shares: 1000, assetType: "fund" });
225
+
226
+ // Set benchmark
227
+ portfolio.setBenchmark("XU100");
228
+
229
+ // Portfolio stats
230
+ console.log(portfolio.value); // Total value
231
+ console.log(portfolio.cost); // Total cost
232
+ console.log(portfolio.pnl); // Profit/loss
233
+ console.log(portfolio.pnlPct); // P/L percentage
234
+ console.log(portfolio.weights); // Asset weights
235
+
236
+ // Performance
237
+ console.log(await portfolio.history({ period: "1y" }));
238
+ console.log(await portfolio.riskMetrics({ period: "1y" }));
239
+ console.log(await portfolio.sharpeRatio());
240
+ console.log(await portfolio.beta());
241
+
242
+ // Export/Import
243
+ const data = portfolio.toDict();
244
+ const newPortfolio = Portfolio.fromDict(data);
245
+ ```
246
+
247
+ ### Technical Analysis
248
+
249
+ ```typescript
250
+ import { Ticker } from "@muhammedaksam/borsats";
251
+
252
+ const stock = new Ticker("THYAO");
253
+
254
+ // Single values
255
+ console.log(await stock.rsi()); // RSI(14)
256
+ console.log(await stock.sma({ period: 20 })); // SMA(20)
257
+ console.log(await stock.ema({ period: 12 })); // EMA(12)
258
+ console.log(await stock.macd()); // MACD
259
+ console.log(await stock.bollingerBands()); // Bollinger Bands
260
+
261
+ // Technical analyzer
262
+ const ta = await stock.technicals({ period: "1y" });
263
+ console.log(ta.latest); // All indicators at once
264
+ console.log(ta.rsi()); // Full RSI series
265
+ console.log(ta.macd()); // Full MACD series
266
+
267
+ // History with indicators
268
+ const df = await stock.historyWithIndicators({
269
+ period: "3mo",
270
+ indicators: ["sma", "rsi", "macd"],
271
+ });
272
+ ```
273
+
274
+ ## Environment Support
275
+
276
+ This library works in both Node.js and browser environments:
277
+
278
+ - **Node.js**: Full support with all features
279
+ - **Browser**: Compatible when bundled (some features may require CORS-enabled APIs)
280
+
281
+ ## API Rate Limiting
282
+
283
+ The library includes built-in rate limiting and retry logic:
284
+
285
+ - Automatic retries with exponential backoff
286
+ - Default: 60 requests per minute per provider
287
+ - Configurable per provider
288
+ - Response caching to reduce API calls
289
+
290
+ ## License
291
+
292
+ MIT © [Muhammed Mustafa AKŞAM](https://github.com/muhammedaksam)
293
+
294
+ ## Credits
295
+
296
+ Inspired by and based on [borsapy](https://github.com/saidsurucu/borsapy/) by Said Sürücü.
297
+
298
+ ## Contributing
299
+
300
+ Contributions are welcome! Please feel free to submit a Pull Request.
301
+
302
+ ## Disclaimer
303
+
304
+ This library is for educational and informational purposes only. It is not financial advice. Always do your own research before making investment decisions.