<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Získání EOD (end of day) dat
Info o verzi a notebooku
Step1:  Informace o použitých python modulech
Step2:  Seznam zdrojů
Step3:  Import dat pomocí Quandlu
Jedna z nejkvalitnějších volně dostupných databází pro futures je CHRIS-Wiki. A pro volně dostupné data jednotlivých akcií pak Wiki databáze. Obě databáze jsou spravované Quandl komunitou.
Bohužel služba Quandl zrušila databáze Yahoo finance a Google finance. Info o databázích google finance a yahoo na https
Step4:  Vše kolem S&P 500, 400, 100
E-mini S&P 500 Futures, Continuous Contract #1 (ES1) (Front Month) (Quandl wiki)
E-mini S&P MidCap 400 Futures, Continuous Contract #1 (MD1) (Front Month) (Quandl wiki)
SPDR S&P 500 ETF (SPY) (google finance)
iShares Core S&P Mid-Cap ETF (IJH) (google finance)
SPDR S&P MIDCAP 400 ETF (MDY) (google finance)
iShares S&P 100 ETF (OEF) (google finance)
Step5:  Dow Jones 30
E-mini Dow Futures, Continuous Contract #1 (YM1) (Front Month) (Quandl wiki)
SPDR Dow Jones Industrial Average ETF (DIA) (google finance)
Step6:  NASDAQ 100
E-mini NASDAQ 100 Futures, Continuous Contract #1 (NQ1) (Front Month) (quandl/wiki)
PowerShares QQQ Trust ETF (QQQ) (google finance)
Step7:  Crude Oil (Ropa)
ETF United States Oil Fund (USO) (google finance)
Step8:  Gold
SPDR Gold Trust ETF (GLD) (google finance)
Step9:  EOD jednotlivých amerických akcií
WIKI Prices (Qandl WIKI table)
<ASSISTANT_TASK:>
Python Code:
import datetime
MY_VERSION = 1,0
print('Verze notebooku:', '.'.join(map(str, MY_VERSION)))
print('Poslední aktualizace:', datetime.datetime.now())
Explanation: Získání EOD (end of day) dat
Info o verzi a notebooku
End of explanation
import sys
import datetime
import pandas as pd
import pandas_datareader as pdr
import quandl as ql
# Load Quandl API key
import json
with open('quandl_key.json','r') as f:
    quandl_api_key = json.load(f)
ql.ApiConfig.api_key = quandl_api_key['API-key']
print('Verze pythonu:')
print(sys.version)
print('---')
print('Pandas:', pd.__version__)
print('pandas-datareader:', pdr.__version__)
print('Quandl version:', ql.version.VERSION)
Explanation: Informace o použitých python modulech
End of explanation
#import pandas_datareader as pdr
import pandas_datareader.data as pdr_web
import datetime 
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
sp500 = pdr.get_data_yahoo('^GSPC', 
                          start=start_date, 
                          end=end_date)
sp500
import pandas_datareader.data as pdr_web
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
QQQ = pdr_web.DataReader("NASDAQ:QQQ", 'google', start=start_date, end=end_date)
QQQ.head()
Explanation: Seznam zdrojů:
Pandas - manipulace a analýza dat
pandas-datareader
Seznam všech webových zdrojů v pandas-datareader
Python For Finance: Algorithmic Trading
Quandl
ETF trhy - finančník
Import volně dostupných dat pomocí pandas-datareader
Služby jako Google finance, Yahoo! Finance, World Bank, a další poskytují data a informace o finančních trzích. Package pandas-datareader umožňuje velmi jednoduše získat data z těchto zdrojů. Seznam všech zdrojů je možné nalézt v dokumentaci.
<font color='red'>Bohužel momentálně nefunguje v pandas-datareader verze 0.4.0 yahoo finance</font>. Nedávno yahoo změnilo api a ještě není zapracováno do pandas-datareaderu, info tady https://github.com/pydata/pandas-datareader/issues/354.
End of explanation
import datetime
import quandl as ql
# Load Quandl API key
import json
with open('quandl_key.json','r') as f:
    quandl_api_key = json.load(f)
