Open the-solipsist opened 3 years ago
It's doable, but would be incomplete. I see the following problems:
So what we can get is, like your script (apologies I've not tested it) is a list of commodities, but you still need a manual job to making it workable on the YAML.
I agree, a script can only get you a "skeleton" of the YAML file, as I'd noted. For instance, it wouldn't distinguish between funds and shares, which apparently is necessary. The resultant file will need to be manually edited. But I feel it would be easier to edit a file, rather than create a file anew.
- The name of the commodity you use in hledger might not be the ISIN so you need to touch manually the file
I'm a bit confused: if the name of the commodity in the journal is not the ISIN, then how will hledger
be able to use the ISIN provided in the price db by msdownloader
? (Wouldn't "GB00B907VX32"
need to be a commodity name for the line P 2021-01-08 "GB00B907VX32" 214.18 GBX
to make sense to hledger
?)
- The ISIN you use requires a universe which is not stored/available in your hledger setup
The "universe", if I understand it correctly, refers to the Morningstar code for the exchange on which the security is traded. Can that be found through a web lookup? (Alphavantage, e.g., provides a SYMBOL_SEARCH
function, for instance, for such a purpose, which can be queried using the ISIN as a keyword, and which returns the exchange as well in the json payload. Perhaps Morningstar provides something similar?) The name of the fund/share can also be found through such a query if the ISIN is available.
Can't believe I missed this.
I'm a bit confused ...
Today everything must be done using only the ISIN. So in hledger
you need to call the commodity/funds/whatever with the ISIN. In the future, I envisaged already the usage of a name
parameter for each ISIN to allow more flexibility.
The "universe", if I understand it correctly, refers to the Morningstar code for the exchange on which the security is traded.
More or less, it's correct. The universe is a Morningstar proprietary definition based on the way they internally categorize data. Most of times it's not needed, particularly on funds you find on major markets like LSE. If something is traded locally, say Frankfurt, and not widely available, you need to provide the universe as the ISIN is not enough.
You might need to inspect the page for it. If you cannot find what you need, ping here a message or write directly to me and I can help you figure it out. It would be good for including additional info the README
at some point.
I am not expert with Alphavantage, but regardless that, from a purely financial standpoint, the same financial instrument can be traded on multiple markets and under different currencies. ISIN is not unique, so unless the ISIN points, by default, to what we need, we must add an additional info.
You could use
ledger commodities
orhledger stats
to get a list of commodities used in the file. By grepping for ISIN numbers, you can use that to build the skeleton of the YAML file.Something like:
(Note: the above is adapted from bash scripts I use, but I haven't tested it myself yet, as I don't have stocks in my journal.)
I use this method for extracting mutual funds and India's national pension scheme units from my hledger journal.