HI:
I use yahoo bundle (only one stock of china stock) , and run backtest, find it's olhc date diff from read direct by datareader !!!
eg.
2017-1-25 bundle data is
price 4.73
open 4.65
high 4.77
low 4.6
close 4.73
volume 58051100
data from datareader is
Open High Low Close Volume Adj Close
Date
2017-01-25 4.39 4.42 4.33 4.35 24978000 4.35
what's wrong with bundle usage ???
---------------------------------------------------------------------------------------------------
from zipline.data.bundles import register, yahoo_equities
# these are the tickers you would like data for
equities = {
'601992.ss',
}
register(
'my-yahoo-equities-bundle', # name this whatever you like
yahoo_equities(equities),
)
------------------------------------------read direct from datareader-------------------------------------------------------
import numpy as np
import pandas_datareader.data as web
from datetime import datetime
start = datetime(2017,1,25)
end = datetime(2017,1,30)
p = web.DataReader('601992.ss','yahoo',start,end)
print(p)
Output
Open High Low Close Volume Adj Close
Date
2017-01-25 4.39 4.42 4.33 4.35 24978000 4.35
2017-01-26 4.37 4.37 4.31 4.33 13096600 4.33
2017-01-27 4.33 4.33 4.33 4.33 0 4.33
2017-01-30 4.33 4.33 4.33 4.33 0 4.33
-------------------------------------run backtest------------------------------------------------------------
from zipline.api import (
symbol,
)
def initialize(context):
pass
def handle_data(context,data):
print(data.current(symbol('601992.SS'), ["last_traded","price","open","high","low","close","volume"]))
pass
Output:
(D:\Anaconda2) C:\Users\xxxx>zipline run -f D:\workspace\algotrading\MyAlgo\test.py --bundle my-yahoo-equities-bundle --start 2017-1-25 --end 2017-1-30
last_traded 2017-01-25 00:00:00+00:00
price 4.73
open 4.65
high 4.77
low 4.6
close 4.73
volume 58051100
Name: 601992.SS, dtype: object
last_traded 2017-01-26 00:00:00+00:00
price 4.61
open 4.66
high 4.68
low 4.6
close 4.61
volume 35766100
Name: 601992.SS, dtype: object
last_traded 2017-01-27 00:00:00+00:00
price 4.54
open 4.61
high 4.62
low 4.51
close 4.54
volume 18532700
Name: 601992.SS, dtype: object
last_traded 2017-01-30 00:00:00+00:00
price 4.59
open 4.53
high 4.62
low 4.5
close 4.59
volume 26073200
Name: 601992.SS, dtype: object
[2017-04-24 07:52:39.892000] INFO: Performance: Simulated 4 trading days out of 4.
[2017-04-24 07:52:39.894000] INFO: Performance: first open: 2017-01-25 14:31:00+00:00
[2017-04-24 07:52:39.895000] INFO: Performance: last close: 2017-01-30 21:00:00+00:00