-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathConfigIBKR_example.py
47 lines (38 loc) · 2.11 KB
/
ConfigIBKR_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from beancount.ingest import extract
from drnukebean.importer import ibkr
# example importer config for IBKR importer by DrNuke
# use with "bean-extract ConfigIBKR_example.py /path/to/ibkr.yaml -f main.Ledgerfile
# your ibkr.yaml file schould look like
# token: 123456789101112131415
# queryId: 123456
# baseCcy: XXX # 'USD', or 'CHF'
# Your IBKR flex Query needs to be XML and have the following fields selected:
# Section "Cash Transactions"
# ct_columns=['type', 'currency', 'description', 'isin', 'amount', 'symbol','reportDate']
# Section "Cash Report"
# cr_columns=['currency', 'fromDate','toDate', 'endingCash']
# Section "Trades"
# tr_columns=['buySell', 'currency', 'symbol', 'description', 'tradeDate', 'quantity',
# 'tradePrice', 'ibCommission', 'ibCommissionCurrency', 'notes', 'cost',
# 'openDateTime', 'levelOfDetail', 'ibOrderID', 'proceeds',
# 'dateTime']
# I do not know a nice way to specify the account structure. This importer is
# based on my own. You can adjust the getXXXAccount() functions of the importer
# class to suit your needs
IBKR = ibkr.IBKRImporter(
Mainaccount = 'Assets:Invest:IB', # main IB account
divSuffix = 'Div', # suffix for dividend account, like
# Assets:Invest:IB:VT:Div
interestSuffix='Interest', # suffix for interest income account
PnLSuffix='PnL', # suffix for PnL Account
FeesSuffix='Fees', # suffix for fees & commisions
currency = 'CHF', # main currency
depositAccount = '', # put in your checkings account if you want deposit transactions
suppressClosedLotPrice=False # Sometimes reports IB an inaccurate lot price.
# In this case it is better to suppress it and let beancount to match lot
fpath = 'testIB/ibfq.pk' # use a pickle dump instead of the API, as it has
# considerable loading times. Set to None for real
# API Flex Query fetching. used mainly for development.
)
CONFIG = [IBKR]
extract.HEADER = '' # remove unnesseccary terminal output