-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarket.py
32 lines (28 loc) · 925 Bytes
/
market.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
28
29
30
31
32
from MetaTrader5 import *
from datetime import datetime
import pandas as pd
# Initializing MT5 connection
#MT5Initialize()
#MT5WaitForTerminal()
#
#print(MT5TerminalInfo())
#print(MT5Version())
# Copying data to pandas data frame
stockdata = pd.DataFrame()
rates = MT5CopyRatesFromPos("EURUSD", MT5_TIMEFRAME_M1, 0, 5000)
# Deinitializing MT5 connection
MT5Shutdown()
stockdata['Open'] = [y.open for y in rates]
stockdata['Close'] = [y.close for y in rates]
stockdata['High'] = [y.high for y in rates]
stockdata['Low'] = [y.low for y in rates]
stockdata['Date'] = [y.time for y in rates]
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
trace = go.Ohlc(x=stockdata['Date'],
open=stockdata['Open'],
high=stockdata['High'],
low=stockdata['Low'],
close=stockdata['Close'])
data = [trace]
plot(data)