Skip to content

Commit

Permalink
Raise (and handle) exception if broker account is not in config
Browse files Browse the repository at this point in the history
  • Loading branch information
todd committed Dec 14, 2022
1 parent 6e7825b commit 89b2d9b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions sysbrokers/IB/ib_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from ib_insync import IB

from sysbrokers.IB.ib_connection_defaults import ib_defaults
from syscore.objects import missing_data, arg_not_supplied
from syscore.exceptions import missingData
from syscore.objects import arg_not_supplied

from syslogdiag.log_to_screen import logtoscreen

Expand Down Expand Up @@ -57,12 +58,11 @@ def __init__(

ib = IB()

if account is arg_not_supplied:
## not passed get from config
account = get_broker_account()

## that may still return missing data...
if account is missing_data:
try:
if account is arg_not_supplied:
## not passed get from config
account = get_broker_account()
except missingData:
self.log.error(
"Broker account ID not found in private config - may cause issues"
)
Expand Down Expand Up @@ -108,5 +108,5 @@ def close_connection(self):

def get_broker_account() -> str:
production_config = get_production_config()
account_id = production_config.get_element_or_missing_data("broker_account")
account_id = production_config.get_element("broker_account")
return account_id

0 comments on commit 89b2d9b

Please sign in to comment.