#NEWLINE# def test_sources_merge_custom_ticker( self ) : #NEWLINE# #INDENT# requests_kwargs = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# def capture_kwargs( zelf , url , **kwargs ) : #NEWLINE# #INDENT# requests_kwargs . update ( mask_requests_args ( url , kwargs ) . requests_kwargs ) #NEWLINE# return PALLADIUM_DATA #NEWLINE# #UNINDENT# with patch ( 'zipline.sources.requests_csv.PandasRequestsCSV.fetch_url' , new = capture_kwargs ) : #NEWLINE# #INDENT# results = self . run_algo ( '\nfrom zipline.api import fetch_csv, record, sid\n\ndef rename_col(df):\n    df = df.rename(columns={\'New York 15:00\': \'price\'})\n    df = df.fillna(method=\'ffill\')\n    return df[[\'price\', \'sid\']]\n\ndef initialize(context):\n    fetch_csv(\'https://dl.dropbox.com/u/16705795/PALL.csv\',\n        date_column=\'Date\',\n        symbol=\'palladium\',\n        post_func=rename_col,\n        date_format=\'%Y-%m-%d\'\n        )\n    context.stock = sid(24)\n\ndef handle_data(context, data):\n    record(palladium=data.current("palladium", "price"))\n    record(aapl=data.current(context.stock, "price"))\n        ' ) #NEWLINE# np . testing . assert_array_equal ( ( [ 24 ] * 251 ) , results [ 'aapl' ] ) #NEWLINE# self . assertEqual ( 337 , results [ 'palladium' ] . iloc [ ( - 1 ) ] ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'allow_redirects' : False , #NEWLINE# 'stream' : True , #NEWLINE# 'timeout' : 30.0 , #NEWLINE# #UNINDENT# } #NEWLINE# self . assertEqual ( expected , requests_kwargs )