tag:infinitekind.tenderapp.com,2009-01-14:/discussions/investments/6141-multiple-securities-for-same-tickerInfinite Kind: Discussion 2021-11-29T13:10:21Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-29T14:25:09Z2021-08-29T14:25:09ZMultiple Securities for same Ticker<div><p>Hi Mike,</p>
<p>To be honest, I'd prefer a different approach to handling this. I wonder if a special object that contained a mapping from CUSIPs to currency objects would solve this in a simpler and less breakable way? Such a table would also provide a much faster way to get the security that is associated with any given CUSIP.</p>
<p>I'll update your extensions ASAP.</p>
<p>Thanks!<br>
Sean</p>
<p>--<br>
Sean Reilly<br>
Developer, The Infinite Kind<br>
<a href="https://infinitekind.com">https://infinitekind.com</a></p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-29T14:41:07Z2021-08-29T14:41:07ZMultiple Securities for same Ticker<div><p>Hi Sean, it is entirely up to you which model you use, all I was really<br>
doing was raising the issue where the current model does not work for<br>
all situations. Of course if you go the route you are proposing the<br>
multiple records for same ticker is no longer needed as long as you can<br>
handle the download of investment transactions with different CUSIP ids.<br>
Regards<br>
Mike</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-29T15:56:13Z2021-08-29T15:56:13ZMultiple Securities for same Ticker<div><p>To chip in… (I helped the user identify the original cusip issue..). I agree with Mike that the design of the appropriate solution is up to you Sean. But it would seem sensible (to me) to have the multiple cusip mapping on the actual (currency)security master record as this is all about the security.</p>
<p>I would say that whatever solution is used, that there needs to be a simple gui to allow the user to change/edit the mappings as otherwise they have to resort to tools like toolbox to do this, when they should be able to do it in the ui.</p>
<p>One last point…… please can the tools/security screen block any attempts to add / edit a security if the ticker is set and if a new duplicate ticker is detected / would be created (clearly it should allow any duplicates that already exist)? The ui should block this.</p>
<p>IMHO, it should also block attempts to add securities or currencies using the same .getIDString() too. Just my two-pennies.</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-30T07:34:13Z2021-08-30T07:34:13ZMultiple Securities for same Ticker<div><p>If we store the CUSIPs in the currencies themselves then it's pretty easy to get the same CUSIP in two different currencies. Also, that means the "map" of CUSIPs to currencies is spread across the data set, which is ok in general but in this case I think a centralised map is preferred because it the data model would match your mental model of it. It would also make it a <em>lot</em> easier to make a UI to edit the mapping of CUSIPs to securities.</p>
<p>I also wouldn't store this in the root account, because that's getting a bit overloaded already and if we put all kinds of data in it then it will start losing some people's changes to sync conflicts. The solution to this is to create a new MoneydanceSyncable object with a hard-coded reserved ID. I wouldn't recommend any extension do this without checking with me first, but if we can specify an agreed upon item ID to hard code then this would be a great place to keep such a map. I do think in a few places in Moneydance with code like the following:</p>
<pre>
<code> // I've just added SECURITY_SUBTYPES_ITEM_ID = "security_subtypes" in MoneydanceSyncableItem
MoneydanceSyncableItem item = book.getItemForID(MoneydanceSyncableItem.SECURITY_SUBTYPES_ITEM_ID);
if (item == null) {
item = new MoneydanceSyncableItem(book);
item.setParameter(SyncableItem.ITEM_KEY_ID, MoneydanceSyncableItem.SECURITY_SUBTYPES_ITEM_ID);
item.setParameter(SyncableItem.ITEM_TYPE_KEY, MoneydanceSyncableItem.SECURITY_SUBTYPES_ITEM_TYPE);
}</code>
</pre>
<p>This lets you have an independent object where you can put related information and have it synced along with the data file. In <code>item</code> we can build a map of CUSIPs to currency UUIDs using something like <code>setCurrencyParameter("cusip."+cusip, mappedCurrencyOrNull)</code> and get them with <code>getCurrencyParameter("cusip."+cusip, null)</code>.</p>
<p>--<br>
Sean Reilly<br>
Developer, The Infinite Kind<br>
<a href="https://infinitekind.com">https://infinitekind.com</a></p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-30T07:42:37Z2021-08-30T07:43:03ZMultiple Securities for same Ticker<div><p>I think in this case it would makes sense to use the code below for the CUSIP map. Please feel free to use it in your extension. I should make convenience methods in MoneydanceSyncableItem, or maybe AccountBook to access these sorts of standard identified objects.</p>
<pre>
<code> MoneydanceSyncableItem cusipMap = book.getItemForID("md.cusip_map");
if (cusipMap == null) {
cusipMap = new MoneydanceSyncableItem(book);
cusipMap.setParameter(SyncableItem.ITEM_KEY_ID, "md.cusip_map");
cusipMap.setParameter(SyncableItem.ITEM_TYPE_KEY, "misc");
}</code>
</pre>
<p>--<br>
Sean Reilly<br>
Developer, The Infinite Kind<br>
<a href="https://infinitekind.com">https://infinitekind.com</a></p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-30T07:43:50Z2021-08-30T07:43:50ZMultiple Securities for same Ticker<div><p>in fact, this object might be a great place to hold more general information about syncing/updated securities and currencies... so maybe a more general object ID would be preferred?</p>
<p>--<br>
Sean Reilly<br>
Developer, The Infinite Kind<br>
<a href="https://infinitekind.com">https://infinitekind.com</a></p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-30T07:48:59Z2021-08-30T07:48:59ZMultiple Securities for same Ticker<div><p>Hi Sean... Your logic makes sense (of course)... We mustn't forget the scheme name as well as the CUSIP(ID).. (as they come as a pair). This is something you would have to initially code (of course) as you interrogate and set the CUSIP in your Investment OFX download routines.... etc.... You would also have to migrate CUSIPs over to the new map. I.E. an extension editing this new table would be of no use if the core MD code is not using it...?</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-30T07:55:22Z2021-08-30T07:55:22ZMultiple Securities for same Ticker<div><p>Yes, good points. I would be happy to migrate Moneydance's CUSIP code over to this. I can't do it just yet, but I will get to this soon after the next release, which I <em>really</em> hope is imminent.</p>
<p>Thanks,<br>
Sean</p>
<p>--<br>
Sean Reilly<br>
Developer, The Infinite Kind<br>
<a href="https://infinitekind.com">https://infinitekind.com</a></p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-30T07:59:27Z2021-08-30T07:59:27ZMultiple Securities for same Ticker<div><p>Understood. Perhaps ping me when you start to look at this in the future and we can collaborate?</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-30T08:01:25Z2021-08-30T08:01:25ZMultiple Securities for same Ticker<div><p>👍</p>
<p>--<br>
Sean Reilly<br>
Developer, The Infinite Kind<br>
<a href="https://infinitekind.com">https://infinitekind.com</a></p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-30T10:04:36Z2021-08-30T10:04:36ZMultiple Securities for same Ticker<div><p>My latest change to Quote Loader can stay in place as I do not touch CUSIP(ID), just allow for multiple Security Currency records with the same root ticker. I will not need to do any changes for what you are suggesting. Should I change QL to be more intelligent about CUSIP(ID), using the CurrencyParameters to store data is useful as my extension runs on all MD builds from 1802 onwards. I don't want new APIs which are only available new builds.</p></div>Mike Bray (Quote Loader Author)tag:infinitekind.tenderapp.com,2009-01-14:Comment/493631432021-08-30T13:03:14Z2021-08-30T13:03:14ZMultiple Securities for same Ticker<div><p>Personally, from a non technical perspective, your enhancement to QL, ignoring cusip, for duplicate tickers is great as it is.</p></div>Stuart Beesley (Mr Toolbox)