def create_secdef_req(requestID, symbol, exchange): data_req = Dtc.SecurityDefinitionForSymbolRequest() # data_req.RequestAction = Dtc.SUBSCRIBE data_req.RequestID = requestID # Note: Make sure this is unique when requesting multiple symbols data_req.Symbol = symbol data_req.Exchange = exchange return data_req
def secdef(requestID, symbol, exchange, sock, logfile): """ Retrieve Security Definition for each symbol. Uses the Market port""" # custom logger with own txt file logRec = create_logger(logfile) # Create sec def request data_req = Dtc.SecurityDefinitionForSymbolRequest() data_req.RequestID = requestID # Note: Make sure this is unique when requesting multiple symbols data_req.Symbol = symbol data_req.Exchange = exchange # Send Request and log response send_message(data_req, Dtc.SECURITY_DEFINITION_FOR_SYMBOL_REQUEST, sock) m_type, m_resp = get_message(sock) logRec.debug("%s, %s", m_type[0], m_resp) logStdout.debug("%s, %s", m_type[0], m_resp) quit(sock)