def __init__(self): EWrapper.__init__(self) EClient.__init__(self, wrapper=self)
def __init__(self): EClient.__init__(self, self) self.lastStamp = datetime.datetime.utcnow()
def __init__(self, wrapper): ## Set up with a wrapper inside EClient.__init__(self, wrapper)
def __init__(self): EClient.__init__(self, self) self.df = pd.DataFrame(columns=['Time', 'Open', 'Close'])
def __init__(self, wrapper): ## Set up with a wrapper inside EClient.__init__(self, wrapper) self._market_data_q_dict = {}
def __init__(self, wrapper): EClient.__init__(self, wrapper)
def __init__(self): EClient.__init__(self, self) self.nextorderId = 1
def __init__(self, callback:Callable[[str, Dict], Any] ): wrapper.EWrapper.__init__(self) EClient.__init__(self, wrapper=self) self.sendMessage = callback self.EVENT_IS_CONNECTED = threading.Event() # Events for main thread
def __init__(self, wrapper, reqIDoffset, log=logtoscreen("ibClient")): ## Set up with a wrapper inside EClient.__init__(self, wrapper) self.ib_init_request_id_factory(reqIDoffset) self.log = log self.last_historic_price_calltime = datetime.datetime.now()
def __init__(self): EClient.__init__(self, self) self.data = [] log('Real time data connection is being established with IB', LOG_PATH)
def options(self,expiry,strike,right,database="Quotes",table=None): table = self.symbol if table == None else table global app app = EClient(Wrapper(self.qdate,self.symbol,self.currency,database,table,expiry,strike,right,self.window)) app.connect(host="127.0.0.1",port=4001,clientId=123) app.run()
def equities(self,database="Quotes",table="Spot"): global app app = EClient(Wrapper(self.qdate,self.symbol,self.currency,database,table,window=self.window)) app.connect(host="127.0.0.1",port=4001,clientId=123) app.run()
def __init__(self, wrapper): EClient.__init__(self, wrapper) self._account_cache = simpleCache(max_staleness_seconds=5 * 60) self._account_cache.update_data = self._update_accounting_data self._market_data_q_dict = {} self._commissions = list_of_execInformation()
def __init__(self): EClient.__init__(self, self) self.positions = {} self.currentDataReqId = 0 self.dataReqIds = {}
def __init__(self, ticker, conid): self.ticker = ticker self.conid = conid self.list = [] EClient.__init__(self, self)
def __init__(self, wrapper): ## Set up with a wrapper inside EClient.__init__(self, wrapper) self._market_data_q_dict = {} self._commissions=list_of_execInformation()
def __init__(self, order_event_queue, market_data_queue): EClient.__init__(self, self) self.nextOrderId = None self._order_event_queue = order_event_queue self._market_data_queue = market_data_queue
def __init__(self): EClient.__init__(self, self) EWrapper.__init__(self)
def __init__(self): EClient.__init__(self,self) self.data={}
def __init__(self,TestWrapper): EClient.__init__(self,TestWrapper)
def __init__(self): EClient.__init__(self, self) self.nextValidOrderId = None self.permId2ord = {} self.df = pd.DataFrame( columns=['Date', 'Open', 'High', 'Low', 'Close', 'Volume']) self.s = pd.Series()
def __init__(self): EClient.__init__(self, self) self.data = [] #Initialize variable to store candle
def __init__(self): EClient.__init__(self, self) self.contract_details = {} #Contract details will be stored here using reqId as a dictionary key
def __init__(self): EClient.__init__(self, self) self.posns = []
def historicalDataEnd(self, reqId: int, start: str, end: str): #8 data is finished print("HistoricalDataEnd. ReqId:", reqId, "from", start, "to", end) #9 this is the logical end of your program app.disconnect() print("finished") def error(self, reqId, errorCode, errorString): # these messages can come anytime. print("Error. Id: ", reqId, " Code: ", errorCode, " Msg: ", errorString) def start(self): queryTime = (datetime.datetime.today() - datetime.timedelta(days=180)).strftime("%Y%m%d %H:%M:%S") fx = Contract() fx.secType = "CASH" fx.symbol = "USD" fx.currency = "JPY" fx.exchange = "IDEALPRO" #6 request data, using fx since I don't have Japanese data app.reqHistoricalData(4102, fx, queryTime, "1 M", "1 day", "MIDPOINT", 1, 1, False, []) app = EClient(MyWrapper()) #1 create wrapper subclass and pass it to EClient app.connect("127.0.0.1", 7497, clientId=123) #2 connect to TWS/IBG app.run() #3 start message thread
def __init__(self): EClient.__init__(self, self) self.barsList = []
def __init__(self, tickers, port, cliente, currentDir): EWrapper.__init__(self) EClient.__init__(self, wrapper=self) ipaddress = "127.0.0.1" portid = port # Gateway: 4002, TWS: 7497 clientid = cliente ################################################################### self.precios = [] self.hora = [] self.nextValidOrderId = None self.Id_File = currentDir + "/" + "NuevoId_file" for i in range(5000): self.precios.append([None, None, None]) self.hora.append(None) self.commission = None self.fill_price = None self.remaining = None self.errorCode = None self.marketDataType = None self.open_position = [None, None] self.tickers = tickers ################################################################### self.connect(ipaddress, portid, clientid) if self.errorCode == 502: # el socket no puede ser abierto print("########################################") print(" Yoe, This Socket cannot be opened or ") print(" IB Wateway is closed") print("########################################") exit() thread = Thread(target=self.run) thread.start() setattr(self, "_thread", thread) ################################################################### #self.reqIds(-1) tiempo = datetime.now( ) # esperando confirmacion de la conexion con IB Gateway conti = None while conti is None: if datetime.now() > tiempo + timedelta(seconds=5): print( "####################################################################" ) print( "Yoe, 5 seconds passed waiting to stablish connection with IB wateway" ) print(" Let's wait 5s more ...") print( "####################################################################" ) tiempo = tiempo + timedelta(seconds=5) conti = self.nextValidOrderId # print("AQUI connect", self.nextValidOrderId) print("########################################") print(" Yoe, connection with IB Gateway is ok,") print(" nextValidOrderId: %s" % self.nextValidOrderId) print("########################################")
def __init__(self): EClient.__init__(self, self)
def __init__(self): EClient.__init__(self, self) self.nextValidOrderId = None self.permId2ord = {}
def __init__(self): EClient.__init__(self,self) #Esto inicia conexion con los servidores de TWS IB