Skip to content

Commit

Permalink
Add info to readme, skip faulty records
Browse files Browse the repository at this point in the history
  • Loading branch information
dickwolff committed Jan 27, 2025
1 parent 8d95920 commit 24c1bbc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ The following parameters can be given to the Docker run command.
| `-v {local_out_folder}:/var/tmp/e2g-output` | N | The output folder where the Ghostfolio import JSON will be placed. Also the input file will be moved here when an error ocurred while processing the file. |
| `-v {local_cache_folder}:/var/tmp/e2g-cache` | Y | The folder where Yahoo Finance symbols will be cached |
| `--env GHOSTFOLIO_ACCOUNT_ID=xxxxxxx` | N | Your Ghostolio account ID [^1] |
| `--env isin-overrides.txt` | Y | Specify a key-value pair file with ISIN overrides |
| `--env USE_POLLING=true` | Y | When set to true, the container will continously look for new files to process and the container will not stop. |
| `--env DEBUG_LOGGING=true` | Y | When set to true, the container will show logs in more detail, useful for error tracing. |
| `--env PURGE_CACHE=true` | Y | When set to true, the file cache will be purged on start. |
Expand Down Expand Up @@ -256,6 +257,18 @@ You can now run `npm run start [exporttype]`. See the table with run commands be

The tool uses `cacache` to store data retrieved from Yahoo Finance on disk. This way the load on Yahoo Finance is reduced and the tool should run faster. The cached data is stored in `/var/tmp/e2g-cache`. If you feel you need to invalidate your cache, you can do so by removing the folder and the tool will recreate the cache when you run it the next time.

### Symbol overriding

Since 0.25.0 you can specify ISIN symbol overrides. This gives you more control to make Export to Ghostfolio to look for a specific symbol. For example `IE00B3RBWM25` (Vanguard FTSE All-World UCITS ETF) will by default return `VWRL.L`. If you bought `VWRL.AS` and want to have this reflected in the export file, you can add this to the overrides file.

The file is a simple key-value pair `.txt` file, which you can provide by environment variable via Docker, or by locally renaming `isin-overrides-sample.txt` to `isin-overrides.txt`. The contenst look like:

```txt
IE00B3RBWM25=VWRL.AS
IE00B02KXK85=FXAC.AS
...=...
```

</details>

## Import to Ghostfolio
Expand Down
12 changes: 11 additions & 1 deletion src/securityService.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as cacache from "cacache";
import { SecurityService } from "./securityService";
import YahooFinanceServiceMock from "./testing/yahooFinanceServiceMock";
import { writeFileSync } from "fs";

describe("securityService", () => {

Expand Down Expand Up @@ -606,9 +607,18 @@ describe("securityService", () => {

// Arrange

let file = "";
file += "IE00B3RBWM25=VWRL.AS\n";
file += "IE00B3RBWM25=\n";
file += "US0378331005=AAPL\n";
file += "=AAPL\n";
file += "===\n";

writeFileSync("isin-overrides-test.txt", file, { encoding: "utf8", flag: "w" });

// Override the environment variable and force Jest to reload all modules.
const oldEnv = process.env.E2G_ISIN_OVERRIDE_FILE;
process.env.E2G_ISIN_OVERRIDE_FILE = "isin-overrides-sample.txt";
process.env.E2G_ISIN_OVERRIDE_FILE = "isin-overrides-test.txt";
jest.resetModules();
const { SecurityService } = require("./securityService");

Expand Down
6 changes: 6 additions & 0 deletions src/securityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ export class SecurityService {
const overrides = readFileSync(symbolOverrideFile, "utf8").split("\n");
for (let idx = 0; idx < overrides.length; idx++) {
const line = overrides[idx].split("=");

// Sanitize input, skip what does not comply.
if (line.length !== 2 || line[0] === "" || line[1] === "") {
continue;
}

this.isinOverrideCache.set(line[0], line[1]);
}
}
Expand Down

0 comments on commit 24c1bbc

Please sign in to comment.