Пример #1
0
def GetPastPerformance(stock):

    day180 = GetTimeSlot(stock)
    day30 = GetTimeSlot(stock, 30)
    day365 = GetTimeSlot(stock, 365)
    entry = -1
    entry_old = 0
    input_list = ['sma10', 'sma20', 'sma100', 'sma200', 'rstd10']
    percent_change30 = 0.0
    percent_change180 = 0.0
    percent_change365 = 0.0
    percent_change = 100 * (stock['close'][entry] -
                            stock['open'][entry]) / stock['open'][entry]
    if len(day30) > 0:
        percent_change30 = 100 * (
            stock['adj_close'][entry] -
            day30['adj_close'][entry_old]) / day30['adj_close'][entry]
    if len(day180) > 0:
        percent_change180 = 100 * (
            stock['adj_close'][entry] -
            day180['adj_close'][entry_old]) / day180['adj_close'][entry]
    if len(day365) > 0:
        percent_change365 = 100 * (
            stock['adj_close'][entry] -
            day365['adj_close'][entry_old]) / day365['adj_close'][entry]
    #print([percent_change,percent_change30,percent_change180,percent_change365])
    return [
        percent_change, percent_change30, percent_change180, percent_change365
    ]
Пример #2
0
def AddInfo(stock, market):
    stock['sma10'] = techindicators.sma(stock['adj_close'], 10)
    stock['sma20'] = techindicators.sma(stock['adj_close'], 20)
    if len(stock['adj_close']) > 100:
        stock['sma100'] = techindicators.sma(stock['adj_close'], 100)
    else:
        stock['sma100'] = np.zeros(len(stock['adj_close']))
    if len(stock['adj_close']) > 200:
        stock['sma200'] = techindicators.sma(stock['adj_close'], 200)
    else:
        stock['sma200'] = np.zeros(len(stock['adj_close']))
    stock['rstd10'] = techindicators.rstd(stock['adj_close'], 10)
    stock['rsi10'] = techindicators.rsi(stock['adj_close'], 10)
    stock['cmf'] = techindicators.cmf(stock['high'], stock['low'],
                                      stock['close'], stock['volume'], 10)
    stock['KeltLower'], stock['KeltCenter'], stock[
        'KeltUpper'] = techindicators.kelt(stock['high'], stock['low'],
                                           stock['close'], 20, 2.0, 20)
    stock['copp'] = techindicators.copp(stock['close'], 14, 11, 10)
    stock['daily_return'] = stock['adj_close'].pct_change(periods=1)
    stock['daily_return_stddev14'] = techindicators.rstd(
        stock['daily_return'], 14)
    stock['beta'] = techindicators.rollingBetav2(stock, 14, market)
    stock['alpha'] = techindicators.rollingAlpha(stock, 14, market)
    #stock['rsquare']=techindicators.rollingRsquare(stock,14)
    stock['rsquare'] = techindicators.rollingRsquare(stock, 14, spy)
    stock['sharpe'] = techindicators.sharpe(stock['daily_return'],
                                            30)  # generally above 1 is good
    stock['cci'] = techindicators.cci(stock['high'], stock['low'],
                                      stock['close'], 20)
    stock['stochK'], stock['stochD'] = techindicators.stoch(
        stock['high'], stock['low'], stock['close'], 14, 3, 3)
    stock['obv'] = techindicators.obv(stock['adj_close'], stock['volume'])
    stock['force'] = techindicators.force(stock['adj_close'], stock['volume'],
                                          13)
    stock['macd'], stock['macdsignal'] = techindicators.macd(
        stock['adj_close'], 12, 26, 9)
    stock['market'] = market['adj_close']
    stock['corr14'] = stock['adj_close'].rolling(14).corr(spy['market'])
    #stock['pdmd'],stock['ndmd'],stock['adx']=techindicators.adx(stock['high'],stock['low'],stock['close'],14)
    #stock['aroonUp'],stock['aroonDown'],stock['aroon']=techindicators.aroon(stock['high'],stock['low'],25)
    stock['vwap14'] = techindicators.vwap(stock['high'], stock['low'],
                                          stock['close'], stock['volume'], 14)
    stock['vwap10'] = techindicators.vwap(stock['high'], stock['low'],
                                          stock['close'], stock['volume'], 10)
    stock['vwap20'] = techindicators.vwap(stock['high'], stock['low'],
                                          stock['close'], stock['volume'], 20)
    stock['chosc'] = techindicators.chosc(stock['high'], stock['low'],
                                          stock['close'], stock['volume'], 3,
                                          10)
    stock['vwap10diff'] = (stock['adj_close'] -
                           stock['vwap10']) / stock['adj_close']
    #stock['max_drawdown'] = stock['adj_close'].rolling(250).apply(max_drawdown)
    day365 = GetTimeSlot(stock, 365)
    stock['max_drawdown'] = np.ones(len(stocks)) * zigzag.max_drawdown(
        day365['adj_close'].values)
