Beispiel #1
0
 def nextValidId(self, orderId: int):
     scanSub = ScannerSubscription()
     scanSub.instrument = 'STK'
     scanSub.locationCode = 'STK.US'
     scanSub.scanCode = 'HIGH_OPT_IMP_VOLAT'
     scanSub.abovePrice = 100
     scanSub.numberOfRows = 1000
     scanSub.scannerSettingPairs = 'Annual, true'
     self.reqScannerSubscription(1, scanSub, [], [])
Beispiel #2
0
def assemble_stock_list(client, sentiment):
    ''' Use scanner to obtain stock list '''

    # Define scanner subscription
    ss = ScannerSubscription()
    ss.instrument = 'STK'
    ss.locationCode = 'STK.US.MAJOR'
    ss.abovePrice = 10.0
    ss.belowPrice = client.funds / 200.0
    ss.aboveVolume = 20000
    ss.numberOfRows = 5

    # Set scan code according to sentiment
    if sentiment == Sentiment.BULLISH:
        ss.scanCode = 'HIGH_VS_13W_HL'
    else:
        ss.scanCode = 'LOW_VS_13W_HL'

    # Request securities
    client.reqScannerSubscription(4, ss, [], [])
    time.sleep(3)