{"id":1902,"date":"2012-12-17T12:49:10","date_gmt":"2012-12-17T17:49:10","guid":{"rendered":"https:\/\/blogs.mathworks.com\/community\/?p=1902"},"modified":"2012-12-17T17:07:27","modified_gmt":"2012-12-17T22:07:27","slug":"trendy-now-gets-data-hourly-desktop-gadgets-more","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2012\/12\/17\/trendy-now-gets-data-hourly-desktop-gadgets-more\/","title":{"rendered":"Trendy now gets data hourly, desktop gadgets &#038; more"},"content":{"rendered":"<p><a title=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\" href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\" target=\"_blank\">Trendy<\/a>\u00a0is 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&#8217;t even need a MATLAB license to use this powerful tool.<\/p>\n<p>For instance, there&#8217;s a plot of several trends for keeping watchful eye over the <a title=\"National Debt: US v. Canada v. UK (normalized)\" href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/plots\/630\" target=\"_blank\">US vs Canada vs the UK national debt, normalized per person<\/a>.<\/p>\n<p><strong>Data Gathering Fidelity:\u00a0Hourly, Daily, Weekly &amp; Monthly<\/strong><\/p>\n<p>Up to now, MATLAB Central had been running trend gathering code only once daily. \u00a0With the latest release, you can instruct Trendy how often to collect data. \u00a0This means you can now use Trendy to capture time series data with higher fidelity.<\/p>\n<p>Now, when you <a title=\"Create a Trend in Trendy\" href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/trends\/new\" target=\"_blank\">Create a Trend<\/a>:<\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/trends\/new\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1923\" title=\"create a trend\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/create-a-trend.png\" alt=\"\" width=\"172\" height=\"284\" \/><\/a><br \/>\nyou will see a fourth step:<br \/>\n<a href=\"https:\/\/blogs.mathworks.com\/community\/files\/tell-us-when.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1924\" title=\"Step Four\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/tell-us-when.png\" alt=\"\" width=\"392\" height=\"165\" \/><\/a><br \/>\nThis new step gives you control over when and how often Trendy collects data from the website you&#8217;ve specified. \u00a0Since there is no point collecting hourly data on something which changes less often, please configure this according to your needs.<\/p>\n<p><strong>Automatic Plots: Your Cody Rank<\/strong><\/p>\n<p>Another great use of Trendy is to <a title=\"Your Cody Rank in Trendy\" href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/externals\/cody_rank\" target=\"_blank\">automatically graph your rank on MATLAB Central Cody<\/a>. \u00a0Follow that link and you&#8217;ll have created a trend plot in Trendy easier than ever!<\/p>\n<p><strong>Debugging: Show me what was sent to MATLAB<\/strong><\/p>\n<p>Sometimes while creating a trend or a plot in Trendy, you may &#8220;Test Code &amp; Show Results&#8221; for testing purposes:<br \/>\n<a href=\"https:\/\/blogs.mathworks.com\/community\/files\/test-code-show-results-show-me.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1926\" title=\"test code show results show me\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/test-code-show-results-show-me.jpg\" alt=\"\" width=\"401\" height=\"98\" \/><\/a><\/p>\n<p>Clicking &#8220;Show me what was sent to MATLAB,&#8221; above, it&#8217;s even easier to prototype and debug Trendy code in concert with MATLAB running on your desktop. \u00a0With this new feature, you see exactly how Trendy renders your code to our server-side MATLAB, e.g.:<br \/>\n<a href=\"https:\/\/blogs.mathworks.com\/community\/files\/as-sent-to-matlab.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1928\" title=\"as sent to matlab\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/as-sent-to-matlab.jpg\" alt=\"\" width=\"438\" height=\"97\" \/><\/a><\/p>\n<p><strong>Using Trend data in MATLAB:<\/strong><\/p>\n<p>A while back, I&#8217;d taken interest in Sam Mirsky&#8217;s <a title=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/plots\/644\" href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/plots\/644\" target=\"_blank\">World Mood 2<\/a>\u00a0trend plot. \u00a0I was aware of the idea of using <a title=\"http:\/\/papers.ssrn.com\/sol3\/papers.cfm?abstract_id=1685150\" href=\"http:\/\/papers.ssrn.com\/sol3\/papers.cfm?abstract_id=1685150\" target=\"_blank\">social media metrics as input into predictive modelling of financial markets<\/a>. \u00a0While I would <em>never<\/em> advocate a trading or investment strategy based\u00a0<em>solely<\/em>\u00a0on one indicator, I had in July already been considering taking a long position in the S&amp;P500 personally (via the <a title=\"S&amp;P500 SPY Exchange-traded Fund\" href=\"http:\/\/www.google.com\/finance?ei=40XPUPj7Hca40gHcag&amp;q=spy\" target=\"_blank\">SPY<\/a> ETF). \u00a0At the time, I lacked conviction in the idea so let that opportunity pass absent a confirming indicator.<\/p>\n<p>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&#8217;s plot with the daily close of SPY:<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/community\/files\/twitter_spy.png\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-1921 alignnone\" title=\"twitter_spy\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/twitter_spy.png\" alt=\"\" width=\"448\" height=\"336\" \/><\/a><\/p>\n<p>Note I&#8217;ve lightened data in each series for which corresponding values in the other series were unavailable.<\/p>\n<p>You can replicate the above plot in MATLAB as follows. \u00a0First, download Sam&#8217;s <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/trends\/1234\" target=\"_blank\">Surprise Tweets\/min<\/a> data from his Trend:<br \/>\n<a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/trends\/1234\/trend_data\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1931\" title=\"show all data\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/show-all-data.jpg\" alt=\"\" width=\"196\" height=\"92\" \/><\/a><\/p>\n<p>then click &#8220;Download&#8221;:<br \/>\n<a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/trends\/1234\/trend_data\/download\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-1932\" title=\"dl\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/dl-300x132.jpg\" alt=\"\" width=\"300\" height=\"132\" \/><\/a><\/p>\n<p>then in MATLAB,<\/p>\n<pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid #c8c8c8;\">twd = struct;\r\ntwv = struct;\r\ntwd.surprise = csv2cell('Surprise Tweets_min.csv','fromfile');\r\nnames=fieldnames(twd);\r\nfor j = 1:numel(names)\r\n    twv.(names{j}) = zeros(size(twd.(names{j}),1),2);\r\n    for i = 1:size(twd.(names{j}),1)\r\n        twd.(names{j}){i,1} = datenum(twd.(names{j}){i,1},'yyyy-mm-dd HH:MM:SS');\r\n        if ~isempty(sscanf(twd.(names{j}){i,2},'[%f]'))\r\n            twd.(names{j}){i,2} = sscanf(twd.(names{j}){i,2},'[%f]');\r\n        else\r\n            twd.(names{j}){i,2} = 0.0;  % clean nulls\r\n        end\r\n        twv.(names{j})(i,2) = twd.(names{j}){i,2};\r\n        twv.(names{j})(i,1) = twd.(names{j}){i,1};\r\n        if twv.(names{j})(i,1) &gt; 735182.483032407\r\n            twv.(names{j})(i,2) = 0;    % omit where no corresponding\r\n        end\r\n    end\r\nend\r\ndata = fetch(yahoo, 'spy','Close',twv.surprise(1,1),twv.surprise(size(twv.surprise(:,1),1),1));  % note \"fetch\" requires the MATLAB datafeed toolbox\r\nfor i = 1:size(data,1)\r\n    if data(i,1) &lt; 735004\r\n        data(i,2) = NaN;  % omit where no corresponding\r\n    end\r\n    if data(i,1) &gt; 735190\r\n        data(i,2) = NaN;  % omit where no corresponding\r\n    end\r\nend\r\n[AX, H1, H2] = plotyy(twv.surprise(:,1),twv.surprise(:,2),data(:,1),data(:,2));\r\nset(AX, 'xTickLabel','')\r\ndatetick('x','mmm','keepticks')\r\nset(get(AX(1),'Ylabel'),'String','Surprise Tweets\/min')\r\nset(get(AX(2),'Ylabel'),'String','SPY Close $\/share')\r\nset(H1,'Marker','.','Color','blue','LineStyle','none' )\r\nset(H2,'LineStyle','-')\r\nset(AX(1),'ylim', [300 2000])\r\nset(AX(2),'ylim', [125 150])\r\nset(AX(1),'YTick',[0:500:2500])\r\nset(AX(2),'YTick',[125:5:150])<\/pre>\n<p>In case you are wondering, I do <em>not<\/em> believe there is such thing as a &#8220;holy grail&#8221; indicator with the power to\u00a0foretell\u00a0financial markets. \u00a0I 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. \u00a0For 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 <em>in concert with<\/em> other factors I personally track\u00a0<em>would<\/em> have been sufficient to have favorably affected <em>my<\/em> conviction at that time. \u00a0I&#8217;m compelled to monitor Surprise Tweets\/min. \u00a0Which brings us to the next topic,<\/p>\n<p><strong>Trendy Gadgets: Windows Vista &amp; Windows 7<\/strong><\/p>\n<p>As human nature would have it, I&#8217;d routinely <em>forget<\/em>\u00a0to open my browser, navigate to the plot page &amp; see what had changed on Sam&#8217;s plot discussed above. \u00a0It&#8217;s why I failed to notice the spike in Surprise Tweets\/min in a timely manner, which cost me the opportunity discussed above. \u00a0While Trendy is a valuable tool, Sam&#8217;s plot page is well outside my daily workflow.<\/p>\n<p>I\u00a0wanted to become aware of changes to Trendy content in a more timely manner. \u00a0To bring this value within my personal workflow, I developed a Windows 7 desktop gadget to keep my favorite Trendy plot always within view:<\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/plots\/send_gadget?id=644\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1929\" title=\"desktop\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/desktop.png\" alt=\"\" width=\"517\" height=\"388\" \/><\/a><\/p>\n<p>On Windows 7, a desktop gadget is implemented as a zip archive with file extension &#8220;.gadget&#8221;.\u00a0 In the case of Trendy, the archive contains HTML, CSS and JavaScript which replicates the web experience of viewing the plot image.\u00a0 If you\u2019re interested, you can learn more about gadgets <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/bb456468(v=vs.85).aspx\">here<\/a>.\u00a0 I\u2019d personally thank anyone who feels inspired to share something similar on <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/\">File Exchange<\/a> for Mac, Linux, Android and\/or Windows 8 \u201clive tile\u201d Metro\/Surface formats.<\/p>\n<p>The MATLAB Central Trendy team felt others may like this ability too, so if you&#8217;re using Windows Vista or 7 you will now find following each Trendy plot an <strong>Extras: Download Gadget<\/strong> tailored to the specific plot you&#8217;re viewing.<\/p>\n<p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/plots\/send_gadget?id=644\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1925\" title=\"download gadget\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/dl-gadget.png\" alt=\"\" width=\"449\" height=\"150\" \/><\/a><\/p>\n<p>Click \u201cDownload Gadget\u201d to download the file. \u00a0Then simply double-click the file which downloads, click &#8220;install&#8221; and enjoy the plot as it updates itself live on your desktop.<\/p>\n<p>Please speak up if you&#8217;ve found the enhancements helpful. \u00a0We&#8217;re always eager to learn more about how we can develop products to best help you.<\/p>\n<p>Thanks,<br \/>\nBob<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Trendy\u00a0is 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&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2012\/12\/17\/trendy-now-gets-data-hourly-desktop-gadgets-more\/\">read more >><\/a><\/p>\n","protected":false},"author":80,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[51,8,36,45],"tags":[199,246,233,243,234,214],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/1902"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/80"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=1902"}],"version-history":[{"count":43,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/1902\/revisions"}],"predecessor-version":[{"id":1943,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/1902\/revisions\/1943"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=1902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=1902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=1902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}