Пример #3
0
def ProcessTicker(ticker, earningsExp, sqlcursor, spy, j, connectionCal):
    print(ticker)
    if debug: print(earningsExp)
    tstock_info, j = ConfigTable(ticker,
                                 sqlcursor,
                                 ts,
                                 readType,
                                 j,
                                 hoursdelay=23)
    if len(tstock_info) == 0:
        return []
    try:
        AddInfo(tstock_info, spy, debug=debug)
    except (ValueError, KeyError):
        print('Error getting infor for %s' % ticker)
        return []
    prev_earnings = None
    overview = None
    try:
        overview = pd.read_sql(
            'SELECT * FROM overview WHERE Symbol="%s"' % (ticker),
            connectionCal)
        prev_earnings = pd.read_sql(
            'SELECT * FROM quarterlyEarnings WHERE ticker="%s"' % (ticker),
            connectionCal)
    except:
        print('no previous info for %s' % ticker)
        return []
    if debug: print(prev_earnings)
    prev_earnings['earningDiff'] = prev_earnings[
        'reportedEPS'] - prev_earnings['estimatedEPS']

    # shift some of the inputs by one day to have the day before inputs
    #print(list(tstock_info.columns))
    for a in [
            'open', 'high', 'low', 'close', 'adj_close', 'volume',
            'dividendamt', 'splitcoef', 'pos_volume', 'neg_volume', 'sma10',
            'sma20', 'sma50', 'sma100', 'sma200', 'rstd10', 'rsi10', 'cmf',
            'BolLower', 'BolCenter', 'BolUpper', 'KeltLower', 'KeltCenter',
            'KeltUpper', 'copp', 'daily_return_stddev14', 'beta', 'alpha',
            'rsquare', 'sharpe', 'cci', 'stochK', 'stochD', 'obv', 'force',
            'macd', 'macdsignal', 'bop', 'HT_DCPERIOD', 'HT_DCPHASE',
            'HT_TRENDMODE', 'HT_SINE', 'HT_SINElead', 'HT_PHASORphase',
            'HT_PHASORquad', 'adx', 'willr', 'ultosc', 'aroonUp', 'aroonDown',
            'aroon', 'senkou_spna_A', 'senkou_spna_B', 'chikou_span', 'SAR',
            'vwap14', 'vwap10', 'vwap20', 'chosc', 'market', 'corr14',
            'fiveday_prior_vix', 'oneday_prior_vix', 'twoday_prior_vix',
            'thrday_prior_vix'
    ]:
        tstock_info[a + '_daybefore'] = tstock_info[a].shift(1)
    #print(tstock_info[['rsi10_daybefore','rsi10','willr_daybefore','willr']].tail())

    # cleaning the previous earnings data types
    prev_earnings['reportedDate'] = pd.to_datetime(
        prev_earnings['reportedDate'], errors='coerce')
    prev_earnings['fiscalDateEnding'] = pd.to_datetime(
        prev_earnings['fiscalDateEnding'], errors='coerce')
    if debug:
        print(tstock_info[[
            'daily_return', 'adj_close', 'thrday_future_return',
            'oneday_future_return'
        ]])
    # Collecting support levels
    prev_earnings['tech_levels'] = ''
    for earn_date in prev_earnings.fiscalDateEnding.values:
        # coverting this datetime64 to datetime
        earn_dateA = (earn_date -
                      np.datetime64('1970-01-01T00:00:00Z')) / np.timedelta64(
                          1, 's')
        earn_dateA = datetime.datetime.utcfromtimestamp(earn_dateA)
        prior_year_tstock_info = GetTimeSlot(tstock_info, startDate=earn_dateA)
        tech_levels = techindicators.supportLevels(prior_year_tstock_info,
                                                   drawhlines=False)
        if len(tech_levels) > 0:
            tech_levels = [str(level[1]) for level in tech_levels]
            prev_earnings.loc[prev_earnings.fiscalDateEnding == earn_date,
                              ['tech_levels']] = ','.join(tech_levels)

    # merging or joining on the report date
    merged_stock_earn = pd.merge(prev_earnings,
                                 tstock_info,
                                 how="left",
                                 left_on='reportedDate',
                                 right_index=True)
    merged_stock_earn['high_from_open'] = merged_stock_earn[
        'high'] - merged_stock_earn['open']
    #merged_stock_earn['e_over_p_diff'] = merged_stock_earn['reportedEPS'].diff()/merged_stock_earn['adj_close'].diff()
    merged_stock_earn['e_over_p_diff'] = (merged_stock_earn['reportedEPS'] /
                                          merged_stock_earn['adj_close']).diff(
                                              periods=-1)
    merged_stock_earn['e_over_p_test'] = (merged_stock_earn['reportedEPS'] /
                                          merged_stock_earn['adj_close'])
    if debug:
        print(merged_stock_earn[[
            'fiscalDateEnding', 'adj_close', 'e_over_p_test', 'e_over_p_diff',
            'open'
        ]])

    # Drawing output
    if doPlot:
        for j in [
                'daily_return', 'oneday_future_return', 'thrday_future_return',
                'high_from_open'
        ]:
            MakePlot(merged_stock_earn['earningDiff'],
                     merged_stock_earn[j],
                     xname='EarningsDiff',
                     yname=j,
                     saveName='earningDiff',
                     hlines=[],
                     title='earningDiff')
            MakePlot(merged_stock_earn['e_over_p_diff'],
                     merged_stock_earn[j],
                     xname='e_over_p_diff',
                     yname=j,
                     saveName='e_over_p_diff',
                     hlines=[],
                     title='e_over_p_diff')
    return merged_stock_earn
