def __init__(self, tws_uri): EWrapper.__init__(self) EClientSocket.__init__(self, anyWrapper=self) self.tws_uri = tws_uri host, port, client_id = self.tws_uri.split(':') self._host = host self._port = int(port) self.client_id = int(client_id) self._next_ticker_id = 0 self._next_request_id = 0 self._next_order_id = None self.managed_accounts = None self.symbol_to_ticker_id = {} self.ticker_id_to_symbol = {} self.last_tick = defaultdict(dict) self.bars = {} # accounts structure: accounts[account_id][currency][value] self.accounts = defaultdict( lambda: defaultdict(lambda: defaultdict(lambda: np.NaN))) self.accounts_download_complete = False self.positions = {} self.portfolio = {} self.open_orders = {} self.order_statuses = {} self.executions = defaultdict(OrderedDict) self.commissions = defaultdict(OrderedDict) self._execution_to_order_id = {} self.time_skew = None self.unrecoverable_error = False self.connect()
def __init__(self, tws_uri): EWrapper.__init__(self) EClientSocket.__init__(self, anyWrapper=self) self.tws_uri = tws_uri host, port, client_id = self.tws_uri.split(':') self._host = host self._port = int(port) self.client_id = int(client_id) self._next_ticker_id = 0 self._next_request_id = 0 self._next_order_id = None self.managed_accounts = None self.symbol_to_ticker_id = {} self.ticker_id_to_symbol = {} self.last_tick = defaultdict(dict) self.bars = {} # accounts structure: accounts[account_id][currency][value] self.accounts = defaultdict( lambda: defaultdict(lambda: defaultdict(lambda: np.NaN))) self.accounts_download_complete = False self.positions = {} self.portfolio = {} self.open_orders = {} self.order_statuses = {} self.executions = defaultdict(OrderedDict) self.commissions = defaultdict(OrderedDict) self._execution_to_order_id = {} self.time_skew = None self.unrecoverable_error = False self.connect()
def __init__(self, tws_uri, order_update_callback): EWrapper.__init__(self) EClientSocket.__init__(self, anyWrapper=self) self.tws_uri = tws_uri host, port, client_id = self.tws_uri.split(':') self._host = host self._port = int(port) self._client_id = int(client_id) self._order_update_callback = order_update_callback self._next_ticker_id = 0 self._next_order_id = None self.managed_accounts = None self.symbol_to_ticker_id = {} self.ticker_id_to_symbol = {} self.last_tick = defaultdict(dict) self.bars = {} # accounts structure: accounts[account_id][currency][value] self.accounts = defaultdict( lambda: defaultdict(lambda: defaultdict(lambda: np.NaN))) self.accounts_download_complete = False self.positions = {} self.portfolio = {} self.orders = {} self.time_skew = None self.connect()
def __init__(self, tws_uri, order_update_callback): EWrapper.__init__(self) EClientSocket.__init__(self, anyWrapper=self) self.tws_uri = tws_uri host, port, client_id = self.tws_uri.split(':') self._order_update_callback = order_update_callback self._next_ticker_id = 0 self._next_order_id = None self.managed_accounts = None self.symbol_to_ticker_id = {} self.ticker_id_to_symbol = {} self.last_tick = defaultdict(dict) self.bars = {} # accounts structure: accounts[account_id][currency][value] self.accounts = defaultdict( lambda: defaultdict(lambda: defaultdict(lambda: np.NaN))) self.accounts_download_complete = False self.positions = {} self.portfolio = {} self.orders = {} self.time_skew = None log.info("Connecting: {}:{}:{}".format(host, int(port), int(client_id))) self.eConnect(host, int(port), int(client_id)) while self.notConnected(): sleep(0.1) self._download_account_details() log.info("Managed accounts: {}".format(self.managed_accounts)) self.reqCurrentTime() self.reqIds(1) while self.time_skew is None or self._next_order_id is None: sleep(0.1) log.info("Local-Broker Time Skew: {}".format(self.time_skew))
def __init__(self, tws_uri): """ :param tws_uri: host:listening_port:client_id - host ip of running tws or ibgw - port, default for tws 7496 and for ibgw 4002 - your client id, could be any number as long as it's not already used """ EWrapper.__init__(self) EClientSocket.__init__(self, anyWrapper=self) self.tws_uri = tws_uri host, port, client_id = self.tws_uri.split(':') self._host = host self._port = int(port) self.client_id = int(client_id) self._next_ticker_id = 0 self._next_request_id = 0 self._next_order_id = None self.managed_accounts = None self.symbol_to_ticker_id = {} self.ticker_id_to_symbol = {} self.last_tick = defaultdict(dict) self.bars = {} # accounts structure: accounts[account_id][currency][value] self.accounts = defaultdict( lambda: defaultdict(lambda: defaultdict(lambda: np.NaN))) self.accounts_download_complete = False self.positions = {} self.portfolio = {} self.open_orders = {} self.order_statuses = {} self.executions = defaultdict(OrderedDict) self.commissions = defaultdict(OrderedDict) self._execution_to_order_id = {} self.time_skew = None self.unrecoverable_error = False self.connect()
def __init__(self, wrapper): EClientSocket.__init__(self, wrapper)
def __init__(self, wrapper): ## Set up with a wrapper inside EClientSocket.__init__(self, wrapper)