MATLAB Community

MATLAB, community & more

Trendy now gets data hourly, desktop gadgets & more

Trendy is a MATLAB Central application that scrapes a time series dataset from website(s) you specify. Trendy uses this data to maintain a plot for you, which it updates automatically with each new data point captured. You don’t even need a MATLAB license to use this powerful tool.

For instance, there’s a plot of several trends for keeping watchful eye over the US vs Canada vs the UK national debt, normalized per person.

Data Gathering Fidelity: Hourly, Daily, Weekly & Monthly

Up to now, MATLAB Central had been running trend gathering code only once daily.  With the latest release, you can instruct Trendy how often to collect data.  This means you can now use Trendy to capture time series data with higher fidelity.

Now, when you Create a Trend:


you will see a fourth step:

This new step gives you control over when and how often Trendy collects data from the website you’ve specified.  Since there is no point collecting hourly data on something which changes less often, please configure this according to your needs.

Automatic Plots: Your Cody Rank

Another great use of Trendy is to automatically graph your rank on MATLAB Central Cody.  Follow that link and you’ll have created a trend plot in Trendy easier than ever!

Debugging: Show me what was sent to MATLAB

Sometimes while creating a trend or a plot in Trendy, you may “Test Code & Show Results” for testing purposes:

Clicking “Show me what was sent to MATLAB,” above, it’s even easier to prototype and debug Trendy code in concert with MATLAB running on your desktop.  With this new feature, you see exactly how Trendy renders your code to our server-side MATLAB, e.g.:

Using Trend data in MATLAB:

A while back, I’d taken interest in Sam Mirsky’s World Mood 2 trend plot.  I was aware of the idea of using social media metrics as input into predictive modelling of financial markets.  While I would never advocate a trading or investment strategy based solely on one indicator, I had in July already been considering taking a long position in the S&P500 personally (via the SPY ETF).  At the time, I lacked conviction in the idea so let that opportunity pass absent a confirming indicator.

Drawing on the idea of using social media metrics as a trading indicator, it is interesting to use MATLAB to overlay the Surprise Tweets/min from Sam’s plot with the daily close of SPY:

Note I’ve lightened data in each series for which corresponding values in the other series were unavailable.

You can replicate the above plot in MATLAB as follows.  First, download Sam’s Surprise Tweets/min data from his Trend:

then click “Download”:

then in MATLAB,

twd = struct;
twv = struct;
twd.surprise = csv2cell('Surprise Tweets_min.csv','fromfile');
names=fieldnames(twd);
for j = 1:numel(names)
    twv.(names{j}) = zeros(size(twd.(names{j}),1),2);
    for i = 1:size(twd.(names{j}),1)
        twd.(names{j}){i,1} = datenum(twd.(names{j}){i,1},'yyyy-mm-dd HH:MM:SS');
        if ~isempty(sscanf(twd.(names{j}){i,2},'[%f]'))
            twd.(names{j}){i,2} = sscanf(twd.(names{j}){i,2},'[%f]');
        else
            twd.(names{j}){i,2} = 0.0;  % clean nulls
        end
        twv.(names{j})(i,2) = twd.(names{j}){i,2};
        twv.(names{j})(i,1) = twd.(names{j}){i,1};
        if twv.(names{j})(i,1) > 735182.483032407
            twv.(names{j})(i,2) = 0;    % omit where no corresponding
        end
    end
end
data = fetch(yahoo, 'spy','Close',twv.surprise(1,1),twv.surprise(size(twv.surprise(:,1),1),1));  % note "fetch" requires the MATLAB datafeed toolbox
for i = 1:size(data,1)
    if data(i,1) < 735004
        data(i,2) = NaN;  % omit where no corresponding
    end
    if data(i,1) > 735190
        data(i,2) = NaN;  % omit where no corresponding
    end
end
[AX, H1, H2] = plotyy(twv.surprise(:,1),twv.surprise(:,2),data(:,1),data(:,2));
set(AX, 'xTickLabel','')
datetick('x','mmm','keepticks')
set(get(AX(1),'Ylabel'),'String','Surprise Tweets/min')
set(get(AX(2),'Ylabel'),'String','SPY Close $/share')
set(H1,'Marker','.','Color','blue','LineStyle','none' )
set(H2,'LineStyle','-')
set(AX(1),'ylim', [300 2000])
set(AX(2),'ylim', [125 150])
set(AX(1),'YTick',[0:500:2500])
set(AX(2),'YTick',[125:5:150])

In case you are wondering, I do not believe there is such thing as a “holy grail” indicator with the power to foretell financial markets.  I believe an effective trading or investing strategy is constructed cautiously using an array of clues validated over time, each in context, as useful for gaining a statistical edge.  For me, the above is only one clue to be confirmed with others; only time will tell its predictive reliability. The materials shared here are for general information purposes only and do not constitute any investment advice. That said, the data available as of July in concert with other factors I personally track would have been sufficient to have favorably affected my conviction at that time.  I’m compelled to monitor Surprise Tweets/min.  Which brings us to the next topic,

Trendy Gadgets: Windows Vista & Windows 7

As human nature would have it, I’d routinely forget to open my browser, navigate to the plot page & see what had changed on Sam’s plot discussed above.  It’s why I failed to notice the spike in Surprise Tweets/min in a timely manner, which cost me the opportunity discussed above.  While Trendy is a valuable tool, Sam’s plot page is well outside my daily workflow.

I wanted to become aware of changes to Trendy content in a more timely manner.  To bring this value within my personal workflow, I developed a Windows 7 desktop gadget to keep my favorite Trendy plot always within view:

On Windows 7, a desktop gadget is implemented as a zip archive with file extension “.gadget”.  In the case of Trendy, the archive contains HTML, CSS and JavaScript which replicates the web experience of viewing the plot image.  If you’re interested, you can learn more about gadgets here.  I’d personally thank anyone who feels inspired to share something similar on File Exchange for Mac, Linux, Android and/or Windows 8 “live tile” Metro/Surface formats.

The MATLAB Central Trendy team felt others may like this ability too, so if you’re using Windows Vista or 7 you will now find following each Trendy plot an Extras: Download Gadget tailored to the specific plot you’re viewing.

Click “Download Gadget” to download the file.  Then simply double-click the file which downloads, click “install” and enjoy the plot as it updates itself live on your desktop.

Please speak up if you’ve found the enhancements helpful.  We’re always eager to learn more about how we can develop products to best help you.

Thanks,
Bob

|
  • print

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.