The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Finance::YahooJPN::Quote -- Fetch historical Japanese stock quotes on Yahoo! Japan Finance.

SYNOPSIS

  use Finance::YahooJPN::Quote;
  
  # Get the quote of Sony Corp. at the Tokyo stock exchange.
  my @quote = Finance::YahooJPN::Quote->historical('6758.t');
  
  print join("\n", @quote);

DESCRIPTION

Historical quote data is basis for analyzing stock market. Here in Japan, standard quote data is indicated as a set of data: the four prices (open, high, low, close) and the volume of each day. This module provides its user some functions to get historical quote of a company.

METHODS

historical($symbol [, 'start' => $start] [, 'noadjust' => 1])

This class method automatically new() and scan() then output() a historical series of quote of the stock which specified with $symbol argument.

See the descriptions about the following methods for the argument and attributes: $symbol, start and noadjust.

new($symbol)

Constructor class method. A stock $symbol should be given with 4-digit code number and optionaly followed by a letter extension (dot `.' and an alphabet). (i.e. `6758' or `6758.t')

Japanese stock markets use 4-digit code numbers for stock symbols. In addtion to that, an alphabetical letter extention is used for indicating its exchanging place. For example, the stock symbol code of Sony Corp. is '6758' and the letter extention of the Tokyo Stock Exchange is '.t'. Hence, the stock quote of Sony Corp. at Tokyo Stock Exchange is specified as '6758.t'.

According to the Yahoo-Japan-Finance's description http://www.yahoo-help.jp/app/answers/detail/p/546/a_id/45387 the letter extentions of exchanging place are:

 .t: Tokyo   Stock Exchange
 .q: JASDAQ
 .n: Nagoya  Stock Exchange
 .s: Sapporo Stock Exchange
 .f: Fukuoka Stock Exchange

Letter extention is omittable. When it is omit, the default exchange market is chosen by the Yahoo-Japan-Finance's server. It is not certain but I guess that the default one should be the main exchange market of the stock. Note: since almost symbols should work without letter extention, I have experienced certain problems with a few symbols those which have originally `.j' letter extention. This is of course not for the module but owe to the Yahoo-Japan-Finance server's behavior.

There is an exception for above. A few symbols of index are indicated in 5 to 7 digit code numbers. They are '998405' (TOPIX), '998407' (NIKKEI) and '23337' (JASDAQ). http://www.yahoo-help.jp/app/answers/detail/p/546/a_id/45388

set_proxy($proxy [, 'socks_version' => $version]) *EXPERIMENTAL*

Set proxy. $proxy must be given in format like '192.168.0.1:8080' (port is needed).

If the proxy server is other than SOCKS5 (inevitably it is SOCKS4), you must give c<$socks_version> (i.e. 'socks_version' => 4).

Unfortunately, I can offer very limited support for this feature since I don't have proper testing environment for proxy. So this feature is just experimental and I have no plan for upgrading it to non-experimental state in the future. And also, the install package's test suite is only for non-proxy.

scan(['start' => $start])

This object method is for scanning the stock's historical quote pages of Yahoo-Japan-Finance from the $start date to the current date. And for picking up quote data of each day on those pages.

Date of $start must be given in the format `YYYY-MM-DD' (ex. `2003-08-14'). Be careful, don't forget to quote the word, because bare word 2000-01-01 will be comprehend by Perl as '2000 - 1 - 1 = 1998'. This attribute is omittable. The default value of $start is '1990-01-01'.

You cannot specify a date of last day. Because, to find the splits you must scan the quote during whole of the period from the $start day. Without split data, estimation of value adjustment for split cannot be done exactly.

Note that datetime of this module is based on JST (Japan Standard Time: GMT +09:00).

output(['noadjust' => 1])

This object method is for returning the collected quote data in a list.

By noadjust option you can turn on/off the function of value adjustment for splits. If you omit this option or set this value '0', adjustment function is effective (by default). If you set this value other than '0', adjustment function is ineffective.

Output data is formatted in TSV (Tab Separated Values). Each row represents quote of each day in the order with 1)date, 2)open, 3)high, 4)low, 5)close and 6)volume.

NOTES

This mudule calculates adjusted values (including closing prices) by itself. Though Yahoo-Japan-Finance doesn't give only four prices but also adjusted closing prices, those values are not rounded but cut for decimal fractions (not good). For this reason, I have decided to ignore Yahoo-Japan-Finance's pre-adjusted closing prices. That is why some adjusted closing prices are different from Yahoo-Japan-Finance's.

AUTHOR

Masanori HATA http://www.mihr.net/ (Saitama, JAPAN)

COPYRIGHT

Copyright (c) 2001-2014 Masanori HATA. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.