Issue #364: Cost basis Fold (#) is broken or unintuitive for short sales (blais/beancount)

18 views
Skip to first unread message

Adam Wolenc

unread,
Jan 19, 2019, 9:56:58 PM1/19/19
to bean...@googlegroups.com
New issue 364: Cost basis Fold (#) is broken or unintuitive for short sales
https://bitbucket.org/blais/beancount/issues/364/cost-basis-fold-is-broken-or-unintuitive

Adam Wolenc:

```
#!python


2018-10-31 * "Sold Short 23 MSFT @ 106.935"
Assets:TDA:Main:Cash 2452.53 USD
Assets:TDA:Main:MSFT -23 MSFT {106.935 # 6.98 USD}

2018-12-21 * "Bought to Cover 23 MSFT @ 98.25"
Income:PnL:ShortTerm
Assets:TDA:Main:Cash -2266.70 USD
Assets:TDA:Main:MSFT 23 MSFT {} @ 98.25 USD
Expenses:Financial:Commission 6.95 USD

2018-11-12 * "Bought 100 PCG @ 31.15"
Assets:TDA:Main:Cash -3121.95 USD
Assets:TDA:Main:PCG 100 PCG {31.15 # 6.95 USD}

2018-11-12 * "Sold 100 PCG @ 33.33"
Income:PnL:ShortTerm
Assets:TDA:Main:Cash 3326.00 USD
Assets:TDA:Main:PCG -100 PCG {} @ 33.33 USD
Expenses:Financial:Commission 6.95 USD
Expenses:Taxes:RegFee 0.05 USD

```

In the above example, folded cost basis works correctly for PCG.
But the MSFT position, a short sale, bails on
```
t:13: Cost is negative: "Cost(number=Decimal('-106.6315217391304347826086957'), currency='USD', date=datetime.date(2018, 10, 31), label=None)"

t:18: Cost is negative: "Cost(number=Decimal('-106.6315217391304347826086957'), currency='USD', date=datetime.date(2018, 10, 31), label=None)"

t:11: Transaction does not balance: (4905.055000000000000000000001 USD)

2018-10-31 * "Sold Short 23 MSFT @ 106.935"
Assets:TDA:Main:Cash 2452.53 USD
Assets:TDA:Main:MSFT -23 MSFT {-106.6315217391304347826086957 USD, 2018-10-31}
```


Reply all
Reply to author
Forward
0 new messages