MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: financial chart with volumes (CORRECTION)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88206] Re: [mg88179] financial chart with volumes (CORRECTION)
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Mon, 28 Apr 2008 04:39:35 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

My first response cut off the bottom of the volume lines rather than compressing the lines. Only change is calculation of adjustedVolume.

ClearAll[financialChart];

financialChart[company_String, startDate_List] :=
  
  financialChart[company, startDate, Take[DateList[], 3]];

financialChart[company_String, startDate_List, endDate_List] :=
  
  Module[
   {dateForm, high, highest, closing, low, lowest,
    volume, maxVolume, minVolume, adjustedVolume},
   
   dateForm = {"MonthShort", "/", "DayShort", "/", "Year"};
   high = FinancialData[company, "High", {startDate, endDate}];
   highest = Max[high[[All, 2]]];
   closing = FinancialData[company, {startDate, endDate}];
   low = FinancialData[company, "Low", {startDate, endDate}];
   lowest = Min[low[[All, 2]]];
   volume = FinancialData[company, "Volume", {startDate, endDate}];
   maxVolume = Max[volume[[All, 2]]];
   minVolume = Min[volume[[All, 2]]];
   adjustedVolume = {#[[1]], ((3*lowest - highest) +
          (highest - lowest) #[[2]]/
            maxVolume)/2} & /@ volume;
   
   DateListPlot[{high, closing, low, adjustedVolume},
    Filling -> {1 -> {{3}, Red},
      4 -> {(3*lowest - highest)/2, {{Thick, Darker[Green, .6]}}}},
    GridLines -> Automatic,
    PlotMarkers -> {"", Style["-", {Bold, Black}], "", ""},
    FrameLabel -> {None, "Price in Dollars ($)"},
    PlotLabel -> 
     FinancialData[company, "StandardName"] <> " (" <>
      
      FinancialData[company, "Symbol"] <> 
      ") Common Stock, " <>
      DateString[startDate, dateForm] <> 
      " - " <>
      DateString[endDate, dateForm],
    ImageSize -> 500]];

financialChart["LLL", DatePlus[-90]]


Bob Hanlon

---- Bob Hanlon <hanlonr at cox.net> wrote: 
> With version 6, this is similar:
> 
> financialChart[company_String, startDate_List] :=
>   
>   financialChart[company, startDate, Take[DateList[], 3]];
> 
> financialChart[company_String, startDate_List, endDate_List] :=
>   
>   Module[
>    {dateForm, high, highest, closing, low, lowest,
>     volume, maxVolume, minVolume, adjustedVolume},
>    dateForm = {"MonthShort", "/", "DayShort", "/", "Year"};
> 
>    high = FinancialData[company, "High", {startDate, endDate}];
>    highest = Max[high[[All, 2]]];
>    closing = FinancialData[company, {startDate, endDate}];
>    low = FinancialData[company, "Low", {startDate, endDate}];
>    lowest = Min[low[[All, 2]]];
>    volume = FinancialData[company, "Volume", {startDate, endDate}];
>    maxVolume = Max[volume[[All, 2]]];
>    minVolume = Min[volume[[All, 2]]];
>    adjustedVolume = {#[[1]], ((3*lowest - highest) +
>           (highest - lowest) (#[[2]] - minVolume)/
>             (maxVolume - minVolume))/2} & /@ volume;
> 
>    DateListPlot[{high, closing, low, adjustedVolume},
>     Filling -> {1 -> {{3}, Red},
>       4 -> {(3*lowest - highest)/2, {{Thick, Darker[Green, .6]}}}},
>     GridLines -> Automatic,
>     PlotMarkers -> {"", Style["-", {Bold, Black}], "", ""},
>     FrameLabel -> {None, "Price in Dollars ($)"},
>     PlotLabel -> 
>      FinancialData[company, "StandardName"] <> " (" <>
>       
>       FinancialData[company, "Symbol"] <> 
>       ") Common Stock, " <>
>       DateString[startDate, dateForm] <> 
>       " - " <>
>       DateString[endDate, dateForm],
>     ImageSize -> 500]];
> 
> financialChart["LLL", DatePlus[-90]]
> 
> 
> Bob Hanlon
> 
> ---- tomtim20 <tomtim20 at gmail.com> wrote: 
> > are there examples to plot such chart ?
> > http://www.wolfram.com/solutions/finance/images/fibonarcs.gif
> > 
> > (the picture is from here: http://www.wolfram.com/solutions/finance/features.html
> > )
> > 



  • Prev by Date: AnyOne Knows how to???
  • Next by Date: Re: Re: Re: Print[Plot] vs Print[text,Plot]? (*now Do and Table*)
  • Previous by thread: AnyOne Knows how to???
  • Next by thread: Question about OneIdentity