Mathematica绘制美元对人民币走势图

startdate = "12/31/1980";
enddate = DateString[{"Month", "/", "Day", "/", "Year"}];

[email protected][
series=356f2a973bbb516442c693dc19615b69&lastObs=&from=", startdate,
"&to=", enddate,
"&filetype=csv&label=include&layout=seriescolumn"];
datelistfx = Cases[fxdata, {_, _?NumberQ}];
datelistfx[[All, 1]] =
Join[[email protected][#, "-"], {0, 0, 0.}] & /@
datelistfx[[All, 1]];

DateListPlot[datelistfx, Joined -> True,
PlotLabel ->
StringJoin["Daily CNY/USD from ",
DateString[datelistfx[[1, 1]], {"Day", "/", "Month", "/", "Year"}],
" to ",
DateString[
datelistfx[[-1, 1]], {"Day", "/", "Month", "/", "Year"}]]]


一个完整的例子

startdate="2015-01-10";
enddate="2015-01-12";
name="1336";
$initialUrl="http://srh.bankofchina.com/search/whpj/searchen.jsp";$dom=Import[$initialUrl,"XMLObject"]; (*$forms=Cases[$dom,XMLElement["form",___],Infinity]; [email protected]$forms*)
(*Cases[$forms,XMLElement[_,attrs_,_]\[RuleDelayed]attrs]*) (*Cases[$forms[[1]],XMLElement["input",___],Infinity]//Column*)
(*$parameters={"erectDate"\[Rule]startdate,"nothing"\[Rule]enddate,"pjname"\[Rule]name}; header=Import[$initialUrl,"Data"
,"RequestMethod"\[Rule]"POST"
,"RequestParameters"\[Rule]$parameters][[2,1]]//TableForm;$parameters={"erectDate"\[Rule]startdate,"nothing"\[Rule]enddate,"pjname"\[Rule]name,"page"\[Rule]ToString[1]};
$results=Import[$initialUrl,"Data"
,"RequestMethod"\[Rule]"POST"
,"RequestParameters"\[Rule]$parameters][[2,2;;]];$results//ColumnForm;
DateListPlot[TimeSeries[$results[[;;,2]]/100,{$results[[;;,7]]}]];

Export["boc"<>startdate<>"_"<>enddate<>"_"<>Block[{$DateStringFormat={"Year","-","Month","-","Day","-","Hour","-","Minute"}}, DateString[]]<>".xls",$results,"xls"]*)

For[i=0;res={},i< =45,i++;
{$parameters={"erectDate"->startdate,"nothing"->enddate,"pjname"->name,"page"->ToString[i]};$results=Import[$initialUrl,"Data" ,"RequestMethod"->"POST" ,"RequestParameters"->$parameters][[2,2;;]];
res=res~Join~$results}]; res//Length Export["boc"<>startdate<>"_"<>enddate<>"_"<>Block[{$DateStringFormat={"Year","-","Month","-","Day","-","Hour","-","Minute"}},
DateString[]]<>".xls",res,"xls"]
timeseq=res[[;;,7]];
DateListPlot[ts,Filling->Axis]
DateListPlot[ts,Joined->True,Filling->Bottom,ImageSize->350]
(*startdate="12/31/1980";
enddate=DateString[{"Month","/","Day","/","Year"}];*)