0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

超初心者がPythonでHistData.comから取得したローソク足データをグラフで表示してみた

Last updated at Posted at 2021-07-18

参考

↓で取得したデータを利用します。

コード

draw_candlestick_chart.py
import pandas as pd
import datetime
 
import mplfinance as mpf

#masta = pd.read_csv('./temp_historical_data/USDJPY.csv')
# とりあえず100行だけ表示してみる
df = pd.read_csv('./temp_historical_data/USDJPY.csv', nrows=100)
df.columns = ["Date", "Open", "High", "Low", "Close", "Volume"]
df["Date"] = pd.to_datetime(df["Date"])
df.set_index("Date", inplace=True)

mpf.plot(df,type='candle', datetime_format='%Y/%m/%d %H:%M', xrotation=90, style="yahoo", savefig=dict(fname='test.png',dpi=100))

できあがったグラフ

test.png

ちょっと説明

ネットでしらべるとmatplotlib.financeやmpl_financeを利用した例が多いが、どちらもdeprecatedなので、利用したのはmplfinance。

参考にも挙げたここがとてもよくまとまっていた。

見やすいグラフ化のパターンなんかは作っておかないと肝心な時に困りそう。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?