Example #1
0
def findLongCall(symbol, expirations_list):
    long_calls = []

    #Find long call
    for expiration in expirations_list:
        options = api.getOptionsChain(symbol, expiration)

        for option_item in options:
            option = util.gatherOptionData(option_item)

            if (option['bid'] is None or option['ask'] is None):
                continue

            #Estimated premium (mid price)
            premium = round((option['bid'] + option['ask']) / 2, 2)
            option['premium'] = premium

            delta = -999
            if ('delta' in option):
                delta = option['delta']

            if (option["type"] == "put" or premium >= 5
                    or option['volume'] == 0 or delta < .5
                    or (option['ask'] - option['bid']) >= MAX_BID_ASK_SPREAD):
                continue

            #Find Long Call
            if (option["type"] == "call"):
                long_calls.append(option)

    return long_calls
Example #2
0
def findCoveredCalls(ListOfSymbols):
    matching_options = []

    for symbol in ListOfSymbols:
        last_price = api.getLastStockPrice(symbol)

        expirations_list = util.listOfLimitedExpirations(symbol, 20, 50)

        numOptions = 0
        for expiration in expirations_list:
            options = api.getOptionsChain(symbol, expiration)

            for option_item in options:
                option = util.gatherOptionData(option_item)

                if (option['strike'] <= last_price):
                    continue

                premium = round((option['bid'] + option['ask']) / 2, 2)
                profit = round(100 *
                               ((option['strike'] - last_price) + premium))
                debit = round((100 * last_price) - (100 * premium))

                if (option['bid'] > 0 and debit <= 1000
                        and option['type'] == "call" and last_price <= 15
                        and option['volume'] > 0):

                    if (numOptions == 0):
                        matching_options.append(
                            f"Symbol: {symbol}, Last: {last_price}")
                        numOptions += 1

                    option_output = '{} {}, {}, BID:{}, ASK:{}, {}, {}(D), Premium: {}, Debit: {}, Profit: {}' \
                        .format(option['type'],
                                option['expiration'],
                                option['strike'],
                                option['bid'],
                                option['ask'],
                                option['open_int'],
                                option['delta'],
                                premium,
                                debit,
                                profit
                                )

                    #Print the screen when a match is found
                    print(f"Found: {option_output}")

                    matching_options.append(option_output)

    return matching_options
Example #3
0
def findShortCall(long_call):
    symbol = long_call["symbol"]
    long_strike = long_call["strike"]
    long_exp = long_call["expiration"]
    long_prem = long_call["premium"]
    expirations_list = util.listOfLimitedExpirations(symbol, 7, 60)

    long_delta = long_call["delta"]

    for expiration in expirations_list:

        options = api.getOptionsChain(symbol, expiration)

        for option_item in options:
            if (option_item['expiration_type'] == "weeklys"):
                break

            option = util.gatherOptionData(option_item)

            if (option['bid'] is None or option['ask'] is None):
                continue

            #Estimated premium (mid price)
            premium = round((option['bid'] + option['ask']) / 2, 2)

            delta = -999
            if ('delta' in option):
                delta = option['delta']

            if (option["type"] == "put" or premium <= .3
                    or option['volume'] == 0 or delta > .3
                    or (option['ask'] - option['bid']) >= MAX_BID_ASK_SPREAD):
                continue

            if (option["type"] == "call"):

                net_debit = round(long_prem - premium, 2)
                width_of_strike = option["strike"] - long_strike

                if (net_debit > 2 or (width_of_strike * .75) <= net_debit):
                    continue

                option_output = util.shortCallOptionOutput(option)

                print("---")
                print(
                    f"PMCC - L: {long_strike} | {long_exp} | {long_delta}(D)")
                print(f"PMCC - S: {option_output}")
                print(f"Net Debit: {net_debit} Width: {width_of_strike}")
