Ejemplo n.º 1
0
        closing_price_today = contract.history(period="1d",
                                               interval="15m")["Close"]
        closing_price_daily = closing_price_daily.append(
            closing_price_today[-1:])

    #closing_price_daily = closing_price_daily.apply(lambda x: round(x,2))
    #print(closing_price_daily[-14:])

    rsi = RSI(closing_price_daily, timeperiod=14)
    print('%s RSI: %.2f' % (symbol, rsi[-1]))

    # if we should trigger an alert and thresholds are met:
    if symbol in triggerAlert:
        if triggerAlert[symbol] == True and (rsi[-1] <= rsiLow):
            triggerAlert[symbol] = False
            notification('%s < %d RSI [14,1d] (%.2f)' %
                         (symbol, rsiLow, rsi[-1]))
        elif triggerAlert[symbol] == True and (rsi[-1] >= rsiHigh):
            notification('%s > %d RSI [14,1d] (%.2f)' %
                         (symbol, rsiHigh, rsi[-1]))
        elif triggerAlert[symbol] == False and (rsi[-1] > rsiLow) and (
                rsi[-1] < rsiHigh):
            triggerAlert[symbol] = True
    else:
        if rsi[-1] <= rsiLow:
            triggerAlert[symbol] = False
            notification('%s < %d RSI [14,1d] (%.2f)' %
                         (symbol, rsiLow, rsi[-1]))
        elif rsi[-1] >= rsiHigh:
            triggerAlert[symbol] = False
            notification('%s > %d RSI [14,1d] (%.2f)' %
                         (symbol, rsiHigh, rsi[-1]))
Ejemplo n.º 2
0
                        'DGS3MO'),
        'oneWeekAgo':
        getValueFromCSV(csv, dates['oneWeekAgo'].strftime('%Y-%m-%d'), 'DATE',
                        'DGS3MO'),
        'yesterday':
        getValueFromCSV(csv, dates['yesterday'].strftime('%Y-%m-%d'), 'DATE',
                        'DGS3MO'),
        'today':
        getValueFromCSV(csv, dates['today'].strftime('%Y-%m-%d'), 'DATE',
                        'DGS3MO'),
    }

    # Send tweet
    tweet = f"US 3-Month Treasury Rate - {lastDate.strftime('%Y-%m-%d')}: {values['today']}%\n\
1d: {values['yesterday']}% ({((values['today']-values['yesterday'])/values['yesterday'])*100:.1f}%)\n\
1w: {values['oneWeekAgo']}% ({((values['today']-values['oneWeekAgo'])/values['oneWeekAgo'])*100:.1f}%)\n\
2w: {values['twoWeeksAgo']}% ({((values['today']-values['twoWeeksAgo'])/values['twoWeeksAgo'])*100:.1f}%)\n\
1m: {values['oneMonthAgo']}% ({((values['today']-values['oneMonthAgo'])/values['oneMonthAgo'])*100:.1f}%)\n\
3m: {values['threeMonthsAgo']}% ({((values['today']-values['threeMonthsAgo'])/values['threeMonthsAgo'])*100:.1f}%)\n\
3m: {values['sixMonthsAgo']}% ({((values['today']-values['sixMonthsAgo'])/values['sixMonthsAgo'])*100:.1f}%)\n\
1y: {values['oneYearAgo']}% ({((values['today']-values['oneYearAgo'])/values['oneYearAgo'])*100:.1f}%)\n\
2y: {values['twoYearsAgo']}% ({((values['today']-values['twoYearsAgo'])/values['twoYearsAgo'])*100:.1f}%)"

    notification(tweet)

else:
    print('Not updated, no new data, last data is ' +
          lastAvailableDate.strftime('%Y-%m-%d %H:%M:%S'))

# Update save file
savePickle(saveFile, lastDate)
Ejemplo n.º 3
0
            impliedMovePuts, callVolume, putVolume, putCallRatio
        ]
        #impliedMove.append([expiry,daysToExpiry,callsIV,putsIV,impliedMoveCalls,impliedMovePuts])

    print(impliedMove)

    # Put/Call Ratio for All Expiries
    putCallRatioAllExpiryDates = putVolumeAllExpiryDates / callVolumeAllExpiryDates
    print('Call volume: %d' % callVolumeAllExpiryDates)
    print('Put volume: %d' % putVolumeAllExpiryDates)
    print('Put/Call Ratio: %.4f' % putCallRatioAllExpiryDates)

    # Send to Twitter
    if putCallRatioAlert[
            ticker] == True and putCallRatioAllExpiryDates > putCallRatioHigh:
        notification('%s > %.2f PUT/CALL RATIO' % (ticker, putCallRatioHigh))
        putCallRatioAlert[ticker] = False
    elif putCallRatioAlert[
            ticker] == True and putCallRatioAllExpiryDates < putCallRatioLow:
        notification('%s < %.2f PUT/CALL RATIO' % (ticker, putCallRatioLow))
        putCallRatioAlert[ticker] = False
    elif putCallRatioAlert[
            ticker] == False and putCallRatioLow < putCallRatioAllExpiryDates and putCallRatioAllExpiryDates > putCallRatioHigh:
        putCallRatioAlert[ticker] = True

    # Check if implied moves are greater than threshold.
    for key, val in impliedMoveThresholds.items():

        # Get the row index that is the least amount of days away from '7 days away', '30 days away', etc
        # https://stackoverflow.com/questions/30112202/how-do-i-find-the-closest-values-in-a-pandas-series-to-an-input-number
        index = impliedMove.iloc[(impliedMove['daysToExpiry'] -