-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetting&plotting.py
executable file
·27 lines (23 loc) · 1005 Bytes
/
getting&plotting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import pandas as pd
import plotly as py
from plotly import subplots
import plotly.graph_objs as go
df = pd.read_csv('data-source/EURUSD_Candlestick_1_Hour_BID_01.01.2019-17.07.2021.csv')
df.columns = ['date', 'open', 'high', 'low', 'close', 'volume']
df.date = pd.to_datetime(df.date,format='%d.%m.%Y %H:%M:%S.%f')
df = df.set_index(df.date)
df = df[['open','high','low','close','volume']]
df = df.drop_duplicates(keep=False)
#print(df.head())
#ma = df.close.rolling(center=False,window=30).std()
ma = df.close.rolling(center=False,window=30).mean()
#trace is just like a set of data for plotting
trace0 = go.Ohlc(x=df.index,open=df.open,high=df.high,low=df.low,close=df.close,name='Currency Qoute')
trace1 = go.Scatter(x=df.index,y=ma)
trace2 = go.Bar(x=df.index,y=df.volume)
data=[trace0,trace1,trace2]
fig = subplots.make_subplots(rows=2,cols=1,shared_xaxes=True)
fig.append_trace(trace0,1,1)
fig.append_trace(trace1,1,1)
fig.append_trace(trace2,2,1)
py.offline.plot(fig,filename='EURUSD_fig.html')