Tweak accounts schema to be per-provider
parent
c9eb0b5afb
commit
87bca9aae1
|
@ -14,12 +14,14 @@ private_key = ""
|
|||
[ib]
|
||||
host = "127.0.0.1"
|
||||
|
||||
[ib.accounts]
|
||||
margin = ""
|
||||
registered = ""
|
||||
paper = ""
|
||||
ports.gw = 4002
|
||||
ports.tws = 7497
|
||||
ports.order = ["gw", "tws",]
|
||||
|
||||
[ib.ports]
|
||||
gw = 4002
|
||||
tws = 7497
|
||||
order = [ "gw", "tws",]
|
||||
accounts.margin = "X0000000"
|
||||
accounts.ira = "X0000000"
|
||||
accounts.paper = "XX0000000"
|
||||
|
||||
# the order in which accounts will be selected (if found through
|
||||
# `brokerd`) when a new symbol is loaded
|
||||
accounts_order = ['paper', 'margin', 'ira']
|
||||
|
|
|
@ -106,6 +106,7 @@ def write(
|
|||
|
||||
|
||||
def load_accounts(
|
||||
|
||||
provider: Optional[str] = None
|
||||
|
||||
) -> bidict[str, Optional[str]]:
|
||||
|
@ -114,17 +115,20 @@ def load_accounts(
|
|||
accounts = bidict({'paper': None})
|
||||
|
||||
conf, path = load()
|
||||
section = conf.get('accounts')
|
||||
if section is None:
|
||||
log.warning('No accounts config found?')
|
||||
|
||||
else:
|
||||
for brokername, account_labels in section.items():
|
||||
if (
|
||||
provider is None or
|
||||
provider and brokername == provider
|
||||
):
|
||||
for name, value in account_labels.items():
|
||||
accounts[f'{brokername}.{name}'] = value
|
||||
for provider_name, section in conf.items():
|
||||
accounts_section = section.get('accounts')
|
||||
if (
|
||||
provider is None or
|
||||
provider and provider_name == provider
|
||||
):
|
||||
if accounts_section is None:
|
||||
log.warning(f'No accounts named for {provider_name}?')
|
||||
continue
|
||||
else:
|
||||
for label, value in accounts_section.items():
|
||||
accounts[
|
||||
f'{provider_name}.{label}'
|
||||
] = value
|
||||
|
||||
return accounts
|
||||
|
|
Loading…
Reference in New Issue