Example #4
0
def findWheels(ListOfSymbols):
    matching_options = []
    for symbol in ListOfSymbols:
        print(f"Processing {symbol}...")

        expirations_list = util.listOfLimitedExpirations(symbol, 1, 15)

        numOptions = 0
        for expiration in expirations_list:
            options = api.getOptionsChain(symbol, expiration)

            for option_item in options:
                option = util.gatherOptionData(option_item)

                if (option['bid'] is None):
                    continue

                #Estimated premium (mid price)
                premium = round((option['bid'] + option['ask']) / 2, 2)

                if ('delta' in option):
                    delta = option['delta']

                if (option['type'] == "put" and option['bid'] > 0
                        and delta >= -.16 and premium >= .19 and
                    (option['ask'] - option['bid']) <= MAX_BID_ASK_SPREAD
                        and option['volume'] > 0):
                    option_output = '{}, {}, BID:{}, ASK:{}, {}, {}(D), Premium: {}'\
                        .format(
                            option['expiration'],
                            option['strike'],
                            option['bid'],
                            option['ask'],
                            option['volume'],
                            option['delta'],
                            premium)

                    if (numOptions == 0):
                        matching_options.append(f"Symbol: {symbol}")
                        numOptions += 1

                    #Print the screen when a match is found
                    print(f"Found: {option_output} - ({datetime.now()})")

    return matching_options
Example #5
0
def findPutSpreads(ListOfSymbols):

    #Options criteria
    MIN_VOLUME = 1
    MAX_BID_ASK_SPREAD = .15
    MAX_STRIKES_WIDTH = 5
    MAX_DELTA = -.2
    MIN_PREMIUM = .21

    matching_options = []
    data_frame = []

    for symbol in ListOfSymbols:
        print(f"Processing {symbol}...")

        expirations_list = util.listOfLimitedExpirations(symbol, 21, 47)

        numOptions = 0
        for expiration in expirations_list:
            #This is temporary... add actual dates later
            if (expiration == "2020-12-08"):
                continue

            options = api.getOptionsChain(symbol, expiration)

            prev_option_strike = 0
            prev_option_prem = 0
            for option_item in options:
                #Ignore weeklys?
                if (option_item['expiration_type'] == "weeklys"):
                    break

                option = util.gatherOptionData(option_item)

                if (option['bid'] is None):
                    continue

                #Estimated premium (mid price)
                premium = round((option['bid'] + option['ask']) / 2, 2)

                #Figure out net credit from credit spread
                net_credit = round((premium - prev_option_prem), 2)

                if ('delta' in option):
                    delta = option['delta']
                    delta = round(delta, 2)

                #Criteria here
                if (option['type'] == "put" and option['bid'] > 0.0
                        and premium >= MIN_PREMIUM and delta >= MAX_DELTA and
                    (option['ask'] - option['bid']) <= MAX_BID_ASK_SPREAD
                        and option['volume'] > MIN_VOLUME):

                    option_output = '{}, {}, BID:{}, ASK:{}, {}, {}(D), Premium: {}'\
                        .format(
                            option['expiration'],
                            option['strike'],
                            option['bid'],
                            option['ask'],
                            option['volume'],
                            delta,
                            premium)

                    if (numOptions == 0):
                        matching_options.append(f"Symbol: {symbol}")
                        numOptions += 1

                    #Mark a strike where the width between the current strike and the previous strike meets the criteria
                    if (net_credit >= MIN_PREMIUM and prev_option_prem > 0
                            and option['strike'] - prev_option_strike <=
                            MAX_STRIKES_WIDTH):

                        option_output = option_output + " <<<<<< "
                        option_output = option_output + f"{net_credit}"

                        data_frame.append([
                            symbol, option['expiration'], option['strike'],
                            option['bid'], option['ask'], option['volume'],
                            delta, premium, net_credit
                        ])

                    #Print the screen when a match is found
                    print(f"Found: {option_output} - ({datetime.now()})")

                    #matching_options.append(option_output)

                if (option['type'] == "put"):
                    prev_option_prem = premium
                    prev_option_strike = option['strike']

    panda_files.exportToFile(data_frame, "output_spreads.csv")

    #print(data_frame)
    return matching_options
