This is the Personal Stock Monitor scripting developers forum.
Subscribe to RSS Feed
Developing Custom Stock Market Software using PSM -> PSM Script to Modify Transactions?
Not logged in.
2010-03-21 16:37:58
1 of 6
#1928
Howdy All,

Was wondering if it is possible to write a PSM script to update a specific transaction within a set of selected tickers, or all tickers in a specific account tab?

I created several account tabs with tickers that track selected indexes (Dow Jones, S&P, etc.), along with some that track sector/industy ETFs. Each ticker contains a single transaction to buy one share at the beginning of each year -- in order to track the year's performance of that item. At the beginning of each year, I change the transaction to reflect the opening price of the ticker on the first trade day of that year.

It would be very helpful if I was able to 'Run a Script' to do this automatically for the selected tickers OR for the entire account tab.

If this can be done, would someone please provide some example code of HOW to do it -- unless someone has already written one.

Thank you all very much!

-Don
Posted by: dgoyette
2010-03-21 18:29:21
2 of 6
#1933
in reply to #1928
Yes. You just loop through your ticker list and add a transaction to each ticker when you want. See the object model documention:

http://www.personalstockmonitor.com/formvista/site_loca...

(See InsertTransaction method of the Ticker object)

And you can check the articles in the developers section for a number of examples of looping over tickers. The capital gains report example, see http://www.personalstockmonitor.com/fv-b-16-129/Recreat... might be a good place to get an idea of how to do the looping you need to do.
Posted by: Yermo
2010-03-21 18:56:23
3 of 6
#1934
in reply to #1933
Thank you Yermo.

Actually, I want to MODIFY the existing transaction for each ticker, changing the Date to a pre-determined value, and changing the Price to the Open Price for the new date of the selected Ticker. More complex than a simple "loop" to me, as the Open Price needs to be looked-up via History for each specific Ticker and Date.

Are you saying that a PSM Extension (Tools-->Extensions...) is the same thing as a PSM Script (Tools-->Run Script) -- it's just run via the Run Script command vs. "installing" an Extension? I thought they were two different things, with different syntax, file locations, requirements, etc. No?

Hope I can figure it all out. I'm sure this first Script / Extension will be the most difficult for me, since I'm just learning how to do it.

Thanks again,

-Don
Posted by: dgoyette
2010-03-22 10:50:36
4 of 6
#1938
in reply to #1934
An extension gets installed into the extension database and is loaded each time on program startup. Extensions are background tasks, and can do more things than regular scripts, because they can create objects such as menu and event handlers that hook into the user interface. Extensions are also asynchronous, meaning that they set up their handlers, then wait for things to happen that call back into the script.

The Run Script command is for manually running scripts to perform specific tasks. You can't create permanent objects such as event handlers in regular scripts, because the script engine is shut down after the script exits. Any script that you run via Run Script does not get installed, and the format is different because it does not use the XML wrapper. Also, scripts run using Run Script are run in the foreground, so if a script stalls, it will stall the entire application. Therefore the script must perform its task quickly and finish so the application can continue running.

Otherwise, scripts run using Run Script have access to the same object model as extensions, so the syntax with regards to that is no different.

Hope this clears some things up.
Posted by: Anatoly
2010-04-07 04:28:14
5 of 6
#1979
in reply to #1938
Thank you Anatoly.
Posted by: dgoyette
2010-11-27 21:49:25
6 of 6
#2600
in reply to #1933
Yermo wrote
You just loop through your ticker list and add a transaction to each ticker when you want.


L O L !!!

My current attempt to do this "simple" update, with some minor date validation and error checking, is OVER 580 lines of VBScript code! Of course, half of it is comments and MsgBox statements, so I can be reminded of what the heck I wanted to do.

"... just loop through your ticker list ..." sounds sooooo easy (LOL). Silly me. I'll bet Anatoly is rolling around on the floor laughing his head off ... right

Thanks for all of your help guys! A few more as-of-yet unhandled (raw) errors to take care of and then it should be done.

-Don

PS. Have you guys thought about creating a script/extension repository or posting section, whereby users could share scripts and extensions? Along with you guys posting the source code for your "official" PSM extensions, included with the program?

I would be happy to share my "simple" ticker update extension with anyone who's interested.
Posted by: dgoyette