pp-portfolio-classifier 0.0.6 → 0.0.8
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.
- package/dist/classifier.js +1 -1
- package/dist/index.js +7 -6
- package/package.json +1 -1
- package/readme.md +2 -8
- package/src/classifier.ts +1 -1
- package/src/index.ts +9 -7
- package/test/multifaktortest.xml +4 -4
package/dist/classifier.js
CHANGED
|
@@ -108,7 +108,7 @@ class Classifier {
|
|
|
108
108
|
if (targetClass) {
|
|
109
109
|
const path = Array.isArray(targetClass) ? targetClass : [targetClass];
|
|
110
110
|
assignments.push({ path, weight: value * 100 });
|
|
111
|
-
console.log(` [${taxonomyId}]
|
|
111
|
+
// console.log(` [${taxonomyId}] Mapping key '${key}' to '${path.join(" > ")}' (${value.toFixed(2)}%)`);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
else {
|
package/dist/index.js
CHANGED
|
@@ -35,16 +35,17 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
|
+
// Load config
|
|
39
|
+
const package_path = path.join(path.dirname(require.resolve("../package.json")), "config");
|
|
40
|
+
const runtime_path = path.normalize(path.join(process.cwd(), "config"));
|
|
41
|
+
process.env["NODE_CONFIG_DIR"] =
|
|
42
|
+
package_path != runtime_path ? package_path + path.delimiter + runtime_path : runtime_path;
|
|
43
|
+
const _config = require("config");
|
|
44
|
+
// console.log("Config dir:", package_path, runtime_path, process.env["NODE_CONFIG_DIR"], _config.util.getConfigSources());
|
|
38
45
|
const classifier_1 = require("./classifier");
|
|
39
46
|
const morningstar_api_1 = require("./morningstar-api");
|
|
40
47
|
const xml_helper_1 = require("./xml-helper");
|
|
41
48
|
async function main() {
|
|
42
|
-
const package_path = path.join(path.dirname(require.resolve("../package.json")), "config");
|
|
43
|
-
const runtime_path = path.normalize(path.join(process.cwd(), "config"));
|
|
44
|
-
process.env["NODE_CONFIG_DIR"] =
|
|
45
|
-
package_path != runtime_path ? package_path + path.delimiter + runtime_path : runtime_path;
|
|
46
|
-
const _config = require("config");
|
|
47
|
-
console.log("Config dir:", package_path, runtime_path, process.env["NODE_CONFIG_DIR"]);
|
|
48
49
|
const inputFile = process.argv[2];
|
|
49
50
|
if (!inputFile) {
|
|
50
51
|
console.error("Usage: npm start <input_file.xml> [output_file.xml]");
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -29,25 +29,19 @@ It is a **TypeScript** adaptation and rewrite of the Python project [Alfons1Qto1
|
|
|
29
29
|
|
|
30
30
|
- [TypeScript](https://www.typescriptlang.org/)
|
|
31
31
|
- [Node.js](https://nodejs.org/) (v22 or higher recommended)
|
|
32
|
-
- yarn or npm
|
|
33
32
|
|
|
34
33
|
## 🚀 Installation & Usage
|
|
35
34
|
|
|
36
35
|
### Installation
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
2. Install dependencies:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
yarn
|
|
43
|
-
```
|
|
37
|
+
No installation is required, `npx` will download and install on the fly the latest release of the package.
|
|
44
38
|
|
|
45
39
|
### Usage
|
|
46
40
|
|
|
47
41
|
To run the classification on your portfolio file:
|
|
48
42
|
|
|
49
43
|
```bash
|
|
50
|
-
|
|
44
|
+
npx pp-portfolio-classifier -- <path_to_your_portfolio.xml> [output_path.xml]
|
|
51
45
|
|
|
52
46
|
```
|
|
53
47
|
|
package/src/classifier.ts
CHANGED
|
@@ -146,7 +146,7 @@ export class Classifier {
|
|
|
146
146
|
if (targetClass) {
|
|
147
147
|
const path = Array.isArray(targetClass) ? targetClass : [targetClass];
|
|
148
148
|
assignments.push({ path, weight: value * 100 });
|
|
149
|
-
console.log(` [${taxonomyId}]
|
|
149
|
+
// console.log(` [${taxonomyId}] Mapping key '${key}' to '${path.join(" > ")}' (${value.toFixed(2)}%)`);
|
|
150
150
|
}
|
|
151
151
|
} else {
|
|
152
152
|
console.log(` [${taxonomyId}] Unmapped key: '${key}' (Value: ${value})`);
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
// Load config
|
|
5
|
+
const package_path = path.join(path.dirname(require.resolve("../package.json")), "config");
|
|
6
|
+
const runtime_path = path.normalize(path.join(process.cwd(), "config"));
|
|
7
|
+
process.env["NODE_CONFIG_DIR"] =
|
|
8
|
+
package_path != runtime_path ? package_path + path.delimiter + runtime_path : runtime_path;
|
|
9
|
+
const _config = require("config");
|
|
10
|
+
// console.log("Config dir:", package_path, runtime_path, process.env["NODE_CONFIG_DIR"], _config.util.getConfigSources());
|
|
11
|
+
|
|
3
12
|
import { Classifier } from "./classifier";
|
|
4
13
|
import { MorningstarAPI } from "./morningstar-api";
|
|
5
14
|
import { XMLHandler } from "./xml-helper";
|
|
6
15
|
|
|
7
16
|
async function main() {
|
|
8
|
-
const package_path = path.join(path.dirname(require.resolve("../package.json")), "config");
|
|
9
|
-
const runtime_path = path.normalize(path.join(process.cwd(), "config"));
|
|
10
|
-
process.env["NODE_CONFIG_DIR"] =
|
|
11
|
-
package_path != runtime_path ? package_path + path.delimiter + runtime_path : runtime_path;
|
|
12
|
-
const _config = require("config");
|
|
13
|
-
console.log("Config dir:", package_path, runtime_path, process.env["NODE_CONFIG_DIR"]);
|
|
14
|
-
|
|
15
17
|
const inputFile = process.argv[2];
|
|
16
18
|
|
|
17
19
|
if (!inputFile) {
|
package/test/multifaktortest.xml
CHANGED
|
@@ -3222,10 +3222,10 @@
|
|
|
3222
3222
|
</taxonomy>
|
|
3223
3223
|
<taxonomy>
|
|
3224
3224
|
<id>ad371a09-edcd-494a-baf0-788750070092</id>
|
|
3225
|
-
<name>Sector
|
|
3225
|
+
<name>Bond Sector</name>
|
|
3226
3226
|
<root>
|
|
3227
3227
|
<id>bb874919-c306-4451-8767-f3ec345babaf</id>
|
|
3228
|
-
<name>Sector
|
|
3228
|
+
<name>Bond Sector</name>
|
|
3229
3229
|
<color>#89afee</color>
|
|
3230
3230
|
<children>
|
|
3231
3231
|
<classification>
|
|
@@ -3316,10 +3316,10 @@
|
|
|
3316
3316
|
</taxonomy>
|
|
3317
3317
|
<taxonomy>
|
|
3318
3318
|
<id>c9b8579d-cdf9-4582-8edc-de484f5d11df</id>
|
|
3319
|
-
<name>Sector</name>
|
|
3319
|
+
<name>Stock Sector</name>
|
|
3320
3320
|
<root>
|
|
3321
3321
|
<id>4f2ef77f-b347-4f6c-947a-1ed4d239e296</id>
|
|
3322
|
-
<name>Sector</name>
|
|
3322
|
+
<name>Stock Sector</name>
|
|
3323
3323
|
<color>#89afee</color>
|
|
3324
3324
|
<children>
|
|
3325
3325
|
<classification>
|