Stock tracking
- To: mathgroup at smc.vnet.net
- Subject: [mg107772] Stock tracking
- From: Chris Degnen <degnen at cwgsy.net>
- Date: Thu, 25 Feb 2010 17:36:36 -0500 (EST)
Similar to examples I've posted earlier. This one plots oil and gold securities. Some lines, probably the URLs, may break in the post and could need rejoining. (* Import crude oil security: tracks 1 month futures *) rawCrud = Import["http://www.etfsecurities.com/en/aum/ Historical_NAV_Outstanding_AUM.zip", "*"]; crudPosition = Position[rawCrud[[1, 1, 3]], "CRUD"][[1, 1]]; crudDates = Drop[rawCrud[[1, 1, All, 1]], 3]; crud = Drop[rawCrud[[1, 1, All, crudPosition]], 3]; crudT = Transpose[{crudDates, crud}]; Export["crud.mx", crudT]; (* Import gold bullion security *) gbss = Import[ "http://www.exchangetradedgold.com/assets/dynamic/ETG/ GBS_UK_GBP_archive.csv"]; gbssData = Drop[gbss, 5]; gbssDates = gbssData[[All, 1]]; gbssPrice = gbssData[[All, 3]]; gbssPlot = Cases[Transpose[{gbssDates, gbssPrice}], {_, _?NumericQ}]; Export["gbss.mx", gbssPlot]; (* Optionally, import saved values *) crudT = Import["crud.mx"]; gbssPlot = Import["gbss.mx"]; (* Plotting *) gbssGBP = {#[[1]], #[[2]]/100} & /@ gbssPlot; DateListPlot[{crudT, gbssGBP}, Joined -> True, PlotLabel -> Style["\nGold Bullion and Crude Oil Futures", Large], FrameLabel -> {{Style["=A3", Hue[106/117, 0.6, 0.6], Large], Style["$", Hue[0.67, 0.6, 0.6], Large]}, {Null, Null}}, RotateLabel -> False, ImageSize -> 450, PlotRange -> {Automatic, {0, 100}}, Epilog -> {Inset[Style["GBSS:LSE", 12, Bold, Hue[106/117, 0.6, 0.6]], Automatic, {-4.5, -6}], Inset[Style["CRUD:LSE", 12, Bold, Hue[0.67, 0.6, 0.6]], Automatic, {-4.5, 7}]}]