{"id":4453,"date":"2015-01-09T17:03:04","date_gmt":"2015-01-09T09:03:04","guid":{"rendered":"https:\/\/lttt.blog.ustc.edu.cn\/?p=4453"},"modified":"2015-01-09T17:03:04","modified_gmt":"2015-01-09T09:03:04","slug":"mathematica%e7%bb%98%e5%88%b6%e7%be%8e%e5%85%83%e5%af%b9%e4%ba%ba%e6%b0%91%e5%b8%81%e8%b5%b0%e5%8a%bf%e5%9b%be","status":"publish","type":"post","link":"https:\/\/lttt.vanabel.cn\/?p=4453","title":{"rendered":"Mathematica\u7ed8\u5236\u7f8e\u5143\u5bf9\u4eba\u6c11\u5e01\u8d70\u52bf\u56fe"},"content":{"rendered":"<pre lang=\"mma\">\nstartdate = \"12\/31\/1980\";\nenddate = DateString[{\"Month\", \"\/\", \"Day\", \"\/\", \"Year\"}];\n\nfxdownload = \n  Import@StringJoin[\n    \"http:\/\/www.federalreserve.gov\/datadownload\/Output.aspx?rel=H10&\\\nseries=356f2a973bbb516442c693dc19615b69&lastObs=&from=\", startdate, \n    \"&to=\", enddate, \n    \"&filetype=csv&label=include&layout=seriescolumn\"];\nfxdata = Drop[fxdownload, 6];\ndatelistfx = Cases[fxdata, {_, _?NumberQ}];\ndatelistfx[[All, 1]] = \n  Join[ToExpression@StringSplit[#, \"-\"], {0, 0, 0.}] & \/@ \n   datelistfx[[All, 1]];\n\nDateListPlot[datelistfx, Joined -> True, \n PlotLabel -> \n  StringJoin[\"Daily CNY\/USD from \", \n   DateString[datelistfx[[1, 1]], {\"Day\", \"\/\", \"Month\", \"\/\", \"Year\"}],\n    \" to \", \n   DateString[\n    datelistfx[[-1, 1]], {\"Day\", \"\/\", \"Month\", \"\/\", \"Year\"}]]]\n<\/pre>\n<p><!--more--><\/p>\n<p>\u53c2\u8003:<a href=\"http:\/\/mathematica.stackexchange.com\/a\/46841\">http:\/\/mathematica.stackexchange.com\/a\/46841<\/a>.<\/p>\n<p><script type=\"text\/javascript\" src=\"https:\/\/www.wolfram.com\/cdf-player\/plugin\/v2.1\/cdfplugin.js\"><\/script><br \/>\n<script type=\"text\/javascript\">\nvar cdf = new cdfplugin();\ncdf.setDefaultContent('<a href=\"https:\/\/www.wolfram.com\/cdf-player\/\"><img decoding=\"async\" src=\"https:\/\/lttt.vanabel.cn\/wp-content\/uploads\/2015\/01\/cny2usd-e1420864720541.png\"\/><\/a>');\ncdf.embed('https:\/\/lttt.blog.ustc.edu.cn\/wp-content\/uploads\/2015\/01\/cny2usd.cdf', 1215, 805);\n<\/script><\/p>\n<h3>\u4e00\u4e2a\u5b8c\u6574\u7684\u4f8b\u5b50<\/h3>\n<pre>\nstartdate=\"2015-01-10\";\nenddate=\"2015-01-12\";\nname=\"1336\";\n$initialUrl=\"http:\/\/srh.bankofchina.com\/search\/whpj\/searchen.jsp\";\n$dom=Import[$initialUrl,\"XMLObject\"];\n(*$forms=Cases[$dom,XMLElement[\"form\",___],Infinity];\nLength@$forms*)\n(*Cases[$forms,XMLElement[_,attrs_,_]\\[RuleDelayed]attrs]*)\n(*Cases[$forms[[1]],XMLElement[\"input\",___],Infinity]\/\/Column*)\n(*$parameters={\"erectDate\"\\[Rule]startdate,\"nothing\"\\[Rule]enddate,\"pjname\"\\[Rule]name};\nheader=Import[$initialUrl,\"Data\"\n,\"RequestMethod\"\\[Rule]\"POST\"\n,\"RequestParameters\"\\[Rule]$parameters][[2,1]]\/\/TableForm;\n$parameters={\"erectDate\"\\[Rule]startdate,\"nothing\"\\[Rule]enddate,\"pjname\"\\[Rule]name,\"page\"\\[Rule]ToString[1]};\n$results=Import[$initialUrl,\"Data\"\n,\"RequestMethod\"\\[Rule]\"POST\"\n,\"RequestParameters\"\\[Rule]$parameters][[2,2;;]];\n$results\/\/ColumnForm;\nDateListPlot[TimeSeries[$results[[;;,2]]\/100,{$results[[;;,7]]}]];\n\nExport[\"boc\"<>startdate<>\"_\"<>enddate<>\"_\"<>Block[{$DateStringFormat={\"Year\",\"-\",\"Month\",\"-\",\"Day\",\"-\",\"Hour\",\"-\",\"Minute\"}},\nDateString[]]<>\".xls\",$results,\"xls\"]*)\n\nFor[i=0;res={},i< =45,i++;\n{$parameters={\"erectDate\"->startdate,\"nothing\"->enddate,\"pjname\"->name,\"page\"->ToString[i]};\n$results=Import[$initialUrl,\"Data\"\n,\"RequestMethod\"->\"POST\"\n,\"RequestParameters\"->$parameters][[2,2;;]];\nres=res~Join~$results}];\nres\/\/Length\nExport[\"boc\"<>startdate<>\"_\"<>enddate<>\"_\"<>Block[{$DateStringFormat={\"Year\",\"-\",\"Month\",\"-\",\"Day\",\"-\",\"Hour\",\"-\",\"Minute\"}},\nDateString[]]<>\".xls\",res,\"xls\"]\nbuyingrate=res[[;;,2]]\/100;\ntimeseq=res[[;;,7]];\nts=TimeSeries[buyingrate,{timeseq}]\nDateListPlot[ts,Filling->Axis]\nDateListPlot[ts,Joined->True,Filling->Bottom,ImageSize->350]\n(*startdate=\"12\/31\/1980\";\nenddate=DateString[{\"Month\",\"\/\",\"Day\",\"\/\",\"Year\"}];*)\n\nfxdownload=Import@StringJoin[\"http:\/\/www.federalreserve.gov\/datadownload\/Output.aspx?rel=H10&series=356f2a973bbb516442c693dc19615b69&lastObs=&from=\",startdate,\"&to=\",enddate,\"&filetype=csv&label=include&layout=seriescolumn\"];\nfxdata=Drop[fxdownload,6];\ndatelistfx=Cases[fxdata,{_,_?NumberQ}];\ndatelistfx[[All,1]]=Join[ToExpression@StringSplit[#,\"-\"],{0,0,0.}]&\/@datelistfx[[All,1]];\n\nDateListPlot[datelistfx,Joined->True,PlotLabel->StringJoin[\"Daily CNY\/USD from \",DateString[datelistfx[[1,1]],{\"Day\",\"\/\",\"Month\",\"\/\",\"Year\"}],\" to \",DateString[datelistfx[[-1,1]],{\"Day\",\"\/\",\"Month\",\"\/\",\"Year\"}]]]\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>startdate = &#8220;12\/31\/1980&#8221;; enddate = Date &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/lttt.vanabel.cn\/?p=4453\"> <span class=\"screen-reader-text\">Mathematica\u7ed8\u5236\u7f8e\u5143\u5bf9\u4eba\u6c11\u5e01\u8d70\u52bf\u56fe<\/span> \u9605\u8bfb\u66f4\u591a &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[560,152,740,328],"class_list":["post-4453","post","type-post","status-publish","format-standard","hentry","category-net","tag-mma","tag-152","tag-740","tag-328"],"_links":{"self":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts\/4453","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4453"}],"version-history":[{"count":0,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts\/4453\/revisions"}],"wp:attachment":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4453"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4453"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4453"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}