<s> import pytz <EOL> import numbers <EOL> from hashlib import md5 <EOL> from datetime import datetime <EOL> from zipline . protocol import DATASOURCE_TYPE <EOL> from six import iteritems , b <EOL> def hash_args ( * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> arg_string = '<STR_LIT:_>' . join ( [ str ( arg ) for arg in args ] ) <EOL> kwarg_string = '<STR_LIT:_>' . join ( [ str ( key ) + '<STR_LIT:=>' + str ( value ) <EOL> for key , value in iteritems ( kwargs ) ] ) <EOL> combined = '<STR_LIT::>' . join ( [ arg_string , kwarg_string ] ) <EOL> hasher = md5 ( ) <EOL> hasher . update ( b ( combined ) ) <EOL> return hasher . hexdigest ( ) <EOL> def assert_datasource_protocol ( event ) : <EOL> """<STR_LIT>""" <EOL> assert event . type in DATASOURCE_TYPE <EOL> if not event . type == DATASOURCE_TYPE . DONE : <EOL> assert isinstance ( event . dt , datetime ) <EOL> assert event . dt . tzinfo == pytz . utc <EOL> def assert_trade_protocol ( event ) : <EOL> """<STR_LIT>""" <EOL> assert_datasource_protocol ( event ) <EOL> assert event . type == DATASOURCE_TYPE . TRADE <EOL> assert isinstance ( event . price , numbers . Real ) <EOL> assert isinstance ( event . volume , numbers . Integral ) <EOL> assert isinstance ( event . dt , datetime ) <EOL> def assert_datasource_unframe_protocol ( event ) : <EOL> """<STR_LIT>""" <EOL> assert event . type in DATASOURCE_TYPE </s>
