# Beancount cost and price

**URL:** <https://forum.plaintextaccounting.org/t/beancount-cost-and-price/391>\
**Category:** General\
**Tags:** beancount\
**Created:** [October 27, 2024, 7:07pm UTC](https://forum.plaintextaccounting.org/t/beancount-cost-and-price/391 "2024-10-27T19:07:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gulugulu](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gulugulu](https://forum.plaintextaccounting.org/u/gulugulu)\
**Post date:** [October 27, 2024, 7:07pm UTC](https://forum.plaintextaccounting.org/t/beancount-cost-and-price/391/1 "2024-10-27T19:07:10Z")

</div>

I'm confused.

## 1.

I buy BTC. I use `{}` instead of `@` because I want to track "capital gains". Then I buy ETH with BTC.

I expect this to work:

```auto
2025-01-01 open Assets:Test

2025-01-02 * "buy btc"
    Assets:Test 1 BTC {123456 USD, "foo"}
    Assets:Test -123456 USD

2025-01-03 * "buy eth"
    Assets:Test 80 ETH {0.005 BTC}
    Assets:Test -0.4 BTC {"foo"}

```

Error: "No position matches ..."

Ok, so I change the last transaction:

```auto
2025-01-03 * "buy eth"
    Assets:Test 80 ETH {0.005 BTC}
    Assets:Test -0.4 BTC {"foo"}
    Assets:Test 0.4 BTC @ 123456 USD ; new posting
    Assets:Test -0.4 BTC ; new posting

```

This seems to be working. Is this the correct approach?

## 2.

I noticed that when I add price to the posting `-0.4 BTC {"foo"}`, for example 49176234 USD, it seems to have no effect. No error.

```auto
2025-01-03 * "buy eth"
    Assets:Test 80 ETH {0.005 BTC}
    Assets:Test -0.4 BTC {"foo"} @ 49176234 USD
    Assets:Test 0.4 BTC @ 123456 USD
    Assets:Test -0.4 BTC

```

I can enter any price, 999999 USD. Is this a bug? What is happening?

```auto
2025-01-03 * "buy eth"
    Assets:Test 80 ETH {0.005 BTC}
    Assets:Test -0.4 BTC {"foo"} @ 999999 USD
    Assets:Test 0.4 BTC @ 123456 USD
    Assets:Test -0.4 BTC

```

---

<div class="post-metadata">

**Author:** ![gulugulu](https://avatars.discourse-cdn.com/v4/letter/g/8e8cbc/32.png) [@gulugulu](https://forum.plaintextaccounting.org/u/gulugulu)\
**Post date:** [October 27, 2024, 9:03pm UTC](https://forum.plaintextaccounting.org/t/beancount-cost-and-price/391/2 "2024-10-27T21:03:36Z")

</div>

1. from the docs:

> Finally, if a posting **has both a cost and a price** , we simply ignore the price. This optional price is used later on to generate an entry in the in-memory prices database, but it is not used in balancing at all.

---

<div class="post-metadata">

**Author:** ![tario](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.plaintextaccounting.org/tario/32/9_2.png) [@tario](https://forum.plaintextaccounting.org/u/tario)\
**Post date:** [October 28, 2024, 8:20am UTC](https://forum.plaintextaccounting.org/t/beancount-cost-and-price/391/3 "2024-10-28T08:20:05Z")

</div>

For 1. are you sure that you really want to use BTC as the cost currency for your ETH? I think that is the issue, if you change the cost tag for ETH to use USD, the first way will work.

For 2. there are some plugins which start to enforce some of the checks (e.g. sellgains), see [beancount.plugins - Beancount Documentation](https://beancount.github.io/docs/api_reference/beancount.plugins.html)