Пример #4
0
today = datetime.datetime.now(tz=est) + datetime.timedelta(minutes=-40)
d1 = today.strftime("%Y-%m-%dT%H:%M:%S-04:00")
thirty_days = (today + datetime.timedelta(days=-30)).strftime("%Y-%m-%dT%H:%M:%S-04:00")
if True:
    minute_prices_thirty  = runTicker(api, ticker, timeframe=TimeFrame.Minute, start=thirty_days, end=d1)
    minute_prices_spy  = runTicker(api, 'SPY', timeframe=TimeFrame.Minute, start=thirty_days, end=d1)
    # add the extra data
    AddData(minute_prices_thirty)
    AddData(minute_prices_spy)
    
    minute_prices_spy['signif_volume_spy'] = minute_prices_spy.signif_volume
    minute_prices_thirty = minute_prices_thirty.join(minute_prices_spy.signif_volume_spy,how='left')
    minute_prices_thirty['signif_volume_over_spy'] = minute_prices_thirty.signif_volume / minute_prices_thirty.signif_volume_spy
    
    # get the last 5 days
    minute_prices = GetTimeSlot(minute_prices_thirty,days=10)
    minute_prices_spy_10d = GetTimeSlot(minute_prices_spy,days=10)
    #minute_prices=minute_prices_thirty
    print(minute_prices)
    AddDataShort(minute_prices)
    AddDataShort(minute_prices_spy_10d)

    draw=False
    if draw:
        plt.plot(minute_prices['volume'], label='volume')
        plt.plot(minute_prices['norm_open'],color='red', label='Perc Chg*10')
        #plt.plot(minute_prices['norm_close'],color='orange')
        #plt.plot(minute_prices['norm_high'],color='cyan')
        #plt.plot(minute_prices['norm_low'],color='cyan')
        plt.plot(minute_prices['ma50_div'],color='yellow', label='50m MA')
        plt.plot(minute_prices['minute_diff'],color='green', label='(C-O)/O')
