Firstly thanks to Chandoo for a wonderful sight. It's the first time I've really been able to get the hang of writing somewhat pseudocode before I start and it was a great help. I've included it here in case the section on this problem is helpful.
The Spreadsheet is record of shares bought and sold on the stock market.
data looks like this
Date, ASX Code, Contract No, Units, Price, Trans Type (whether bought or sold)
N.B. Contract No is unique
ASX Code is a three or more letter code that identifies the company shares being bought or sold e.g. AAPL
N.B. I never short sell so I must own sufficient shares before I can sell them. (this makes me think that a condition based on date prior to sale may be helpful)
A separate sheet is created for each individual stock e.g AAPL, MSOFT etc.
It records all transactions for that stock and a separate table for the record of sales.
There latter table tells me what share I still hold, how many on each contract and the cost of those remaining shares.
It also tells me how much profit I make on each sale.
Sample data not used in attached spreadsheet but to explain this as simply as I can.
1/1/12, BHP ConNote A001buy 100 shares totalling $1200
2/1/12, BHP ConNote A002 buy 100 shares totalling $1150
Now the problem is when I sell.
I could sell 50 shares from either parcel and end up with RemNumShares = 50 for one ConNote and 100 for the other
I could sell 100 shares from either parcel and end up with RemNumShares = 0 for one ConNote and 100 for the other or,
I could sell 150 shares from either parcel and end up with RemNumShares = 50 for one ConNote and Nil for the other or of course sell the lot and that makes it easy but just another condition.
This scenario affects the number remaining the cost of those remaining and the profit on the sale.
Hold it, don't get too excited because there's one extra problem. I can't do it on FIFO. I need to be able to select which contract I want to first apply the sale to. This is because here down under there can be a tax benefit for doing so.
I really hope I can make some progress with this I've been trying to do it for a number of years in Filemaker and I just can't get the relationships right.
Here's the link to the excel file
https://www.dropbox.com/s/0dygfy4hnro1irf/Sample_Share_Portfolio_File.xls
and to my Pseudocode. If anyone is interested I'd appreciate some tips on the way I've done it.
https://www.dropbox.com/s/nidjklu48i2jh03/Share%20Project.pdf
Thanks for your help
Rob
The Spreadsheet is record of shares bought and sold on the stock market.
data looks like this
Date, ASX Code, Contract No, Units, Price, Trans Type (whether bought or sold)
N.B. Contract No is unique
ASX Code is a three or more letter code that identifies the company shares being bought or sold e.g. AAPL
N.B. I never short sell so I must own sufficient shares before I can sell them. (this makes me think that a condition based on date prior to sale may be helpful)
A separate sheet is created for each individual stock e.g AAPL, MSOFT etc.
It records all transactions for that stock and a separate table for the record of sales.
There latter table tells me what share I still hold, how many on each contract and the cost of those remaining shares.
It also tells me how much profit I make on each sale.
Sample data not used in attached spreadsheet but to explain this as simply as I can.
1/1/12, BHP ConNote A001buy 100 shares totalling $1200
2/1/12, BHP ConNote A002 buy 100 shares totalling $1150
Now the problem is when I sell.
I could sell 50 shares from either parcel and end up with RemNumShares = 50 for one ConNote and 100 for the other
I could sell 100 shares from either parcel and end up with RemNumShares = 0 for one ConNote and 100 for the other or,
I could sell 150 shares from either parcel and end up with RemNumShares = 50 for one ConNote and Nil for the other or of course sell the lot and that makes it easy but just another condition.
This scenario affects the number remaining the cost of those remaining and the profit on the sale.
Hold it, don't get too excited because there's one extra problem. I can't do it on FIFO. I need to be able to select which contract I want to first apply the sale to. This is because here down under there can be a tax benefit for doing so.
I really hope I can make some progress with this I've been trying to do it for a number of years in Filemaker and I just can't get the relationships right.
Here's the link to the excel file
https://www.dropbox.com/s/0dygfy4hnro1irf/Sample_Share_Portfolio_File.xls
and to my Pseudocode. If anyone is interested I'd appreciate some tips on the way I've done it.
https://www.dropbox.com/s/nidjklu48i2jh03/Share%20Project.pdf
Thanks for your help
Rob