예제 #1
0
파일: tws.py 프로젝트: jessetane/2502
 def makeScannerSubscription(self, code, limit):
     sub = ScannerSubscription()
     sub.numberOfRows(limit)
     sub.instrument("STK")
     sub.scanCode(code)
     sub.locationCode("STK.US.MAJOR")
     return sub
예제 #2
0
log = Logger('scanner')

msgs = queue.Queue()
wrapper = Wrapper({}, msgs)
connection = EClientSocket(wrapper)

host = "54.197.15.42"
port = 7496

connection.eConnect(host, port, 1)
subscription = ScannerSubscription()
subscription.numberOfRows(100)
subscription.instrument('STK')
subscription.locationCode('STK.US')
subscription.scanCode('TOP_PERC_GAIN')
subscription.abovePrice(1.0)
subscription.aboveVolume(1)
subscription.marketCapBelow(1000000000.0)

ticker_id = 10

log.operation('Requesting subscription')

connection.reqScannerSubscription(ticker_id, subscription)

while True:
    msg = msgs.get()
    if msg['type'] == 'scannerDataEnd':
        log.operation('Received end scanner data end signal')
        break