Пример #5
0
spy['daily_returnma20'] = ((spy['daily_return'] + 1).rolling(20).apply(gmean) -
                           1)
spy['openclosepctmavg20'] = spy['openclosepct'].rolling(20).mean()
spy['closeopenpctmavg20'] = spy['closeopenpct'].rolling(20).mean()
spy['daily_returnmavg20'] = spy['daily_return'].rolling(20).mean()
spy['openclosepctma5'] = ((spy['openclosepct'] + 1).rolling(5).apply(gmean) -
                          1)
spy['closeopenpctma5'] = ((spy['closeopenpct'] + 1).rolling(5).apply(gmean) -
                          1)
spy['daily_returnma5'] = ((spy['daily_return'] + 1).rolling(5).apply(gmean) -
                          1)
spy['openclosepctmag5'] = spy['openclosepct'].rolling(5).mean()
spy['closeopenpctmag5'] = spy['closeopenpct'].rolling(5).mean()
spy['daily_returnmag5'] = spy['daily_return'].rolling(5).mean()

spy_1y = GetTimeSlot(spy, days=365)
MakePlotMulti(spy.index,
              yaxis=[
                  spy['openclosepctma20'], spy['closeopenpctma20'],
                  spy['daily_returnma20']
              ],
              colors=['black', 'green', 'red'],
              labels=['trading hours', 'overnight', 'close to close'],
              xname='Date',
              yname='Returns Geo MA20',
              saveName=ticker + '_returns_daynight',
              hlines=[],
              title='',
              doSupport=False,
              my_stock_info=None)
