Simplify IBKR client creation by removing optional host and port input parameters

This commit is contained in:
moshferatu 2024-02-19 08:53:18 -08:00
parent cfdfb1421f
commit e91cbb696b
2 changed files with 3 additions and 7 deletions

View File

@ -89,10 +89,6 @@ def enter_iron_condor(entry_time: datetime):
logging.error('Error: %s', traceback.format_exc())
def _enter_iron_condor(entry_time: datetime):
ibkr_host = getenv('IBKR_HOST')
ibkr_port = getenv('IBKR_PORT')
ibkr_client = Client(host = ibkr_host, port = ibkr_port)
# The weekly symbol for SPX (SPXW) is required in order to distinguish from monthly options.
symbol, sub_symbol = 'SPX', 'SPXW'
expiration = datetime.now()
@ -123,6 +119,8 @@ def _enter_iron_condor(entry_time: datetime):
logging.info(f'Short Call Strike: {short_call_strike}')
logging.info(f'Long Call Strike: {long_call_strike}')
ibkr_client = Client()
trade_records = []
call_spread_details = {}
put_spread_details = {}

View File

@ -22,9 +22,7 @@ def enter_trade(entry_time: datetime):
def connection_successful():
try:
ibkr_host = getenv('IBKR_HOST')
ibkr_port = getenv('IBKR_PORT')
Client(host = ibkr_host, port = ibkr_port)
Client()
return True
except:
return False