I want to graph a portfolio of stock trades over a period of say one year.
I will have many trades with many different stocks. The question becomes, what is the best way to calculate the value of the profile over the year.
1) Query for all transactions before or on the start of the period.
2) Calculate their price and totals on that day.
Now, what would be the best method?
Do I loop through each day in the period selected, then find and sum all transactions on a stock before that day.
Loop through all the stocks, sum, store and then do it again for the next day?
How do the pros do this? Curious.
Similarly to what happens in reality, you should go day by day. You move to the next day only after you summed all the transactions on all stocks at a certain day. This will allow you to impose portfolio-level restrictions and allocation. Some examples:
This kind of management will be possible only when you calculate all transactions per day before moving to the next.