Created
September 24, 2014 16:14
-
-
Save mzmttks/2bb6e525eac322aceafe to your computer and use it in GitHub Desktop.
pandas で日経平均株価指数を plot する ref: http://qiita.com/mzmttks/items/214ab3ffb6e3d1c05fcb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas.io.data as web | |
import matplotlib.pyplot as plt | |
import datetime | |
# 取得する日の範囲を指定する | |
start = datetime.datetime(2014, 1, 1) | |
end = datetime.datetime(2014, 9, 1) | |
# Yahoo ファイナンスから、 ^N225 (日経平均株価指数) を | |
# とってくる。 | |
f = web.DataReader('^N225', 'yahoo', start, end) | |
plt.title('Nikkei 255 from 2014.1.1 to 2014.9.1') | |
# fill_between でその日の最高値と最低値をプロットする | |
plt.fill_between(f.index, f['Low'], f['High'], color="b", alpha=0.2) | |
# plot で、始値をプロットする。 | |
# 自動的に Index が Date になっているので、横軸が時間になる。 | |
f['Open'].plot() | |
print f[:10] | |
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Open High Low Close Volume Adj Close | |
Date | |
2014-01-06 16147.54 16164.01 15864.44 15908.88 192700 15908.88 | |
2014-01-07 15835.41 15935.37 15784.25 15814.37 165900 15814.37 | |
2014-01-08 15943.68 16121.45 15906.57 16121.45 206700 16121.45 | |
2014-01-09 16002.88 16004.56 15838.44 15880.33 217400 15880.33 | |
2014-01-10 15785.15 15922.14 15754.70 15912.06 237500 15912.06 | |
2014-01-13 15912.06 15912.06 15912.06 15912.06 0 15912.06 | |
2014-01-14 15657.20 15661.71 15383.69 15422.40 214500 15422.40 | |
2014-01-15 15649.07 15808.73 15636.57 15808.73 185800 15808.73 | |
2014-01-16 15845.15 15941.08 15710.14 15747.20 214200 15747.20 | |
2014-01-17 15695.46 15783.37 15621.80 15734.46 180100 15734.46 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment