borsapy.index
Index class for market index data - yfinance-like API.
1"""Index class for market index data - yfinance-like API.""" 2 3from datetime import datetime 4from typing import Any 5 6import pandas as pd 7 8from borsapy._providers.bist_index import get_bist_index_provider 9from borsapy._providers.tradingview import get_tradingview_provider 10from borsapy.technical import TechnicalMixin 11 12# Known market indices with their names 13INDICES = { 14 # Main indices 15 "XU100": "BIST 100", 16 "XU050": "BIST 50", 17 "XU030": "BIST 30", 18 "XUTUM": "BIST Tüm", 19 # Participation (Katılım) indices 20 "XKTUM": "BIST Katılım Tüm", 21 "XK100": "BIST Katılım 100", 22 "XK050": "BIST Katılım 50", 23 "XK030": "BIST Katılım 30", 24 "XKTMT": "BIST Katılım Model Portföy", 25 # Sector indices 26 "XBANK": "BIST Banka", 27 "XUSIN": "BIST Sınai", 28 "XUMAL": "BIST Mali", 29 "XHOLD": "BIST Holding ve Yatırım", 30 "XUTEK": "BIST Teknoloji", 31 "XGIDA": "BIST Gıda", 32 "XTRZM": "BIST Turizm", 33 "XULAS": "BIST Ulaştırma", 34 "XSGRT": "BIST Sigorta", 35 "XMANA": "BIST Metal Ana", 36 "XKMYA": "BIST Kimya", 37 "XMADN": "BIST Maden", 38 "XELKT": "BIST Elektrik", 39 "XTEKS": "BIST Tekstil", 40 "XILTM": "BIST İletişim", 41 # Thematic indices 42 "XSRDK": "BIST Sürdürülebilirlik", 43 "XKURY": "BIST Kurumsal Yönetim", 44 "XYLDZ": "BIST Yıldız", 45 "XBANA": "BIST Banka Dışı Likit 10", 46 "XSPOR": "BIST Spor", 47 "XGMYO": "BIST GYO", 48 "XTUMY": "BIST Tüm-100", 49 "XYORT": "BIST Yatırım Ortaklıkları", 50 "XSDNZ": "BIST Seçme Divident", 51} 52 53 54class Index(TechnicalMixin): 55 """ 56 A yfinance-like interface for Turkish market indices. 57 58 Examples: 59 >>> import borsapy as bp 60 >>> xu100 = bp.Index("XU100") 61 >>> xu100.info 62 {'symbol': 'XU100', 'name': 'BIST 100', 'last': 9500.5, ...} 63 >>> xu100.history(period="1mo") 64 Open High Low Close Volume 65 Date 66 2024-12-01 9400.00 9550.00 9380.00 9500.50 1234567890 67 ... 68 69 # Available indices 70 >>> bp.indices() 71 ['XU100', 'XU050', 'XU030', 'XBANK', ...] 72 """ 73 74 def __init__(self, symbol: str): 75 """ 76 Initialize an Index object. 77 78 Args: 79 symbol: Index symbol (e.g., "XU100", "XU030", "XBANK"). 80 """ 81 self._symbol = symbol.upper() 82 self._tradingview = get_tradingview_provider() 83 self._bist_index = get_bist_index_provider() 84 self._info_cache: dict[str, Any] | None = None 85 self._components_cache: list[dict[str, Any]] | None = None 86 87 @property 88 def symbol(self) -> str: 89 """Return the index symbol.""" 90 return self._symbol 91 92 @property 93 def info(self) -> dict[str, Any]: 94 """ 95 Get current index information. 96 97 Returns: 98 Dictionary with index data: 99 - symbol: Index symbol 100 - name: Index full name 101 - last: Current value 102 - open: Opening value 103 - high: Day high 104 - low: Day low 105 - close: Previous close 106 - change: Value change 107 - change_percent: Percent change 108 - update_time: Last update timestamp 109 """ 110 if self._info_cache is None: 111 # Use TradingView API to get quote (same endpoint works for indices) 112 quote = self._tradingview.get_quote(self._symbol) 113 quote["name"] = INDICES.get(self._symbol, self._symbol) 114 quote["type"] = "index" 115 self._info_cache = quote 116 return self._info_cache 117 118 @property 119 def components(self) -> list[dict[str, Any]]: 120 """ 121 Get constituent stocks of this index. 122 123 Returns: 124 List of component dicts with 'symbol' and 'name' keys. 125 Empty list if index components are not available. 126 127 Examples: 128 >>> import borsapy as bp 129 >>> xu030 = bp.Index("XU030") 130 >>> xu030.components 131 [{'symbol': 'AKBNK', 'name': 'AKBANK'}, ...] 132 >>> len(xu030.components) 133 30 134 """ 135 if self._components_cache is None: 136 self._components_cache = self._bist_index.get_components(self._symbol) 137 return self._components_cache 138 139 @property 140 def component_symbols(self) -> list[str]: 141 """ 142 Get just the ticker symbols of constituent stocks. 143 144 Returns: 145 List of stock symbols. 146 147 Examples: 148 >>> import borsapy as bp 149 >>> xu030 = bp.Index("XU030") 150 >>> xu030.component_symbols 151 ['AKBNK', 'AKSA', 'AKSEN', ...] 152 """ 153 return [c["symbol"] for c in self.components] 154 155 def history( 156 self, 157 period: str = "1mo", 158 interval: str = "1d", 159 start: datetime | str | None = None, 160 end: datetime | str | None = None, 161 ) -> pd.DataFrame: 162 """ 163 Get historical index data. 164 165 Args: 166 period: How much data to fetch. Valid periods: 167 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, ytd, max. 168 Ignored if start is provided. 169 interval: Data interval. Valid intervals: 170 1m, 5m, 15m, 30m, 1h, 1d, 1wk, 1mo. 171 start: Start date (string or datetime). 172 end: End date (string or datetime). Defaults to today. 173 174 Returns: 175 DataFrame with columns: Open, High, Low, Close, Volume. 176 Index is the Date. 177 178 Examples: 179 >>> idx = Index("XU100") 180 >>> idx.history(period="1mo") # Last month 181 >>> idx.history(period="1y") # Last year 182 >>> idx.history(start="2024-01-01", end="2024-06-30") 183 """ 184 # Parse dates 185 start_dt = self._parse_date(start) if start else None 186 end_dt = self._parse_date(end) if end else None 187 188 # Use TradingView provider (same API works for indices) 189 return self._tradingview.get_history( 190 symbol=self._symbol, 191 period=period, 192 interval=interval, 193 start=start_dt, 194 end=end_dt, 195 ) 196 197 def _parse_date(self, date: str | datetime) -> datetime: 198 """Parse a date string to datetime.""" 199 if isinstance(date, datetime): 200 return date 201 for fmt in ["%Y-%m-%d", "%Y/%m/%d", "%d-%m-%Y", "%d/%m/%Y"]: 202 try: 203 return datetime.strptime(date, fmt) 204 except ValueError: 205 continue 206 raise ValueError(f"Could not parse date: {date}") 207 208 def _get_ta_symbol_info(self) -> tuple[str, str]: 209 """Get TradingView symbol and screener for TA signals. 210 211 Returns: 212 Tuple of (tv_symbol, screener) for TradingView Scanner API. 213 """ 214 return (f"BIST:{self._symbol}", "turkey") 215 216 def scan( 217 self, 218 condition: str, 219 period: str = "3mo", 220 interval: str = "1d", 221 ) -> "pd.DataFrame": 222 """Scan index components for technical conditions. 223 224 Convenience method for scanning all stocks in this index. 225 226 Args: 227 condition: Condition string (e.g., "rsi < 30", "price > sma_50") 228 period: Historical data period for indicator calculation 229 interval: Data interval 230 231 Returns: 232 DataFrame with matching symbols and their data 233 234 Examples: 235 >>> import borsapy as bp 236 >>> xu030 = bp.Index("XU030") 237 >>> xu030.scan("rsi < 30") 238 >>> xu030.scan("price > sma_50 and rsi > 50") 239 >>> xu030.scan("sma_20 crosses_above sma_50") 240 """ 241 from borsapy.scanner import scan 242 243 return scan(self.component_symbols, condition, period, interval) 244 245 def __repr__(self) -> str: 246 return f"Index('{self._symbol}')" 247 248 249def indices(detailed: bool = False) -> list[str] | list[dict[str, Any]]: 250 """ 251 Get list of available market indices. 252 253 Args: 254 detailed: If True, return list of dicts with symbol, name, and count. 255 If False (default), return just the symbol list. 256 257 Returns: 258 List of index symbols, or list of dicts if detailed=True. 259 260 Examples: 261 >>> import borsapy as bp 262 >>> bp.indices() 263 ['XU100', 'XU050', 'XU030', 'XBANK', 'XUSIN', ...] 264 >>> bp.indices(detailed=True) 265 [{'symbol': 'XU100', 'name': 'BIST 100', 'count': 100}, ...] 266 """ 267 if not detailed: 268 return list(INDICES.keys()) 269 270 # Get component counts from provider 271 provider = get_bist_index_provider() 272 available = provider.get_available_indices() 273 274 # Create lookup for counts 275 count_map = {item["symbol"]: item["count"] for item in available} 276 277 result = [] 278 for symbol, name in INDICES.items(): 279 result.append({ 280 "symbol": symbol, 281 "name": name, 282 "count": count_map.get(symbol, 0), 283 }) 284 return result 285 286 287def all_indices() -> list[dict[str, Any]]: 288 """ 289 Get all indices from BIST with component counts. 290 291 This returns all 79 indices available in the BIST data, 292 not just the commonly used ones in indices(). 293 294 Returns: 295 List of dicts with 'symbol', 'name', and 'count' keys. 296 297 Examples: 298 >>> import borsapy as bp 299 >>> bp.all_indices() 300 [{'symbol': 'X030C', 'name': 'BIST 30 Capped', 'count': 30}, ...] 301 """ 302 provider = get_bist_index_provider() 303 return provider.get_available_indices() 304 305 306def index(symbol: str) -> Index: 307 """ 308 Get an Index object for the given symbol. 309 310 This is a convenience function that creates an Index object. 311 312 Args: 313 symbol: Index symbol (e.g., "XU100", "XBANK"). 314 315 Returns: 316 Index object. 317 318 Examples: 319 >>> import borsapy as bp 320 >>> xu100 = bp.index("XU100") 321 >>> xu100.history(period="1mo") 322 """ 323 return Index(symbol)
55class Index(TechnicalMixin): 56 """ 57 A yfinance-like interface for Turkish market indices. 58 59 Examples: 60 >>> import borsapy as bp 61 >>> xu100 = bp.Index("XU100") 62 >>> xu100.info 63 {'symbol': 'XU100', 'name': 'BIST 100', 'last': 9500.5, ...} 64 >>> xu100.history(period="1mo") 65 Open High Low Close Volume 66 Date 67 2024-12-01 9400.00 9550.00 9380.00 9500.50 1234567890 68 ... 69 70 # Available indices 71 >>> bp.indices() 72 ['XU100', 'XU050', 'XU030', 'XBANK', ...] 73 """ 74 75 def __init__(self, symbol: str): 76 """ 77 Initialize an Index object. 78 79 Args: 80 symbol: Index symbol (e.g., "XU100", "XU030", "XBANK"). 81 """ 82 self._symbol = symbol.upper() 83 self._tradingview = get_tradingview_provider() 84 self._bist_index = get_bist_index_provider() 85 self._info_cache: dict[str, Any] | None = None 86 self._components_cache: list[dict[str, Any]] | None = None 87 88 @property 89 def symbol(self) -> str: 90 """Return the index symbol.""" 91 return self._symbol 92 93 @property 94 def info(self) -> dict[str, Any]: 95 """ 96 Get current index information. 97 98 Returns: 99 Dictionary with index data: 100 - symbol: Index symbol 101 - name: Index full name 102 - last: Current value 103 - open: Opening value 104 - high: Day high 105 - low: Day low 106 - close: Previous close 107 - change: Value change 108 - change_percent: Percent change 109 - update_time: Last update timestamp 110 """ 111 if self._info_cache is None: 112 # Use TradingView API to get quote (same endpoint works for indices) 113 quote = self._tradingview.get_quote(self._symbol) 114 quote["name"] = INDICES.get(self._symbol, self._symbol) 115 quote["type"] = "index" 116 self._info_cache = quote 117 return self._info_cache 118 119 @property 120 def components(self) -> list[dict[str, Any]]: 121 """ 122 Get constituent stocks of this index. 123 124 Returns: 125 List of component dicts with 'symbol' and 'name' keys. 126 Empty list if index components are not available. 127 128 Examples: 129 >>> import borsapy as bp 130 >>> xu030 = bp.Index("XU030") 131 >>> xu030.components 132 [{'symbol': 'AKBNK', 'name': 'AKBANK'}, ...] 133 >>> len(xu030.components) 134 30 135 """ 136 if self._components_cache is None: 137 self._components_cache = self._bist_index.get_components(self._symbol) 138 return self._components_cache 139 140 @property 141 def component_symbols(self) -> list[str]: 142 """ 143 Get just the ticker symbols of constituent stocks. 144 145 Returns: 146 List of stock symbols. 147 148 Examples: 149 >>> import borsapy as bp 150 >>> xu030 = bp.Index("XU030") 151 >>> xu030.component_symbols 152 ['AKBNK', 'AKSA', 'AKSEN', ...] 153 """ 154 return [c["symbol"] for c in self.components] 155 156 def history( 157 self, 158 period: str = "1mo", 159 interval: str = "1d", 160 start: datetime | str | None = None, 161 end: datetime | str | None = None, 162 ) -> pd.DataFrame: 163 """ 164 Get historical index data. 165 166 Args: 167 period: How much data to fetch. Valid periods: 168 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, ytd, max. 169 Ignored if start is provided. 170 interval: Data interval. Valid intervals: 171 1m, 5m, 15m, 30m, 1h, 1d, 1wk, 1mo. 172 start: Start date (string or datetime). 173 end: End date (string or datetime). Defaults to today. 174 175 Returns: 176 DataFrame with columns: Open, High, Low, Close, Volume. 177 Index is the Date. 178 179 Examples: 180 >>> idx = Index("XU100") 181 >>> idx.history(period="1mo") # Last month 182 >>> idx.history(period="1y") # Last year 183 >>> idx.history(start="2024-01-01", end="2024-06-30") 184 """ 185 # Parse dates 186 start_dt = self._parse_date(start) if start else None 187 end_dt = self._parse_date(end) if end else None 188 189 # Use TradingView provider (same API works for indices) 190 return self._tradingview.get_history( 191 symbol=self._symbol, 192 period=period, 193 interval=interval, 194 start=start_dt, 195 end=end_dt, 196 ) 197 198 def _parse_date(self, date: str | datetime) -> datetime: 199 """Parse a date string to datetime.""" 200 if isinstance(date, datetime): 201 return date 202 for fmt in ["%Y-%m-%d", "%Y/%m/%d", "%d-%m-%Y", "%d/%m/%Y"]: 203 try: 204 return datetime.strptime(date, fmt) 205 except ValueError: 206 continue 207 raise ValueError(f"Could not parse date: {date}") 208 209 def _get_ta_symbol_info(self) -> tuple[str, str]: 210 """Get TradingView symbol and screener for TA signals. 211 212 Returns: 213 Tuple of (tv_symbol, screener) for TradingView Scanner API. 214 """ 215 return (f"BIST:{self._symbol}", "turkey") 216 217 def scan( 218 self, 219 condition: str, 220 period: str = "3mo", 221 interval: str = "1d", 222 ) -> "pd.DataFrame": 223 """Scan index components for technical conditions. 224 225 Convenience method for scanning all stocks in this index. 226 227 Args: 228 condition: Condition string (e.g., "rsi < 30", "price > sma_50") 229 period: Historical data period for indicator calculation 230 interval: Data interval 231 232 Returns: 233 DataFrame with matching symbols and their data 234 235 Examples: 236 >>> import borsapy as bp 237 >>> xu030 = bp.Index("XU030") 238 >>> xu030.scan("rsi < 30") 239 >>> xu030.scan("price > sma_50 and rsi > 50") 240 >>> xu030.scan("sma_20 crosses_above sma_50") 241 """ 242 from borsapy.scanner import scan 243 244 return scan(self.component_symbols, condition, period, interval) 245 246 def __repr__(self) -> str: 247 return f"Index('{self._symbol}')"
A yfinance-like interface for Turkish market indices.
Examples:
import borsapy as bp xu100 = bp.Index("XU100") xu100.info {'symbol': 'XU100', 'name': 'BIST 100', 'last': 9500.5, ...} xu100.history(period="1mo") Open High Low Close Volume Date 2024-12-01 9400.00 9550.00 9380.00 9500.50 1234567890 ...
# Available indices >>> bp.indices() ['XU100', 'XU050', 'XU030', 'XBANK', ...]
75 def __init__(self, symbol: str): 76 """ 77 Initialize an Index object. 78 79 Args: 80 symbol: Index symbol (e.g., "XU100", "XU030", "XBANK"). 81 """ 82 self._symbol = symbol.upper() 83 self._tradingview = get_tradingview_provider() 84 self._bist_index = get_bist_index_provider() 85 self._info_cache: dict[str, Any] | None = None 86 self._components_cache: list[dict[str, Any]] | None = None
Initialize an Index object.
Args: symbol: Index symbol (e.g., "XU100", "XU030", "XBANK").
93 @property 94 def info(self) -> dict[str, Any]: 95 """ 96 Get current index information. 97 98 Returns: 99 Dictionary with index data: 100 - symbol: Index symbol 101 - name: Index full name 102 - last: Current value 103 - open: Opening value 104 - high: Day high 105 - low: Day low 106 - close: Previous close 107 - change: Value change 108 - change_percent: Percent change 109 - update_time: Last update timestamp 110 """ 111 if self._info_cache is None: 112 # Use TradingView API to get quote (same endpoint works for indices) 113 quote = self._tradingview.get_quote(self._symbol) 114 quote["name"] = INDICES.get(self._symbol, self._symbol) 115 quote["type"] = "index" 116 self._info_cache = quote 117 return self._info_cache
Get current index information.
Returns: Dictionary with index data: - symbol: Index symbol - name: Index full name - last: Current value - open: Opening value - high: Day high - low: Day low - close: Previous close - change: Value change - change_percent: Percent change - update_time: Last update timestamp
119 @property 120 def components(self) -> list[dict[str, Any]]: 121 """ 122 Get constituent stocks of this index. 123 124 Returns: 125 List of component dicts with 'symbol' and 'name' keys. 126 Empty list if index components are not available. 127 128 Examples: 129 >>> import borsapy as bp 130 >>> xu030 = bp.Index("XU030") 131 >>> xu030.components 132 [{'symbol': 'AKBNK', 'name': 'AKBANK'}, ...] 133 >>> len(xu030.components) 134 30 135 """ 136 if self._components_cache is None: 137 self._components_cache = self._bist_index.get_components(self._symbol) 138 return self._components_cache
Get constituent stocks of this index.
Returns: List of component dicts with 'symbol' and 'name' keys. Empty list if index components are not available.
Examples:
import borsapy as bp xu030 = bp.Index("XU030") xu030.components [{'symbol': 'AKBNK', 'name': 'AKBANK'}, ...] len(xu030.components) 30
140 @property 141 def component_symbols(self) -> list[str]: 142 """ 143 Get just the ticker symbols of constituent stocks. 144 145 Returns: 146 List of stock symbols. 147 148 Examples: 149 >>> import borsapy as bp 150 >>> xu030 = bp.Index("XU030") 151 >>> xu030.component_symbols 152 ['AKBNK', 'AKSA', 'AKSEN', ...] 153 """ 154 return [c["symbol"] for c in self.components]
Get just the ticker symbols of constituent stocks.
Returns: List of stock symbols.
Examples:
import borsapy as bp xu030 = bp.Index("XU030") xu030.component_symbols ['AKBNK', 'AKSA', 'AKSEN', ...]
156 def history( 157 self, 158 period: str = "1mo", 159 interval: str = "1d", 160 start: datetime | str | None = None, 161 end: datetime | str | None = None, 162 ) -> pd.DataFrame: 163 """ 164 Get historical index data. 165 166 Args: 167 period: How much data to fetch. Valid periods: 168 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, ytd, max. 169 Ignored if start is provided. 170 interval: Data interval. Valid intervals: 171 1m, 5m, 15m, 30m, 1h, 1d, 1wk, 1mo. 172 start: Start date (string or datetime). 173 end: End date (string or datetime). Defaults to today. 174 175 Returns: 176 DataFrame with columns: Open, High, Low, Close, Volume. 177 Index is the Date. 178 179 Examples: 180 >>> idx = Index("XU100") 181 >>> idx.history(period="1mo") # Last month 182 >>> idx.history(period="1y") # Last year 183 >>> idx.history(start="2024-01-01", end="2024-06-30") 184 """ 185 # Parse dates 186 start_dt = self._parse_date(start) if start else None 187 end_dt = self._parse_date(end) if end else None 188 189 # Use TradingView provider (same API works for indices) 190 return self._tradingview.get_history( 191 symbol=self._symbol, 192 period=period, 193 interval=interval, 194 start=start_dt, 195 end=end_dt, 196 )
Get historical index data.
Args: period: How much data to fetch. Valid periods: 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, ytd, max. Ignored if start is provided. interval: Data interval. Valid intervals: 1m, 5m, 15m, 30m, 1h, 1d, 1wk, 1mo. start: Start date (string or datetime). end: End date (string or datetime). Defaults to today.
Returns: DataFrame with columns: Open, High, Low, Close, Volume. Index is the Date.
Examples:
idx = Index("XU100") idx.history(period="1mo") # Last month idx.history(period="1y") # Last year idx.history(start="2024-01-01", end="2024-06-30")
217 def scan( 218 self, 219 condition: str, 220 period: str = "3mo", 221 interval: str = "1d", 222 ) -> "pd.DataFrame": 223 """Scan index components for technical conditions. 224 225 Convenience method for scanning all stocks in this index. 226 227 Args: 228 condition: Condition string (e.g., "rsi < 30", "price > sma_50") 229 period: Historical data period for indicator calculation 230 interval: Data interval 231 232 Returns: 233 DataFrame with matching symbols and their data 234 235 Examples: 236 >>> import borsapy as bp 237 >>> xu030 = bp.Index("XU030") 238 >>> xu030.scan("rsi < 30") 239 >>> xu030.scan("price > sma_50 and rsi > 50") 240 >>> xu030.scan("sma_20 crosses_above sma_50") 241 """ 242 from borsapy.scanner import scan 243 244 return scan(self.component_symbols, condition, period, interval)
Scan index components for technical conditions.
Convenience method for scanning all stocks in this index.
Args: condition: Condition string (e.g., "rsi < 30", "price > sma_50") period: Historical data period for indicator calculation interval: Data interval
Returns: DataFrame with matching symbols and their data
Examples:
import borsapy as bp xu030 = bp.Index("XU030") xu030.scan("rsi < 30") xu030.scan("price > sma_50 and rsi > 50") xu030.scan("sma_20 crosses_above sma_50")
250def indices(detailed: bool = False) -> list[str] | list[dict[str, Any]]: 251 """ 252 Get list of available market indices. 253 254 Args: 255 detailed: If True, return list of dicts with symbol, name, and count. 256 If False (default), return just the symbol list. 257 258 Returns: 259 List of index symbols, or list of dicts if detailed=True. 260 261 Examples: 262 >>> import borsapy as bp 263 >>> bp.indices() 264 ['XU100', 'XU050', 'XU030', 'XBANK', 'XUSIN', ...] 265 >>> bp.indices(detailed=True) 266 [{'symbol': 'XU100', 'name': 'BIST 100', 'count': 100}, ...] 267 """ 268 if not detailed: 269 return list(INDICES.keys()) 270 271 # Get component counts from provider 272 provider = get_bist_index_provider() 273 available = provider.get_available_indices() 274 275 # Create lookup for counts 276 count_map = {item["symbol"]: item["count"] for item in available} 277 278 result = [] 279 for symbol, name in INDICES.items(): 280 result.append({ 281 "symbol": symbol, 282 "name": name, 283 "count": count_map.get(symbol, 0), 284 }) 285 return result
Get list of available market indices.
Args: detailed: If True, return list of dicts with symbol, name, and count. If False (default), return just the symbol list.
Returns: List of index symbols, or list of dicts if detailed=True.
Examples:
import borsapy as bp bp.indices() ['XU100', 'XU050', 'XU030', 'XBANK', 'XUSIN', ...] bp.indices(detailed=True) [{'symbol': 'XU100', 'name': 'BIST 100', 'count': 100}, ...]
288def all_indices() -> list[dict[str, Any]]: 289 """ 290 Get all indices from BIST with component counts. 291 292 This returns all 79 indices available in the BIST data, 293 not just the commonly used ones in indices(). 294 295 Returns: 296 List of dicts with 'symbol', 'name', and 'count' keys. 297 298 Examples: 299 >>> import borsapy as bp 300 >>> bp.all_indices() 301 [{'symbol': 'X030C', 'name': 'BIST 30 Capped', 'count': 30}, ...] 302 """ 303 provider = get_bist_index_provider() 304 return provider.get_available_indices()
Get all indices from BIST with component counts.
This returns all 79 indices available in the BIST data, not just the commonly used ones in indices().
Returns: List of dicts with 'symbol', 'name', and 'count' keys.
Examples:
import borsapy as bp bp.all_indices() [{'symbol': 'X030C', 'name': 'BIST 30 Capped', 'count': 30}, ...]
307def index(symbol: str) -> Index: 308 """ 309 Get an Index object for the given symbol. 310 311 This is a convenience function that creates an Index object. 312 313 Args: 314 symbol: Index symbol (e.g., "XU100", "XBANK"). 315 316 Returns: 317 Index object. 318 319 Examples: 320 >>> import borsapy as bp 321 >>> xu100 = bp.index("XU100") 322 >>> xu100.history(period="1mo") 323 """ 324 return Index(symbol)
Get an Index object for the given symbol.
This is a convenience function that creates an Index object.
Args: symbol: Index symbol (e.g., "XU100", "XBANK").
Returns: Index object.
Examples:
import borsapy as bp xu100 = bp.index("XU100") xu100.history(period="1mo")