zerodha-summary 0.1.0__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.
@@ -0,0 +1,3 @@
1
+ config.ini
2
+ *.pdf
3
+ *.png
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rama Narayana
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,163 @@
1
+ Metadata-Version: 2.4
2
+ Name: zerodha-summary
3
+ Version: 0.1.0
4
+ Summary: Screenshot Zerodha portfolio pages, compile to PDF, and email it
5
+ Project-URL: Homepage, https://github.com/ramnar/zerodha-summary
6
+ Author-email: Rama Narayana <raam.soft@gmail.com>
7
+ License: MIT
8
+ License-File: LICENSE
9
+ Keywords: email,pdf,portfolio,screenshot,zerodha
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: End Users/Desktop
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Office/Business :: Financial
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: img2pdf>=0.5.0
19
+ Requires-Dist: pillow>=10.0.0
20
+ Requires-Dist: playwright>=1.40.0
21
+ Description-Content-Type: text/markdown
22
+
23
+ # Zerodha Portfolio Summary Mailer
24
+
25
+ Automates the process of logging into Zerodha, taking screenshots of key portfolio pages, compiling them into a PDF, and emailing the PDF to a recipient.
26
+
27
+ ---
28
+
29
+ ## What it does
30
+
31
+ 1. Opens a visible browser and navigates to the Zerodha login page
32
+ 2. Waits for you to log in manually (supports OTP / 2FA)
33
+ 3. Screenshots each configured page
34
+ 4. For the **Tradebook** page, iterates through every segment (Equity, F&O, Currency, etc.) with a 3-month date range, and captures all pagination pages per segment
35
+ 5. Compiles all screenshots into a single PDF
36
+ 6. Opens the PDF for your review
37
+ 7. Sends the PDF by email only after you confirm
38
+
39
+ ---
40
+
41
+ ## Requirements
42
+
43
+ - Python 3.10+
44
+ - A Gmail account with an **App Password** (see setup below)
45
+
46
+ ### Install dependencies
47
+
48
+ ```bash
49
+ pip install playwright pillow img2pdf
50
+ playwright install chromium
51
+ ```
52
+
53
+ ---
54
+
55
+ ## Configuration
56
+
57
+ The program reads settings from `config.ini`. A template is provided — copy it and fill in your details:
58
+
59
+ ```bash
60
+ cp config.ini.template config.ini
61
+ ```
62
+
63
+ Then edit `config.ini`:
64
+
65
+ ```ini
66
+ [settings]
67
+ base_url = https://kite.zerodha.com/ # Login page URL
68
+ pages = https://console.zerodha.com/reports/tradebook
69
+ https://console.zerodha.com/account/demat
70
+ https://console.zerodha.com/portfolio/corporate-action-order-window
71
+ https://coin.zerodha.com/dashboard
72
+
73
+ receiver_email = recipient@example.com # Who receives the PDF
74
+ sender_email = yourname@gmail.com # Gmail address used to send
75
+ password = your-gmail-app-password # Gmail App Password (see below)
76
+ smtp_host = smtp.gmail.com
77
+ smtp_port = 587
78
+ no_tls = false
79
+ subject = Zerodha Portfolio Summary
80
+ body = Please find the Zerodha screenshots attached as a PDF.
81
+ output_pdf = zerodha_summary.pdf
82
+ width = 1280 # Browser viewport width in pixels
83
+ ```
84
+
85
+ > **Note:** `config.ini` is excluded from git (via `.gitignore`) to protect your credentials. Never commit it.
86
+
87
+ ### Gmail App Password setup
88
+
89
+ Gmail requires an App Password when 2-Step Verification is enabled:
90
+
91
+ 1. Go to [Google Account → Security](https://myaccount.google.com/security)
92
+ 2. Under **How you sign in to Google**, click **2-Step Verification**
93
+ 3. Scroll to the bottom and click **App passwords**
94
+ 4. Create a new app password (e.g. name it "Zerodha Mailer")
95
+ 5. Copy the 16-character password (spaces are optional) into `config.ini` under `password`
96
+
97
+ ### Pages configuration
98
+
99
+ - Each URL goes on its own line, indented under `pages =`
100
+ - The **Tradebook** page (`/reports/tradebook`) is handled specially: the program automatically iterates all segments and date ranges
101
+ - All other pages are screenshotted as-is (full page)
102
+
103
+ ---
104
+
105
+ ## Running the program
106
+
107
+ ```bash
108
+ python3 screenshot_to_pdf_mailer.py
109
+ ```
110
+
111
+ ### What happens step by step
112
+
113
+ | Step | What you see |
114
+ |------|-------------|
115
+ | 1 | Browser opens to `base_url` (Zerodha login) |
116
+ | 2 | Log in with your credentials + OTP |
117
+ | 3 | Press **Enter** in the terminal to confirm login |
118
+ | 4 | Program navigates to each page and takes screenshots |
119
+ | 5 | For Tradebook: selects each segment, sets Dec 1 – today date range, captures all pages |
120
+ | 6 | PDF is compiled and opened in your PDF viewer |
121
+ | 7 | Type **`yes`** in the terminal to send the email, or anything else to cancel |
122
+
123
+ ### Overriding config from the command line
124
+
125
+ Any setting in `config.ini` can be overridden with a CLI argument:
126
+
127
+ ```bash
128
+ python3 screenshot_to_pdf_mailer.py \
129
+ --receiver-email other@example.com \
130
+ --subject "March 2026 Summary" \
131
+ --output-pdf march_2026.pdf
132
+ ```
133
+
134
+ Use `--config` to point to a different config file:
135
+
136
+ ```bash
137
+ python3 screenshot_to_pdf_mailer.py --config my_other_config.ini
138
+ ```
139
+
140
+ ---
141
+
142
+ ## File structure
143
+
144
+ ```
145
+ zerodha-summary/
146
+ ├── screenshot_to_pdf_mailer.py # Main program
147
+ ├── config.ini.template # Template — safe to commit
148
+ ├── config.ini # Your local config — DO NOT commit
149
+ ├── .gitignore # Excludes config.ini, *.pdf, *.png
150
+ └── README.md # This file
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Troubleshooting
156
+
157
+ | Problem | Fix |
158
+ |---------|-----|
159
+ | `Missing dependency` error | Run `pip install playwright pillow img2pdf` and `playwright install chromium` |
160
+ | Gmail login fails | Make sure you are using an **App Password**, not your regular Gmail password |
161
+ | Tradebook segment not found | Check the `[DOM] selects` line printed in the terminal — the segment name must match exactly |
162
+ | Pagination not detected | Check the `[pagination]` line printed in the terminal for the actual button classes |
163
+ | PDF not opening | Install a PDF viewer (`sudo apt install evince` on Ubuntu) |
@@ -0,0 +1,141 @@
1
+ # Zerodha Portfolio Summary Mailer
2
+
3
+ Automates the process of logging into Zerodha, taking screenshots of key portfolio pages, compiling them into a PDF, and emailing the PDF to a recipient.
4
+
5
+ ---
6
+
7
+ ## What it does
8
+
9
+ 1. Opens a visible browser and navigates to the Zerodha login page
10
+ 2. Waits for you to log in manually (supports OTP / 2FA)
11
+ 3. Screenshots each configured page
12
+ 4. For the **Tradebook** page, iterates through every segment (Equity, F&O, Currency, etc.) with a 3-month date range, and captures all pagination pages per segment
13
+ 5. Compiles all screenshots into a single PDF
14
+ 6. Opens the PDF for your review
15
+ 7. Sends the PDF by email only after you confirm
16
+
17
+ ---
18
+
19
+ ## Requirements
20
+
21
+ - Python 3.10+
22
+ - A Gmail account with an **App Password** (see setup below)
23
+
24
+ ### Install dependencies
25
+
26
+ ```bash
27
+ pip install playwright pillow img2pdf
28
+ playwright install chromium
29
+ ```
30
+
31
+ ---
32
+
33
+ ## Configuration
34
+
35
+ The program reads settings from `config.ini`. A template is provided — copy it and fill in your details:
36
+
37
+ ```bash
38
+ cp config.ini.template config.ini
39
+ ```
40
+
41
+ Then edit `config.ini`:
42
+
43
+ ```ini
44
+ [settings]
45
+ base_url = https://kite.zerodha.com/ # Login page URL
46
+ pages = https://console.zerodha.com/reports/tradebook
47
+ https://console.zerodha.com/account/demat
48
+ https://console.zerodha.com/portfolio/corporate-action-order-window
49
+ https://coin.zerodha.com/dashboard
50
+
51
+ receiver_email = recipient@example.com # Who receives the PDF
52
+ sender_email = yourname@gmail.com # Gmail address used to send
53
+ password = your-gmail-app-password # Gmail App Password (see below)
54
+ smtp_host = smtp.gmail.com
55
+ smtp_port = 587
56
+ no_tls = false
57
+ subject = Zerodha Portfolio Summary
58
+ body = Please find the Zerodha screenshots attached as a PDF.
59
+ output_pdf = zerodha_summary.pdf
60
+ width = 1280 # Browser viewport width in pixels
61
+ ```
62
+
63
+ > **Note:** `config.ini` is excluded from git (via `.gitignore`) to protect your credentials. Never commit it.
64
+
65
+ ### Gmail App Password setup
66
+
67
+ Gmail requires an App Password when 2-Step Verification is enabled:
68
+
69
+ 1. Go to [Google Account → Security](https://myaccount.google.com/security)
70
+ 2. Under **How you sign in to Google**, click **2-Step Verification**
71
+ 3. Scroll to the bottom and click **App passwords**
72
+ 4. Create a new app password (e.g. name it "Zerodha Mailer")
73
+ 5. Copy the 16-character password (spaces are optional) into `config.ini` under `password`
74
+
75
+ ### Pages configuration
76
+
77
+ - Each URL goes on its own line, indented under `pages =`
78
+ - The **Tradebook** page (`/reports/tradebook`) is handled specially: the program automatically iterates all segments and date ranges
79
+ - All other pages are screenshotted as-is (full page)
80
+
81
+ ---
82
+
83
+ ## Running the program
84
+
85
+ ```bash
86
+ python3 screenshot_to_pdf_mailer.py
87
+ ```
88
+
89
+ ### What happens step by step
90
+
91
+ | Step | What you see |
92
+ |------|-------------|
93
+ | 1 | Browser opens to `base_url` (Zerodha login) |
94
+ | 2 | Log in with your credentials + OTP |
95
+ | 3 | Press **Enter** in the terminal to confirm login |
96
+ | 4 | Program navigates to each page and takes screenshots |
97
+ | 5 | For Tradebook: selects each segment, sets Dec 1 – today date range, captures all pages |
98
+ | 6 | PDF is compiled and opened in your PDF viewer |
99
+ | 7 | Type **`yes`** in the terminal to send the email, or anything else to cancel |
100
+
101
+ ### Overriding config from the command line
102
+
103
+ Any setting in `config.ini` can be overridden with a CLI argument:
104
+
105
+ ```bash
106
+ python3 screenshot_to_pdf_mailer.py \
107
+ --receiver-email other@example.com \
108
+ --subject "March 2026 Summary" \
109
+ --output-pdf march_2026.pdf
110
+ ```
111
+
112
+ Use `--config` to point to a different config file:
113
+
114
+ ```bash
115
+ python3 screenshot_to_pdf_mailer.py --config my_other_config.ini
116
+ ```
117
+
118
+ ---
119
+
120
+ ## File structure
121
+
122
+ ```
123
+ zerodha-summary/
124
+ ├── screenshot_to_pdf_mailer.py # Main program
125
+ ├── config.ini.template # Template — safe to commit
126
+ ├── config.ini # Your local config — DO NOT commit
127
+ ├── .gitignore # Excludes config.ini, *.pdf, *.png
128
+ └── README.md # This file
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Troubleshooting
134
+
135
+ | Problem | Fix |
136
+ |---------|-----|
137
+ | `Missing dependency` error | Run `pip install playwright pillow img2pdf` and `playwright install chromium` |
138
+ | Gmail login fails | Make sure you are using an **App Password**, not your regular Gmail password |
139
+ | Tradebook segment not found | Check the `[DOM] selects` line printed in the terminal — the segment name must match exactly |
140
+ | Pagination not detected | Check the `[pagination]` line printed in the terminal for the actual button classes |
141
+ | PDF not opening | Install a PDF viewer (`sudo apt install evince` on Ubuntu) |
@@ -0,0 +1,17 @@
1
+ [settings]
2
+ base_url = https://kite.zerodha.com/
3
+ pages = https://console.zerodha.com/reports/tradebook
4
+ https://console.zerodha.com/account/demat
5
+ https://console.zerodha.com/portfolio/corporate-action-order-window
6
+ https://coin.zerodha.com/dashboard
7
+
8
+ receiver_email = recipient@example.com
9
+ sender_email = yourname@gmail.com
10
+ password = your-gmail-app-password
11
+ smtp_host = smtp.gmail.com
12
+ smtp_port = 587
13
+ no_tls = false
14
+ subject = Zerodha Portfolio Summary
15
+ body = Please find the Zerodha screenshots attached as a PDF.
16
+ output_pdf = zerodha_summary.pdf
17
+ width = 1280
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "zerodha-summary"
7
+ version = "0.1.0"
8
+ description = "Screenshot Zerodha portfolio pages, compile to PDF, and email it"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Rama Narayana", email = "raam.soft@gmail.com"}
14
+ ]
15
+ keywords = ["zerodha", "portfolio", "pdf", "screenshot", "email"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: End Users/Desktop",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Topic :: Office/Business :: Financial",
24
+ ]
25
+ dependencies = [
26
+ "playwright>=1.40.0",
27
+ "pillow>=10.0.0",
28
+ "img2pdf>=0.5.0",
29
+ ]
30
+
31
+ [project.scripts]
32
+ zerodha-summary = "zerodha_summary.mailer:main"
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/ramnar/zerodha-summary"
36
+
37
+ [tool.hatch.build.targets.wheel]
38
+ packages = ["zerodha_summary"]
@@ -0,0 +1,3 @@
1
+ playwright
2
+ pillow
3
+ img2pdf