A Python library for access thai stock fundamental data up to 10+ years.
Project description
thaifin: ข้อมูลพื้นฐานหุ้น ง่ายแค่สามบรรทัด
The same author as PythaiNAV
A Python library for access thai stock fundamental data up to 10+ years.
- faster and lesser load to server with cachetools
- more robust with auto retry with expo wait via tenacity
- better than nothing docs with pdoc
ไพทอนไลบารี่สำหรับเข้าถึงข้อมูลปัจจัยพื้นฐานของหุ้นในตลาดไทยมากถึง 10+ ปี
Get Started
# Pick one ✨
$ pip install thaifin
$ conda install thaifin
# Import both classes for different use cases
from thaifin import Stock, Stocks
# Collection operations with Stocks class
# Get all stock symbols
all_symbols = Stocks.list()
# ['T', 'A', 'U', 'J', 'W', 'B', 'D', 'S', 'M', 'K', 'EE', ...
# Smart search with auto language detection
top5match = Stocks.search('จัสมิน') # Thai search
# [<Stock JTS - updated just now>, <Stock JAS - updated just now>, <Stock JASIF - updated just now>, ...
cp_stocks = Stocks.search('cp') # English search
# [<Stock CPALL - updated just now>, <Stock CPANEL - updated just now>, <Stock CPAXT - updated just now>, ...
# Get detailed stock list with company info
stock_df = Stocks.list_with_names()
# symbol name industry sector market
# 0 24CS Twenty-Four Con & Supply Public Company Limited Property & Construction - mai
# 1 2S 2S METAL PUBLIC COMPANY LIMITED Industrials Steel and Metal Products SET
# Filter stocks by sector or market
banking_stocks = Stocks.filter_by_sector('Banking')
mai_stocks = Stocks.filter_by_market('mai')
# Individual stock operations with Stock class
stock = Stock('PTT')
# <Stock PTT - updated just now>
# Access company information
print(f"Company: {stock.company_name}")
print(f"Sector: {stock.sector}")
print(f"Industry: {stock.industry}")
# Get financial data as pandas DataFrames
stock.quarter_dataframe
# Cash DA ... FinancingActivities Asset
# Time ...
# 2009Q1 9.383006e+07 1.070218e+07 ... 3.101551e+07 9.453044e+08
# 2009Q2 9.643438e+07 8.893013e+06 ... 3.195314e+07 1.042480e+09
# 2009Q3 1.050549e+08 1.127702e+07 ... 1.100019e+07 1.099084e+09
# 2009Q4 1.040559e+08 1.227756e+07 ... -1.356621e+07 1.103590e+09
# ...
# 2019Q4 2.925425e+08 3.581462e+07 ... -2.179443e+07 2.484439e+09
# 2020Q1 2.543450e+08 3.586543e+07 ... -2.705637e+07 2.499666e+09
# 2020Q2 2.578579e+08 3.460213e+07 ... 2.117104e+07 2.449277e+09
# [46 rows x 35 columns]
stock.yearly_dataframe
# Cash DA ... FinancingActivities Asset
# Fiscal ...
# 2009 1.040559e+08 4.314976e+07 ... 6.040263e+07 1.103590e+09
# 2010 1.356320e+08 5.122258e+07 ... 3.761321e+06 1.249148e+09
# 2011 1.161321e+08 5.531816e+07 ... -4.542309e+07 1.402412e+09
# 2012 1.369176e+08 6.523743e+07 ... 2.771070e+07 1.631320e+09
# 2013 1.576835e+08 7.631456e+07 ... -5.579036e+07 1.801722e+09
# 2014 2.037854e+08 1.170070e+08 ... -4.731543e+07 1.779179e+09
# 2015 2.399779e+08 1.488855e+08 ... -1.638133e+08 2.173996e+09
# 2016 2.155664e+08 1.297570e+08 ... -1.162034e+08 2.232331e+09
# 2017 1.661890e+08 1.171472e+08 ... -1.624979e+08 2.232314e+09
# 2018 2.921843e+08 1.235563e+08 ... -1.114676e+08 2.355484e+09
# 2019 2.925425e+08 1.332042e+08 ... -7.022567e+07 2.484439e+09
# [11 rows x 35 columns]
Columns Data
class QuarterFinancialSheetDatum(BaseModel):
security_id: str
fiscal: int
quarter: int
cash: Optional[str]
da: Optional[str]
debt_to_equity: Optional[str]
equity: Optional[str]
earning_per_share: Optional[str]
earning_per_share_yoy: Optional[str]
earning_per_share_qoq: Optional[str]
gpm: Optional[str]
gross_profit: Optional[str]
net_profit: Optional[str]
net_profit_yoy: Optional[str]
net_profit_qoq: Optional[str]
npm: Optional[str]
revenue: Optional[str]
revenue_yoy: Optional[str]
revenue_qoq: Optional[str]
roa: Optional[str]
roe: Optional[str]
sga: Optional[str]
sga_per_revenue: Optional[str]
total_debt: Optional[str]
dividend_yield: Optional[str]
book_value_per_share: Optional[str]
close: Optional[str]
mkt_cap: Optional[str]
price_earning_ratio: Optional[str]
price_book_value: Optional[str]
ev_per_ebit_da: Optional[str]
ebit_dattm: Optional[str]
paid_up_capital: Optional[str]
cash_cycle: Optional[str]
operating_activities: Optional[str]
investing_activities: Optional[str]
financing_activities: Optional[str]
asset: Optional[str]
end_of_year_date: Optional[str]
Disclaimer
เราไม่รับประกันความเสียหายใดๆทั้งสิ้นที่เกิดจาก แหล่งข้อมูล, library, source code,sample code, documentation, library dependencies และอื่นๆ
FAQ
Q: อยากขอบคุณอ่ะ อยากตอบแทนอ่ะ 😋 ทำไงดี?
A: ถ้าเป็น developer สามารถช่วยส่ง PR หรือ pull request ได้ครับ ไม่ว่าจะเป็นงานเล็กน้อยเช่นแก้การพิมพ์ผิด หรือช่วยทำคู่มือ ยินดีมากๆครับ สามารถสนับสนุนผม
โดยการบริจาคครั้งเดียวผ่าน Ko-fi หรือ patreon ก็ได้เช่นกันครับ นอกจากนี้ยังสามารถเขียนให้กำลังใจผมได้ทาง
Q: แจ้งปัญหาไงอ่ะ ?
A: ถ้าเป็น error วิธีการใช้งานเขียน stackoverflow ได้ครับ ถ้าเป็น bug หรืออยากแนะนำขอ feature เขียน issue มาได้ครับ
Q: ข้อมูลมาจากไหน เชื่อถือได้แค่ไหน ?
A: ข้อมูลมาจากสาธารณะหลายแหล่งครับ ตอนที่เขียนมีเว็ป Finnomena, Set, Settrade เชื่อถือได้ไม่ได้คงต้องตัดสินเองนะครับ
Q: สร้างมาทำไม ?
A: สมัยเป็นนักศึกษา ผมก็อยากได้สิ่งนี้มาก่อนครับ เป็นเครื่องมือช่วยประกอบการลงทุน และใช้ความรู้ทาง data science กับข้อมูลได้ ตอนนั้นไม่มีใครทำครับ ข้อมูลผูกขาดเฉพาะกับบริษัทลงทุนเท่านั้น ตอนนี้ก็ยังเหมือนเดิม เพิ่มเติมคือผมมีความสามารถที่จะสร้างมัน ก็อยากให้คนรุ่นต่อไปได้มี library ดีๆ เป็นสมบัติ ของทุกคน(License ISC) ผมจึงใช้เวลาส่วนตัวมาพัฒนาครับ ทุกคนให้ความรักมันด้วยนะครับ code ก็ต้องการความรักนะ อิอิ
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file thaifin-1.1.0.tar.gz.
File metadata
- Download URL: thaifin-1.1.0.tar.gz
- Upload date:
- Size: 309.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75a8ab2b22588065bf20808c3bb4a156654c7ad4c384e29acb13b42985e16448
|
|
| MD5 |
c2ab60417cbf3d6f83828e81a006c08d
|
|
| BLAKE2b-256 |
f0740c9a7d710d085728ac88a226279e64acc7636af8bc68d85b8b641b2f6f7a
|
File details
Details for the file thaifin-1.1.0-py3-none-any.whl.
File metadata
- Download URL: thaifin-1.1.0-py3-none-any.whl
- Upload date:
- Size: 20.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c90739b01edb786d6c41cd625cf047ab632be577ae07b7ea1ed268b6ef32071b
|
|
| MD5 |
71f4da6c9974dac31e5204fc6b205405
|
|
| BLAKE2b-256 |
59fa9fff047a29b3a89cebebac7d4343e74b64da6a345d47c8190d0b1d20eaae
|