Looking for a Quandl/Sharadar CSV Data Loader
-
I'm new to backtrader (coming from Zipline) and I'm looking for a pice of code which correctly load a Quandl Sharadar price csv datafile. (SEP )
Could someone provide this? I tried to change may Zipline ingesting code but it's not working...thanks in advance
-
I build this data Loader, which reads around 16.000 tickers from the Sharadar SEP file.(draft copy from my Zipline loader)
I'm not sure if I handle the ticker correctly.Inside the loop I read for one ticker all dates and pass it to the data=PandasData(dataname=df)
and then to cerebro.adddata(data, symbol) ; symbol contains the stain of the ticker, like 'AAPL'
Where to supply the ticker correctly?Thanks
import backtrader as bt import pandas as pd from datetime import datetime from tqdm import tqdm class PandasData(bt.feeds.PandasData): params = ( ('datetime', None), ('open','open'), ('high','high'), ('low','low'), ('close','close'), ('volume','volume'), ('openinterest',None), ) def read_Quand_SEP_dump(startdate,enddate): file_name='/Users/carsten/ziplinetools/data/quandl/SHARADAR_SEP.csv' print("starting ingesting data from: {}".format(file_name)) df = pd.read_csv(file_name, index_col='date', parse_dates=['date'], na_values=['NA']) print('loaded the dump') # drop unused columns, dividends will be used later df = df.drop(['lastupdated', 'dividends', 'closeunadj'], axis=1) for index, df in tqdm(df.groupby('ticker')): df_new = df.sort_index() #print(df) symbol = df.iloc[0,0] # get ticker symbol #print(symbol) df=df.drop(df[ df.index < startdate ].index) df=df.drop(df[ enddate < df.index ].index) df = df.drop(['ticker'], axis=1) data=PandasData(dataname=df) cerebro.adddata(data, symbol) cerebro = bt.Cerebro() read_Quand_SEP_dump(datetime(2010,1,1) , datetime(2015,12,31))
-
looks fine to me
-
if its not working maybe you're missing session start and end params