#NEWLINE# def test_minutely_fetcher( self ) : #NEWLINE# #INDENT# self . responses . add ( self . responses . GET , 'https://fake.urls.com/aapl_minute_csv_data.csv' , body = AAPL_MINUTE_CSV_DATA , content_type = 'text/csv' ) #NEWLINE# sim_params = factory . create_simulation_parameters ( start = pd . Timestamp ( '2006-01-03' , tz = 'UTC' ) , end = pd . Timestamp ( '2006-01-10' , tz = 'UTC' ) , emission_rate = 'minute' , data_frequency = 'minute' ) #NEWLINE# test_algo = TradingAlgorithm ( script = '\nfrom zipline.api import fetch_csv, record, sid\n\ndef initialize(context):\n    fetch_csv(\'https://fake.urls.com/aapl_minute_csv_data.csv\')\n\ndef handle_data(context, data):\n    record(aapl_signal=data.current(sid(24), "signal"))\n' , sim_params = sim_params , data_frequency = 'minute' , env = self . env ) #NEWLINE# test_algo . data_portal = FetcherDataPortal ( self . env ) #NEWLINE# gen = test_algo . get_generator ( ) #NEWLINE# perf_packets = list ( gen ) #NEWLINE# signal = [ result [ 'minute_perf' ] [ 'recorded_vars' ] [ 'aapl_signal' ] for result in perf_packets if ( 'minute_perf' in gen ) ] #NEWLINE# self . assertEqual ( ( 6 * 390 ) , len ( signal ) ) #NEWLINE# np . testing . assert_array_equal ( ( [ np . NaN ] * 390 ) , signal [ 0 : 390 ] ) #NEWLINE# np . testing . assert_array_equal ( ( [ 2 ] * 390 ) , signal [ 390 : 780 ] ) #NEWLINE# np . testing . assert_array_equal ( ( [ 3 ] * 780 ) , signal [ 780 : 1560 ] ) #NEWLINE# np . testing . assert_array_equal ( ( [ 4 ] * 780 ) , signal [ 1560 : ] )