pp-portfolio-classifier 0.0.1

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.
Files changed (37) hide show
  1. package/.github/workflows/npm-publish.yml +45 -0
  2. package/.prettierignore +6 -0
  3. package/.prettierrc.json +11 -0
  4. package/.vscode/settings.json +30 -0
  5. package/BLUEPRINT.md +28 -0
  6. package/config/default.json +1121 -0
  7. package/dist/classifier.js +195 -0
  8. package/dist/index.js +88 -0
  9. package/dist/morningstar-api.js +137 -0
  10. package/dist/types.js +2 -0
  11. package/dist/xml-helper.js +244 -0
  12. package/docs/img/autoclassified-regions.png +0 -0
  13. package/docs/img/autoclassified-sectors.png +0 -0
  14. package/docs/img/autoclassified-stock-style.png +0 -0
  15. package/docs/img/top-10-holdings.png +0 -0
  16. package/docs/taxonomy-json-templates/AllTaxonomies.json +1313 -0
  17. package/docs/taxonomy-json-templates/Asset_Type.json +45 -0
  18. package/docs/taxonomy-json-templates/Bond_Sector.json +38 -0
  19. package/docs/taxonomy-json-templates/Bond_Style.json +42 -0
  20. package/docs/taxonomy-json-templates/Country.json +214 -0
  21. package/docs/taxonomy-json-templates/Holding.json +302 -0
  22. package/docs/taxonomy-json-templates/Region.json +72 -0
  23. package/docs/taxonomy-json-templates/Region_Country.json +280 -0
  24. package/docs/taxonomy-json-templates/Stock_Sector.json +50 -0
  25. package/docs/taxonomy-json-templates/Stock_Style.json +42 -0
  26. package/docs/taxonomy-json-templates/info.txt +1 -0
  27. package/docs/taxonomy-json-templates/views.xml +45 -0
  28. package/eslint.config.mjs +65 -0
  29. package/package.json +38 -0
  30. package/readme.md +156 -0
  31. package/src/classifier.ts +242 -0
  32. package/src/index.ts +64 -0
  33. package/src/morningstar-api.ts +155 -0
  34. package/src/types.ts +28 -0
  35. package/src/xml-helper.ts +240 -0
  36. package/test/multifaktortest.xml +3983 -0
  37. package/tsconfig.json +15 -0
@@ -0,0 +1,45 @@
1
+ name: Publish Package to npmjs
2
+
3
+ on:
4
+ release:
5
+ types: [created]
6
+ push:
7
+ branches:
8
+ - "main"
9
+
10
+ jobs:
11
+ build-and-publish:
12
+ runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: write
15
+ id-token: write
16
+
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Setup Node.js
22
+ uses: actions/setup-node@v4
23
+ with:
24
+ node-version: "22"
25
+ registry-url: "https://registry.npmjs.org"
26
+
27
+ # Automated Version Bump
28
+ - name: "Automated Version Bump"
29
+ if: github.event_name == 'push'
30
+ uses: "phips28/gh-action-bump-version@master"
31
+ with:
32
+ tag-prefix: ""
33
+ env:
34
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35
+
36
+ - name: Install dependencies
37
+ run: yarn install --frozen-lockfile
38
+
39
+ - name: Build project
40
+ run: yarn build
41
+
42
+ - name: Publish to npm
43
+ run: npm publish
44
+ env:
45
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,6 @@
1
+ node_modules
2
+ .DS_Store
3
+ dist
4
+ dist-ssr
5
+ *.local
6
+ .eslintcache
@@ -0,0 +1,11 @@
1
+ {
2
+ "printWidth": 120,
3
+ "tabWidth": 2,
4
+ "semi": true,
5
+ "trailingComma": "all",
6
+ "singleQuote": false,
7
+ "quoteProps": "as-needed",
8
+ "bracketSpacing": true,
9
+ "arrowParens": "always",
10
+ "endOfLine": "lf"
11
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "editor.codeActionsOnSave": {
3
+ "source.fixAll.eslint": "explicit",
4
+ "source.fixAll.format": "explicit",
5
+ "source.organizeImports": "explicit",
6
+ "source.sortPackageJson": "explicit"
7
+ },
8
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
9
+ "editor.formatOnSave": true,
10
+ "files.exclude": {
11
+ "**/.DS_Store": true,
12
+ "**/.git": true,
13
+ "**/.hg": true,
14
+ "**/.svn": true,
15
+ "**/CVS": true,
16
+ "dist/**": true,
17
+ "node_modules": true
18
+ },
19
+ "typescript.enablePromptUseWorkspaceTsdk": true,
20
+ "typescript.tsdk": "./node_modules/typescript/lib",
21
+ "js/ts.implicitProjectConfig.target": "ESNext",
22
+ "[xml]": {
23
+ "editor.defaultFormatter": "redhat.vscode-xml"
24
+ },
25
+ "IDX.aI.enableInlineCompletion": true,
26
+ "IDX.aI.enableCodebaseIndexing": true,
27
+ "eslint.useFlatConfig": true,
28
+ "eslint.nodePath": "./node_modules",
29
+ "eslint.validate": ["javascript", "typescript"]
30
+ }
package/BLUEPRINT.md ADDED
@@ -0,0 +1,28 @@
1
+ # Blueprint: Migration Portfolio Classifier (Python -> TypeScript)
2
+
3
+ ## Objectif
4
+
5
+ Convertir le script de classification automatique pour Portfolio Performance en TypeScript/Node.js pour améliorer la maintenabilité, la performance et la configurabilité.
6
+
7
+ ## Architecture
8
+
9
+ - **Language**: TypeScript (Node.js)
10
+ - **Config**: `node-config` (fichiers JSON/YAML externes pour les mappings)
11
+ - **XML**: `fast-xml-parser` (Lecture/Écriture en préservant les attributs)
12
+ - **HTTP**: `axios` (Gestion des requêtes et des headers)
13
+
14
+ ## Étapes du POC (Proof of Concept)
15
+
16
+ 1. [x] Structure du projet (package.json, tsconfig)
17
+ 2. [x] Configuration externe (mappings Morningstar -> Taxonomies PP)
18
+ 3. [x] Module API Morningstar (Token + Fetch Data optimisé)
19
+ 4. [x] Module XML (Lecture + Sauvegarde compatible PP)
20
+ 5. [x] Logique de Classification (Mapping des données API vers la structure XML)
21
+ 6. [x] Gestion des "Titres vifs" (Stocks) vs Fonds
22
+ 7. [x] Support des taxonomies à profondeur variable
23
+
24
+ ## Optimisations vs Python
25
+
26
+ - **Appels API**: Le script Python fait 1 appel par taxonomie par titre. Le script TS fera 1 appel par titre et distribuera les données.
27
+ - **Typage**: Utilisation d'interfaces TS pour sécuriser la manipulation des objets XML complexes.
28
+ - **Flexible**: La configuration externe permet de modifier les mappings sans toucher au code.