# settfex
> Your friendly Python library for fetching Thai stock market data ๐น๐ญ
[](https://badge.fury.io/py/settfex)
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/MIT)
**settfex** makes it super easy to get stock market data from the Stock Exchange of Thailand (SET) and Thailand Futures Exchange (TFEX). Whether you're building a trading bot, doing market analysis, or just curious about Thai stocks, we've got you covered!
## โก Quick Install
```bash
pip install settfex
```
**Optional**: To run the Jupyter notebook examples, install with:
```bash
pip install settfex[examples]
```
This includes pandas, matplotlib, and jupyter notebook support.
## ๐ Interactive Examples
**New to settfex? Start here!** We have comprehensive Jupyter notebook examples that teach you everything step-by-step:
### ๐ Learning Path
**Beginners (30 min):** Start with these three notebooks to get comfortable:
- [Stock List](examples/set/01_stock_list.ipynb) - Discover all Thai stocks
- [Highlight Data](examples/set/02_highlight_data.ipynb) - Get key metrics like P/E, market cap, dividends
- [Corporate Actions](examples/set/05_corporate_action.ipynb) - Track dividends and shareholder meetings
**Fundamental Analysis (2 hrs):** Build a complete stock analysis workflow:
- [Stock List](examples/set/01_stock_list.ipynb) โ [Highlight Data](examples/set/02_highlight_data.ipynb) โ [Price Performance](examples/set/10_price_performance.ipynb) โ [Financial Statements](examples/set/11_financial.ipynb)
**Professional Trading (3 hrs):** Master all features for institutional use:
- All 11 SET notebooks + 2 TFEX notebooks (see below)
### ๐ SET Examples (Stock Exchange of Thailand)
All examples include beginner explanations, professional trading use cases, and data export examples:
1. **[Stock List](examples/set/01_stock_list.ipynb)** - Fetch and filter all stocks, build portfolio universes
2. **[Highlight Data](examples/set/02_highlight_data.ipynb)** - Value screeners, dividend portfolios, risk-adjusted returns
3. **[Stock Profile](examples/set/03_stock_profile.ipynb)** - Listing details, IPO data, foreign ownership
4. **[Company Profile](examples/set/04_company_profile.ipynb)** - ESG ratings, governance scores, management
5. **[Corporate Actions](examples/set/05_corporate_action.ipynb)** - Dividend calendars, shareholder meetings
6. **[Shareholder Data](examples/set/06_shareholder.ipynb)** - Ownership analysis, free float monitoring
7. **[NVDR Holders](examples/set/07_nvdr_holder.ipynb)** - NVDR ownership tracking and analysis
8. **[Board of Directors](examples/set/08_board_of_director.ipynb)** - Board composition and management structure
9. **[Trading Statistics](examples/set/09_trading_statistics.ipynb)** - Multi-period performance and volatility
10. **[Price Performance](examples/set/10_price_performance.ipynb)** - Sector comparison and alpha calculation
11. **[Financial Statements](examples/set/11_financial.ipynb)** - Balance sheet, income, cash flow analysis
### ๐ TFEX Examples (Thailand Futures Exchange)
Professional derivatives trading workflows with margin calculations and risk management:
1. **[Series List](examples/tfex/01_series_list.ipynb)** - Discover futures/options, rollover monitoring, options chains
2. **[Trading Statistics](examples/tfex/02_trading_statistics.ipynb)** - Margin requirements, position sizing, P/L tracking
**[๐ View All Examples](examples/)** - Complete index with learning guides
## ๐ Full Documentation
Want to dig deeper? Check out our detailed guides:
### SET Services
- **[Stock List Service](docs/settfex/services/set/list.md)** - Get all stocks on SET/mai
- **[Highlight Data Service](docs/settfex/services/set/highlight_data.md)** - Market metrics and valuations
- **[Stock Profile Service](docs/settfex/services/set/profile_stock.md)** - Listing details and share structure
- **[Company Profile Service](docs/settfex/services/set/profile_company.md)** - Full company information
- **[Corporate Action Service](docs/settfex/services/set/corporate_action.md)** - Dividends, meetings, and events
- **[Shareholder Service](docs/settfex/services/set/shareholder.md)** - Major shareholders and ownership data
- **[NVDR Holder Service](docs/settfex/services/set/nvdr_holder.md)** - NVDR holder information and ownership
- **[Board of Director Service](docs/settfex/services/set/board_of_director.md)** - Board of directors and management structure
- **[Trading Statistics Service](docs/settfex/services/set/trading_stat.md)** - Historical trading performance and metrics
- **[Price Performance Service](docs/settfex/services/set/price_performance.md)** - Stock, sector, and market price performance comparison
- **[Financial Service](docs/settfex/services/set/financial.md)** - Balance sheet, income statement, and cash flow data
### TFEX Services
- **[TFEX Series List Service](docs/settfex/services/tfex/list.md)** - Get all futures and options series on TFEX
- **[TFEX Trading Statistics Service](docs/settfex/services/tfex/trading_statistics.md)** - Trading statistics, settlement prices, and margin requirements
### Utilities
- **[AsyncDataFetcher](docs/settfex/utils/data_fetcher.md)** - Low-level async HTTP client
- **[Session Caching](docs/settfex/utils/session_caching.md)** - How we make things 25x faster
## ๐ฏ What Can You Do?
### SET (Stock Exchange of Thailand)
#### ๐ Get Stock List
Want to see all stocks trading on SET? Easy!
```python
from settfex.services.set import get_stock_list
stock_list = await get_stock_list()
print(f"Found {stock_list.count} stocks!")
# Filter by market
set_stocks = stock_list.filter_by_market("SET")
mai_stocks = stock_list.filter_by_market("mai")
```
**๐ [Learn more about Stock Lists](docs/settfex/services/set/list.md)**
---
#### ๐ฐ Get Stock Highlight Data
Need market cap, P/E ratio, dividend yield? We got you!
```python
from settfex.services.set import Stock
stock = Stock("CPALL")
data = await stock.get_highlight_data()
print(f"Market Cap: {data.market_cap:,.0f} THB")
print(f"P/E Ratio: {data.pe_ratio}")
print(f"Dividend Yield: {data.dividend_yield}%")
```
**๐ [Learn more about Highlight Data](docs/settfex/services/set/highlight_data.md)**
---
#### ๐ Get Stock Profile
Want to know when a company was listed? Its IPO price? Foreign ownership limits?
```python
from settfex.services.set import get_profile
profile = await get_profile("PTT")
print(f"Listed: {profile.listed_date}")
print(f"IPO Price: {profile.ipo} {profile.currency}")
print(f"Foreign Limit: {profile.percent_foreign_limit}%")
```
**๐ [Learn more about Stock Profiles](docs/settfex/services/set/profile_stock.md)**
---
#### ๐ข Get Company Profile
Curious about company details, management, auditors, or ESG ratings?
```python
from settfex.services.set import get_company_profile
company = await get_company_profile("CPN")
print(f"Company: {company.name}")
print(f"Website: {company.url}")
print(f"CG Score: {company.cg_score}/5")
print(f"ESG Rating: {company.setesg_rating}")
print(f"Executives: {len(company.managements)}")
```
**๐ [Learn more about Company Profiles](docs/settfex/services/set/profile_company.md)**
---
#### ๐
Get Corporate Actions
Track dividends, shareholder meetings, and other corporate events:
```python
from settfex.services.set import get_corporate_actions
actions = await get_corporate_actions("AOT")
for action in actions:
if action.ca_type == "XD":
print(f"Dividend: {action.dividend} {action.currency}")
print(f"XD Date: {action.x_date}")
print(f"Payment Date: {action.payment_date}")
elif action.ca_type == "XM":
print(f"Meeting: {action.meeting_type}")
print(f"Agenda: {action.agenda}")
```
**๐ [Learn more about Corporate Actions](docs/settfex/services/set/corporate_action.md)**
---
#### ๐ฅ Get Shareholder Data
See who owns what! Get major shareholders, free float, and ownership distribution:
```python
from settfex.services.set import get_shareholder_data
data = await get_shareholder_data("MINT")
print(f"Total Shareholders: {data.total_shareholder:,}")
print(f"Free Float: {data.free_float.percent_free_float:.2f}%")
for sh in data.major_shareholders[:5]:
print(f"{sh.sequence}. {sh.name}: {sh.percent_of_share:.2f}%")
```
**๐ [Learn more about Shareholder Data](docs/settfex/services/set/shareholder.md)**
---
#### ๐ Get NVDR Holder Data
Track Non-Voting Depository Receipt (NVDR) holders and their ownership:
```python
from settfex.services.set import get_nvdr_holder_data
data = await get_nvdr_holder_data("MINT")
print(f"Symbol: {data.symbol}") # MINT-R
print(f"Total NVDR Holders: {data.total_shareholder:,}")
for holder in data.major_shareholders[:5]:
print(f"{holder.sequence}. {holder.name}: {holder.percent_of_share:.2f}%")
```
**๐ [Learn more about NVDR Holder Data](docs/settfex/services/set/nvdr_holder.md)**
---
#### ๐ Get Board of Directors
See who's running the show! Get board of directors and management information:
```python
from settfex.services.set import get_board_of_directors
directors = await get_board_of_directors("MINT")
for director in directors:
positions = ", ".join(director.positions)
print(f"{director.name}: {positions}")
# Find the Chairman
chairman = next((d for d in directors if "CHAIRMAN" in d.positions), None)
if chairman:
print(f"Chairman: {chairman.name}")
```
**๐ [Learn more about Board of Directors](docs/settfex/services/set/board_of_director.md)**
---
#### ๐ Get Trading Statistics
Track historical trading performance with comprehensive statistics across multiple time periods:
```python
from settfex.services.set import get_trading_stats
stats = await get_trading_stats("MINT")
# YTD performance
ytd = next(s for s in stats if s.period == "YTD")
print(f"YTD Performance: {ytd.percent_change:.2f}%")
print(f"Current Price: {ytd.close:.2f} THB")
print(f"P/E Ratio: {ytd.pe}, Market Cap: {ytd.market_cap:,.0f} THB")
# Compare different periods
for stat in stats:
print(f"{stat.period}: {stat.close:.2f} THB ({stat.percent_change:+.2f}%)")
```
**๐ [Learn more about Trading Statistics](docs/settfex/services/set/trading_stat.md)**
---
#### ๐ Get Price Performance
Compare stock performance against sector and market with comprehensive price change data:
```python
from settfex.services.set import get_price_performance
data = await get_price_performance("MINT")
# Stock performance
print(f"Stock: {data.stock.symbol}")
print(f" YTD: {data.stock.ytd_percent_change:+.2f}%")
print(f" P/E: {data.stock.pe_ratio}, P/B: {data.stock.pb_ratio}")
# Sector comparison
print(f"Sector ({data.sector.symbol}): {data.sector.ytd_percent_change:+.2f}%")
# Market comparison
print(f"Market ({data.market.symbol}): {data.market.ytd_percent_change:+.2f}%")
```
**๐ [Learn more about Price Performance](docs/settfex/services/set/price_performance.md)**
---
#### ๐ฐ Get Financial Statements
Fetch comprehensive financial data including balance sheet, income statement, and cash flow:
```python
from settfex.services.set import (
get_balance_sheet,
get_income_statement,
get_cash_flow
)
# Balance sheet
balance_sheets = await get_balance_sheet("CPALL")
latest = balance_sheets[0]
print(f"Period: {latest.quarter} {latest.year}")
print(f"Total Assets: {latest.accounts[0].amount:,.0f}K")
# Income statement
income_statements = await get_income_statement("CPALL")
for stmt in income_statements[:3]:
print(f"{stmt.quarter} {stmt.year}: {stmt.status}")
# Cash flow
cash_flows = await get_cash_flow("CPALL")
```
**๐ [Learn more about Financial Service](docs/settfex/services/set/financial.md)**
---
### TFEX (Thailand Futures Exchange)
#### ๐ Get TFEX Series List
Want to see all futures and options trading on TFEX? Easy!
```python
from settfex.services.tfex import get_series_list
series_list = await get_series_list()
print(f"Found {series_list.count} series!")
# Filter active futures only
active_futures = [s for s in series_list.get_futures() if s.active]
print(f"Active futures: {len(active_futures)}")
# Filter by underlying
set50_series = series_list.filter_by_underlying("SET50")
print(f"SET50 contracts: {len(set50_series)}")
```
**๐ [Learn more about TFEX Series List](docs/settfex/services/tfex/list.md)**
---
#### ๐ Get TFEX Trading Statistics
Get comprehensive trading statistics including settlement prices, margin requirements, and days to maturity!
```python
from settfex.services.tfex import get_trading_statistics
stats = await get_trading_statistics("S50Z25")
print(f"Settlement Price: {stats.settlement_price:.5f}")
print(f"Days to Maturity: {stats.day_to_maturity}")
print(f"Initial Margin: {stats.im:,.2f} THB")
print(f"Maintenance Margin: {stats.mm:,.2f} THB")
# Calculate margin coverage
capital = 500000
max_contracts = int(capital / stats.im)
print(f"Can trade {max_contracts} contracts with {capital:,.0f} THB")
```
**๐ [Learn more about TFEX Trading Statistics](docs/settfex/services/tfex/trading_statistics.md)**
---
## ๐ Why settfex?
### โก Blazing Fast
First request takes ~2 seconds (warming up). After that? **100ms!** That's 25x faster thanks to smart session caching.
**Dual-Site Support**: Separate cached sessions for SET and TFEX - each optimized for its own API!
**๐ [Learn about Session Caching](docs/settfex/utils/session_caching.md)**
### ๐น๐ญ Thai Language Support
Full UTF-8 support for Thai characters. Company names, sectors, everything just works!
### ๐ Type Safe
Everything is type-hinted and validated with Pydantic. Your IDE will love it!
### ๐ชต Smart Logging
Beautiful logs with loguru. Debug issues easily or turn them off in production.
## ๐ก Quick Example
Here's everything in action:
```python
import asyncio
from settfex.services.set import (
get_stock_list,
get_profile,
get_company_profile,
get_corporate_actions,
get_board_of_directors,
get_trading_stats,
Stock
)
async def analyze_stock(symbol: str):
# Get basic info from stock list
stock_list = await get_stock_list()
stock_info = stock_list.get_symbol(symbol)
if not stock_info:
print(f"Stock {symbol} not found!")
return
print(f"๐ {stock_info.name_en} ({symbol})")
print(f"Market: {stock_info.market}")
print(f"Sector: {stock_info.sector}")
# Get detailed metrics
stock = Stock(symbol)
highlight = await stock.get_highlight_data()
print(f"\n๐ฐ Valuation:")
print(f"Market Cap: {highlight.market_cap:,.0f} THB")
print(f"P/E Ratio: {highlight.pe_ratio}")
print(f"Dividend Yield: {highlight.dividend_yield}%")
# Get listing details
profile = await get_profile(symbol)
print(f"\n๐
Listed: {profile.listed_date}")
print(f"IPO: {profile.ipo} {profile.currency}")
# Get company info
company = await get_company_profile(symbol)
print(f"\n๐ข {company.name}")
print(f"Website: {company.url}")
print(f"ESG Rating: {company.setesg_rating}")
# Get corporate actions
actions = await get_corporate_actions(symbol)
print(f"\n๐
Corporate Actions: {len(actions)}")
for action in actions[:3]: # Show first 3
if action.ca_type == "XD":
print(f" Dividend: {action.dividend} {action.currency}")
elif action.ca_type == "XM":
print(f" Meeting: {action.meeting_type}")
# Get board of directors
directors = await get_board_of_directors(symbol)
print(f"\n๐ Board of Directors: {len(directors)}")
chairman = next((d for d in directors if "CHAIRMAN" in d.positions), None)
if chairman:
print(f" Chairman: {chairman.name}")
# Get trading statistics
stats = await get_trading_stats(symbol)
ytd = next((s for s in stats if s.period == "YTD"), None)
if ytd:
print(f"\n๐ Trading Statistics (YTD):")
print(f" Performance: {ytd.percent_change:+.2f}%")
print(f" Volume: {ytd.total_volume:,.0f} shares")
print(f" Turnover: {ytd.turnover_ratio:.2f}%")
# Run it!
asyncio.run(analyze_stock("PTT"))
```
## ๐ ๏ธ Advanced Usage
Need more control? We've got you covered!
```python
from settfex.utils.data_fetcher import AsyncDataFetcher, FetcherConfig
# Custom configuration
config = FetcherConfig(
timeout=60, # Longer timeout
max_retries=5, # More retries
browser_impersonate="safari17_0" # Different browser
)
# Use with any service
from settfex.services.set.stock import StockHighlightDataService
service = StockHighlightDataService(config=config)
data = await service.fetch_highlight_data("CPALL")
```
**๐ [Learn more about AsyncDataFetcher](docs/settfex/utils/data_fetcher.md)**
## ๐งช Optional: Configure Logging
By default, settfex only shows ERROR-level logs to keep your terminal clean. Want to see more?
```python
from settfex.utils.logging import setup_logger
# Turn on detailed logs for debugging
setup_logger(level="DEBUG", log_file="logs/settfex.log")
# Or just INFO level for general monitoring
setup_logger(level="INFO")
# Now run your code - you'll see what's happening!
stock_list = await get_stock_list()
```
Great for debugging or monitoring in production. Default is ERROR level for clean output.
## ๐ค Contributing
We'd love your help making settfex better! Here's how:
1. Fork the repo
2. Create a feature branch: `git checkout -b feature/cool-new-thing`
3. Make your changes with proper type hints and tests
4. Run tests: `pytest`
5. Run linting: `ruff check .`
6. Commit: `git commit -m 'Add cool new thing'`
7. Push: `git push origin feature/cool-new-thing`
8. Open a Pull Request
## ๐ License
MIT License - feel free to use this in your projects!
## โ ๏ธ Disclaimer
This library is not officially affiliated with the Stock Exchange of Thailand or Thailand Futures Exchange. Use at your own risk for educational and informational purposes.
## ๐ Need Help?
- ๐ Check the [detailed documentation](docs/settfex/)
- ๐ Found a bug? [Open an issue](https://github.com/lumduan/settfex/issues)
---
Raw data
{
"_id": null,
"home_page": null,
"name": "settfex",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": "batt <b@candythink.com>",
"keywords": "api, async, exchange, finance, futures, market-data, set, stock, tfex, thai-stocks, thailand, trading",
"author": null,
"author_email": "batt <b@candythink.com>",
"download_url": "https://files.pythonhosted.org/packages/23/23/1df10c25be1bf1a5fbe6f07a97546464dcf14ea2667925ff7fabaa7d2034/settfex-0.1.0.tar.gz",
"platform": null,
"description": "# settfex\n\n> Your friendly Python library for fetching Thai stock market data \ud83c\uddf9\ud83c\udded\n\n[](https://badge.fury.io/py/settfex)\n[](https://www.python.org/downloads/)\n[](https://opensource.org/licenses/MIT)\n\n**settfex** makes it super easy to get stock market data from the Stock Exchange of Thailand (SET) and Thailand Futures Exchange (TFEX). Whether you're building a trading bot, doing market analysis, or just curious about Thai stocks, we've got you covered!\n\n## \u26a1 Quick Install\n\n```bash\npip install settfex\n```\n\n**Optional**: To run the Jupyter notebook examples, install with:\n\n```bash\npip install settfex[examples]\n```\n\nThis includes pandas, matplotlib, and jupyter notebook support.\n\n## \ud83d\udcd3 Interactive Examples\n\n**New to settfex? Start here!** We have comprehensive Jupyter notebook examples that teach you everything step-by-step:\n\n### \ud83c\udf93 Learning Path\n\n**Beginners (30 min):** Start with these three notebooks to get comfortable:\n- [Stock List](examples/set/01_stock_list.ipynb) - Discover all Thai stocks\n- [Highlight Data](examples/set/02_highlight_data.ipynb) - Get key metrics like P/E, market cap, dividends\n- [Corporate Actions](examples/set/05_corporate_action.ipynb) - Track dividends and shareholder meetings\n\n**Fundamental Analysis (2 hrs):** Build a complete stock analysis workflow:\n- [Stock List](examples/set/01_stock_list.ipynb) \u2192 [Highlight Data](examples/set/02_highlight_data.ipynb) \u2192 [Price Performance](examples/set/10_price_performance.ipynb) \u2192 [Financial Statements](examples/set/11_financial.ipynb)\n\n**Professional Trading (3 hrs):** Master all features for institutional use:\n- All 11 SET notebooks + 2 TFEX notebooks (see below)\n\n### \ud83d\udcca SET Examples (Stock Exchange of Thailand)\n\nAll examples include beginner explanations, professional trading use cases, and data export examples:\n\n1. **[Stock List](examples/set/01_stock_list.ipynb)** - Fetch and filter all stocks, build portfolio universes\n2. **[Highlight Data](examples/set/02_highlight_data.ipynb)** - Value screeners, dividend portfolios, risk-adjusted returns\n3. **[Stock Profile](examples/set/03_stock_profile.ipynb)** - Listing details, IPO data, foreign ownership\n4. **[Company Profile](examples/set/04_company_profile.ipynb)** - ESG ratings, governance scores, management\n5. **[Corporate Actions](examples/set/05_corporate_action.ipynb)** - Dividend calendars, shareholder meetings\n6. **[Shareholder Data](examples/set/06_shareholder.ipynb)** - Ownership analysis, free float monitoring\n7. **[NVDR Holders](examples/set/07_nvdr_holder.ipynb)** - NVDR ownership tracking and analysis\n8. **[Board of Directors](examples/set/08_board_of_director.ipynb)** - Board composition and management structure\n9. **[Trading Statistics](examples/set/09_trading_statistics.ipynb)** - Multi-period performance and volatility\n10. **[Price Performance](examples/set/10_price_performance.ipynb)** - Sector comparison and alpha calculation\n11. **[Financial Statements](examples/set/11_financial.ipynb)** - Balance sheet, income, cash flow analysis\n\n### \ud83d\udcc8 TFEX Examples (Thailand Futures Exchange)\n\nProfessional derivatives trading workflows with margin calculations and risk management:\n\n1. **[Series List](examples/tfex/01_series_list.ipynb)** - Discover futures/options, rollover monitoring, options chains\n2. **[Trading Statistics](examples/tfex/02_trading_statistics.ipynb)** - Margin requirements, position sizing, P/L tracking\n\n**[\ud83d\udcc2 View All Examples](examples/)** - Complete index with learning guides\n\n## \ud83d\udcda Full Documentation\n\nWant to dig deeper? Check out our detailed guides:\n\n### SET Services\n\n- **[Stock List Service](docs/settfex/services/set/list.md)** - Get all stocks on SET/mai\n- **[Highlight Data Service](docs/settfex/services/set/highlight_data.md)** - Market metrics and valuations\n- **[Stock Profile Service](docs/settfex/services/set/profile_stock.md)** - Listing details and share structure\n- **[Company Profile Service](docs/settfex/services/set/profile_company.md)** - Full company information\n- **[Corporate Action Service](docs/settfex/services/set/corporate_action.md)** - Dividends, meetings, and events\n- **[Shareholder Service](docs/settfex/services/set/shareholder.md)** - Major shareholders and ownership data\n- **[NVDR Holder Service](docs/settfex/services/set/nvdr_holder.md)** - NVDR holder information and ownership\n- **[Board of Director Service](docs/settfex/services/set/board_of_director.md)** - Board of directors and management structure\n- **[Trading Statistics Service](docs/settfex/services/set/trading_stat.md)** - Historical trading performance and metrics\n- **[Price Performance Service](docs/settfex/services/set/price_performance.md)** - Stock, sector, and market price performance comparison\n- **[Financial Service](docs/settfex/services/set/financial.md)** - Balance sheet, income statement, and cash flow data\n\n### TFEX Services\n\n- **[TFEX Series List Service](docs/settfex/services/tfex/list.md)** - Get all futures and options series on TFEX\n- **[TFEX Trading Statistics Service](docs/settfex/services/tfex/trading_statistics.md)** - Trading statistics, settlement prices, and margin requirements\n\n### Utilities\n\n- **[AsyncDataFetcher](docs/settfex/utils/data_fetcher.md)** - Low-level async HTTP client\n- **[Session Caching](docs/settfex/utils/session_caching.md)** - How we make things 25x faster\n\n## \ud83c\udfaf What Can You Do?\n\n### SET (Stock Exchange of Thailand)\n\n#### \ud83d\udccb Get Stock List\n\nWant to see all stocks trading on SET? Easy!\n\n```python\nfrom settfex.services.set import get_stock_list\n\nstock_list = await get_stock_list()\nprint(f\"Found {stock_list.count} stocks!\")\n\n# Filter by market\nset_stocks = stock_list.filter_by_market(\"SET\")\nmai_stocks = stock_list.filter_by_market(\"mai\")\n```\n\n**\ud83d\udc49 [Learn more about Stock Lists](docs/settfex/services/set/list.md)**\n\n---\n\n#### \ud83d\udcb0 Get Stock Highlight Data\n\nNeed market cap, P/E ratio, dividend yield? We got you!\n\n```python\nfrom settfex.services.set import Stock\n\nstock = Stock(\"CPALL\")\ndata = await stock.get_highlight_data()\n\nprint(f\"Market Cap: {data.market_cap:,.0f} THB\")\nprint(f\"P/E Ratio: {data.pe_ratio}\")\nprint(f\"Dividend Yield: {data.dividend_yield}%\")\n```\n\n**\ud83d\udc49 [Learn more about Highlight Data](docs/settfex/services/set/highlight_data.md)**\n\n---\n\n#### \ud83d\udcca Get Stock Profile\n\nWant to know when a company was listed? Its IPO price? Foreign ownership limits?\n\n```python\nfrom settfex.services.set import get_profile\n\nprofile = await get_profile(\"PTT\")\n\nprint(f\"Listed: {profile.listed_date}\")\nprint(f\"IPO Price: {profile.ipo} {profile.currency}\")\nprint(f\"Foreign Limit: {profile.percent_foreign_limit}%\")\n```\n\n**\ud83d\udc49 [Learn more about Stock Profiles](docs/settfex/services/set/profile_stock.md)**\n\n---\n\n#### \ud83c\udfe2 Get Company Profile\n\nCurious about company details, management, auditors, or ESG ratings?\n\n```python\nfrom settfex.services.set import get_company_profile\n\ncompany = await get_company_profile(\"CPN\")\n\nprint(f\"Company: {company.name}\")\nprint(f\"Website: {company.url}\")\nprint(f\"CG Score: {company.cg_score}/5\")\nprint(f\"ESG Rating: {company.setesg_rating}\")\nprint(f\"Executives: {len(company.managements)}\")\n```\n\n**\ud83d\udc49 [Learn more about Company Profiles](docs/settfex/services/set/profile_company.md)**\n\n---\n\n#### \ud83d\udcc5 Get Corporate Actions\n\nTrack dividends, shareholder meetings, and other corporate events:\n\n```python\nfrom settfex.services.set import get_corporate_actions\n\nactions = await get_corporate_actions(\"AOT\")\n\nfor action in actions:\n if action.ca_type == \"XD\":\n print(f\"Dividend: {action.dividend} {action.currency}\")\n print(f\"XD Date: {action.x_date}\")\n print(f\"Payment Date: {action.payment_date}\")\n elif action.ca_type == \"XM\":\n print(f\"Meeting: {action.meeting_type}\")\n print(f\"Agenda: {action.agenda}\")\n```\n\n**\ud83d\udc49 [Learn more about Corporate Actions](docs/settfex/services/set/corporate_action.md)**\n\n---\n\n#### \ud83d\udc65 Get Shareholder Data\n\nSee who owns what! Get major shareholders, free float, and ownership distribution:\n\n```python\nfrom settfex.services.set import get_shareholder_data\n\ndata = await get_shareholder_data(\"MINT\")\n\nprint(f\"Total Shareholders: {data.total_shareholder:,}\")\nprint(f\"Free Float: {data.free_float.percent_free_float:.2f}%\")\n\nfor sh in data.major_shareholders[:5]:\n print(f\"{sh.sequence}. {sh.name}: {sh.percent_of_share:.2f}%\")\n```\n\n**\ud83d\udc49 [Learn more about Shareholder Data](docs/settfex/services/set/shareholder.md)**\n\n---\n\n#### \ud83d\udcdc Get NVDR Holder Data\n\nTrack Non-Voting Depository Receipt (NVDR) holders and their ownership:\n\n```python\nfrom settfex.services.set import get_nvdr_holder_data\n\ndata = await get_nvdr_holder_data(\"MINT\")\n\nprint(f\"Symbol: {data.symbol}\") # MINT-R\nprint(f\"Total NVDR Holders: {data.total_shareholder:,}\")\n\nfor holder in data.major_shareholders[:5]:\n print(f\"{holder.sequence}. {holder.name}: {holder.percent_of_share:.2f}%\")\n```\n\n**\ud83d\udc49 [Learn more about NVDR Holder Data](docs/settfex/services/set/nvdr_holder.md)**\n\n---\n\n#### \ud83d\udc54 Get Board of Directors\n\nSee who's running the show! Get board of directors and management information:\n\n```python\nfrom settfex.services.set import get_board_of_directors\n\ndirectors = await get_board_of_directors(\"MINT\")\n\nfor director in directors:\n positions = \", \".join(director.positions)\n print(f\"{director.name}: {positions}\")\n\n# Find the Chairman\nchairman = next((d for d in directors if \"CHAIRMAN\" in d.positions), None)\nif chairman:\n print(f\"Chairman: {chairman.name}\")\n```\n\n**\ud83d\udc49 [Learn more about Board of Directors](docs/settfex/services/set/board_of_director.md)**\n\n---\n\n#### \ud83d\udcca Get Trading Statistics\n\nTrack historical trading performance with comprehensive statistics across multiple time periods:\n\n```python\nfrom settfex.services.set import get_trading_stats\n\nstats = await get_trading_stats(\"MINT\")\n\n# YTD performance\nytd = next(s for s in stats if s.period == \"YTD\")\nprint(f\"YTD Performance: {ytd.percent_change:.2f}%\")\nprint(f\"Current Price: {ytd.close:.2f} THB\")\nprint(f\"P/E Ratio: {ytd.pe}, Market Cap: {ytd.market_cap:,.0f} THB\")\n\n# Compare different periods\nfor stat in stats:\n print(f\"{stat.period}: {stat.close:.2f} THB ({stat.percent_change:+.2f}%)\")\n```\n\n**\ud83d\udc49 [Learn more about Trading Statistics](docs/settfex/services/set/trading_stat.md)**\n\n---\n\n#### \ud83d\udcc8 Get Price Performance\n\nCompare stock performance against sector and market with comprehensive price change data:\n\n```python\nfrom settfex.services.set import get_price_performance\n\ndata = await get_price_performance(\"MINT\")\n\n# Stock performance\nprint(f\"Stock: {data.stock.symbol}\")\nprint(f\" YTD: {data.stock.ytd_percent_change:+.2f}%\")\nprint(f\" P/E: {data.stock.pe_ratio}, P/B: {data.stock.pb_ratio}\")\n\n# Sector comparison\nprint(f\"Sector ({data.sector.symbol}): {data.sector.ytd_percent_change:+.2f}%\")\n\n# Market comparison\nprint(f\"Market ({data.market.symbol}): {data.market.ytd_percent_change:+.2f}%\")\n```\n\n**\ud83d\udc49 [Learn more about Price Performance](docs/settfex/services/set/price_performance.md)**\n\n---\n\n#### \ud83d\udcb0 Get Financial Statements\n\nFetch comprehensive financial data including balance sheet, income statement, and cash flow:\n\n```python\nfrom settfex.services.set import (\n get_balance_sheet,\n get_income_statement,\n get_cash_flow\n)\n\n# Balance sheet\nbalance_sheets = await get_balance_sheet(\"CPALL\")\nlatest = balance_sheets[0]\nprint(f\"Period: {latest.quarter} {latest.year}\")\nprint(f\"Total Assets: {latest.accounts[0].amount:,.0f}K\")\n\n# Income statement\nincome_statements = await get_income_statement(\"CPALL\")\nfor stmt in income_statements[:3]:\n print(f\"{stmt.quarter} {stmt.year}: {stmt.status}\")\n\n# Cash flow\ncash_flows = await get_cash_flow(\"CPALL\")\n```\n\n**\ud83d\udc49 [Learn more about Financial Service](docs/settfex/services/set/financial.md)**\n\n---\n\n### TFEX (Thailand Futures Exchange)\n\n#### \ud83d\udccb Get TFEX Series List\n\nWant to see all futures and options trading on TFEX? Easy!\n\n```python\nfrom settfex.services.tfex import get_series_list\n\nseries_list = await get_series_list()\nprint(f\"Found {series_list.count} series!\")\n\n# Filter active futures only\nactive_futures = [s for s in series_list.get_futures() if s.active]\nprint(f\"Active futures: {len(active_futures)}\")\n\n# Filter by underlying\nset50_series = series_list.filter_by_underlying(\"SET50\")\nprint(f\"SET50 contracts: {len(set50_series)}\")\n```\n\n**\ud83d\udc49 [Learn more about TFEX Series List](docs/settfex/services/tfex/list.md)**\n\n---\n\n#### \ud83d\udcca Get TFEX Trading Statistics\n\nGet comprehensive trading statistics including settlement prices, margin requirements, and days to maturity!\n\n```python\nfrom settfex.services.tfex import get_trading_statistics\n\nstats = await get_trading_statistics(\"S50Z25\")\n\nprint(f\"Settlement Price: {stats.settlement_price:.5f}\")\nprint(f\"Days to Maturity: {stats.day_to_maturity}\")\nprint(f\"Initial Margin: {stats.im:,.2f} THB\")\nprint(f\"Maintenance Margin: {stats.mm:,.2f} THB\")\n\n# Calculate margin coverage\ncapital = 500000\nmax_contracts = int(capital / stats.im)\nprint(f\"Can trade {max_contracts} contracts with {capital:,.0f} THB\")\n```\n\n**\ud83d\udc49 [Learn more about TFEX Trading Statistics](docs/settfex/services/tfex/trading_statistics.md)**\n\n---\n\n## \ud83d\ude80 Why settfex?\n\n### \u26a1 Blazing Fast\n\nFirst request takes ~2 seconds (warming up). After that? **100ms!** That's 25x faster thanks to smart session caching.\n\n**Dual-Site Support**: Separate cached sessions for SET and TFEX - each optimized for its own API!\n\n**\ud83d\udc49 [Learn about Session Caching](docs/settfex/utils/session_caching.md)**\n\n### \ud83c\uddf9\ud83c\udded Thai Language Support\n\nFull UTF-8 support for Thai characters. Company names, sectors, everything just works!\n\n### \ud83d\udd12 Type Safe\n\nEverything is type-hinted and validated with Pydantic. Your IDE will love it!\n\n### \ud83e\udeb5 Smart Logging\n\nBeautiful logs with loguru. Debug issues easily or turn them off in production.\n\n## \ud83d\udca1 Quick Example\n\nHere's everything in action:\n\n```python\nimport asyncio\nfrom settfex.services.set import (\n get_stock_list,\n get_profile,\n get_company_profile,\n get_corporate_actions,\n get_board_of_directors,\n get_trading_stats,\n Stock\n)\n\nasync def analyze_stock(symbol: str):\n # Get basic info from stock list\n stock_list = await get_stock_list()\n stock_info = stock_list.get_symbol(symbol)\n\n if not stock_info:\n print(f\"Stock {symbol} not found!\")\n return\n\n print(f\"\ud83d\udcca {stock_info.name_en} ({symbol})\")\n print(f\"Market: {stock_info.market}\")\n print(f\"Sector: {stock_info.sector}\")\n\n # Get detailed metrics\n stock = Stock(symbol)\n highlight = await stock.get_highlight_data()\n\n print(f\"\\n\ud83d\udcb0 Valuation:\")\n print(f\"Market Cap: {highlight.market_cap:,.0f} THB\")\n print(f\"P/E Ratio: {highlight.pe_ratio}\")\n print(f\"Dividend Yield: {highlight.dividend_yield}%\")\n\n # Get listing details\n profile = await get_profile(symbol)\n print(f\"\\n\ud83d\udcc5 Listed: {profile.listed_date}\")\n print(f\"IPO: {profile.ipo} {profile.currency}\")\n\n # Get company info\n company = await get_company_profile(symbol)\n print(f\"\\n\ud83c\udfe2 {company.name}\")\n print(f\"Website: {company.url}\")\n print(f\"ESG Rating: {company.setesg_rating}\")\n\n # Get corporate actions\n actions = await get_corporate_actions(symbol)\n print(f\"\\n\ud83d\udcc5 Corporate Actions: {len(actions)}\")\n for action in actions[:3]: # Show first 3\n if action.ca_type == \"XD\":\n print(f\" Dividend: {action.dividend} {action.currency}\")\n elif action.ca_type == \"XM\":\n print(f\" Meeting: {action.meeting_type}\")\n\n # Get board of directors\n directors = await get_board_of_directors(symbol)\n print(f\"\\n\ud83d\udc54 Board of Directors: {len(directors)}\")\n chairman = next((d for d in directors if \"CHAIRMAN\" in d.positions), None)\n if chairman:\n print(f\" Chairman: {chairman.name}\")\n\n # Get trading statistics\n stats = await get_trading_stats(symbol)\n ytd = next((s for s in stats if s.period == \"YTD\"), None)\n if ytd:\n print(f\"\\n\ud83d\udcca Trading Statistics (YTD):\")\n print(f\" Performance: {ytd.percent_change:+.2f}%\")\n print(f\" Volume: {ytd.total_volume:,.0f} shares\")\n print(f\" Turnover: {ytd.turnover_ratio:.2f}%\")\n\n# Run it!\nasyncio.run(analyze_stock(\"PTT\"))\n```\n\n## \ud83d\udee0\ufe0f Advanced Usage\n\nNeed more control? We've got you covered!\n\n```python\nfrom settfex.utils.data_fetcher import AsyncDataFetcher, FetcherConfig\n\n# Custom configuration\nconfig = FetcherConfig(\n timeout=60, # Longer timeout\n max_retries=5, # More retries\n browser_impersonate=\"safari17_0\" # Different browser\n)\n\n# Use with any service\nfrom settfex.services.set.stock import StockHighlightDataService\n\nservice = StockHighlightDataService(config=config)\ndata = await service.fetch_highlight_data(\"CPALL\")\n```\n\n**\ud83d\udc49 [Learn more about AsyncDataFetcher](docs/settfex/utils/data_fetcher.md)**\n\n## \ud83e\uddea Optional: Configure Logging\n\nBy default, settfex only shows ERROR-level logs to keep your terminal clean. Want to see more?\n\n```python\nfrom settfex.utils.logging import setup_logger\n\n# Turn on detailed logs for debugging\nsetup_logger(level=\"DEBUG\", log_file=\"logs/settfex.log\")\n\n# Or just INFO level for general monitoring\nsetup_logger(level=\"INFO\")\n\n# Now run your code - you'll see what's happening!\nstock_list = await get_stock_list()\n```\n\nGreat for debugging or monitoring in production. Default is ERROR level for clean output.\n\n## \ud83e\udd1d Contributing\n\nWe'd love your help making settfex better! Here's how:\n\n1. Fork the repo\n2. Create a feature branch: `git checkout -b feature/cool-new-thing`\n3. Make your changes with proper type hints and tests\n4. Run tests: `pytest`\n5. Run linting: `ruff check .`\n6. Commit: `git commit -m 'Add cool new thing'`\n7. Push: `git push origin feature/cool-new-thing`\n8. Open a Pull Request\n\n## \ud83d\udcdc License\n\nMIT License - feel free to use this in your projects!\n\n## \u26a0\ufe0f Disclaimer\n\nThis library is not officially affiliated with the Stock Exchange of Thailand or Thailand Futures Exchange. Use at your own risk for educational and informational purposes.\n\n## \ud83d\ude4b Need Help?\n\n- \ud83d\udcd6 Check the [detailed documentation](docs/settfex/)\n- \ud83d\udc1b Found a bug? [Open an issue](https://github.com/lumduan/settfex/issues)\n\n---\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Async Python library for fetching real-time and historical data from the Stock Exchange of Thailand (SET) and Thailand Futures Exchange (TFEX)",
"version": "0.1.0",
"project_urls": {
"Documentation": "https://github.com/lumduan/settfex#readme",
"Homepage": "https://github.com/lumduan/settfex",
"Issues": "https://github.com/lumduan/settfex/issues",
"Repository": "https://github.com/lumduan/settfex"
},
"split_keywords": [
"api",
" async",
" exchange",
" finance",
" futures",
" market-data",
" set",
" stock",
" tfex",
" thai-stocks",
" thailand",
" trading"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c8365d168171dac55d65eed4912adff157b8ab6db324a9e6de9653584752345f",
"md5": "2499bfb4dc1b09dad12da84d8045c6e6",
"sha256": "1d08ec2064d9d0af72173d620e98b12f9c0c941e25fb3a658e978cdc31b88f7f"
},
"downloads": -1,
"filename": "settfex-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2499bfb4dc1b09dad12da84d8045c6e6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 68143,
"upload_time": "2025-10-06T02:45:27",
"upload_time_iso_8601": "2025-10-06T02:45:27.061500Z",
"url": "https://files.pythonhosted.org/packages/c8/36/5d168171dac55d65eed4912adff157b8ab6db324a9e6de9653584752345f/settfex-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "23231df10c25be1bf1a5fbe6f07a97546464dcf14ea2667925ff7fabaa7d2034",
"md5": "6c477acd70e3bfd687810787e872211e",
"sha256": "2472922849d3dd5934e888973e8f5ee681c05749387314828c723ad063315211"
},
"downloads": -1,
"filename": "settfex-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "6c477acd70e3bfd687810787e872211e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 429610,
"upload_time": "2025-10-06T02:45:29",
"upload_time_iso_8601": "2025-10-06T02:45:29.576058Z",
"url": "https://files.pythonhosted.org/packages/23/23/1df10c25be1bf1a5fbe6f07a97546464dcf14ea2667925ff7fabaa7d2034/settfex-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-06 02:45:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lumduan",
"github_project": "settfex#readme",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "settfex"
}