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 Current Prices of all tickers in the first portfolio
Not logged in.
2009-01-12 22:07:47
1 of 1
#1317
This snippet of VB code, added to a top level object, will first display all the current prices and then display each update as it comes in. In this example I've tied the code to the File->New menu item:

Private Sub mnuFileNew_Click()
    
    ' get connection to PSS
    
    Set PSSObject = GetObject(, "PSSScript.PSSScriptModule")
    Set PSSApp = PSSObject.Application
    Set PSSDoc = PSSApp.ActiveDocument
    
    ' get top portfolio
    
    Set Portfolios = PSSDoc.Portfolios
    
    Debug.Print "Looking at Portfolio: " + Portfolios.Item(1).Name
        
    ' get tickers at top of portfolio (i.e. ones not in folders)

    Set Tickers = Portfolios.Item(1).Tickers
    
    For n2 = 1 To Tickers.Count
        Debug.Print "Ticker is " + Tickers.Item(n2).GetProperty("Symbol")
        Debug.Print "Starting Price is " + CStr(Tickers.Item(n2).GetProperty("Price"))
    Next
    
    ' the following is if you have your tickers organized in folders.
    
    Set Folders = Portfolios.Item(1).Folders
       
    For n = 1 To Folders.Count
        Debug.Print "Looking at Folder: " + Folders.Item(n).Name
    
        Set Tickers = Folders.Item(n).Tickers
        
        For n2 = 1 To Tickers.Count
            Debug.Print "Ticker is " + Tickers.Item(n2).GetProperty("Symbol")
            Debug.Print "Starting Price is " + CStr(Tickers.Item(n2).GetProperty("Price"))
        Next
        
    Next
        
    ' get the EventManager class which will notify us when events happen
    
    Set PSSEventManager = PSSApp.GetObject("EventManager")
        
    ' tell the event manager to call the OnTickerUpdated method in our
    ' tickerEvent handler class for each tick on any ticker that comes in.
    ' note that this callback can happen up to once a second so it should
    ' run quickly.
    
    PSSEventManager.RegisterHandlerMethod frmMain, "OnTickerUpdated"
    
End Sub

Public Function onTickerUpdated(ticker)
    Debug.Print "Ticker Update"
    Debug.Print " Symbol: " + ticker.GetProperty("Symbol")
    Debug.Print " Price: " + CStr(ticker.GetProperty("Price"))
End Function

----------------------
DTLink Software
----------------------
DTLink Software
Posted by: Yermo