PharaghY-codal 0.3.1__tar.gz
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.
- pharaghy_codal-0.3.1/.gitignore +52 -0
- pharaghy_codal-0.3.1/CHANGELOG.md +46 -0
- pharaghy_codal-0.3.1/LICENSE +21 -0
- pharaghy_codal-0.3.1/PKG-INFO +262 -0
- pharaghy_codal-0.3.1/README.md +226 -0
- pharaghy_codal-0.3.1/docs/.gitkeep +0 -0
- pharaghy_codal-0.3.1/docs/API.md +60 -0
- pharaghy_codal-0.3.1/docs/logo.png +0 -0
- pharaghy_codal-0.3.1/examples/README.md +15 -0
- pharaghy_codal-0.3.1/examples/basic_income.py +13 -0
- pharaghy_codal-0.3.1/examples/demo_by_category.py +83 -0
- pharaghy_codal-0.3.1/examples/download_files.py +10 -0
- pharaghy_codal-0.3.1/examples/invalid_symbol.py +38 -0
- pharaghy_codal-0.3.1/examples/list_notice_codes.py +18 -0
- pharaghy_codal-0.3.1/examples/monthly_activity.py +12 -0
- pharaghy_codal-0.3.1/examples/monthly_tir_1405.py +46 -0
- pharaghy_codal-0.3.1/examples/read_one_letter.py +39 -0
- pharaghy_codal-0.3.1/examples/search_capital_increase.py +14 -0
- pharaghy_codal-0.3.1/examples/search_monthly_type.py +7 -0
- pharaghy_codal-0.3.1/examples/search_notice_code.py +16 -0
- pharaghy_codal-0.3.1/examples/workflow_notice_download.py +23 -0
- pharaghy_codal-0.3.1/pyproject.toml +82 -0
- pharaghy_codal-0.3.1/src/pharaghy_codal/__init__.py +130 -0
- pharaghy_codal-0.3.1/src/pharaghy_codal/client.py +417 -0
- pharaghy_codal-0.3.1/src/pharaghy_codal/company.py +134 -0
- pharaghy_codal-0.3.1/src/pharaghy_codal/constants.py +196 -0
- pharaghy_codal-0.3.1/src/pharaghy_codal/financials.py +369 -0
- pharaghy_codal-0.3.1/src/pharaghy_codal/letter.py +746 -0
- pharaghy_codal-0.3.1/src/pharaghy_codal/models.py +102 -0
- pharaghy_codal-0.3.1/src/pharaghy_codal/monthly.py +274 -0
- pharaghy_codal-0.3.1/src/pharaghy_codal/search.py +355 -0
- pharaghy_codal-0.3.1/src/pharaghy_codal/types.py +79 -0
- pharaghy_codal-0.3.1/src/pharaghy_codal/utils.py +73 -0
- pharaghy_codal-0.3.1/tests/test_client_config.py +16 -0
- pharaghy_codal-0.3.1/tests/test_constants.py +23 -0
- pharaghy_codal-0.3.1/tests/test_financials_helpers.py +31 -0
- pharaghy_codal-0.3.1/tests/test_letter_helpers.py +50 -0
- pharaghy_codal-0.3.1/tests/test_search_helpers.py +14 -0
- pharaghy_codal-0.3.1/tests/test_utils.py +32 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.venv/
|
|
25
|
+
venv/
|
|
26
|
+
ENV/
|
|
27
|
+
env/
|
|
28
|
+
|
|
29
|
+
# Test / type / lint
|
|
30
|
+
.pytest_cache/
|
|
31
|
+
.coverage
|
|
32
|
+
htmlcov/
|
|
33
|
+
.mypy_cache/
|
|
34
|
+
.ruff_cache/
|
|
35
|
+
.tox/
|
|
36
|
+
|
|
37
|
+
# IDE
|
|
38
|
+
.idea/
|
|
39
|
+
.vscode/
|
|
40
|
+
*.swp
|
|
41
|
+
*.swo
|
|
42
|
+
.DS_Store
|
|
43
|
+
|
|
44
|
+
# Local / debug downloads from Codal
|
|
45
|
+
*.xlsx
|
|
46
|
+
!tests/fixtures/*.xlsx
|
|
47
|
+
debug_*.xlsx
|
|
48
|
+
test_*.xlsx
|
|
49
|
+
|
|
50
|
+
# Env
|
|
51
|
+
.env
|
|
52
|
+
.env.*
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
## 0.3.0 — 2026-11-25
|
|
2
|
+
|
|
3
|
+
### مرحله ۵: API عمومی تمیز
|
|
4
|
+
- `__init__` و `__all__` پایدار و گروهبندیشده
|
|
5
|
+
- `docs/API.md` مرجع سریع توابع
|
|
6
|
+
- نسخه 0.3.0 بهعنوان نقطهٔ تثبیت API پیش از 1.0
|
|
7
|
+
|
|
8
|
+
## 0.2.0 — 2026-11-25
|
|
9
|
+
|
|
10
|
+
### مرحله ۱: کشف و جستجوی کامل
|
|
11
|
+
- `iter_letters` / `search_all` صفحهبندی خودکار
|
|
12
|
+
- `search_by_notice_code(symbol, "ن-42")` با فیلتر API + کلاینت
|
|
13
|
+
- `search_by_letter_type(symbol, 6)`
|
|
14
|
+
- `normalize_letter_code` (ن-۴۲ ≡ ن-42)
|
|
15
|
+
- پارامتر `title_contains` برای جدا کردن عادی سالیانه از فوقالعاده
|
|
16
|
+
- `max_pages` برای محدود کردن اسکن در تست
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Changelog
|
|
20
|
+
|
|
21
|
+
## 0.1.6 — 2026-11-25
|
|
22
|
+
|
|
23
|
+
- `download_pdf(tracing_no, path)` برای ذخیره PDF روی دیسک
|
|
24
|
+
- `download_file(url, path)` برای هر لینک کدال (پیوست و ...)
|
|
25
|
+
- `download_attachments(tracing_no, directory)` برای همه پیوستها
|
|
26
|
+
- بهبود پر کردن `pdf_url` حتی وقتی فلگ HasPdf ناسازگار است
|
|
27
|
+
- پارامتر `letter_code` در `search_letters`
|
|
28
|
+
|
|
29
|
+
## 0.1.5 — 2026-11-25
|
|
30
|
+
|
|
31
|
+
- کدهای رسمی اطلاعیه کدال (ن-۱۰ … ن-۸۱) در `constants.NOTICE_CODES`
|
|
32
|
+
- گروهبندی موضوعی: مالی، افشا، ماهانه، مجمع، افزایش سرمایه، …
|
|
33
|
+
- توابع `list_notice_codes`، `notice_title`، `notice_group_of`
|
|
34
|
+
- نام پکیج PyPI: `PharaghY-codal`
|
|
35
|
+
- لوگوی پروژه در `docs/logo.png`
|
|
36
|
+
|
|
37
|
+
## 0.1.4 — 2026-11-24
|
|
38
|
+
|
|
39
|
+
- ماژول `constants` اولیه
|
|
40
|
+
- مثالهای `examples/`
|
|
41
|
+
- README حرفهایتر
|
|
42
|
+
|
|
43
|
+
## 0.1.3 — 2026-11-24
|
|
44
|
+
|
|
45
|
+
- گزارش فعالیت ماهانه (`get_monthly_activity` و مرتبطها)
|
|
46
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PharaghY
|
|
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.
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: PharaghY-codal
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Python library to extract raw financial data from Codal (codal.ir) for fundamental analysis of Iranian listed companies.
|
|
5
|
+
Project-URL: Homepage, https://github.com/YusefRahimi/PharaghY_Codal
|
|
6
|
+
Project-URL: Issues, https://github.com/YusefRahimi/PharaghY_Codal/issues
|
|
7
|
+
Project-URL: Changelog, https://github.com/YusefRahimi/PharaghY_Codal/blob/main/CHANGELOG.md
|
|
8
|
+
Project-URL: Telegram, https://t.me/bourse_faraghy
|
|
9
|
+
Author: PharaghY
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: bourse,capital-increase,codal,codal-ir,disclosures,financial-statements,fundamental-analysis,iran,monthly-activity,tehran-stock-exchange,tse
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: httpx>=0.27
|
|
26
|
+
Requires-Dist: lxml>=4.9
|
|
27
|
+
Requires-Dist: openpyxl>=3.1
|
|
28
|
+
Requires-Dist: pandas>=2.0
|
|
29
|
+
Provides-Extra: curl
|
|
30
|
+
Requires-Dist: curl-cffi>=0.6; extra == 'curl'
|
|
31
|
+
Requires-Dist: httpx-curl-cffi>=0.1.4; extra == 'curl'
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
<img src="docs/logo.png" alt="PharaghY Codal" width="160"/>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
# PharaghY-codal
|
|
42
|
+
|
|
43
|
+
##### این ماژول با هدف دسترسی به اطلاعیهها و گزارشهای سامانهٔ **کدال** در محیط برنامهنویسی پایتون توسعه یافته است. با آن میتوانید صورتهای مالی، گزارش فعالیت ماهانه، مجامع، افزایش سرمایه و سایر افشاها را بهصورت برنامهنویسی دریافت کنید و در مدلهای تحلیل بنیادی یا پردازش داده بهکار ببرید. خروجی بسیاری از توابع، **دیتافریم پانداز** یا اشیاء سادهٔ پایتونی است.
|
|
44
|
+
|
|
45
|
+
#### از جمله ویژگیهای مهم این ماژول میتوان به موارد زیر اشاره کرد
|
|
46
|
+
|
|
47
|
+
قابلیت جستجوی شرکت با نماد و دریافت مشخصات ناشر ←
|
|
48
|
+
|
|
49
|
+
قابلیت جستجوی اطلاعیهها بر اساس نماد، نوع گزارش، دوره، تاریخ و کد اطلاعیه (ن-۱۰ … ن-۸۱) ←
|
|
50
|
+
|
|
51
|
+
قابلیت خواندن جداول یک اطلاعیه و تبدیل به DataFrame ←
|
|
52
|
+
|
|
53
|
+
قابلیت دریافت صورت سود و زیان با اولویت گزارش تلفیقی ←
|
|
54
|
+
|
|
55
|
+
قابلیت دریافت گزارش فعالیت ماهانه (تولید، مواد، انرژی و …) ←
|
|
56
|
+
|
|
57
|
+
قابلیت دانلود فایل اکسل، PDF و پیوستهای اطلاعیه ←
|
|
58
|
+
|
|
59
|
+
مدیریت فاصله بین درخواستها، retry روی قطع اتصال و صبر خودکار روی rate-limit کدال ←
|
|
60
|
+
|
|
61
|
+
پشتیبانی از پروکسی ایرانی از طریق متغیر محیطی ←
|
|
62
|
+
|
|
63
|
+
##### این مخزن در حال توسعه است. برای نمونه کدها به پوشهٔ [examples](examples/) مراجعه کنید.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
# نصب ماژول
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install PharaghY-codal
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
یا از سورس:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
git clone https://github.com/YusefRahimi/PharaghY_Codal.git
|
|
77
|
+
cd PharaghY_Codal
|
|
78
|
+
pip install -e .
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
# فراخوانی ماژول
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import pharaghy_codal as fpyc
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
در صورت نیاز به پروکسی:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Windows PowerShell
|
|
91
|
+
$env:PHARAGHY_CODAL_PROXY = "http://127.0.0.1:PORT"
|
|
92
|
+
|
|
93
|
+
# Linux / macOS
|
|
94
|
+
export PHARAGHY_CODAL_PROXY=http://127.0.0.1:PORT
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
> کدال معمولاً فقط از داخل ایران یا با IP/پروکسی ایرانی پاسخ میدهد.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
# اطلاعات شرکت
|
|
102
|
+
|
|
103
|
+
### دریافت مشخصات شرکت
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
fpyc.get_company(symbol="شپنا")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### دریافت پایان سالهای مالی
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
fpyc.get_financial_years(symbol="شپنا")
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
# جستجوی اطلاعیهها
|
|
118
|
+
|
|
119
|
+
### لیست انواع و گروههای گزارش
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
fpyc.get_letter_groups()
|
|
123
|
+
fpyc.get_letter_types(category=1)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### جستجو
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
fpyc.search_letters(
|
|
130
|
+
symbol="خودرو",
|
|
131
|
+
letter_type=None, # مثلاً 6 = صورت مالی، 58 = ماهانه
|
|
132
|
+
letter_code="ن-42", # کد رسمی اطلاعیه (در صورت پشتیبانی API)
|
|
133
|
+
title=None, # کلمات کوتاه داخل عنوان
|
|
134
|
+
period_months=None,
|
|
135
|
+
from_date=None, # YYYY/MM/DD شمسی
|
|
136
|
+
to_date=None,
|
|
137
|
+
page=1,
|
|
138
|
+
)
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### کدهای رسمی اطلاعیه (ن-۱۰ … ن-۸۱)
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
fpyc.list_notice_codes()
|
|
145
|
+
fpyc.list_notice_codes("capital_increase")
|
|
146
|
+
fpyc.notice_title("ن-30")
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
# خواندن یک اطلاعیه و دانلود فایل
|
|
152
|
+
|
|
153
|
+
### خواندن جداول و متادیتا
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
letter = fpyc.get_letter(tracing_no=1562697)
|
|
157
|
+
print(letter.title, letter.period_end, letter.unit_note)
|
|
158
|
+
print(len(letter.tables))
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### دانلود اکسل / PDF / پیوست
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
fpyc.download_excel(1562697, "report.xlsx")
|
|
165
|
+
fpyc.download_pdf(1592996, "notice.pdf")
|
|
166
|
+
fpyc.download_attachments(1592996, "attachments_folder")
|
|
167
|
+
fpyc.download_file(url, "file.bin") # هر لینک کدال
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
# صورتهای مالی (سطح بالاتر)
|
|
173
|
+
|
|
174
|
+
### لیست گزارشها با امتیاز (ترجیح تلفیقی)
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
fpyc.list_financial_letters(symbol="شپنا", period_months=12)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### صورت سود و زیان
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
df = fpyc.get_income_statement(symbol="شپنا", period_months=12)
|
|
184
|
+
print(df.head())
|
|
185
|
+
print(df.attrs.get("period_end"), df.attrs.get("unit_note"))
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
# گزارش فعالیت ماهانه
|
|
191
|
+
|
|
192
|
+
### لیست و دریافت
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
fpyc.list_monthly_letters(symbol="شپنا")
|
|
196
|
+
|
|
197
|
+
data = fpyc.get_monthly_activity(symbol="شپنا")
|
|
198
|
+
print(data["meta"])
|
|
199
|
+
print({k: len(v) for k, v in data["tables"].items()})
|
|
200
|
+
|
|
201
|
+
fpyc.get_monthly_production_sales(symbol="شپنا")
|
|
202
|
+
fpyc.get_monthly_materials(symbol="شپنا")
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### یک ماه مشخص
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
chosen = fpyc.find_monthly_letter("شپنا", "1405/04") # تیر
|
|
209
|
+
data = fpyc.get_monthly_activity("شپنا", tracing_no=chosen["tracing_no"])
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
# نمونهٔ جریان کار: ن-۴۲ نماد خودرو
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
import pharaghy_codal as fpyc
|
|
218
|
+
|
|
219
|
+
def norm_code(c):
|
|
220
|
+
s = (c or "").replace(" ", "")
|
|
221
|
+
for a, b in zip("۰۱۲۳۴۵۶۷۸۹", "0123456789"):
|
|
222
|
+
s = s.replace(a, b)
|
|
223
|
+
return s
|
|
224
|
+
|
|
225
|
+
items = []
|
|
226
|
+
first = fpyc.search_letters(symbol="خودرو", page=1)
|
|
227
|
+
pages = max(1, (first.total + 19) // 20)
|
|
228
|
+
for page in range(1, min(pages, 30) + 1): # برای تست محدود کنید
|
|
229
|
+
r = first if page == 1 else fpyc.search_letters(symbol="خودرو", page=page)
|
|
230
|
+
for L in r.letters:
|
|
231
|
+
if norm_code(L.code) == "ن-42" and "عادی سالیانه" in (L.title or ""):
|
|
232
|
+
items.append(L)
|
|
233
|
+
|
|
234
|
+
for i, L in enumerate(items, 1):
|
|
235
|
+
print(i, L.tracing_no, L.title)
|
|
236
|
+
|
|
237
|
+
# پس از انتخاب کاربر:
|
|
238
|
+
# fpyc.download_pdf(items[0].tracing_no, "khodro_n42.pdf")
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
# وابستگیها
|
|
244
|
+
|
|
245
|
+
- Python ≥ 3.10
|
|
246
|
+
- httpx, pandas, openpyxl, lxml
|
|
247
|
+
|
|
248
|
+
# مجوز
|
|
249
|
+
|
|
250
|
+
MIT License — استفاده، تغییر و انتشار آزاد است.
|
|
251
|
+
دادهها از API عمومی غیررسمی کدال خوانده میشوند؛ این پروژه وابسته به سازمان بورس نیست.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
# ارتباط
|
|
256
|
+
|
|
257
|
+
- **کانال تلگرام:** [bourse_faraghy](https://t.me/bourse_faraghy)
|
|
258
|
+
- Issues و پیشنهادها: از بخش Issues همین ریپو استفاده کنید.
|
|
259
|
+
|
|
260
|
+
# وضعیت
|
|
261
|
+
|
|
262
|
+
نسخهٔ فعلی: **0.3.1** (Alpha)
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/logo.png" alt="PharaghY Codal" width="160"/>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# PharaghY-codal
|
|
6
|
+
|
|
7
|
+
##### این ماژول با هدف دسترسی به اطلاعیهها و گزارشهای سامانهٔ **کدال** در محیط برنامهنویسی پایتون توسعه یافته است. با آن میتوانید صورتهای مالی، گزارش فعالیت ماهانه، مجامع، افزایش سرمایه و سایر افشاها را بهصورت برنامهنویسی دریافت کنید و در مدلهای تحلیل بنیادی یا پردازش داده بهکار ببرید. خروجی بسیاری از توابع، **دیتافریم پانداز** یا اشیاء سادهٔ پایتونی است.
|
|
8
|
+
|
|
9
|
+
#### از جمله ویژگیهای مهم این ماژول میتوان به موارد زیر اشاره کرد
|
|
10
|
+
|
|
11
|
+
قابلیت جستجوی شرکت با نماد و دریافت مشخصات ناشر ←
|
|
12
|
+
|
|
13
|
+
قابلیت جستجوی اطلاعیهها بر اساس نماد، نوع گزارش، دوره، تاریخ و کد اطلاعیه (ن-۱۰ … ن-۸۱) ←
|
|
14
|
+
|
|
15
|
+
قابلیت خواندن جداول یک اطلاعیه و تبدیل به DataFrame ←
|
|
16
|
+
|
|
17
|
+
قابلیت دریافت صورت سود و زیان با اولویت گزارش تلفیقی ←
|
|
18
|
+
|
|
19
|
+
قابلیت دریافت گزارش فعالیت ماهانه (تولید، مواد، انرژی و …) ←
|
|
20
|
+
|
|
21
|
+
قابلیت دانلود فایل اکسل، PDF و پیوستهای اطلاعیه ←
|
|
22
|
+
|
|
23
|
+
مدیریت فاصله بین درخواستها، retry روی قطع اتصال و صبر خودکار روی rate-limit کدال ←
|
|
24
|
+
|
|
25
|
+
پشتیبانی از پروکسی ایرانی از طریق متغیر محیطی ←
|
|
26
|
+
|
|
27
|
+
##### این مخزن در حال توسعه است. برای نمونه کدها به پوشهٔ [examples](examples/) مراجعه کنید.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
# نصب ماژول
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install PharaghY-codal
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
یا از سورس:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
git clone https://github.com/YusefRahimi/PharaghY_Codal.git
|
|
41
|
+
cd PharaghY_Codal
|
|
42
|
+
pip install -e .
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
# فراخوانی ماژول
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import pharaghy_codal as fpyc
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
در صورت نیاز به پروکسی:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Windows PowerShell
|
|
55
|
+
$env:PHARAGHY_CODAL_PROXY = "http://127.0.0.1:PORT"
|
|
56
|
+
|
|
57
|
+
# Linux / macOS
|
|
58
|
+
export PHARAGHY_CODAL_PROXY=http://127.0.0.1:PORT
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
> کدال معمولاً فقط از داخل ایران یا با IP/پروکسی ایرانی پاسخ میدهد.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
# اطلاعات شرکت
|
|
66
|
+
|
|
67
|
+
### دریافت مشخصات شرکت
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
fpyc.get_company(symbol="شپنا")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### دریافت پایان سالهای مالی
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
fpyc.get_financial_years(symbol="شپنا")
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
# جستجوی اطلاعیهها
|
|
82
|
+
|
|
83
|
+
### لیست انواع و گروههای گزارش
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
fpyc.get_letter_groups()
|
|
87
|
+
fpyc.get_letter_types(category=1)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### جستجو
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
fpyc.search_letters(
|
|
94
|
+
symbol="خودرو",
|
|
95
|
+
letter_type=None, # مثلاً 6 = صورت مالی، 58 = ماهانه
|
|
96
|
+
letter_code="ن-42", # کد رسمی اطلاعیه (در صورت پشتیبانی API)
|
|
97
|
+
title=None, # کلمات کوتاه داخل عنوان
|
|
98
|
+
period_months=None,
|
|
99
|
+
from_date=None, # YYYY/MM/DD شمسی
|
|
100
|
+
to_date=None,
|
|
101
|
+
page=1,
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### کدهای رسمی اطلاعیه (ن-۱۰ … ن-۸۱)
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
fpyc.list_notice_codes()
|
|
109
|
+
fpyc.list_notice_codes("capital_increase")
|
|
110
|
+
fpyc.notice_title("ن-30")
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
# خواندن یک اطلاعیه و دانلود فایل
|
|
116
|
+
|
|
117
|
+
### خواندن جداول و متادیتا
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
letter = fpyc.get_letter(tracing_no=1562697)
|
|
121
|
+
print(letter.title, letter.period_end, letter.unit_note)
|
|
122
|
+
print(len(letter.tables))
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### دانلود اکسل / PDF / پیوست
|
|
126
|
+
|
|
127
|
+
```python
|
|
128
|
+
fpyc.download_excel(1562697, "report.xlsx")
|
|
129
|
+
fpyc.download_pdf(1592996, "notice.pdf")
|
|
130
|
+
fpyc.download_attachments(1592996, "attachments_folder")
|
|
131
|
+
fpyc.download_file(url, "file.bin") # هر لینک کدال
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
# صورتهای مالی (سطح بالاتر)
|
|
137
|
+
|
|
138
|
+
### لیست گزارشها با امتیاز (ترجیح تلفیقی)
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
fpyc.list_financial_letters(symbol="شپنا", period_months=12)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### صورت سود و زیان
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
df = fpyc.get_income_statement(symbol="شپنا", period_months=12)
|
|
148
|
+
print(df.head())
|
|
149
|
+
print(df.attrs.get("period_end"), df.attrs.get("unit_note"))
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
# گزارش فعالیت ماهانه
|
|
155
|
+
|
|
156
|
+
### لیست و دریافت
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
fpyc.list_monthly_letters(symbol="شپنا")
|
|
160
|
+
|
|
161
|
+
data = fpyc.get_monthly_activity(symbol="شپنا")
|
|
162
|
+
print(data["meta"])
|
|
163
|
+
print({k: len(v) for k, v in data["tables"].items()})
|
|
164
|
+
|
|
165
|
+
fpyc.get_monthly_production_sales(symbol="شپنا")
|
|
166
|
+
fpyc.get_monthly_materials(symbol="شپنا")
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### یک ماه مشخص
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
chosen = fpyc.find_monthly_letter("شپنا", "1405/04") # تیر
|
|
173
|
+
data = fpyc.get_monthly_activity("شپنا", tracing_no=chosen["tracing_no"])
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
# نمونهٔ جریان کار: ن-۴۲ نماد خودرو
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
import pharaghy_codal as fpyc
|
|
182
|
+
|
|
183
|
+
def norm_code(c):
|
|
184
|
+
s = (c or "").replace(" ", "")
|
|
185
|
+
for a, b in zip("۰۱۲۳۴۵۶۷۸۹", "0123456789"):
|
|
186
|
+
s = s.replace(a, b)
|
|
187
|
+
return s
|
|
188
|
+
|
|
189
|
+
items = []
|
|
190
|
+
first = fpyc.search_letters(symbol="خودرو", page=1)
|
|
191
|
+
pages = max(1, (first.total + 19) // 20)
|
|
192
|
+
for page in range(1, min(pages, 30) + 1): # برای تست محدود کنید
|
|
193
|
+
r = first if page == 1 else fpyc.search_letters(symbol="خودرو", page=page)
|
|
194
|
+
for L in r.letters:
|
|
195
|
+
if norm_code(L.code) == "ن-42" and "عادی سالیانه" in (L.title or ""):
|
|
196
|
+
items.append(L)
|
|
197
|
+
|
|
198
|
+
for i, L in enumerate(items, 1):
|
|
199
|
+
print(i, L.tracing_no, L.title)
|
|
200
|
+
|
|
201
|
+
# پس از انتخاب کاربر:
|
|
202
|
+
# fpyc.download_pdf(items[0].tracing_no, "khodro_n42.pdf")
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
# وابستگیها
|
|
208
|
+
|
|
209
|
+
- Python ≥ 3.10
|
|
210
|
+
- httpx, pandas, openpyxl, lxml
|
|
211
|
+
|
|
212
|
+
# مجوز
|
|
213
|
+
|
|
214
|
+
MIT License — استفاده، تغییر و انتشار آزاد است.
|
|
215
|
+
دادهها از API عمومی غیررسمی کدال خوانده میشوند؛ این پروژه وابسته به سازمان بورس نیست.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
# ارتباط
|
|
220
|
+
|
|
221
|
+
- **کانال تلگرام:** [bourse_faraghy](https://t.me/bourse_faraghy)
|
|
222
|
+
- Issues و پیشنهادها: از بخش Issues همین ریپو استفاده کنید.
|
|
223
|
+
|
|
224
|
+
# وضعیت
|
|
225
|
+
|
|
226
|
+
نسخهٔ فعلی: **0.3.1** (Alpha)
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# مرجع سریع API — PharaghY-codal
|
|
2
|
+
|
|
3
|
+
```python
|
|
4
|
+
import pharaghy_codal as fpyc
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
## شرکت
|
|
8
|
+
|
|
9
|
+
| تابع | کار |
|
|
10
|
+
|------|-----|
|
|
11
|
+
| `get_company(symbol)` | مشخصات ناشر |
|
|
12
|
+
| `get_financial_years(symbol)` | پایان سالهای مالی |
|
|
13
|
+
|
|
14
|
+
## جستجو
|
|
15
|
+
|
|
16
|
+
| تابع | کار |
|
|
17
|
+
|------|-----|
|
|
18
|
+
| `search_letters(...)` | یک صفحه نتیجه |
|
|
19
|
+
| `iter_letters(...)` | پیمایش همه صفحات |
|
|
20
|
+
| `search_all(...)` | لیست همه نتایج |
|
|
21
|
+
| `search_by_notice_code(symbol, "ن-42")` | فیلتر کد رسمی ن-… |
|
|
22
|
+
| `search_by_letter_type(symbol, 6)` | فیلتر letter_type عددی |
|
|
23
|
+
|
|
24
|
+
**LetterType** = عدد API (۶، ۵۸، …)
|
|
25
|
+
**LetterCode** = برچسب `ن-10` / `ن-42` روی هر اطلاعیه
|
|
26
|
+
|
|
27
|
+
## خواندن یک اطلاعیه
|
|
28
|
+
|
|
29
|
+
| تابع | کار |
|
|
30
|
+
|------|-----|
|
|
31
|
+
| `get_letter(tracing_no)` | متادیتا + جداول/متن + پیوستها |
|
|
32
|
+
| `list_files(tracing_no)` | منابع قابل دانلود |
|
|
33
|
+
| `letter_content_kind(letter)` | `tables` / `text` / `files_only` / `empty` |
|
|
34
|
+
|
|
35
|
+
## دانلود
|
|
36
|
+
|
|
37
|
+
| تابع | کار |
|
|
38
|
+
|------|-----|
|
|
39
|
+
| `download_excel(tn, path)` | اکسل کدال |
|
|
40
|
+
| `download_pdf(tn, path)` | PDF یا پیوست جایگزین |
|
|
41
|
+
| `download_attachments(tn, dir)` | همه پیوستها |
|
|
42
|
+
| `download_all_files(tn, dir)` | اکسل + PDF + پیوستها |
|
|
43
|
+
| `download_file(url, path)` | هر لینک کدال |
|
|
44
|
+
|
|
45
|
+
## سطح بالاتر (تحلیل)
|
|
46
|
+
|
|
47
|
+
| تابع | کار |
|
|
48
|
+
|------|-----|
|
|
49
|
+
| `get_income_statement(symbol)` | صورت سود → DataFrame |
|
|
50
|
+
| `get_monthly_activity(symbol)` | گزارش ماهانه گروهبندیشده |
|
|
51
|
+
| `list_notice_codes()` | فهرست ن-۱۰ … ن-۸۱ |
|
|
52
|
+
|
|
53
|
+
## شبکه
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
fpyc.configure_client(timeout=60, min_interval=2.5, cache_dir=".codal_cache")
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
متغیرهای محیطی: `PHARAGHY_CODAL_PROXY`, `PHARAGHY_CODAL_TIMEOUT`,
|
|
60
|
+
`PHARAGHY_CODAL_MIN_INTERVAL`, `PHARAGHY_CODAL_MAX_RETRIES`, `PHARAGHY_CODAL_CACHE_DIR`
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# مثالهای PharaghY-codal
|
|
2
|
+
|
|
3
|
+
نیاز به اتصال به کدال (ترجیحاً IP ایران).
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install -e .
|
|
7
|
+
python examples/list_notice_codes.py # بدون شبکه
|
|
8
|
+
python examples/basic_income.py # صورت سود
|
|
9
|
+
python examples/monthly_activity.py # ماهانه
|
|
10
|
+
python examples/search_notice_code.py # ن-42 و مشابه
|
|
11
|
+
python examples/search_monthly_type.py # letter_type=58
|
|
12
|
+
python examples/download_files.py # دانلود فایلها
|
|
13
|
+
python examples/workflow_notice_download.py # جریان کامل
|
|
14
|
+
python examples/invalid_symbol.py # نماد نامعتبر
|
|
15
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""مثال: صورت سود و زیان سالانه یک نماد."""
|
|
2
|
+
from pharaghy_codal import get_company, get_income_statement
|
|
3
|
+
|
|
4
|
+
SYMBOL = "شپنا"
|
|
5
|
+
|
|
6
|
+
company = get_company(SYMBOL)
|
|
7
|
+
print(f"{company.symbol} | {company.name} | {company.market}")
|
|
8
|
+
|
|
9
|
+
df = get_income_statement(SYMBOL, period_months=12)
|
|
10
|
+
print("عنوان:", df.attrs.get("title"))
|
|
11
|
+
print("پایان دوره:", df.attrs.get("period_end"))
|
|
12
|
+
print("واحد:", df.attrs.get("unit_note"))
|
|
13
|
+
print(df.head(15).to_string(index=False))
|