'Wipe the existing trade log for the day, leaving only
the headers in an empty CSV.
It allows for multiple backtests to be run
in a simple way, but quite likely makes it unsuitable for
a production environment that requires strict record-keeping.'

def __init__(self, config):

    self.config = config
    today = datetime.datetime.utcnow().date()
    self.csv_filename = (('tradelog_' + today.strftime('%Y-%m-%d')) + '.csv')
    try:
        fname = os.path.expanduser(os.path.join(config.OUTPUT_DIR, self.csv_filename))
        os.remove(fname)
    except (IOError, OSError):
        print 'No    tradelog    files    to    clean.'
    fieldnames = ['timestamp', 'ticker', 'action', 'quantity', 'exchange', 'price', 'commission']
    fname = os.path.expanduser(os.path.join(self.config.OUTPUT_DIR, self.csv_filename))
    with open(fname, 'a') as csvfile:
        writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
        writer.writeheader()
