Question: Maple Toolbox for MATLAB

 

MATLAB has this Index extracting symbol function for yahoo finance (which works well in MATLAB)
 

function tickers = yahooTickers(index)
% example: tickers = yahooTickers('^GSPC');
% Copyright 2008 trade-strategy.com

index = regexprep(index, '\^', '');
tickers = {};
iter = 0;
while true
    s = urlread(['http://finance.yahoo.com/q/cp?s=%5E', index,'&c=', num2str(iter)]);
    [st, fi] = regexp(s, '>\S+</a></b></td>');
    if isempty(st)
        break
    end
    for i = 1:length(st)
        tickers = [tickers; {s(st(i)+1:fi(i)-13)}];
    end
    iter = iter + 1;
end

 


I tried to simply convert it to Maple code by using the "Maple Toolbox for MATLAB" but it does not really work that well:

 

with(Matlab);
mfile := "C:\\Program Files\\MATLAB\\R2009a Student\\User Files\\yahooTickers.m";
FromMFile(mfile);


yahooTickers := proc( m_index )
    uses ArrayTools;
    local tickers;
    # tickers = yahooTickers('^GSPC')  Copyright 2008 trade-strategy.com
    m_index := regexprep(m_index, "\\", "");
    tickers := Vector();
    iter := 0;
    while ArrayTools[AllNonZero](true) do
        s := urlread(Vector[row](["http://finance.yahoo.com/q/cp?s=%5E", m_index, "&c=", num2str(iter)]));
        (st, fi) := regexp(s, ">\\+</a></b></td>");
        if ArrayTools[AllNonZero](`if`(ArrayTools:-NumElems(st) = 0, true, false)) then
            break;
        end if;
        for Matlab_i from 1 to rtable_scanblock(ArrayTools:-Size(st), [rtable_dims(ArrayTools:-Size(st))], 'Maximum') do
            tickers := Concatenate(1, tickers, rtable([s((st(Matlab_i) +~ 1)..(fi(Matlab_i) -~ 13))],subtype='Vector[row]'));
        end do;
        iter := iter +~ 1;
    end do;
        return tickers;
end proc;

 

Error, (in Matlab:-FromMFile) incorrect syntax in parse: reserved word `fi` unexpected (near 401st character of parsed string)
 

any ideas ?

Please Wait...