-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathforex_getdata.py
46 lines (30 loc) · 1.14 KB
/
forex_getdata.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import yfinance as yf
import investpy
def get_data(pair = 'EURUSD=X',timeframe = '60m',period = '1d'):
"""
period: 1d,5d,1mo,3mo,6mo,1y,2y,5y,10y,ytd,max
valid intervals: 1m,2m,5m,15m,30m,60m,90m,1h,1d,5d,1wk,1mo,3mo
"""
print(pair+" is analysing")
data = yf.download(tickers=pair,period=period,interval=timeframe)
data.index.names=['Date']
return data
# from alpha_vantage.timeseries import TimeSeries
# import pandas as pd
# def get_data(pair = 'EURUSD',timeframe = '60min',outputsize = 'compact'):
# """
# timeframe = '1min', '5min', '15min', '30min', '60min',
# outputsize = 'compact , 'full'
# """
# ts = TimeSeries(key='JQCOBLCVEU9ID060',output_format='pandas',indexing_type='date')
# data = ts.get_intraday(symbol = pair,interval=timeframe,outputsize=outputsize)
# d = list(data)
# # d = pd.DataFrame(data)
# # print(data)
# df = pd.DataFrame()
# df['Open'] = d[0]['1. open']
# df['High'] = d[0]['2. high']
# df['Low'] = d[0]['3. low']
# df['Close'] = d[0]['4. close']
# df = df.iloc[::-1]
# return df