def get_end_of_month_assets(self, final_date):
     """
     Gets the end of month asset map for each month
     """
     dates = sorted(self.portfolio.keys())
     final_date = Trade.string_to_datetime(final_date, '%Y-%m-%d')
     prior_date = dates[0]
     for date in dates:
         if date == final_date:
             print date, self.portfolio[date]
             break
         if date.month != prior_date.month:
             print prior_date, self.portfolio[prior_date]
         prior_date = date
 def parse_from_csv(self, csv):
     for csv_record in csv:
         csv_record = csv_record.strip()
         transaction_type = csv_record.split(',')[1]
         if transaction_type == "Bought" or transaction_type == "Sold":
             csv_record = Trade.from_string(csv_record)
             self.trades.append(csv_record)
         elif transaction_type == "Dividend":
             csv_record = Dividend.from_string(csv_record)
             self.dividends.append(csv_record)
         elif transaction_type == "Contrib":
             csv_record = Contribution.from_string(csv_record)
             self.deposits.append(csv_record)
         elif transaction_type == "Interest":
             csv_record = Interest.from_string(csv_record)
             self.interest.append(csv_record)
         elif transaction_type == "Deposit":
             csv_record = Deposit.from_string(csv_record)
             self.deposits.append(csv_record)
         elif transaction_type == "Withdrawal":
             csv_record = Withdrawal.from_string(csv_record)
             self.withdrawals.append(csv_record)
         elif transaction_type == "Principal":
             csv_record = Principal.from_string(csv_record)
             self.principal.append(csv_record)
         elif transaction_type == "Promotion":
             csv_record = Promotion.from_string(csv_record)
             self.promotions.append(csv_record)
         elif transaction_type == "Split":
             record = Record()
             record.transaction_type = "Split"
             csv_record = csv_record.split(',')
             record.date = Record.string_to_datetime(csv_record[0], '%Y-%m-%d')
             #record.date = csv_record[0]
             record.symbol = csv_record[2]
             record.split_from = int(csv_record[3])
             record.split_to = int(csv_record[4])
             self.splits.append(record)
         else:
             print csv_record
             raise Exception