MathGroup Archive 2011

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

Search the Archive

Re: FinancialData still broken

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120671] Re: FinancialData still broken
  • From: Dana DeLouis <dana.del at gmail.com>
  • Date: Wed, 3 Aug 2011 07:06:40 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

...As you see, FinancialData says the price was 10.23.
...But I BOUGHT the stock through Janus Funds on that day, (10 Feb)
...and the price was 10.36.

Don't know if this is of interest.
Following Chris's example, this extracts data from the Historical Chart section at Yahoo Finance.
There's probably a better way to write this.
Here's the data on JANFX from 9-11 Feb, 2011

Historical["JANFX","9 Feb 2011","11 Feb 2011"]
	Month	Day	Year	Open	High	Low	Close	Volume	Adj Close
1	Feb	11	2011	10.37	10.37	10.37	10.37	0	10.24
2	Feb	10	2011	10.36	10.36	10.36	10.36	0	10.23
3	Feb	9	2011	10.38	10.38	10.38	10.38	0	10.25


Historical["JANFX", "1 Jun 2011", "31 Jul 2011"]

<... Shows dividend on 30 June >

One can change the ending character from d (daily) to w (for weekly), etc.

Historical[sym_, start_, end_] := Module[
  {k, lnk, s, z, nl, hd, tbl},
  k = "http://finance.yahoo.com/q/hp?s=#&a=#&b=#&c=#&d=#&e=#&f=#&g=d=94;
 
  lnk = StringReplace[k, "#" -> sym, 1];
 
  (* Note:  Chart Month is zero based *)
  s = DateList[start][[;; 3]];
  lnk = StringReplace[lnk, "#" -> ToString[s[[2]] - 1], 1];
  lnk = StringReplace[lnk, "#" -> ToString[s[[3]]], 1];
  lnk = StringReplace[lnk, "#" -> ToString[s[[1]]], 1];
 
  s = DateList[end][[;; 3]];
  lnk = StringReplace[lnk, "#" -> ToString[s[[2]] - 1], 1];
  lnk = StringReplace[lnk, "#" -> ToString[s[[3]]], 1];
  lnk = StringReplace[lnk, "#" -> ToString[s[[1]]], 1];
 
  z = Import[lnk];
  nl = StringPosition[z, "\n"][[All, 1]];
 
  (* Extract Heading *)
 
  hd = StringTake[z, {sp[[13]] + 1, sp[[14]] - 2}];
  hd = Append[StringSplit[hd, " "][[;; -3]], "Adj Close"];
  hd = Join[{"Month", "Day", "Year"}, Rest[hd]];
 
  (* Remove text from beginning and end *)
 
  tbl = StringTake[z, {nl[[14]] + 1, nl[[-12]] - 1}];
  tbl = StringReplace[tbl, "," -> ""];
  tbl = StringSplit[tbl, "\n"];
  tbl = Map[StringSplit, tbl];
  TableForm[tbl, TableHeadings -> {Automatic, hd}]
 
  ]

= = = = = = = = = = = =
HTH  :>)
Dana DeLouis
$Version
8.0 for Mac OS X x86 (64-bit) (November 6, 2010)




On Jul 21, 5:47 am, DrMajorBob <btre... at austin.rr.com> wrote:
> Erroneous prices are randomly returned:
>
> FinancialData /@ {"ACEIX", "FCNTX", "JACNX", "JANFX", "JANWX",
>    "JMSCX", "JNGIX", "JNGLX", "JNMCX", "JNOSX", "JNSGX", "JNSTX",
>    "PTTAX", "RGACX", "STRFX"}
>
> {8.81, 72.4, 14., 10.64, 46.49, 12.48,
>   5.03202*10^8, 26.48, 23.72, 45.35, 12.48,
>   5.03241*10^8, 11.04, 31.44, 32.47}
>
> FinancialData /@ {"ACEIX", "FCNTX", "JACNX", "JANFX", "JANWX",
>    "JMSCX", "JNGIX", "JNGLX", "JNMCX", "JNOSX", "JNSGX", "JNSTX",
>    "PTTAX", "RGACX", "STRFX"}
>
> {5.03241*10^8, 72.4, 14., 10.64, 5.03241*10^8,
>   5.03168*10^8, 32.61, 26.48, 23.72, 5.03168*10^8,
>   5.03168*10^8, 3.1, 11.04, 5.03241*10^8, 32.47}
>
> Bobby
>
> --
> DrMajor... at yahoo.com






  • Prev by Date: Re: Integrating Interpolating function
  • Next by Date: Re: Poincare section for double pendulum
  • Previous by thread: Re: RegionGrowing function
  • Next by thread: Re: FinancialData still broken