Example #6
0
def findPutSpreads(ListOfSymbols):

    #Options criteria
    MIN_VOLUME = 1
    MAX_BID_ASK_SPREAD = .15
    MAX_STRIKES_WIDTH = 5
    DELTA = -.2
    MIN_PREMIUM = .29

    data_frame = []

    for symbol in ListOfSymbols:
        print(f"Processing {symbol}...")

        expirations_list = util.listOfLimitedExpirations(symbol, 21, 47)
        #Try hard-coded expirations for faster processing
        #expirations_list = ["2021-02-19"]

        for expiration in expirations_list:

            options = api.getOptionsChain(symbol, expiration)

            prev_option_strike = 0
            prev_option_prem = 0
            for option_item in options:
                #Ignore weeklys?
                if (option_item['expiration_type'] == "weeklys"):
                    break

                option = util.gatherOptionData(option_item)

                if (option['bid'] is None):
                    continue

                #Estimated premium (mid price)
                premium = round((option['bid'] + option['ask']) / 2, 2)

                #Figure out net credit from credit spread
                net_credit = round((premium - prev_option_prem), 2)

                if ('delta' in option):
                    delta = option['delta']
                    delta = round(delta, 2)

                #Criteria here
                if (option['type'] == "put" and option['bid'] > 0.0
                        and premium >= MIN_PREMIUM and delta >= DELTA and
                    (option['ask'] - option['bid']) <= MAX_BID_ASK_SPREAD
                        and option['volume'] > MIN_VOLUME):

                    option_output = '{}, {}, BID:{}, ASK:{}, {}, {}(D), Premium: {}'\
                        .format(
                            option['expiration'],
                            option['strike'],
                            option['bid'],
                            option['ask'],
                            option['volume'],
                            delta,
                            premium)

                    #Mark a strike where the width between the current strike and the previous strike meets the criteria
                    if (net_credit >= MIN_PREMIUM and prev_option_prem > 0
                            and option['strike'] - prev_option_strike <=
                            MAX_STRIKES_WIDTH):

                        option_output = option_output + " <<<<<< "
                        option_output = option_output + f"{net_credit}"

                        data_frame.append([
                            symbol, option['expiration'], option['strike'],
                            option['bid'], option['ask'], option['volume'],
                            delta, premium, net_credit,
                            util.getTimeStamp()
                        ])

                        #Print the screen when a match is found
                        print(
                            f"Found: {option_output} - ({util.getTimeStamp()})"
                        )

                if (option['type'] == "put"):
                    prev_option_prem = premium
                    prev_option_strike = option['strike']

    panda_files.exportToFile(data_frame, "output_spreads.csv")
    if (config.REMOTE):
        panda_files.exportToWeb(data_frame, "output_spreads")
        panda_files.exportToJson(data_frame, "output_spreads")
