self.logger.info("UPWARDS BREAKOUT %s" % ohlc.mdiId) # let's also pull up the breakout point self.upperBoundaries[ ohlc.mdiId] = ohlc.close + self.currentPriceRanges[ ohlc.mdiId] self.xmpp.outgoingQueue.put( [self.targetjid, ohlc.mdiId + ' UPWARDS BREAKOUT']) if ohlc.close < lowerBoundary: self.logger.info("DOWNWARDS BREAKOUT %s" % ohlc.mdiId) # let's pull it down ... self.lowerBoundaries[ ohlc.mdiId] = ohlc.close - self.currentPriceRanges[ ohlc.mdiId] self.xmpp.outgoingQueue.put( [self.targetjid, ohlc.mdiId + ' DOWNWARDS BREAKOUT']) return ############### MAIN CODE START # let's create the listener. logging.basicConfig(level=logging.INFO, format='%(asctime)-15s %(name)s| %(message)s') brokeraqUid = 'XXXX' brokeraqPwd = 'XXXX' listener = MyListener() aqsPrice = AqSocket(listener) aqsPrice.host = '78.47.96.150' aqsPrice.connect()
if lastEma20Val > lastEma50Val: self.currentDirections[ohlc.mdiId] = 'LONG' else: self.currentDirections[ohlc.mdiId] = 'SHORT' if self.crossing(ewma20, ewma50) > 0: # let's trigger some action ... self.xmpp.outgoingQueue.put([self.targetjid, 'LONG ' + ohlc.mdiId]) return if self.crossing(ewma20, ewma50) < 0: # let's trigger some action ... self.xmpp.outgoingQueue.put( [self.targetjid, 'SHORT ' + ohlc.mdiId]) return return ############### MAIN CODE START # let's create the listener. brokeraqUid = 'XXXX' brokeraqPwd = 'XXXX' # let's set up basic logging. logging.basicConfig(level=logging.INFO, format='%(asctime)-15s %(name)s| %(message)s') listener = CrossOverMonitor() aqsPrice = AqSocket(listener) listener.setAqsPrice(aqsPrice) aqsPrice.connect()
percDistUp = (upperBoundary / ohlc.close - 1.0) * 100.0 percDistDown = (lowerBoundary / ohlc.close - 1.0) * 100.0 print datetime.datetime.now(), "\t", ohlc.mdiId, '\tClose:', ohlc.close, '\tUpper boundary:', upperBoundary, '(', percDistUp, ')\tLower boundary:', lowerBoundary, '(', percDistDown, ')' if ohlc.close > upperBoundary: self.logger.info("UPWARDS BREAKOUT %s" % ohlc.mdiId) # let's also pull up the breakout point self.upperBoundaries[ohlc.mdiId] = ohlc.close + self.currentPriceRanges[ohlc.mdiId] self.xmpp.outgoingQueue.put([self.targetjid, ohlc.mdiId + ' UPWARDS BREAKOUT']) if ohlc.close < lowerBoundary: self.logger.info("DOWNWARDS BREAKOUT %s" % ohlc.mdiId) # let's pull it down ... self.lowerBoundaries[ohlc.mdiId] = ohlc.close - self.currentPriceRanges[ohlc.mdiId] self.xmpp.outgoingQueue.put([self.targetjid, ohlc.mdiId + ' DOWNWARDS BREAKOUT']) return ############### MAIN CODE START # let's create the listener. logging.basicConfig(level=logging.INFO, format='%(asctime)-15s %(name)s| %(message)s') brokeraqUid = 'XXXX' brokeraqPwd = 'XXXX' listener = MyListener() aqsPrice = AqSocket(listener) aqsPrice.host = '78.47.96.150' aqsPrice.connect()
else: self.currentDirections[ohlc.mdiId] = 'SHORT' if self.crossing(ewma20, ewma50) > 0: # let's trigger some action ... self.xmpp.outgoingQueue.put([self.targetjid, 'LONG ' + ohlc.mdiId]) return if self.crossing(ewma20, ewma50) < 0: # let's trigger some action ... self.xmpp.outgoingQueue.put([self.targetjid, 'SHORT ' + ohlc.mdiId]) return return ############### MAIN CODE START # let's create the listener. brokeraqUid = 'XXXX' brokeraqPwd = 'XXXX' # let's set up basic logging. logging.basicConfig(level=logging.INFO, format='%(asctime)-15s %(name)s| %(message)s') listener = CrossOverMonitor() aqsPrice = AqSocket(listener) listener.setAqsPrice(aqsPrice) aqsPrice.connect()