MakePlotMulti(spy_1y.index,
Пример #6
0
from ReadData import ALPACA_REST,runTicker,ConfigTable,ALPHA_TIMESERIES,GetTimeSlot,SQL_CURSOR
import sys
import sqlite3
ts = ALPHA_TIMESERIES()
sqlcursor = SQL_CURSOR()
sc = sqlcursor.cursor()
doClean=False
doReload=False

ticker='DUG'
daily_prices,j    = ConfigTable(ticker, sqlcursor,ts,'full',hoursdelay=18)
daily_prices_365d = GetTimeSlot(daily_prices, days=365)
split_dates = daily_prices_365d[daily_prices_365d.splitcoef!=1.0]
if len(split_dates)>0:
    print(split_dates)
#print(daily_prices.to_string())
#sc.execute('DROP TABLE DUG')

#list_of_tables = 
table_names = sc.execute("SELECT name from sqlite_master WHERE type ='table' AND name NOT LIKE 'sqlite_%';").fetchall()

print("tables: %s" %len(table_names))

#splitID = sc.execute('SELECT COUNT(splitcoef) from DUG WHERE splitcoef!=1.0 AND Date>2021-01-23').fetchall()[0][0]
splitID = sc.execute("SELECT COUNT(splitcoef) from SPY WHERE splitcoef!=1.0 AND Date>'2021-01-23'").fetchall()[0][0]
#splitID = sc.execute("SELECT * from DUG WHERE splitcoef!=1.0 AND Date>'2021-01-23'").fetchall()[0][0]
splitIDl = sc.execute("SELECT * from DUG WHERE splitcoef!=1.0 AND Date>'2021-01-23'").fetchall()[0]
print(splitID)
print(splitIDl)

# create a list to reload
Пример #7
0
    def ARIMA(self, model_var='adj_close', n_periods=50, timescale='D'):
        #timeseries = self.tstock_info[model_var]
        timeseries = None

        if model_var == 'close':
            timeseries = self.minute_prices[model_var]
            timeseries.index = np.arange(0, len(timeseries))
        else:
            timeseries = GetTimeSlot(self.tstock_info, days=5 * 365)[model_var]
        fig = plt.figure(figsize=(10, 10))
        ax1 = fig.add_subplot(311)
        fig = plot_acf(timeseries,
                       ax=ax1,
                       title="Autocorrelation on Original Series")
        ax2 = fig.add_subplot(312)
        fig = plot_acf(timeseries.diff().dropna(),
                       ax=ax2,
                       title="1st Order Differencing")
        ax3 = fig.add_subplot(313)
        fig = plot_acf(timeseries.diff().diff().dropna(),
                       ax=ax3,
                       title="2nd Order Differencing")

        #model = ARIMA(timeseries, order=(1, 1, 1))
        #results = model.fit()
        #results.plot_predict(1, 210)
        autoarima_model = pmd.auto_arima(timeseries,
                                         start_p=1,
                                         start_q=1,
                                         test="adf",
                                         trace=True)
        #timeseries['ARIMA'] =
        fitted, confint = autoarima_model.predict(n_periods,
                                                  return_conf_int=True,
                                                  start=timeseries.index[-1])
        fittedv = autoarima_model.predict_in_sample()
        index_of_fc = pd.date_range(timeseries.index[-1],
                                    periods=n_periods,
                                    freq=timescale)
        if model_var == 'close':
            index_of_fc = np.arange(timeseries.index[-1],
                                    +timeseries.index[-1] + n_periods)
        # make series for plotting purpose
        plt.show()
        fittedv_series = pd.Series(fittedv, index=timeseries.index)
        fitted_series = pd.Series(fitted, index=index_of_fc)
        print(fittedv_series - timeseries)
        lower_series = pd.Series(confint[:, 0], index=index_of_fc)
        upper_series = pd.Series(confint[:, 1], index=index_of_fc)
        print(lower_series)
        print(fitted_series)
        print(upper_series)
        # Plot
        plt.plot(timeseries)
        plt.plot(fitted_series, color='darkgreen')
        plt.plot(fittedv_series, color='yellow')
        plt.fill_between(lower_series.index,
                         lower_series,
                         upper_series,
                         color='k',
                         alpha=.15)

        plt.title(
            "SARIMA - Final Forecast of Stock prices - Time Series Dataset")
        plt.show()
Пример #8
0
        minute_prices_spy.signif_volume_spy, how='left')
    minute_prices_thirty = minute_prices_thirty.join(
        minute_prices_spy.change_spy, how='left')
    minute_prices_thirty = minute_prices_thirty.join(
        minute_prices_spy.minute_diff_spy, how='left')
    minute_prices_thirty = minute_prices_thirty.join(
        minute_prices_spy.minute_diffHL_spy, how='left')
    minute_prices_thirty[
        'signif_volume_over_spy'] = minute_prices_thirty.signif_volume / minute_prices_thirty.signif_volume_spy
    minute_prices_thirty[
        'change_over_spy'] = minute_prices_thirty.change - minute_prices_thirty.change_spy
    minute_prices_thirty['change_over_spy'] *= 10.0
    minute_prices_thirty['change_over_spy'] -= 1.0

    # get the last 5 days
    minute_prices = GetTimeSlot(minute_prices_thirty, days=7)
    minute_prices_spy_10d = GetTimeSlot(minute_prices_spy, days=10)
    #minute_prices=minute_prices_thirty
    print(minute_prices)
    print(minute_prices.describe())
    AddDataShort(minute_prices)
    AddDataShort(minute_prices_spy_10d)
    print(minute_prices.to_string())
    if False:
        DrawMinuteDiffs(minute_prices_thirty)

    plt.plot(minute_prices['volume'], label='volume')
    plt.plot(minute_prices['norm_open'], color='red', label='Perc Chg*10')
    #plt.plot(minute_prices['norm_close'],color='orange')
    #plt.plot(minute_prices['norm_high'],color='cyan')
    #plt.plot(minute_prices['norm_low'],color='cyan')