ql.ApiConfig.api_key = quandl_api_key['API-key']
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
ES = ql.get("CHRIS/CME_ES1", start_date=start_date, end_date=end_date)
ES.head()
Explanation: Import dat pomocí Quandlu
Jedna z nejkvalitnějších volně dostupných databází pro futures je CHRIS-Wiki. A pro volně dostupné data jednotlivých akcií pak Wiki databáze. Obě databáze jsou spravované Quandl komunitou.
Bohužel služba Quandl zrušila databáze Yahoo finance a Google finance. Info o databázích google finance a yahoo na https://www.quantopian.com/posts/quandl-dropping-goog-and-yahoo-databases.
End of explanation
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
ES = ql.get("CHRIS/CME_ES1", start_date=start_date, end_date=end_date)
ES.head()
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
SPY = pdr_web.DataReader("NYSEARCA:SPY", 'google', start=start_date, end=end_date)
SPY.head()
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
IJH = pdr_web.DataReader("NYSEARCA:IJH", 'google', start=start_date, end=end_date)
IJH.head()
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
MDY = pdr_web.DataReader("NYSEARCA:MDY", 'google', start=start_date, end=end_date)
MDY.head()
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
OEF = pdr_web.DataReader("NYSEARCA:OEF", 'google', start=start_date, end=end_date)
OEF.head()
Explanation: Vše kolem S&P 500, 400, 100
E-mini S&P 500 Futures, Continuous Contract #1 (ES1) (Front Month) (Quandl wiki)
E-mini S&P MidCap 400 Futures, Continuous Contract #1 (MD1) (Front Month) (Quandl wiki)
SPDR S&P 500 ETF (SPY) (google finance)
iShares Core S&P Mid-Cap ETF (IJH) (google finance)
SPDR S&P MIDCAP 400 ETF (MDY) (google finance)
iShares S&P 100 ETF (OEF) (google finance)
End of explanation
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
YM = ql.get("CHRIS/CME_YM1", start_date=start_date, end_date=end_date)
YM.head()
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
DIA = pdr_web.DataReader("NYSEARCA:DIA", 'google', start=start_date, end=end_date)
DIA.head()
Explanation: Dow Jones 30
E-mini Dow Futures, Continuous Contract #1 (YM1) (Front Month) (Quandl wiki)
SPDR Dow Jones Industrial Average ETF (DIA) (google finance)
End of explanation
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
NQ = ql.get("CHRIS/CME_NQ1", start_date=start_date, end_date=end_date)
NQ.head()
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
QQQ = pdr_web.DataReader("NASDAQ:QQQ", 'google', start=start_date, end=end_date)
QQQ.head()
Explanation: NASDAQ 100
E-mini NASDAQ 100 Futures, Continuous Contract #1 (NQ1) (Front Month) (quandl/wiki)
PowerShares QQQ Trust ETF (QQQ) (google finance)
End of explanation
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
USO = pdr_web.DataReader("NYSEARCA:USO", 'google', start=start_date, end=end_date)
USO.head()
Explanation: Crude Oil (Ropa)
ETF United States Oil Fund (USO) (google finance)
End of explanation
start_date = datetime.datetime(2015, 1, 1)
end_date = datetime.datetime.now()
GLD = pdr_web.DataReader("NYSEARCA:GLD", 'google', start=start_date, end=end_date)
GLD.head()
Explanation: Gold
SPDR Gold Trust ETF (GLD) (google finance)
End of explanation
tickers = ['AAPL', 'GOOG']
#EODdata = ql.get_table('WIKI/PRICES', ticker=['AAPL'], paginate=True)
EODdata = ql.get_table('WIKI/PRICES', ticker=tickers, qopts = { 'columns': ['ticker', 'date', 'open', 'high', 'low', 'close', 'volume'] }, paginate=True)
EODdata
Explanation: EOD jednotlivých amerických akcií
WIKI Prices (Qandl WIKI table)
End of explanation
<END_TASK>