ITQuants blog

Fusion Invest: how to know which portfolio columns are displayed?

Dec 7

Written by:
12/7/2014 8:01 PM  RssIcon

The root cause of needing this information is that we want to display user portfolio columns on which we need to calculate aggregation. I've already seen some client implementation on which the aggregation is calculated when the callback CSRPortfolioColumn::GetPositionCell is called, when detecting any change on the GetRefreshVersion of the same class.

The advantage is that this code is called only if the column is displayed, but unfortunately, that's not the right way to do it and for these reasons:

 - on GetPositionCell, we don't know at which level we need to calculate the aggregation and the parsing of all folios is then  needed. When many folios are already loaded, it decreases dramatically the performances and the software freezes in most cases.

- on the CSRGlobalFunctions, Misys provides a method, StartPortfolioAddition, which is called each time that the core engine needs to make an aggregation. For instance, changing the currency of a folio will call this method, with the folioId corresponding to the root folio on which the aggregation needs to be recalculated. 

In the last case, the method does not give the list of columns on which we need to aggregate. To detect it, Misys provides unfortunately no official and supported method. 

The goal of this post is to give the way to get it, in all Sophis versions.

In previous versions of Sophis, it is possible to get this list of columns using the Low Level Toolkit. Each MDI child window which appears in Sophis Risque is described as a CSWindow object. Handles are not the Microsoft HWND ones, but the WindowPtr ones, which inherits from old Mac versions. Using these "Mac" handles, the manager of the CSWindow gApplicationSophis, it is possible to parse all open window in order to know which columns are displayed. The Portfolio screen corresponds to a child class of CSWindow, CSWindFolio. On this class, we can access the data manager, which inherits from  the CSRMgrFolio class. On this class two methods are available:

GetNbVisCol, which gives the number of columns displayed for this window

GetVisColName, which gives the name of the column.

The code will then this one:

For the next version of Sophis Risque/Value, named Fusion Invest, all portfolio windows were changed and are developed in C#, using the DevExpress TreeList control, instead of a specific implementation of the Sophis internal CSCtrlGrille control. The CSWindow mechanism was not kept: using the gApplicationSophis, we cannot parse any list in order to get some information . But, by chance, since it is written in C #, we have access to the code on this part. For example, the dll SophisPortfolioGUI.dll is an assembly. Adding it as reference will give us access to the NavigationManager class and its singleton instance, which replaces the gApplicationSophis previous one. NavigationManager gives us the opportunity to know which portfolio windows are displayed and which column configuration is selected.

typedef std::set UniqueColNames; 
UniqueColNames colNames; 
if(gApplicationSophis!=NULL) 
    WindowPtr wndPtr = FrontWindow(); 
    while(wndPtr!=NULL) 
    
        try
        
            CSWindow* window = gApplicationSophis->GetCSWindow(wndPtr); 
            CSWindFolio* wndFolio = dynamic_cast(window); 
            if(wndFolio!=NULL) 
            
                CSMgrFolio* mgr = wndFolio->GetMgr(); 
                if(mgr!=NULL) 
                
                    int nbCol = mgr->GetNbVisCol(); 
                    for(int i=0;i 
                    
                        char szBuffer[512]; 
                        memset(szBuffer,0,sizeof(szBuffer)); 
                        mgr->GetVisColName(i,szBuffer); 
                        if(strlen(szBuffer)>0) 
                            colNames.insert(szBuffer); 
                    
                
            
        
        catch(...) 
        
        
        wndPtr = GetNextWindowSophis(wndPtr); 
    

Finally, the right code to get all porfolio columns displayed at screen on this version is the following one:

int nbOpenFolio = Sophis.Data.Utils.NavigationManager.Instance.AlivePortfolioContextControls.Count; 
if (nbOpenFolio > 0) 
    List<string> colNames = new List<string>(); 
    for(int i=0;i    { 
        string configName = Sophis.Data.Utils.NavigationManager.Instance.AlivePortfolioContextControls[i].GetDefaultColumnsConfigName(); 
        Sophis.Util.ColumnsConfigs configs = Sophis.Portfolios.RisqueColumnsConfigs.PortfolioColumnsConfigs; 
        foreach(KeyValuePair<string, List> kvp in configs.CurrentConfigurations) 
        
            if(kvp.Key==configName) 
            
                foreach(Sophis.Data.Utils.IColumn item in kvp.Value) 
                    colNames.Add(item.Caption); 
            
        
    
}

Tags:
Categories: Sophis

1 comment(s) so far...


Gravatar

Re: Fusion Invest: how to know which portfolio columns are displayed?

For information, NavigationManager is defined in the SophisPortfoliosGUI C# assembly.

By Philippe Bonneau on   12/11/2015 4:15 PM

Search blog