olhc data from yahoo bundle seem diff with data from datareader directly?

42 views
Skip to first unread message

Kang Hua

unread,
Apr 24, 2017, 5:20:05 AM4/24/17
to Zipline Python Opensource Backtester
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

Kang Hua

unread,
Apr 25, 2017, 6:03:18 AM4/25/17
to Zipline Python Opensource Backtester
calendar wrong ? 

在 2017年4月24日星期一 UTC+8下午5:20:05,Kang Hua写道:

Kang Hua

unread,
Apr 27, 2017, 4:08:35 AM4/27/17
to Zipline Python Opensource Backtester
Yes, I give a china calendar , It works 

在 2017年4月25日星期二 UTC+8下午6:03:18,Kang Hua写道:
Reply all
Reply to author
Forward
0 new messages