Пример #9
0
        df = pd.read_csv(inFileName)
    except (FileNotFoundError) as e:
        print("Testing multiple exceptions. {}".format(e.args[-1]))
        df = []
    if debug: print(df)
    todayFilter = (today + datetime.timedelta(days=-1 * filter_shift_days))
    d1 = todayFilter.strftime("%Y-%m-%dT%H:%M:%S-05:00")
    thirty_days = (
        todayFilter +
        datetime.timedelta(days=-30)).strftime("%Y-%m-%dT%H:%M:%S-05:00")
    one_day = (todayFilter +
               datetime.timedelta(days=-1)).strftime("%Y-%m-%dT%H:%M:%S-05:00")

    spy, j = ConfigTable('SPY', sqlcursor, ts, 'full', hoursdelay=18)
    if filter_shift_days > 0:
        spy = GetTimeSlot(spy, days=6 * 365, startDate=todayFilter)
    spy_daily_prices_60d = GetTimeSlot(spy, days=60 + filter_shift_days)
    spy_daily_prices_365d = GetTimeSlot(spy, days=365 + filter_shift_days)
    spy_daily_prices_5y = GetTimeSlot(spy, days=5 * 365 + filter_shift_days)

    # create a dataframe to store all of the info
    curr_results = pd.DataFrame(columns=[
        'ticker', 'quote', 'trade', 'bar_close', 'bar_high', 'bar_low',
        'bar_open'
    ])
    df_store_data = pd.DataFrame(columns=[
        'ticker', 'time_span', 'fit_expectations', 'stddev',
        'fit_diff_significance', 'current_price'
    ])
    if os.path.exists(outFileName):
        df_store_data = pd.read_csv(outFileName)
Пример #10
0
    proc_all_tickers = all_tickers
    if debug: print('Processing: %s' % len(proc_all_tickers))
    iticker = 0
    for ticker in proc_all_tickers:
        iticker += 1

        # if not loaded, then let's compute stuff
        if len(df_store_data[(df_store_data['ticker'] == ticker)]) == 0:
            daily_prices, j = ConfigTable(ticker,
                                          sqlcursor,
                                          ts,
                                          'full',
                                          hoursdelay=18)
            if filter_shift_days > 0:
                daily_prices = GetTimeSlot(daily_prices,
                                           days=6 * 365,
                                           startDate=todayFilter)
            daily_prices_60d = GetTimeSlot(daily_prices,
                                           days=60 + filter_shift_days)
            daily_prices_180d = GetTimeSlot(daily_prices,
                                            days=180 + filter_shift_days)
            daily_prices_365d = GetTimeSlot(daily_prices,
                                            days=365 + filter_shift_days)
            daily_prices_3y = GetTimeSlot(daily_prices,
                                          days=3 * 365 + filter_shift_days)
            daily_prices_5y = GetTimeSlot(daily_prices,
                                          days=5 * 365 + filter_shift_days)
            daily_prices_180d['daily_return'] = daily_prices_180d[
                'adj_close'].pct_change(periods=1)
            #if debug: print('ticker,time_span,fit_expectations,stddev,fit_diff_significance,current_price')
