parameters: (csvfile, book, trades)
docstring: Add row to CSV file for the trades
docstring_summary: Add row to CSV file for the trades
docstring_tokens: Add row to CSV file for the trades
function: def csv_trade_update(csvfile, book, trades):
          """
              Add row to CSV file for the trades
          """
          for trade in trades:
              row = {'timestamp' : now_nanos(),
                     'secid' : book.security,
                     'trade_valid' : True,
                     'book_valid' : 'False'}
              trade_dict = trade._asdict()
              row.update({
                  LEVEL_FORMAT.format(1, 'bid', f) : None for f in LEVEL_FIELDS
                  })
              row.update({
                  LEVEL_FORMAT.format(1, 'offer', f) : None for f in LEVEL_FIELDS
                  })
              row.update({TRADE_FORMAT.format(f) : trade_dict[f] for f in TRADE_FIELDS})
              csvfile.writerow(row)
function_tokens: def csv_trade_update ( csvfile , book , trades ) : for trade in trades : row = { 'timestamp' : now_nanos ( ) , 'secid' : book . security , 'trade_valid' : True , 'book_valid' : 'False' } trade_dict = trade . _asdict ( ) row . update ( { LEVEL_FORMAT . format ( 1 , 'bid' , f ) : None for f in LEVEL_FIELDS } ) row . update ( { LEVEL_FORMAT . format ( 1 , 'offer' , f ) : None for f in LEVEL_FIELDS } ) row . update ( { TRADE_FORMAT . format ( f ) : trade_dict [ f ] for f in TRADE_FIELDS } ) csvfile . writerow ( row )