Example #7
0
def findWheels(ListOfSymbols):
    #filename_out = "output_{}.txt".format(config.STRATEGY)

    MAX_BID_ASK_SPREAD = .10
    MIN_PRICE = 10
    MAX_PRICE = 20
    MIN_PREM = .2
    MAX_DELTA = -.16

    matching_options = []
    data_frame = []
    for symbol in ListOfSymbols:
        print(f"Processing {symbol}...")

        last_price = api.getLastStockPrice(symbol)
        if (last_price <= MIN_PRICE or last_price >= MAX_PRICE):
            continue

        expirations_list = util.listOfLimitedExpirations(symbol,30,45)

        numOptions = 0
        for expiration in expirations_list:
            options = api.getOptionsChain(symbol, expiration)

            for option_item in options:
                option = util.gatherOptionData(option_item)

                if (option['bid'] is None):
                    continue

                #Estimated premium (mid price)
                premium = round((option['bid'] + option['ask']) / 2,2)

                if ('delta' in option):
                    delta = option['delta']

                if (option['type'] == "put"
                    and option['bid'] > 0
                    and delta >= MAX_DELTA
                    and premium >= MIN_PREM
                    and (option['ask'] - option['bid']) <= MAX_BID_ASK_SPREAD
                    and option['volume'] > 0
                ):
                    option_output = '{}, {}, BID:{}, ASK:{}, {}, {}(D), Premium: {}'\
                        .format(
                            option['expiration'],
                            option['strike'],
                            option['bid'],
                            option['ask'],
                            option['volume'],
                            option['delta'],
                            premium)

                    if (numOptions == 0):
                        matching_options.append(f"Symbol: {symbol}")
                        numOptions += 1
                    
                    #matching_options.append(f"Wheel: {option_output} - ({datetime.now()})")
                    #line = f"Wheel: {symbol} {option_output} - ({datetime.now()})"
                    #files.appendLineToFile(line, filename_out)

                    #Print the screen when a match is found
                    print(f"Wheel: {option_output} - ({datetime.now()})")

                    data_frame.append([symbol,
                                        option['expiration'],
                                        option['strike'],
                                        option['bid'],
                                        option['ask'],
                                        option['volume'],
                                        delta,
                                        premium,
                                        ""])
    panda_files.exportToFile(data_frame, "output_wheels.csv")
    return ""
Example #8
0
def findPutSpreads(ListOfSymbols):
    matching_options = []

    for symbol in ListOfSymbols:
        print(f"Processing {symbol}...")

        expirations_list = util.listOfLimitedExpirations(symbol, 20, 50)

        numOptions = 0
        for expiration in expirations_list:
            options = api.getOptionsChain(symbol, expiration)

            prev_option_strike = 0
            prev_option_prem = 0
            for option_item in options:
                #Ignore weeklys?
                if (option_item['expiration_type'] == "weeklys"):
                    break

                option = util.gatherOptionData(option_item)

                if (option['bid'] is None):
                    continue

                #Estimated premium (mid price)
                premium = round((option['bid'] + option['ask']) / 2, 2)

                #Figure out net credit from credit spread
                net_credit = round((premium - prev_option_prem), 2)

                if ('delta' in option):
                    delta = option['delta']

                #Criteria here
                if (option['type'] == "put" and option['bid'] > 0.0
                        and premium >= MIN_PREMIUM and delta >= MAX_DELTA and
                    (option['ask'] - option['bid']) <= MAX_BID_ASK_SPREAD
                        and option['volume'] > MIN_VOLUME):

                    option_output = '{}, {}, BID:{}, ASK:{}, {}, {}(D), Premium: {}'\
                        .format(
                            option['expiration'],
                            option['strike'],
                            option['bid'],
                            option['ask'],
                            option['volume'],
                            option['delta'],
                            premium)

                    if (numOptions == 0):
                        matching_options.append(f"Symbol: {symbol}")
                        numOptions += 1

                    #Mark a strike where the width between the current strike and the previous strike meets the criteria
                    if (net_credit >= MIN_PREMIUM and prev_option_prem > 0
                            and option['strike'] - prev_option_strike <=
                            MAX_STRIKES_WIDTH):

                        option_output = option_output + " <<<<<< "
                        option_output = option_output + f"{net_credit}"

                    #Print the screen when a match is found
                    print(f"Found: {option_output} - ({datetime.now()})")

                    matching_options.append(option_output)

                if (option['type'] == "put"):
                    prev_option_prem = premium
                    prev_option_strike = option['strike']

    return matching_options
