Getting historical of cost basis and P&L is a little challenging because I have to match historical data with purchase dates etc. Better approach might be to keep a database based on when the user adds a transaction.