Currency conversion support for bookkeeper if bkpr-currency is provided, and bkpr-report generic command#8937
Conversation
|
I have reviewed the currencyrate plugin changes and they are fine, except that one review above. The schemas also look correct to me. Should these commands be added to |
f312502 to
d354ab8
Compare
|
I reviewed the changes to the existing tests for currencyrate aswell. I have not reviewed the new tests with the bookkeeper integration. |
544ef63 to
d39273d
Compare
I think that's automagic now? Ah there's a utils.py list :( But when I added it it complained about: Which it does have, so I'm confused. |
d39273d to
93c2952
Compare
It is, wich is why i made #8873 . I always cheated when i added new commands by forcing all new added annotations in patch.py. After 8873 that is no longer necessary, but everything in new commands needs the Uncomment and change to this: if f.added is None and 'added' not in m:
m['added'] = 'v26.04'run
|
609a96c to
de29e73
Compare
bookkeeper-currency is provided.bkpr-currency is provided, and bkpr-report generic command
de29e73 to
821dbd9
Compare
821dbd9 to
b75aeb0
Compare
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
It was using *only* the latest one, not all the fresh ones. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
We process at least one stale entry per iteration (more if it has changed by +/- 1%), so we should sleep for less if we have more entries, in order to average hitting each source once per hour. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
… fiat unit. This is the first step in updating the API. Subtly, the median of BTC prices is different from the median of msat-per-dollar, given it's the invoice. This changes our test: ``` FAILED tests/test_currencyrate.py::test_cached_median - assert 133333 == 150000 ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…or currencyconvert. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…more CLN-ish. And add a schema file. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: JSON-RPC: `listcurrencyrates` API for examining the current values from the `currencyconvert` plugin's sources.
For the simple case of offers conversion, converting a given amount of fiat to BTC is the desired API. But for almost everything else, we want to get the (median) per-BTC rate. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: JSON-RPC: `currencyrate` API for getting the current median BTC conversion top a given fiat currency.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
It's explicitly designed for "these will occur, don't know what order". Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Added: Config: `bkpr-currency` option to record conversion rate at each event.
b75aeb0 to
3520b13
Compare
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
If we're doing currency conversion, we can't refresh lazily on each command: we need to watch for new events and refresh then. This is fairly easy to do, however. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Now we're refreshing more regularly, so it's worth avoiding races rather than simply letting them happen and ignoring the results. Keep a pointer in bkpr and piggy back on that one if it's there. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
In particular, for dynamic options we want to create an aux_command in the case of bookkeeper-currency. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This means doing more work if we set it; in particular, we need to clean up any old values. We define the empty string as "unset", since setconfig has no other way to "unset" variables. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Thanks ChatGPT! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
For now we simply save every one. Later we will get more efficient when they are duplicates (as often happens). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
3520b13 to
4fafd63
Compare
The currencyrate plugin aims for 10 minute polls, so it just doesn't move that fast. If we're busy, recording the rate every second is overkill. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4fafd63 to
2dd7743
Compare
…s them. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
e.g. USD = 2, CLF = 4, XAU = 0. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This does mostly the right thing, but this removes e.g. \" -> ", and \\ to \. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
You can specify the format for each line in a flexible way, using format tags (inclding defaults if they are not set, recursively). Changelog-Added: JSON-RPC: `bkpr-report` allows flexible summaries of bookkeeper income. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
I used daywalker's hack to patch.py to make this work:
```
if f.added is None and 'added' not in m:
m['added'] = 'v26.04'
```
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2dd7743 to
5de8b0f
Compare
This involved a change to the currencyrate plugin's API, now I'm using it for more than just offers: I hope @daywalker90 doesn't mind. I got some help from ChatGPT here, but it made sense.
There is also a generic report-producing API which can take advantage of this
This Fixes #8915