def run_prog(self):
        con = ibConnection(host='127.0.0.1', port=7497, clientId=100)
        con.connect()

        # Assign the error handling function defined above
        # to the TWS connection
        con.register(self.error_handler, 'Error')

        # Assign all of the server reply messages to the
        # reply_handler function defined above
        #con.registerAll(reply_handler)
        con.register(self.scan_results, message.scannerData)
        con.register(self.get_valid_order_id, 'NextValidId')
        #con.reqIds(-1)
        time.sleep(1)
        print("Order ID", self.orderid[0])

        self.gappingup_id = self.orderid[0]
        gappingup = ScannerSubscription()
        gappingup.numberOfRows(5)
        gappingup.m_scanCode = 'HIGH_OPEN_GAP'
        gappingup.m_instrument = 'STK'
        gappingup.m_averageOptionVolumeAbove = '0'
        gappingup.m_abovePrice = '5'
        gappingup.m_aboveVolume = '100000'

        self.gappingdown_id = self.gappingup_id + 1
        gappingdown = ScannerSubscription()
        gappingdown.numberOfRows(5)
        gappingdown.m_scanCode = 'LOW_OPEN_GAP'
        gappingdown.m_instrument = 'STK'
        gappingdown.m_averageOptionVolumeAbove = '0'
        gappingdown.m_abovePrice = '5'
        gappingdown.m_aboveVolume = '100000'

        con.reqScannerSubscription(self.gappingup_id, gappingup)
        time.sleep(5)
        con.reqScannerSubscription(self.gappingdown_id, gappingdown)
        time.sleep(5)

        print(self.gapup)
        print(self.gapdown)
예제 #2
0
파일: server.py 프로젝트: dm04806/systemn
	def mostactive(self, location, pricemin, pricemax):
		global scan 
		scan = []
		subscript = ScannerSubscription() 
		subscript.numberOfRows(200) 
		subscript.m_scanCode = 'MOST_ACTIVE' 
		subscript.m_instrument = 'STK' 
		subscript.m_averageOptionVolumeAbove = '' 
		subscript.m_couponRateAbove = '' 
		subscript.m_couponRateBelow = '' 
		subscript.m_abovePrice = pricemin 
		subscript.m_belowPrice = pricemax
		subscript.m_marketCapAbove = '' 
		subscript.m_marketCapBelow = '' 
		subscript.m_aboveVolume = '' 
		subscript.m_stockTypeFilter = 'ALL' 
		#subscript.locationCode('STK.NASDAQ.NMS') 
		#subscript.locationCode('STK.NYSE') 
		#subscript.locationCode('STK.AMEX') 
		subscript.locationCode(location) 
		con.reqScannerSubscription(qqqq_id, subscript) 
		sleep(10)
		return(scan)
예제 #3
0
#Get market data stream
#con.reqMktData(1, goog_contract, '', False)

# Go long 100 shares of Google
goog_order = create_order('MKT', 100, 'BUY')

# Use the connection to the send the order to IB
#con.placeOrder(100,goog_contract, goog_order)

gappingup_id = 13851
gappingup = ScannerSubscription()
gappingup.numberOfRows(5)
gappingup.m_scanCode = 'HIGH_OPEN_GAP'
gappingup.m_instrument = 'STK'
gappingup.m_averageOptionVolumeAbove = '0'
gappingup.m_abovePrice = '5'
gappingup.m_aboveVolume = '100000'

gappingdown_id = gappingup_id + 1
gappingdown = ScannerSubscription()
gappingdown.numberOfRows(5)
gappingdown.m_scanCode = 'LOW_OPEN_GAP'
gappingdown.m_instrument = 'STK'
gappingdown.m_averageOptionVolumeAbove = '0'
gappingdown.m_abovePrice = '5'
gappingdown.m_aboveVolume = '100000'

con.reqScannerSubscription(gappingup_id, gappingup)
time.sleep(5)
con.reqScannerSubscription(gappingdown_id, gappingdown)