Back to Community
Custom data Bundle

hi guys i'm trying construct a bundle data with BR assets. So to do this I'm following the steps presented in this tutorial: Link -

I'm using the code below to download from the yahoo and save de data into directory C:/Users/ivo/PycharmProjects/finance/datas/BVSP.csv

def download_csv_data(ticker, start_date, end_date, freq, path):  
    yahoo_financials = YahooFinancials(ticker)

    df = yahoo_financials.get_historical_price_data(start_date, end_date, freq)  
    df = pd.DataFrame(df[ticker]['prices']).drop(['date'], axis=1) \  
             .rename(columns={'formatted_date': 'date'}) \  
             .loc[:, ['date', 'open', 'high', 'low', 'close', 'volume']] \  
    df.index = pd.to_datetime(df.index)  
    df['dividend'] = 0  
    df['split'] = 1

    # save data to csv for later ingestion  
    df.to_csv(path, header=True, index=True)

    # plot the time series  
    df.close.plot(title='{} prices --- {}:{}'.format(ticker, start_date, end_date))


And I've add a code in the file in the directory: C:\Users\ivo\Anaconda3\envs\z35\Lib\site-packages\zipline

I add the code below into

import pandas as pd

from import register  
from import csvdir_equities

start_session = pd.Timestamp('2019-1-1', tz='utc')  
end_session = pd.Timestamp('2018-12-31', tz='utc')

    calendar_name='BVMF', # US equities  

but, I've tried to ingest the data bundle running this code in python console:

!zipline ingest -b br_bundle  

I got the error below:

Traceback (most recent call last):  
  File "C:\Users\ivo\Anaconda3\envs\z35\Scripts\", line 11, in <module>  
    load_entry_point('zipline==1.3.0', 'console_scripts', 'zipline')()  
  File "C:\Users\ivo\Anaconda3\envs\z35\lib\site-packages\pkg_resources\", line 484, in load_entry_point  
    return get_distribution(dist).load_entry_point(group, name)  
  File "C:\Users\ivo\Anaconda3\envs\z35\lib\site-packages\pkg_resources\", line 2707, in load_entry_point  
    return ep.load()  
  File "C:\Users\ivo\Anaconda3\envs\z35\lib\site-packages\pkg_resources\", line 2325, in load  
    return self.resolve()  
  File "C:\Users\ivo\Anaconda3\envs\z35\lib\site-packages\pkg_resources\", line 2331, in resolve  
    module = __import__(self.module_name, fromlist=['__name__'], level=0)  
  File "C:\Users\ivo\Anaconda3\envs\z35\lib\site-packages\zipline\", line 29, in <module>  
    from .utils.run_algo import run_algorithm  
  File "C:\Users\ivo\Anaconda3\envs\z35\lib\site-packages\zipline\utils\", line 27, in <module>  
    from zipline.algorithm import TradingAlgorithm  
  File "C:\Users\ivo\Anaconda3\envs\z35\lib\site-packages\zipline\", line 68, in <module>  
    from import SimulationBlotter  
  File "C:\Users\ivo\Anaconda3\envs\z35\lib\site-packages\zipline\finance\blotter\", line 16, in <module>  
    from .simulation_blotter import SimulationBlotter  
  File "C:\Users\ivo\Anaconda3\envs\z35\lib\site-packages\zipline\finance\blotter\", line 43, in <module>  
    class SimulationBlotter(Blotter):  
TypeError: 'str' object is not callable  

Plese guys, help me. I need this to solve this to do a task of my university.

7 responses

File "C:\Users\ivo\Anaconda3\envs\z35\Scripts\", line 11, in
load_entry_point('zipline==1.3.0', 'console_scripts', 'zipline')()
... TypeError: 'str' object is not callable

It sounds like load_entry_point returns a string and you try to call it. Try to remove the second pair of paretheses in line 11 of

load_entry_point('zipline==1.3.0', 'console_scripts', 'zipline')  

instead of

load_entry_point('zipline==1.3.0', 'console_scripts', 'zipline')()  

thanks, but didn't work. Do you or someone have another sugestion to solve this issue?

No, sorry. But could you try to post that link again? There's no url...

I forgot to attach the link in the post. I've already edited the post and attached the link.

Ok, I just tried it out. The tutorial is not very clear

modify the file located in the zipline directory

I found another file in another directory called zipline and it was empty - that was the right one. I'm on ubuntu and in my user folder is a hidden folder called .zipline. In your case it might be in "C:\Users\ivo\" (or just search for and make sure to include hidden folders).
There should be another where you can paste your code above. I had to change the dates to

start_session = pd.Timestamp('2019-1-2', tz='utc')  
end_session = pd.Timestamp('2019-12-30', tz='utc')  

In the folder where I put BVSP.csv I had to make a subfolder called 'daily' and moved the csv file there. After that the ingestion seems to have worked.

There were some NaN rows in the csv file, so I filled them with

import pandas as pd  
df = pd.read_csv('daily/BVSP.csv', index_col=0).ffill()  

and ingested the bundle again. Now I'm working on the problem that zipline doesn't find the benchmark...

You can find a soution for the benchmark problem here, it's near the end of the page:

Understanding the benchmarking process and how to overcome errors if they creep in

I donwloaded historical SPY data from the yahoo finance website, changed the column names to lowercase and in the file I just replaced

df = pd.DataFrame(data)  


df = pd.read_csv('full/path/to/SPY.csv')  

After all that I successfully ran a backtest with BVSP from the br_bundle

I will do what you said tomorrow and I will get the results. Thanks for help me Tentor.