Пример #11
0
def generateMeanRevFigure(apiA, sqlA, tsA, tickerA, doRelativeToSpy=False):
    """generateMeanRevFigure:
       apiA - alpaca api
       sqlA - mysql cursor
       tsA - time series api
       tickerA - str - ticker
       doRelativeToSpy - bool - compute the ratio to SPY for performance
    """
    figs = []

    today = datetime.datetime.now(tz=est)
    d1 = today.strftime("%Y-%m-%dT%H:%M:%S-05:00")
    d1_set = today.strftime("%Y-%m-%d")
    #d1_set = "2022-01-19"
    twelve_hours = (
        today +
        datetime.timedelta(hours=-12)).strftime("%Y-%m-%dT%H:%M:%S-05:00")
    minute_prices = runTicker(apiA,
                              tickerA,
                              timeframe=TimeFrame.Minute,
                              start=twelve_hours,
                              end=d1)

    daily_prices, j = ConfigTable(tickerA, sqlA, tsA, 'full', hoursdelay=18)

    # add todays numbers if available
    if len(minute_prices) > 0:
        df_today = pd.DataFrame([[
            minute_prices['open'][0], minute_prices['high'].max(),
            minute_prices['low'].min(), minute_prices['close'][-1],
            minute_prices['close'][-1], minute_prices['volume'].sum(), 0.0, 1.0
        ]],
                                columns=[
                                    'open', 'high', 'low', 'close',
                                    'adj_close', 'volume', 'dividendamt',
                                    'splitcoef'
                                ],
                                index=[d1_set
                                       ])  #index=[minute_prices.index[-1]])
        df_today.index = pd.to_datetime(df_today.index)
        if len(daily_prices
               ) == 0 or daily_prices.index[-1] < df_today.index[0]:
            daily_prices = pd.concat([daily_prices, df_today])
            daily_prices = daily_prices.sort_index()

    #st.table(daily_prices.tail())
    filter_shift_days = 0
    if filter_shift_days > 0:
        daily_prices = GetTimeSlot(daily_prices,
                                   days=6 * 365,
                                   startDate=todayFilter)
    daily_prices_60d = GetTimeSlot(daily_prices, days=60 + filter_shift_days)
    daily_prices_180d = GetTimeSlot(daily_prices, days=180 + filter_shift_days)
    daily_prices_365d = GetTimeSlot(daily_prices, days=365 + filter_shift_days)
    daily_prices_3y = GetTimeSlot(daily_prices,
                                  days=3 * 365 + filter_shift_days)
    daily_prices_5y = GetTimeSlot(daily_prices,
                                  days=5 * 365 + filter_shift_days)
    daily_prices_180d['daily_return'] = daily_prices_180d[
        'adj_close'].pct_change(periods=1)

    figs += [
        FitWithBand(
            daily_prices_60d.index,
            daily_prices_60d[['adj_close', 'high', 'low', 'open', 'close']],
            ticker=tickerA,
            outname='60d')
    ]
    figs += [
        FitWithBand(
            daily_prices_180d.index,
            daily_prices_180d[['adj_close', 'high', 'low', 'open', 'close']],
            ticker=tickerA,
            outname='180d')
    ]
    figs += [
        FitWithBand(
            daily_prices_365d.index,
            daily_prices_365d[['adj_close', 'high', 'low', 'open', 'close']],
            ticker=tickerA,
            outname='365d')
    ]
    figs += [
        FitWithBand(
            daily_prices_3y.index,
            daily_prices_3y[['adj_close', 'high', 'low', 'open', 'close']],
            ticker=tickerA,
            outname='3y')
    ]
    figs += [
        FitWithBand(
            daily_prices_5y.index,
            daily_prices_5y[['adj_close', 'high', 'low', 'open', 'close']],
            ticker=tickerA,
            outname='5y')
    ]

    # Compute relative to spy
    if doRelativeToSpy:
        spy, j = ConfigTable('SPY', sqlA, tsA, 'full', hoursdelay=18)
        if filter_shift_days > 0:
            spy = GetTimeSlot(spy, days=6 * 365, startDate=todayFilter)
        spy_daily_prices_60d = GetTimeSlot(spy, days=60 + filter_shift_days)
        spy_daily_prices_365d = GetTimeSlot(spy, days=365 + filter_shift_days)
        spy_daily_prices_5y = GetTimeSlot(spy,
                                          days=5 * 365 + filter_shift_days)

        figs += [
            FitWithBand(daily_prices_365d.index,
                        daily_prices_365d[[
                            'adj_close', 'high', 'low', 'open', 'close'
                        ]],
                        ticker=tickerA,
                        outname='365dspycomparison',
                        spy_comparison=spy_daily_prices_365d[[
                            'adj_close', 'high', 'low', 'open', 'close'
                        ]])
        ]
        figs += [
            FitWithBand(
                daily_prices_60d.index,
                daily_prices_60d[['adj_close', 'high', 'low', 'open',
                                  'close']],
                ticker=tickerA,
                outname='60dspycomparison',
                spy_comparison=spy_daily_prices_60d[[
                    'adj_close', 'high', 'low', 'open', 'close'
                ]])
        ]
        figs += [
            FitWithBand(
                daily_prices_5y.index,
                daily_prices_5y[['adj_close', 'high', 'low', 'open', 'close']],
                ticker=tickerA,
                outname='5yspycomparison',
                spy_comparison=spy_daily_prices_5y[[
                    'adj_close', 'high', 'low', 'open', 'close'
                ]])
        ]
    return figs