ayush-ipo 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,62 @@
1
+ name: "Release and Publish"
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*.*.*"
7
+
8
+ jobs:
9
+ Build:
10
+ name: "Tagged Release"
11
+ runs-on: "ubuntu-latest"
12
+
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v3
16
+ with:
17
+ ref: main
18
+
19
+ - name: Set ENV
20
+ run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
21
+
22
+ - name: Install uv
23
+ uses: astral-sh/setup-uv@v4
24
+ with:
25
+ enable-cache: true
26
+
27
+ - name: Setup Python
28
+ run: uv python install 3.11
29
+
30
+ - name: Bump package version
31
+ run: |
32
+ VERSION=$(echo "${{ env.RELEASE_VERSION }}" | sed 's/v//')
33
+ sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
34
+
35
+ - name: Commit and push version bump
36
+ run: |
37
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
38
+ git config user.name "github-actions[bot]"
39
+ git add -u
40
+ git commit -m "chore(release): ${{ env.RELEASE_VERSION }} release"
41
+ git push
42
+
43
+ - name: Install Dependencies
44
+ run: uv sync
45
+
46
+ - name: Build
47
+ run: uv build
48
+
49
+ - name: Release
50
+ shell: bash
51
+ env:
52
+ PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
53
+ run: |
54
+ uv publish --token $PYPI_API_TOKEN
55
+
56
+ - uses: "marvinpinto/action-automatic-releases@latest"
57
+ with:
58
+ repo_token: "${{ secrets.GITHUB_TOKEN }}"
59
+ prerelease: false
60
+ draft: true
61
+ files: |
62
+ dist/*.whl
@@ -0,0 +1,8 @@
1
+ dist/
2
+ .vim/
3
+ .vscode/
4
+ __pycache__/
5
+ capitals.json
6
+ data.json
7
+ test.py
8
+ nepseutils_sync.json
@@ -0,0 +1,580 @@
1
+ # NEPSE Utils - Complete API Calls Analysis
2
+
3
+ ## Base Configuration
4
+ - **API Base URL**: `https://webbackend.cdsc.com.np/api`
5
+ - **Result API**: `https://iporesult.cdsc.com.np`
6
+ - **Web Frontend**: `https://meroshare.cdsc.com.np`
7
+
8
+ ---
9
+
10
+ ## Task 1: ADD ACCOUNT
11
+ **Command**: `add {dmat} {password} {crn} {pin}`
12
+
13
+ ### Purpose
14
+ Add a new investment account to the system.
15
+
16
+ ### API Calls
17
+
18
+ #### 1.1 Login (Authentication)
19
+ ```
20
+ Method: POST
21
+ Endpoint: /meroShare/auth/
22
+ Headers:
23
+ - Authorization: "null"
24
+ - Content-Type: application/json
25
+ Body:
26
+ {
27
+ "clientId": str(capital_id),
28
+ "username": username,
29
+ "password": password
30
+ }
31
+ Response: auth_token in Authorization header
32
+ Error Handling: Checks for passwordExpired, accountExpired, dematExpired
33
+ ```
34
+
35
+ #### 1.2 Get Account Details
36
+ ```
37
+ Method: GET
38
+ Endpoint: /meroShareView/myDetail/{dmat}
39
+ Headers:
40
+ - Authorization: auth_token
41
+ Response: Account details including name, bankCode
42
+ ```
43
+
44
+ #### 1.3 Get Bank Details by Code
45
+ ```
46
+ Method: GET
47
+ Endpoint: /bankRequest/{bank_code}
48
+ Headers:
49
+ - Authorization: auth_token
50
+ Response: Bank details including accountNumber
51
+ ```
52
+
53
+ #### 1.4 Get Bank List
54
+ ```
55
+ Method: GET
56
+ Endpoint: /meroShare/bank/
57
+ Headers:
58
+ - Authorization: auth_token
59
+ Response: List of banks with their IDs
60
+ ```
61
+
62
+ #### 1.5 Get Bank-Specific Details
63
+ ```
64
+ Method: GET
65
+ Endpoint: /meroShare/bank/{bank_id}
66
+ Headers:
67
+ - Authorization: auth_token
68
+ Response: Bank details including accountBranchId, accountTypeId
69
+ ```
70
+
71
+ #### 1.6 Fetch Capital List (Background)
72
+ ```
73
+ Method: GET
74
+ Endpoint: /meroShare/capital/
75
+ Headers:
76
+ - Authorization: "null"
77
+ Response: List of capitals with code and ID mappings
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Task 2: APPLY FOR IPO
83
+ **Command**: `apply`
84
+
85
+ ### Purpose
86
+ Apply for available IPO shares across selected accounts.
87
+
88
+ ### API Calls
89
+
90
+ #### 2.1 Login
91
+ ```
92
+ Method: POST
93
+ Endpoint: /meroShare/auth/
94
+ (Same as Task 1.1)
95
+ ```
96
+
97
+ #### 2.2 Fetch Applicable Issues (Available IPOs)
98
+ ```
99
+ Method: POST
100
+ Endpoint: /meroShare/companyShare/applicableIssue/
101
+ Headers:
102
+ - Authorization: auth_token
103
+ - Content-Type: application/json
104
+ Body:
105
+ {
106
+ "filterFieldParams": [
107
+ {
108
+ "key": "companyIssue.companyISIN.script",
109
+ "alias": "Scrip"
110
+ },
111
+ {
112
+ "key": "companyIssue.companyISIN.company.name",
113
+ "alias": "Company Name"
114
+ },
115
+ {
116
+ "key": "companyIssue.assignedToClient.name",
117
+ "value": "",
118
+ "alias": "Issue Manager"
119
+ }
120
+ ],
121
+ "page": 1,
122
+ "size": 10,
123
+ "searchRoleViewConstants": "VIEW_APPLICABLE_SHARE",
124
+ "filterDateParams": [...]
125
+ }
126
+ Response: List of applicable IPO issues
127
+ ```
128
+
129
+ #### 2.3 Get Details (if not cached)
130
+ ```
131
+ Method: GET
132
+ Endpoint: /meroShareView/myDetail/{dmat}
133
+ (Same as Task 1.2)
134
+ ```
135
+
136
+ #### 2.4 Get Bank Details
137
+ ```
138
+ Method: GET
139
+ Endpoint: /meroShare/bank/
140
+ (Same as Task 1.4)
141
+ ```
142
+
143
+ #### 2.5 Get Bank-Specific Details
144
+ ```
145
+ Method: GET
146
+ Endpoint: /meroShare/bank/{bank_id}
147
+ (Same as Task 1.5)
148
+ ```
149
+
150
+ #### 2.6 Apply for IPO Share
151
+ ```
152
+ Method: POST
153
+ Endpoint: /meroShare/applicantForm/share/apply
154
+ Headers:
155
+ - Authorization: auth_token
156
+ - Content-Type: application/json
157
+ - Pragma: no-cache
158
+ - Cache-Control: no-cache
159
+ Body:
160
+ {
161
+ "demat": dmat,
162
+ "boid": dmat[-8:],
163
+ "accountNumber": account_number,
164
+ "customerId": customer_id,
165
+ "accountBranchId": branch_id,
166
+ "accountTypeId": account_type_id,
167
+ "appliedKitta": str(quantity),
168
+ "crnNumber": crn,
169
+ "transactionPIN": pin,
170
+ "companyShareId": str(share_id),
171
+ "bankId": bank_id
172
+ }
173
+ Response: Confirmation of applied application
174
+ Status Code: 201 (Created)
175
+ ```
176
+
177
+ #### 2.7 Fetch Applied Issues (to update local cache)
178
+ ```
179
+ Method: POST
180
+ Endpoint: /meroShare/applicantForm/active/search/
181
+ Headers:
182
+ - Authorization: auth_token
183
+ - Content-Type: application/json
184
+ Body:
185
+ {
186
+ "filterFieldParams": [...],
187
+ "page": 1,
188
+ "size": 200,
189
+ "searchRoleViewConstants": "VIEW_APPLICANT_FORM_COMPLETE",
190
+ "filterDateParams": [...]
191
+ }
192
+ Response: List of active applications
193
+ ```
194
+
195
+ ---
196
+
197
+ ## Task 3: CHECK IPO APPLICATION STATUS
198
+ **Command**: `status`
199
+
200
+ ### Purpose
201
+ Check the current status of IPO applications (Alloted/Not Alloted/Rejected/Pending).
202
+
203
+ ### API Calls
204
+
205
+ #### 3.1 Login
206
+ ```
207
+ Method: POST
208
+ Endpoint: /meroShare/auth/
209
+ (Same as Task 1.1)
210
+ ```
211
+
212
+ #### 3.2 Fetch Application Reports (Active)
213
+ ```
214
+ Method: POST
215
+ Endpoint: /meroShare/applicantForm/active/search/
216
+ Headers:
217
+ - Authorization: auth_token
218
+ - Content-Type: application/json
219
+ Body:
220
+ {
221
+ "filterFieldParams": [...],
222
+ "page": 1,
223
+ "size": 200,
224
+ "searchRoleViewConstants": "VIEW_APPLICANT_FORM_COMPLETE",
225
+ "filterDateParams": [...]
226
+ }
227
+ Response: List of active applications with company_share_id
228
+ ```
229
+
230
+ #### 3.3 Get Detailed Application Status (For Each Issue)
231
+ ```
232
+ Method: GET
233
+ Endpoint: /meroShare/applicantForm/report/detail/{applicant_form_id}
234
+ Headers:
235
+ - Authorization: auth_token
236
+ Response: Detailed status including:
237
+ - statusName (Alloted/Not Alloted/Rejected)
238
+ - receivedKitta (alloted quantity)
239
+ - appliedDate
240
+ - appliedKitta
241
+ - amount
242
+ - meroshareRemark
243
+ ```
244
+
245
+ #### 3.4 Get Detailed Application Status (For Migrated Old Issues)
246
+ ```
247
+ Method: GET
248
+ Endpoint: /meroShare/migrated/applicantForm/report/{applicant_form_id}
249
+ Headers:
250
+ - Authorization: auth_token
251
+ Response: Same as 3.3 but for old/migrated issues
252
+ ```
253
+
254
+ ---
255
+
256
+ ## Task 4: CHECK IPO RESULT
257
+ **Command**: `result`
258
+
259
+ ### Purpose
260
+ Check allotment results for closed IPOs.
261
+
262
+ ### API Calls
263
+
264
+ #### 4.1 Fetch Result Company List
265
+ ```
266
+ Method: GET
267
+ Endpoint: https://iporesult.cdsc.com.np/result/companyShares/fileUploaded
268
+ Headers:
269
+ - User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0
270
+ - Accept: application/json
271
+ Response:
272
+ {
273
+ "body": {
274
+ "companyShareList": [
275
+ {
276
+ "companyName": string,
277
+ "symbol": string,
278
+ "id": string,
279
+ "companyShareId": string,
280
+ ...
281
+ }
282
+ ]
283
+ }
284
+ }
285
+ ```
286
+
287
+ #### 4.2 Fetch Allotment Results (No additional API call needed)
288
+ - Results are displayed from the company share list above
289
+ - User interactively selects from the company list
290
+
291
+ ---
292
+
293
+ ## Task 5: VIEW PORTFOLIO
294
+ **Command**: `portfolio`
295
+
296
+ ### Purpose
297
+ Display the holdings and portfolio value of an account.
298
+
299
+ ### API Calls
300
+
301
+ #### 5.1 Login
302
+ ```
303
+ Method: POST
304
+ Endpoint: /meroShare/auth/
305
+ (Same as Task 1.1)
306
+ ```
307
+
308
+ #### 5.2 Fetch Portfolio
309
+ ```
310
+ Method: POST
311
+ Endpoint: /meroShareView/myPortfolio/
312
+ Headers:
313
+ - Authorization: auth_token
314
+ - Content-Type: application/json
315
+ Body:
316
+ {
317
+ "sortBy": "script",
318
+ "demat": [dmat],
319
+ "clientCode": dpid,
320
+ "page": 1,
321
+ "size": 200,
322
+ "sortAsc": true
323
+ }
324
+ Response:
325
+ {
326
+ "meroShareMyPortfolio": [
327
+ {
328
+ "script": string,
329
+ "scriptDesc": string,
330
+ "currentBalance": float,
331
+ "lastTransactionPrice": float,
332
+ "previousClosingPrice": float,
333
+ "valueAsOfLastTransactionPrice": float,
334
+ "valueAsOfPreviousClosingPrice": float
335
+ }
336
+ ],
337
+ "totalItems": int,
338
+ "totalValueAsOfLastTransactionPrice": float,
339
+ "totalValueAsOfPreviousClosingPrice": float
340
+ }
341
+ ```
342
+
343
+ ---
344
+
345
+ ## Task 6: SYNC PORTFOLIO AND APPLICATION STATUS
346
+ **Command**: `sync`
347
+
348
+ ### Purpose
349
+ Refresh portfolio and application status from MeroShare.
350
+
351
+ ### API Calls
352
+
353
+ #### 6.1 All APIs from Task 3 (Status Check)
354
+ - Fetch Application Reports (Active & Migrated)
355
+ - Get Detailed Application Status
356
+
357
+ #### 6.2 All APIs from Task 5 (Portfolio)
358
+ - Fetch Portfolio
359
+
360
+ ---
361
+
362
+ ## Task 7: GET ACCOUNT DETAILS
363
+ **Command**: `add` (during account addition)
364
+
365
+ ### Purpose
366
+ Get account information (name, account number, bank ID, branch ID, etc.)
367
+
368
+ ### API Calls
369
+ (Same as Task 1, sections 1.2-1.5)
370
+
371
+ ---
372
+
373
+ ## Task 8: FETCH EDIS HISTORY
374
+ **Command**: `sync` (Background operation)
375
+
376
+ ### Purpose
377
+ Fetch Electronic Delivery Instruction System history.
378
+
379
+ ### API Calls
380
+
381
+ #### 8.1 Login
382
+ ```
383
+ Method: POST
384
+ Endpoint: /meroShare/auth/
385
+ (Same as Task 1.1)
386
+ ```
387
+
388
+ #### 8.2 Search EDIS History
389
+ ```
390
+ Method: POST
391
+ Endpoint: /EDIS/report/search/
392
+ Headers:
393
+ - Authorization: auth_token
394
+ - Content-Type: application/json
395
+ Body:
396
+ {
397
+ "filterFieldParams": [
398
+ {
399
+ "key": "requestStatus.name",
400
+ "value": "",
401
+ "alias": "Status"
402
+ },
403
+ {
404
+ "key": "contractObligationMap.obligation.settleId",
405
+ "alias": "Settlement Id"
406
+ },
407
+ {
408
+ "key": "contractObligationMap.obligation.scriptCode",
409
+ "alias": "Script"
410
+ },
411
+ {
412
+ "key": "contractObligationMap.obligation.sellCmId",
413
+ "alias": "CM ID",
414
+ "condition": "': '"
415
+ }
416
+ ],
417
+ "page": 1,
418
+ "size": 200,
419
+ "searchRoleViewConstants": "VIEW",
420
+ "filterDateParams": [...]
421
+ }
422
+ Response:
423
+ {
424
+ "object": [
425
+ {
426
+ "contract": {
427
+ "obligation": {
428
+ "scriptCode": string,
429
+ "settleDate": string,
430
+ ...
431
+ }
432
+ },
433
+ "statusName": string,
434
+ ...
435
+ }
436
+ ]
437
+ }
438
+ ```
439
+
440
+ ---
441
+
442
+ ## Task 9: FIND MINIMUM APPLY UNIT
443
+ **Command**: `apply` (Background operation)
444
+
445
+ ### Purpose
446
+ Get minimum number of shares required for IPO application.
447
+
448
+ ### API Calls
449
+
450
+ #### 9.1 Login
451
+ ```
452
+ Method: POST
453
+ Endpoint: /meroShare/auth/
454
+ (Same as Task 1.1)
455
+ ```
456
+
457
+ #### 9.2 Get Minimum Apply Unit
458
+ ```
459
+ Method: GET
460
+ Endpoint: /meroShare/active/{company_share_id}
461
+ Headers:
462
+ - Authorization: auth_token
463
+ Response:
464
+ {
465
+ "minUnit": int,
466
+ "maxUnit": int,
467
+ ...
468
+ }
469
+ ```
470
+
471
+ ---
472
+
473
+ ## Task 10: LOGOUT
474
+ **Command**: `apply`, `status`, `portfolio` (After operations complete)
475
+
476
+ ### Purpose
477
+ Cleanup session after operations.
478
+
479
+ ### API Calls
480
+
481
+ #### 10.1 Logout
482
+ ```
483
+ Method: GET
484
+ Endpoint: /meroShare/auth/logout/
485
+ Headers:
486
+ - Authorization: auth_token
487
+ Status Code: 201 (Created)
488
+ Response: Empty or confirmation
489
+ ```
490
+
491
+ ---
492
+
493
+ ## Authentication Flow
494
+
495
+ All authenticated operations follow this pattern:
496
+ 1. **Login**: POST to `/meroShare/auth/` with clientId, username, password
497
+ 2. **Receive**: Authorization token in response headers
498
+ 3. **Use**: Add Authorization header to all subsequent requests
499
+ 4. **Logout**: GET to `/meroShare/auth/logout/` (optional but recommended)
500
+
501
+ ---
502
+
503
+ ## Summary of All Unique API Endpoints
504
+
505
+ ### MeroShare API (https://webbackend.cdsc.com.np/api)
506
+ 1. `POST /meroShare/auth/` - Login
507
+ 2. `GET /meroShare/auth/logout/` - Logout
508
+ 3. `GET /meroShareView/myDetail/{dmat}` - Get Account Details
509
+ 4. `GET /bankRequest/{bank_code}` - Get Bank Details
510
+ 5. `GET /meroShare/bank/` - Get Bank List
511
+ 6. `GET /meroShare/bank/{bank_id}` - Get Bank-Specific Details
512
+ 7. `GET /meroShare/capital/` - Get Capital List
513
+ 8. `POST /meroShare/companyShare/applicableIssue/` - Fetch Applicable Issues
514
+ 9. `POST /meroShare/applicantForm/share/apply` - Apply for IPO
515
+ 10. `POST /meroShare/applicantForm/active/search/` - Search Active Applications
516
+ 11. `POST /meroShare/migrated/applicantForm/search/` - Search Migrated Applications
517
+ 12. `GET /meroShare/applicantForm/report/detail/{form_id}` - Get Application Status
518
+ 13. `GET /meroShare/migrated/applicantForm/report/{form_id}` - Get Migrated Application Status
519
+ 14. `POST /meroShareView/myPortfolio/` - Get Portfolio
520
+ 15. `GET /meroShare/active/{company_share_id}` - Get Minimum Apply Unit
521
+ 16. `POST /EDIS/report/search/` - Search EDIS History
522
+
523
+ ### External API (https://iporesult.cdsc.com.np)
524
+ 1. `GET /result/companyShares/fileUploaded` - Fetch IPO Result Companies
525
+
526
+ ---
527
+
528
+ ## Request/Response Headers
529
+
530
+ ### Default Headers (All Requests)
531
+ ```
532
+ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0
533
+ Accept: application/json, text/plain, */*
534
+ Accept-Language: en-US,en;q=0.5
535
+ Accept-Encoding: gzip, deflate, br, zstd
536
+ Content-Type: application/json
537
+ Origin: https://meroshare.cdsc.com.np
538
+ Connection: keep-alive
539
+ Referer: https://meroshare.cdsc.com.np/
540
+ Sec-Fetch-Dest: empty
541
+ Sec-Fetch-Mode: cors
542
+ Sec-Fetch-Site: same-site
543
+ Pragma: no-cache
544
+ Cache-Control: no-cache
545
+ ```
546
+
547
+ ### Authentication Header
548
+ ```
549
+ Authorization: {auth_token}
550
+ ```
551
+ (Set to "null" for public endpoints like login and capital list)
552
+
553
+ ---
554
+
555
+ ## Error Handling
556
+
557
+ - **Status Code 200**: Success
558
+ - **Status Code 201**: Created (successful POST/PUT)
559
+ - **Status Code != Expected**: Raises `LocalException` or `GlobalError`
560
+
561
+ ### Login-Specific Validations
562
+ - `passwordExpired`: Password needs to be updated
563
+ - `accountExpired`: Account has expired
564
+ - `dematExpired`: DMAT has expired
565
+
566
+ ---
567
+
568
+ ## Rate Limiting and Retry Strategy
569
+
570
+ - **Retry Logic**: 3 attempts maximum
571
+ - **Wait Time**: 2 seconds between retries
572
+ - **Applied To**: Most API calls except data-only operations
573
+
574
+ ---
575
+
576
+ ## Data Persistence
577
+
578
+ - All account data is encrypted using Fernet encryption
579
+ - Stored in config file at: `%APPDATA%\ipo\config.json` (Windows)
580
+ - Credentials include: DMAT, password, PIN, CRN, account details, portfolio, issues
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Arpan Koirala
4
+ Copyright (c) 2026 Ayush Joshi
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.