Пример #1
0
 def start_run(self, ibcon):
     try:
         log.info("IB Service started running")
         ibcon.run()
     except Exception as ex:
         log.error(ex)
         log.error(traceback.format_exc())
Пример #2
0
 def start_streaming(self):
     try:
         self.ibobj.connect_ib(self.ibobj)
         for contract in tsobj.ib_subcribed_scripts:
             self.ibobj.subscribe_contract(contract, self.ibobj)
             log.info("Sucessfully Subscribed " + str(contract))
         self.ibobj.start_run(self.ibobj)
     except Exception as ex:
         log.error(ex)
         log.error(traceback.format_exc())
Пример #3
0
 def connect_ib(ib_connection):
     try:
         if not ib_connection.isConnected():
             ib_connection.connect(TWS_IP, TMS_PORT, clientId=IB_CLIENT_ID)
             log.info("serverVersion:%s connectionTime:%s" %
                      (ib_connection.serverVersion(),
                       ib_connection.twsConnectionTime()))
     except Exception as ex:
         log.error(ex)
         log.error(traceback.format_exc())
Пример #4
0
 def __init__(self):
     try:
         log.info("TickStream service started")
         json_path = str(tsobj.basepath) + os.path.join(
             tsobj.get_value("common", "masters"),
             tsobj.get_value("common", "stream_list"))
         log.info("Loading scripts details from json " +
                  str(tsobj.get_value("common", "stream_list")))
         company_dicts = None
         if json_path:
             with open(json_path, 'r') as f:
                 company_dicts = json.load(f)
         log.info("List of company loaded \n" + str(company_dicts))
         strmobj = streamer()
         log.info("Creating IB symbol mapping dictionary")
         for index, script in enumerate(company_dicts):
             tsobj.ib_subcribed_scripts.append({
                 "reqid":
                 index + 1,
                 "ibsymbol":
                 strmobj.get_ib_symbol_from_map(script["Symbol"])
             })
         log.info("NSE and IB Symbol Mapping Done !! \n" +
                  str(tsobj.ib_subcribed_scripts))
         if tsobj.ib_subcribed_scripts is not None:
             log.info("Tick Streamer starting streaming..")
             strmobj.start_streaming()
     except Exception as ex:
         log.error(ex)