set prices python script
Greetings,
I am trying to figure out why some of the stocks get a price update when I use this script (my version is md_price_history_script.py) and a data file as shown in the example (md_sph.csv).
The results when I run the script indicate the price was successfully set for each stock but when I back check a significant number are not updated and others have the current price every time.
Please let me know what I can check to try to resolve this issue.
Best regards,
Larry
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Stuart Beesley ... on 12 Mar, 2025 08:18 AM
Please attach your script and csv file otherwise we cannot help.
2 Posted by Larry Thoma on 12 Mar, 2025 12:26 PM
Sorry, they were attached, but when I submitted the discussion there was a glitch and must have dropped. I am attaching again.
3 Posted by Stuart Beesley ... on 12 Mar, 2025 02:05 PM
This looks suspect:
Try trapping ‘if not dateint’ and also I’ll have to check out the ‘ security.setSnapshotInt(dateint, price).syncItem()’ as I’m not sure which object this is syncing?
4 Posted by Stuart Beesley ... on 12 Mar, 2025 02:08 PM
Ok. It’s returning the snapshot object so that should be fine. I’ll debug it later.
5 Posted by Stuart Beesley ... on 12 Mar, 2025 02:12 PM
Do any of these tickers consistently NOT work? Or is it random? And is it the dated price that’s missing, or the current price, or both, or is that random too?
6 Posted by Stuart Beesley ... on 12 Mar, 2025 03:22 PM
OK, I ran your script with your data and all securities updated fine?
7 Posted by Larry Thoma on 13 Mar, 2025 04:01 AM
Greetings Stuart,
Sorry for the late reply,
I've had a mixture.
Some always seem to update (ABSI, BFLY, CAMT, CRS, EXLS)
Some that updated but have since quit (TTD)
Some that never update since I have been using the script (WHD, CTRE, EXEL)
I started using the script in June of 2024.
Some of the stocks I have had for long periods, others were recent
additions.
The dated price is not current, and the current price reflects the last
dated price
one that is working:
[image: image.png]
one that is not - note that the most current entry is 2/20/25 when the
stock was last bought.
[image: image.png]
These are the values from the csv I attached to the discussion.
EXEL,39.1550,20250310
EXLS,45.7700,20250310
Please let me know your thoughts.
Best regards,
Larry
8 Posted by dwg on 13 Mar, 2025 04:18 AM
It seems to me you may be trying to reinvent the wheel here.
Have you looked at Mike Bray's Security Price and History Load extensions?
https://github.com/mrbray99/moneydanceproduction/wiki/Security-Price-and-History-Load
9 Posted by Stuart Beesley ... on 13 Mar, 2025 07:16 AM
I’m confused why in your screenshot for EXEL you have differing highs and lows as these are not from your import file? How were these set?
Questions:
1. Are you you sure that you’re not running QL or Q&ER extensions?
2. Run toolbox extension. Update mode. Security menu. Diagnose your hidden price date field.
3. What version of MD are you running.
4. Show me the settings on the edit screen of these two securities.
10 Posted by Larry Thoma on 13 Mar, 2025 01:26 PM
Sorry for the confusion on the csv. When I run the script it will only have
the end of day price for that specific day. In the example csv they were
the prices for Mar 10. The CSV file would have been different for Mar 7,
Feb 28, etc and would have values specific for those days.
Q&ER extensions are loaded from when I could get prices from
Alphavantage (before they limited the number of stocks), and TDA before it
became Schwab and the interface unavailable. I have a different group of
scripts that allow me to get price information from Schwab for separate
stock tracking that I have developed using python / postgresql. The csv
file is an extract from the postgresql data. Q&ER is listed as do not
update for rates and prices and has not been run since sept 3 2024.
Should I remove Q&ER? I see a warning about it on the opening screen of
toolbox.
[image: image.png]
MD version 2024.4 (5253)
[image: image.png]
[image: image.png]
I just noted that EXEL stock was used in a different investment account in
2023. It appears the script is updating the stock prices in this account
but not the one I noted earlier.
[image: image.png]
[image: image.png]
[image: image.png]
***
To answer the question from dwg on Mike Bray's extensions. I have not
looked at them, most of the options I have looked at wanted you to sign up
for expensive services to get the daily information. More for real time
traders.
11 Posted by Stuart Beesley ... on 13 Mar, 2025 03:37 PM
If you're not using QL / Q&ER, then yes, remove then...
I have updated your script with more diagnostic logging... Can you try it (perhaps on a test dataset, or at least backup first)..
(You will have to edit line 3 (filename))
12 Posted by Larry Thoma on 13 Mar, 2025 04:54 PM
I removed Q&ER, did not see QL installed.
I ran your script, this is the result file.
I checked a couple of the stocks that I had noted not updated before (TTD,
WHD, CTRE) and they still do not show the prices for Mar 10 even though
they were noted as successful.
Excl still shows as current in one account (however that account does not
currently have quantities of this stock) and not updated in the one that
does.
do you want me to run the
1.
Run toolbox extension. Update mode. Security menu. Diagnose your hidden
price date field.
I did not earlier due to the notices of issues with Q&ER.
Please let me know, since you are working the issue with me I don't want to
do things that may conflict with your troubleshooting.
Thanks for the help!
Best regards,
Larry
13 Posted by Stuart Beesley ... on 13 Mar, 2025 05:20 PM
do not run the diagnose yet...
I do not understand... This was CTRE
Processing: CTRE 25.81 03/10/2025 (Security: CareTrust REIT, Inc. - Common Stock)
... SKIPPING: CTRE (as price for date 03/10/2025 already exists: ph: 25.81 vs snap: 25.81)
It clearly says that CTRE already has a dated price.. Are you saying that it doesn't? If it doesn't, please send screenshot of that security and also its edit screen.
Also, are you sure that you do not have duplicated securities with the same ticker?
14 Posted by Larry Thoma on 13 Mar, 2025 05:54 PM
This is the info from the account that has stocks currently.
[image: image.png]
[image: image.png]
The other two accounts (one active, one inactive) have the same values for
the security history and edit security shown above.
Is there a way to search by ticker symbol to see if there was an issue when
the stock was added by downloads from fidelity, tda, or schwab?
Trying to figure out how to search for duplicate tickers as you indicated.
Best regards,
15 Posted by Stuart Beesley ... on 13 Mar, 2025 07:23 PM
Toolbox can find duplicates.
16 Posted by Stuart Beesley ... on 13 Mar, 2025 07:33 PM
I'm convinced you have duplicates...
Run this code:
17 Posted by Larry Thoma on 13 Mar, 2025 09:05 PM
received the following error when trying to run from developer console
Welcome to the interactive development console for Moneydance 2024.4(5253)
Java version: 21.0.5, Jython version: 2.7.2(final), running on
Linux(6.8.0-55-generic) amd64(intel64)
Use the variable 'moneydance' to access Moneydance's API...
example: 'moneydance.getUI()' for the GUI, and
'moneydance.getCurrentAccountBook()' for the dataset
---------------------------------------------------------------------------------------------------
Beginning snippet at Thu Mar 13 14:02:02 MST 2025
-------------------------
Error running snippet...: File "<string>", line 19
if secID != "": foundSecIDs[secID] = foundSecIDs.get(secID,
[]) + [sec]
^
SyntaxError: no viable alternative at input '&'
-------------------------
18 Posted by Stuart Beesley ... on 13 Mar, 2025 09:09 PM
That’s a copy / paste issue. You need to click the link to open this support page and then copy just the code and paste.
19 Posted by Stuart Beesley ... on 13 Mar, 2025 09:59 PM
OK, version 3 attached. I have included the duplicate ticker check within this code:
20 Posted by Larry Thoma on 13 Mar, 2025 10:27 PM
Here is the result from the script.
Thanks again for your help
Larry
21 Posted by Stuart Beesley ... on 14 Mar, 2025 09:45 AM
I think the results speak for themselves.. All the tickers you are saying are not updating, have duplicates... You should only have ONE security/ticker for all accounts that hold any security. It looks like you have one security per account.. The script is working, it's just random which of the duplicate tickers it updates first... You really need to merge the duplicate securities (using toolbox)...
If you really want to, I can show you how to update this script to update the duplicate tickers too..?
22 Posted by Larry Thoma on 14 Mar, 2025 02:09 PM
I agree that there should only be one security/ticker for all accounts.
First, I would like to know how to use toolbox to merge the duplicate
securities. Second, what do I need to do differently so that I do not have
to recreate the security if I use it in a different account but instead use
the existing security/ticker. It seems that the automated downloads and
when I add manually I am prompted to create the ticker before it can be
used.
Best regards,
Larry
Support Staff 23 Posted by Maddy on 14 Mar, 2025 02:31 PM
Hi Larry,
In order to merge duplicate securities within the same account, you could proceed as follow:
In the MENU: Currency & Security tools tab, choose:
FIX: Detect and merge/fix duplicate Security within same Investment Account
Select->proceed and follow the on-screen instruction.
Finally, restart Moneydance to retain the changes.
Please let us know if you have further questions or need more assistance.
--
Maddy, Infinite Kind Support
24 Posted by Larry Thoma on 14 Mar, 2025 04:22 PM
Hi Maddy,
Thanks for the feedback.
However, I have several investment accounts and I think that my issue is
that each investment account has its own set of securities.
Will this correct that issue so there is only one ticker?
Best regards,
Larry
On Fri, Mar 14, 2025 at 7:31 AM Maddy <[email blocked]>
wrote:
25 Posted by Stuart Beesley ... on 14 Mar, 2025 09:20 PM
There is another toolbox menu option to merge duplicate securities. This is the one you want. So that you end up with singular securities shared across several accounts.
26 Posted by Larry Thoma on 15 Mar, 2025 12:35 AM
Hi Stuart,
I tried the toolbox option to merge duplicate securities into one master
file.
it appears that there are several criteria that must be in place to start
with, including identical price history data.
How would you approach matching the price history data? Is there other
criteria I need to address before trying to merge the data?
The attached is the output from the attempt to merge the data.
Thanks again for your help, sorry this is such a hassle.
Best regards,
Larry
27 Posted by Stuart Beesley ... on 15 Mar, 2025 01:51 PM
(Sorry for delay, I’m not getting notified of your replies).
The price history does NOT have to match. The merge will allow you to merge history.
The rules are clearly stated.
So make sure for each ticker, the duplicate securities have different IDs - eg ticker APPLE. IDs Apple1, Apple2 etc.
The error in the log you provided said to make the current price the same on duplicate securities you want to merge. Eg for Apple all current prices should be 213.49 for example.
Keep me posted.
By all means email me:
…
28 Posted by Larry Thoma on 16 Mar, 2025 01:54 AM
Hi Stuart,
Have fixed all of the validation rule issues. Now starting to work through
the security merge. I think it will take a bit since it appears to be only
one at a time.
Thanks again for the help, I will keep you posted.
Best regards,
Larry
29 Posted by Stuart Beesley ... on 16 Mar, 2025 07:32 AM
Backup first.
I would do one security at a time and restart MD in between each merge.