Forex data on this site Display candlesticks.
Regarding the display, this post is described in more detail. The sample of Site here is displayed as it is.
fig.py
import plotly.graph_objects as go
import pandas as pd
from datetime import datetime
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')
fig = go.Figure(data=[go.Candlestick(x=df['Date'],
open=df['AAPL.Open'],
high=df['AAPL.High'],
low=df['AAPL.Low'],
close=df['AAPL.Close'])])
fig.show()
It was displayed as follows.
Display HISTDATA_COM_ASCII_EURJPY_M1_201911.zip of this site I would like to try. To do this, first convert the contents of the zip file to pd.DataFrame.
import pandas as pd
from zipfile import ZipFile
ascii_minute_names = ["datetime_str", "Open", "High", "Low", "Close", "Volume"]
ascii_minute_datetime_format = "%Y%m%d %H%M%S"
with ZipFile("HISTDATA_COM_ASCII_EURJPY_M1201911.zip", 'r') as z:
with z.open("DAT_ASCII_EURJPY_M1_201911.csv") as f:
df = pd.read_csv(f, names=ascii_minute_names, sep=";")
df["datetime"] = pd.to_datetime(df.datetime_str, format=ascii_minute_datetime_format)
df = df.set_index("datetime")
del df["datetime_str"]
print(df.head())
"""
output:
Open High Low Close Volume
datetime
2019-11-01 00:00:00 120.599 120.601 120.595 120.598 0
2019-11-01 00:01:00 120.597 120.598 120.592 120.595 0
2019-11-01 00:02:00 120.597 120.603 120.597 120.601 0
2019-11-01 00:03:00 120.600 120.600 120.592 120.598 0
2019-11-01 00:04:00 120.597 120.603 120.593 120.597 0
"""
Display! * It takes time to execute because the data is large.
import plotly.graph_objects as go
import pandas as pd
from datetime import datetime
fig = go.Figure(data=[
go.Candlestick(
x=df.index,
open=df.Open,
high=df.High,
low=df.Low,
close=df.Close
)
])
fig.show()
It was displayed as follows.
that's all!
Recommended Posts