Beispiel #1
0
    async def readOptionChain(self, ctx, stock=None):
        """Takes a stock ticker as the parameter to parse multiple option chains for multiple dynamically generated
         expirations (currently set to next 3 monthly expirations) and prints out information regarding a stock option's
         volume * current price. The printout takes the 5 best results and showcases it, as well as the entire OCs
         tallied up to show a preferred side.

        :param ctx:
        :param stock:
        :return:
        """
        if stock and s.validateTicker(stock):
            price = s.tickerPrice(stock)
            if price >= 10:
                junk = await ctx.send("```" + "Loading the option chain for " + str(stock).upper() + "..." + "```")
                try:
                    res = flow.mostExpensive(stock)
                    if res:
                        await ctx.send("```" + res + "```")
                except:
                    await ctx.send("```" + "Failed to load the option chain for " + str(stock).upper() + "\n"
                                            "This may be due to low activity in the option chain, Robinhood API, "
                                            "or other abnormal activity." + "```")
                finally:
                    await junk.delete()
            else:
                await ctx.send("```" + stock.upper() + " is not a valid ticker for options.\n" + "```")
        elif stock:
            await ctx.send("```" + stock.upper() + " is not a valid ticker.\n" + "```")
        else:
            res = "Read Option Info: Displays closest valued options for a ticker with which side is dominating and " \
                  "top 5 most valued strikes.\n" + \
                  "Ex. .read [stock]\n"
            await ctx.send("```" + res + "```")
Beispiel #2
0
    async def findOptionChain(self, ctx, stock=None, type=None, expir=None):
        """Takes in a stock ticker, an optional expiration date (defaulted to friday expiration [if applicable]),
        a type (defaulted to call) and prints the information (Strike, price, volume, OI) on 1 ITM strike and 3
        OTM strikes to discord.

        :param ctx:
        :param stock: {1-5} character stock-ticker.
        :param type: Defaulted to 'call'. Can be either 'call' or 'put'.
        :param expir: Defaulted to 'None'. Represents the expiration date in the format YYYY-MM-DD
        :return:
        """
        if stock and s.validateTicker(stock):
            price = s.tickerPrice(stock)
            if price >= 5:
                res = o.pcOptionChain(stock, type, expir, price)
                await ctx.send("```" + res + "```")
            else:
                await ctx.send("```" + stock.upper() + " is not a valid ticker for options.\n" + "```")
        elif stock:
            await ctx.send("```" + stock.upper() + " is not a valid ticker.\n" + "```")
        else:
            res = "Option chain: Displays stock option chain information based on ticker, type (call or put), " \
                  "and expiration.\n" + \
                  "Ex: .f [stock]\n" + \
                  "Ex: .f [stock], [type]\n" + \
                  "Ex: .f [stock], [type], [expiration]\n"
            await ctx.send("```" + res + "```")
Beispiel #3
0
def generate_multiple_months(ticker, quantity):
    strike = round10(s.tickerPrice(ticker))
    monthly1 = validateExp(ticker, str(third_friday(getYear(), getMonth(), getMonthlyDay())), 'call', strike)
    months = [monthly1]
    for i in range(1, quantity):
        months.append(validateExp(ticker, generate_next_month_exp(months[i - 1]), 'call', strike))
    return months
Beispiel #4
0
def loadStrikes_SPY():
    """Loads strikes into call_strikes & put_strikes for SPY

    :return:
    """
    price = s.tickerPrice('SPY')
    callprice = o.roundPrice(price, 1, 'call')
    putprice = o.roundPrice(price, 1, 'put')

    for i in range(0, 15):  # Now that we have the iterator and rounded price, collect actual strikes
        call_strikes_SPY.append(o.grabStrike(callprice, 1, 'call', i))
        put_strikes_SPY.append(o.grabStrike(putprice, 1, 'put', i))
Beispiel #5
0
def validateStrike(stock, type, expir, strike):
    """Given parameters that should all be correct validate strike price. If strike price is not correct, return a
    correct one.

    :param stock:
    :param type:
    :param expir:
    :param strike:
    :return:
    """
    price = s.tickerPrice(stock)
    if not r.find_options_by_expiration_and_strike(stock, expir, strike, type):
        strikeIterator = searchStrikeIterator(stock, type, expir, price)
        price = roundPrice(price, strikeIterator, type)
        return grabStrike(price, strikeIterator, type, 0)
    else:
        return strike
Beispiel #6
0
def checkAnomalies(timestamp, daystamp):
    """Called every 3m to check records against current option values. Reports any anomalies found.

    :param timestamp:
    :return:
    """
    anomaly = generate_SPY()

    if anomaly:
        price = s.tickerPrice('SPY')
        res = "Found large cash movement in past 3 min:\nCurrent SPY price @ " + str(price) + "\n"
        w = csv.writer(open(anomalies_csv, "w"))

        for val in anomaly:
            cost = formatIntForHumans(anomaly.get(val)['diff'])
            curr = str(int(anomaly.get(val)['curr']))
            volume = str(anomaly.get(val)['volume'])
            gamma = str(anomaly.get(val)['gamma'])
            dte = str(anomaly.get(val)['dte'])
            w.write([val, dte, cost, curr, volume, gamma, daystamp, timestamp[2:]])
            res += dte + val[10:] + ': +$' + cost + "   Price: $" + curr + "   Vol: " + volume + "   Gamma: " + gamma + "\n"
        return res
Beispiel #7
0
def loadStrikes(ticker, expir):
    """Loads strikes into call_strikes & put_strikes

    :return: 2 lists: call_strikes & put_strikes
    """
    strike_value = {}
    days_till_expiration = []
    callStrikeIterator = []
    price = s.tickerPrice(ticker)
    for exp in expir:
        days_till_expiration.append(cal.DTE(exp))
        callStrikeIterator.append(
            o.searchStrikeIterator(ticker, 'call', exp, price))

    call_value = o.pcOptionMin(
        ticker, 'call', expir, strike_value, days_till_expiration,
        o.roundPrice(price, callStrikeIterator[0], 'call'), callStrikeIterator)

    put_value = o.pcOptionMin(
        ticker, 'put', expir, strike_value, days_till_expiration,
        o.roundPrice(price, callStrikeIterator[0], 'put'), callStrikeIterator)

    return strike_value, [call_value, put_value]