Code covered by the BSD License  

Highlights from
FinMetrics

  • fm(varargin) This source file is subject to version 3 of the GPL license,
  • AssetThis source file is subject to version 3 of the GPL license,
  • AssetUniverseThis source file is subject to version 3 of the GPL license,
  • AxlThis source file is subject to version 3 of the GPL license,
  • CashPositionThis source file is subject to version 3 of the GPL license,
  • CashTransactionThis source file is subject to version 3 of the GPL license,
  • Config This source file is subject to version 3 of the GPL license,
  • ConsoleMenuThis source file is subject to version 3 of the GPL license,
  • ConsoleMenuItemThis source file is subject to version 3 of the GPL license,
  • CurrencyAssetThis source file is subject to version 3 of the GPL license,
  • ExchangeTradedAssetThis source file is subject to version 3 of the GPL license,
  • FinMetricsThis source file is subject to version 3 of the GPL license,
  • PortfolioThis source file is subject to version 3 of the GPL license,
  • PositionThis source file is subject to version 3 of the GPL license,
  • StatisticsThis source file is subject to version 3 of the GPL license,
  • StockPositionThis source file is subject to version 3 of the GPL license,
  • StockTransactionThis source file is subject to version 3 of the GPL license,
  • TextUIThis source file is subject to version 3 of the GPL license,
  • TextUILocaleThis source file is subject to version 3 of the GPL license,
  • TextUIQuestionThis source file is subject to version 3 of the GPL license,
  • TextUIQuestionnaireThis source file is subject to version 3 of the GPL license,
  • TransactionThis source file is subject to version 3 of the GPL license,
  • View all files

FinMetrics

by

 

Open source/open architecture quantitative portfolio management environment.

fm(varargin)
% This source file is subject to version 3 of the GPL license, 
% that is bundled with this package in the file LICENSE, and is 
% available online at http://www.gnu.org/licenses/gpl.txt
%
% This source file can be linked to GPL-incompatible facilities, 
% produced or made available by MathWorks, Inc.

function varargout = fm(varargin)        

    fmLocale = FM.TextUILocale('en_US');
    
    while (true)
        clear global FinMetrics;     
       
        % Check if we need to expose major application data to "Base" workspace.
        %
        if (FM.Config.ExposeDataToBase)        
            eval('global FinMetrics');
            evalin('base', 'global FinMetrics');
        end
       
        if (exist('varargin', 'var'))
            if ~isempty(varargin)
                projectFile = char(varargin(1));
            end
        end
        
        if (exist('projectFile', 'var'))
            if (exist(projectFile, 'file') ~= 2)
                fprintf('File ''%s'' not found. Usage: fm [ ''project file.mat'' ]\n\n', projectFile);                
                return;
            else
                pf = load(projectFile);
                FinMetrics = pf.(char(fieldnames(pf)));
                
                if (~strcmp(class(FinMetrics), 'FM.FinMetrics'))
                    fprintf('File ''%s'' is not a valid FinMetrics project.\n\n', projectFile);                
                    return;
                end                
            end
        else
            % Create main application class (project)
            FinMetrics = FM.FinMetrics;    
            FinMetrics.Init();
        end                
        
        FMUI = FM.TextUI(FinMetrics);
        % Code  0 = normal exit
        % Code -1 = create new project
        % Code -2 = open existing project
        code = FMUI.Init;
        
        switch code
            case 0
                break;
            case -1 
                clear all;
                continue;
            case -2
                projectFile = askProjectFile();                
        end                
    end       
    
    function ret = askProjectFile()
            ret = false;
            opTQ = FM.TextUIQuestionnaire(fmLocale.Q_OPEN_PROJECT_TITLE);
                                                
            opTQ.InsertItem(FM.TextUIQuestion(fmLocale.Q_OPEN_PROJECT_FILE, 'askProjectFile', {'ValidateCallback', @askProjectFileCallback, }), 'END');                        
                        
            if (opTQ.Ask == 1)
                ret = opTQ.GetItemByTag('askProjectFile').DefaultAnswer;
                return;
            end            
            
            function ret = askProjectFileCallback(answer)
                if (exist(answer, 'file') ~= 2)
                    fprintf ('%s: %s\n', fmLocale.ERR_GEN_FILE_NOT_FOUND, answer)
                    ret = 0;
                else
                    ret = 1;
                end
            end

    end
end   




Contact us