How to handle sale of partial lots of stock?
David G Hamblen
dhamblen at adelphia.net
Thu Mar 16 10:30:28 EST 2006
I ran into this problem a year ago, and was able to hack the source to
get it working the way I liked. I posted to the developer group on
3/10/05 with the title "weighted average in Balance Sheet (patch)" At
this point I don't recall what version of Gnucash it applied to, but I
had various versions that applied to 1.8.10 and 1.9.x. My solution had
to do with removing absolute values from the calculation. The files
affected were
commodity-utilities.scm
report-utilities.scm
In that same (or similar) thread I had posted a simple test file that
demonstrated the problem
Dave
Derek Atkins wrote:
> Okay, looking at the balance sheet in 1.9/SVN, when I reset to "Most
> Recent"
> in the Price Source, it displays the 100 shares -> $2000, which is
> correct.
> But yes, the Unrealized Gains are incorrect at $333.33.
>
> So... Could you file a bug report in bugzilla and attach this
> data file to the bug report?
>
> -derek
>
> Quoting John Schoffstall <john.schoffstall at pobox.com>:
>
>> Derek Atkins wrote:
>>
>>> Could you send me the test data file you're using? Feel free
>>> to send it off-list and just attach it to the message.
>>
>>
>> Attached.
>>
>> Thanks for helping with this!
>>
>> == John
>>
>>> -derek
>>>
>>> Quoting John Schoffstall <john.schoffstall at pobox.com>:
>>>
>>>> Derek Atkins wrote:
>>>>
>>>>> Well, it's also possible that the balance sheet is screwed up..
>>>>> I'm assuming you're running 1.8 and not 1.9?
>>>>
>>>>
>>>>
>>>> 1.8.10, the version being distributed with Debian etch.
>>>>
>>>> == John
>>>>
>>>>> -derek
>>>>>
>>>>> John Schoffstall <john.schoffstall at pobox.com> writes:
>>>>>
>>>>>
>>>>>> Derek Atkins wrote:
>>>>>>
>>>>>>> You're using Weighted Balance for the stock price. Don't do that.
>>>>>>> You want to use the "most recent pricedb entry" and make sure you
>>>>>>> have a pricedb entry for the $20/share
>>>>>>
>>>>>>
>>>>>>
>>>>>> Okay, I did that. Now the balance sheet looks like this:
>>>>>>
>>>>>> Assets
>>>>>> Assets $0.00
>>>>>> Investments: $3995.00
>>>>>> Assets $3995.00
>>>>>>
>>>>>> Liabilities
>>>>>> Liabilities $0.00
>>>>>> Unrealized Gains(Losses) $333.33
>>>>>>
>>>>>> Equity
>>>>>> Equity $0.00
>>>>>> Opening Balances: $2000.00
>>>>>> Retained earnings: $0.00
>>>>>> Net Profit: $995.00
>>>>>> Total Equity: $2995.00
>>>>>>
>>>>>> Liabilities & Equity: $3328.33
>>>>>>
>>>>>> But Unrealized Gains should be $1000, not $333.33. Price db
>>>>>> entries are $10 for 3/14 and $20 for 3/15-present.
>>>>>>
>>>>>> == John
>>>>>>
>>>>>>
>>>>>>> -derek
>>>>>>> Quoting John Schoffstall <john.schoffstall at pobox.com>:
>>>>>>>
>>>>>>>
>>>>>>>> Derek Atkins wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>> Um, it should work just fine if you put in the correct
>>>>>>>>> gain/loss splits.
>>>>>>>>> Can you show an example of where it's failing, please?
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Create a GnuCash file with Assets, Expense, Income, and Equity
>>>>>>>> accounts. Create a stock account under the Brokerage account,
>>>>>>>> "Digital Datawack" (DWAK). We'll use these accounts:
>>>>>>>>
>>>>>>>> Assets:Investments:Brokerage
>>>>>>>> Assets:Investments:Brokerage:DWAK
>>>>>>>> Expense:Commissions
>>>>>>>> Income:Capital Gains
>>>>>>>> Equity:Opening Balances
>>>>>>>>
>>>>>>>> Enter a transaction for 200 shares of Digital Datawack at $10 a
>>>>>>>> share as an opening balance:
>>>>>>>>
>>>>>>>> Date Action Account Shares Price
>>>>>>>> Debit Credit
>>>>>>>> 03/14/2006 Buy Assets:Investments:Brokerage:DWAK 200
>>>>>>>> 10 2000
>>>>>>>> Equity:Opening Balances
>>>>>>>> 2000
>>>>>>>>
>>>>>>>> Our balance sheet looks like this:
>>>>>>>>
>>>>>>>> Assets
>>>>>>>> Assets $0.00
>>>>>>>> Investments: $2000.00 Assets $2000.00
>>>>>>>> Liabilities
>>>>>>>> Liabilities $0.00
>>>>>>>> Unrealized Gains(Losses) $0.00
>>>>>>>>
>>>>>>>> Equity
>>>>>>>> Equity $0.00 Opening Balances: $2000.00
>>>>>>>> Retained earnings: $0.00
>>>>>>>> Net Profit: $0.00
>>>>>>>> Total Equity: $2000.00
>>>>>>>>
>>>>>>>> Liabilities & Equity: $2000.00
>>>>>>>>
>>>>>>>>
>>>>>>>> Digital Datawack doubles in a day! We'll lock in profits and sell
>>>>>>>> half our shares:
>>>>>>>>
>>>>>>>> Date Action Account Shares Price
>>>>>>>> Debit Credit
>>>>>>>> 03/15/2006 Sell
>>>>>>>> Assets:Investments:Brokerage 1995
>>>>>>>> Expenses:Commissions
>>>>>>>> 5 Assets:Investments:Brokerage:DWAK
>>>>>>>> 1000
>>>>>>>> Assets:Investments:Brokerage:DWAK -100 20
>>>>>>>> 2000
>>>>>>>> Income:Capital Gains
>>>>>>>> 1000
>>>>>>>>
>>>>>>>> But now our balance sheet looks like this:
>>>>>>>>
>>>>>>>> Assets
>>>>>>>> Assets $0.00
>>>>>>>> Investments: $3661.67 Assets $3661.67
>>>>>>>> Liabilities
>>>>>>>> Liabilities $0.00
>>>>>>>> Unrealized Gains(Losses) $0.00
>>>>>>>>
>>>>>>>> Equity
>>>>>>>> Equity $0.00 Opening Balances: $2000.00
>>>>>>>> Retained earnings: $0.00
>>>>>>>> Net Profit: $995.00
>>>>>>>> Total Equity: $2995.00
>>>>>>>>
>>>>>>>> Liabilities & Equity: $2995.00
>>>>>>>>
>>>>>>>> Drilling down into the balance sheet a little, it seems that
>>>>>>>> everything is correct, except that our remaining shares of DWAK
>>>>>>>> are
>>>>>>>> being assigned the value of $1666.67. Huh?
>>>>>>>>
>>>>>>>> So: what's going on here? What am I missing?
>>>>>>>>
>>>>>>>> == John
>>>>>>>>
>>>>>>>>
>>>>>>>>> -derek
>>>>>>>>>
>>>>>>>>> Quoting John Schoffstall <john.schoffstall at pobox.com>:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> [ack, replied to Derek instead of to the list, sorry]
>>>>>>>>>>
>>>>>>>>>> Thanks for the fast reply!
>>>>>>>>>>
>>>>>>>>>> Yes, I read that, and set up the splits as described. It
>>>>>>>>>> works if
>>>>>>>>>> I sell exactly the number of shares that I own. But if
>>>>>>>>>> -NUM_SHARES is less than my total owned shares, my balance sheet
>>>>>>>>>> will be unbalanced as a result. It remains unbalanced until I
>>>>>>>>>> sell the rest of the shares of that stock account.
>>>>>>>>>>
>>>>>>>>>> == John
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Derek Atkins wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> You should read the concepts guide.
>>>>>>>>>>>
>>>>>>>>>>> http://www.gnucash.org/docs/v1.8/C/gnucash-guide/invest_sell1.html
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> -derek
>>>>>>>>>>>
>>>>>>>>>>> Quoting John Schoffstall <john.schoffstall at pobox.com>:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> Greetings! Running 1.8.10 on Debian etch. New GnuCash user,
>>>>>>>>>>>> new
>>>>>>>>>>>> list user, new Linux user.
>>>>>>>>>>>>
>>>>>>>>>>>> I've been climbing the GnuCash learning curve for the past
>>>>>>>>>>>> week, been happy with the software, and making good progress
>>>>>>>>>>>> until now. I've hit a snag I can't get past, though.
>>>>>>>>>>>>
>>>>>>>>>>>> How do you sell a partial lot of stock -- e.g., selling only
>>>>>>>>>>>> 100 of 200 owned shares -- without unbalancing your balance
>>>>>>>>>>>> sheet? I've tried creating two lots, each of 100 shares and
>>>>>>>>>>>> only selling one, but that still whacks the balance sheet.
>>>>>>>>>>>>
>>>>>>>>>>>> The examples in the docs all seem to show only the purchase
>>>>>>>>>>>> and
>>>>>>>>>>>> sale of equivalent amounts. I've googled the net and the
>>>>>>>>>>>> mailing list archives, but can't find an answer I can
>>>>>>>>>>>> understand.
>>>>>>>>>>>>
>>>>>>>>>>>> This is a common situation; there must be an answer. Can
>>>>>>>>>>>> anyone help?
>>>>>>>>>>>>
>>>>>>>>>>>> == John
>>>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>
>
More information about the gnucash-user
mailing list