@@ -8,13 +8,10 @@ class Network(enum.Enum):
8
8
if __name__ == '__main__' :
9
9
10
10
import typer
11
-
12
11
import server
13
12
14
13
def make_cli (logger ):
15
14
16
- import beancounter
17
- beancounter .logger = logger
18
15
19
16
cli = typer .Typer ()
20
17
@@ -24,7 +21,7 @@ def run():
24
21
import uvicorn
25
22
26
23
assert logger
27
- logger .info (f'server.app. debug: { server .app .debug } ' )
24
+ logger .info (f'debug: { server .app .debug } ' )
28
25
uvicorn .run ('server:app' ,
29
26
host = '127.0.0.1' ,
30
27
port = 5000 ,
@@ -34,39 +31,6 @@ def run():
34
31
reload_includes = ['spotbit.config' ] # FIXME(nochiel) Does nothing?
35
32
)
36
33
37
- default_exchange_id = list (server .supported_exchanges .keys ())[0 ]
38
- default_currency = server .settings .currencies [0 ]
39
- @cli .command ()
40
- def beancount (descriptor : beancounter .Descriptor ,
41
- network : str = Network .TESTNET .value ,
42
- exchange : server .ExchangeName = default_exchange_id ,
43
- currency : server .CurrencyName = default_currency ):
44
- '''
45
- Generate a beancount file using the transactions found by generating addresses from the bitcoin mainnet descriptor.
46
-
47
- Ref. https://beancount.github.io/docs/trading_with_beancount.html
48
- '''
49
-
50
- typer .echo (f'Generating beancount report for descriptor: { descriptor } ' )
51
- typer .echo (f'Using currency: { currency } ' )
52
- typer .echo (f'Using exchange: { exchange } ' )
53
-
54
- import bdkpython as bdk
55
- bdk_network = bdk .Network .TESTNET
56
- match network :
57
- case Network .BITCOIN :
58
- bdk_network = bdk .Network .BITCOIN
59
- case Network .TESTNET :
60
- bdk_network = bdk .Network .TESTNET
61
- try :
62
- beancounter .make_beancount_from_descriptor (descriptor = descriptor ,
63
- exchange = exchange ,
64
- currency = currency ,
65
- network = bdk_network )
66
- except Exception as e :
67
- typer .echo (f'An error occurred while generating a beancount file: { e } ' )
68
-
69
-
70
34
return cli
71
35
72
36
cli = make_cli (server .logger )
0 commit comments