Posted by Mo on June 07, 2001 10:59 AM
Hello, I have this problem which I will try to simplify. For the sake of clarity lets just assume 4 columns. First column is Stock name, second column is bought/sold, this column is filled as B or S. Third column is amount of shares bought, and the fourth column is value, i.e amount of shares multiplied by price. If anyone wants a sample of the data to analyse, Ill be more than happy to supply.
What Im trying to do is calculate profit and loss. Clients buy and sell a particular stock many times over a period of time, sometimes buying same stock 3 times in different days, and then sell them in six small chunks, so to get a profit/loss, one needs to make sure shares sold are equal to shares bought, i.e I only want to calculate when a position is closed, sometime shares sold are not equal to shares bought, i.e the position is still open.
So is there a formula that will look for a stock, add all shares bought for that particular stock, see if it matches with shares sold. If so add the value of shares sold and minus the value of shares bought.
Is this possible or am I taking liberties? Lol.
PS: if this problem is unsolvable, please say it too.