Forum

Free Download More Info
Welcome to the Personal Stock Streamer Developers Forum. Anyone can read messages, but you must be a registered user in order to post. (Sorry, we did this in order to prevent forum spam.)

Everyone who is registered for the Developers Forum on this site should now also have permission to log in and post to the Support Forum.  This was done by hand, so we may have missed a couple of people.  Please let us know if you do not have access to both forums.
Subscribe to RSS Feed
PSS Developers Forum -> Getting History and Intraday data from a VB application
Not logged in.
2007-12-11 22:41:50
1 of 1
#1157
This thread:

http://personalstockstreamer.com/support/forum.html?thr...

moved over from the support forum to here.

You can interact and to some degree control PSS from a Visual Basic application. The first step to making this work is to import the "type library" for the PSS Scripting interface into Visual Basic.

In the Visual Basic UI go to Project->References and click on BROWSE. Browse for the file c:\program files\personal stock streamer\plugins\PSMSCript.dll

This will make the features of PSS available to VB.

The first thing you have to do now is get a reference to the top level PSS application object. You do this in your VB code using:

Set PSSObject = GetObject(, "PSSScript.PSSScriptModule")
Set Application = PSSObject.Application

You have to have PSS running before these calls are made otherwise it'll fail.

From here you can use all the API calls described in the developers reference documentation located here:

http://personalstockstreamer.com/uploaded_html/dev-webh...

Now I am no Visual Basic programmer, but here's a little script that I slapped together this evening to try to point you in the right direction. It will loop through all the portfolios, folders and tickers and print out 10 lines of end of day history data. It's got a few serious problems which I will have to work on when time permits:

1. it does not automatically download the history data for a ticker.
2. it doesn't correctly loop through empty folders.
3. it doesn't handle tickers that don't have history data.

So to run this, open a new stock file (File->New in PSS). Add a folder and put a single ticker in the folder. Open an end of day chart on it to download some history data.

Then try running this:

' get the PSS object

Set PSSObject = GetObject(, "PSSScript.PSSScriptModule")
Set Application = PSSObject.Application
    
Print "after application " + Application.ActiveDocument.Name

' get the list of portfolios
    
Set Portfolios = Application.ActiveDocument.Portfolios
    
For i = 1 To Portfolios.Count
   Print "Looking at Portfolio: " + Portfolios.Item(i).Name

   ' get all the folders in the current porfolio
       
   Set Folders = Portfolios.Item(i).Folders
       
   For n = 1 To Folders.Count
      Print "Looking at Folder: " + Folders.Item(n).Name
 
      ' get all the tickers in the current folder
         
      Set Tickers = Folders.Item(n).Tickers
          
      Print "Number of tickers: " + CStr(Tickers.Count)
          
      For X = 1 To Tickers.Count
         Print "Looking at Ticker: " + Tickers.Item(X).GetProperty("Symbol")

         ' get the history data for the current ticker. To get
         ' intraday data you can just use IntradayData
             
         Set HistoryData = Tickers.Item(X).HistoryData
             
         Print "Records of history data: " + CStr(HistoryData.Count)
             
         For Y = 1 To HistoryData.Count

            ' print out the date and open values.
            Print "EOD date " + CStr(HistoryData.Item(Y).GetProperty("Date")) + " had open " + CStr(HistoryData.Item(Y).GetProperty("Open"))
            
            ' limit us to 10 lines just for this demo.
                 
            If (Y > 10) Then
               Exit For
            End If
                              
         Next
             
      Next
   Next
       
Next


There are a number of different ways you can find a given ticker. You can even ask PSS to add a ticker and tell it to download the data for you automatically. Take a careful look through the developer documentation.

My purpose here was to give you a starting point for your project. Like I said, this code snippet has some problems but it should give you an idea of how to approach this. If you have questions please feel free and post them here and we'll try to answer them best we can.
 
----------------------
DTLink Software
----------------------
DTLink Software
Posted by: Yermo