Example #9
0
def findHigherRiskCreditSpreads(ListOfSymbols):

    for symbol in ListOfSymbols:
        expirations_list = util.listOfLimitedExpirations(symbol, 0, 90)

        for expiration in expirations_list:
            options = api.getOptionsChain(symbol, expiration)

            cheapest_option = 0
            highest_premium = 0
            for option_item in options:
                option = util.gatherOptionData(option_item)

                #Estimated premium (mid price)
                premium = round((option['bid'] + option['ask']) / 2, 2)

                if ('delta' in option):
                    delta = option['delta']

                #Criteria
                if (option['type'] == "put" and option['open_int'] > 0
                        and option['bid'] > 0.0):

                    if (cheapest_option == 0):
                        cheapest_option = option
                        cheapest_option['premium'] = premium

                if (option['type'] == "put" and option['bid'] > 0.0
                        and option['volume'] > MIN_VOLUME and delta >= -.16):

                    highest_premium = option
                    highest_premium['premium'] = premium

            if (cheapest_option == 0):
                continue

            if (highest_premium == 0):
                continue

            ### OUTPUT
            high_spread = highest_premium['ask'] - highest_premium['bid']
            net = round(
                highest_premium['premium'] - cheapest_option['premium'], 2)
            max_loss = (
                (highest_premium['strike'] - cheapest_option['strike']) - net)
            if (max_loss > 0 and net > 0):
                risk = round(max_loss / net, 2)

            #Only print the options worth our while
            if (net >= .3 and max_loss <= 8 and high_spread <= .15):

                #Print LONG option
                output = 'Buy: {}, {}, {}'\
                            .format(
                                cheapest_option['expiration'],
                                cheapest_option['strike'],
                                cheapest_option['premium']
                            )
                print(f"{symbol} {output}")

                #Print SHORT option
                output = 'Sell: {}, {}, {}'\
                            .format(
                                highest_premium['expiration'],
                                highest_premium['strike'],
                                highest_premium['premium']
                            )
                print(f"{symbol} {output}")

                #Print net profit
                print(f"Net: {net}")

                #Print Max loss
                print(f"Max Loss: {max_loss}")
                print(f"Risk: {risk}")
                print("--")
Example #10
0
def findWheels(ListOfSymbols, minDays, maxDays):

    MAX_BID_ASK_SPREAD = .15
    MIN_PRICE = 10
    MAX_PRICE = 70
    MIN_PREM = .30
    MAX_DELTA = -.2

    matching_options = []
    data_frame = []
    for symbol in ListOfSymbols:
        print(f"Processing {symbol}...")

        last_price = api.getLastStockPrice(symbol)
        if (last_price <= MIN_PRICE or last_price >= MAX_PRICE):
            continue

        expirations_list = util.listOfLimitedExpirations(
            symbol, minDays, maxDays)

        numOptions = 0
        for expiration in expirations_list:
            options = api.getOptionsChain(symbol, expiration)

            for option_item in options:
                option = util.gatherOptionData(option_item)

                if (option['bid'] is None or option['ask'] is None):
                    continue

                #Estimated premium (mid price)
                premium = round((option['bid'] + option['ask']) / 2, 2)

                delta = -999
                if ('delta' in option):
                    delta = option['delta']

                if (option['type'] == "put" and option['bid'] > 0
                        and delta >= MAX_DELTA and premium >= MIN_PREM and
                    (option['ask'] - option['bid']) <= MAX_BID_ASK_SPREAD
                        and option['volume'] > 0):
                    option_output = '{}, {}, BID:{}, ASK:{}, {}, {}(D), Premium: {}'\
                        .format(
                            option['expiration'],
                            option['strike'],
                            option['bid'],
                            option['ask'],
                            option['volume'],
                            delta,
                            premium)

                    if (numOptions == 0):
                        matching_options.append(f"Symbol: {symbol}")
                        numOptions += 1

                    #Print the screen when a match is found
                    print(f"Wheel: {option_output} - ({util.getTimeStamp()})")

                    data_frame.append([
                        symbol, option['expiration'], option['strike'],
                        option['bid'], option['ask'], option['volume'], delta,
                        premium, "",
                        util.getTimeStamp()
                    ])

    panda_files.exportToFile(data_frame, "output_wheels.csv")

    if (config.REMOTE):
        panda_files.exportToWeb(data_frame, "output_wheels")
        panda_files.exportToJson(data_frame, "output_wheels")

    return ""