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
Example #2
0
        '180d_return', 'volatitilty', '5d_vol', '30d_vol', '180d_vol'
    ]
    earn_points = [
        'ShortPercentFloat', 'PercentInsiders', 'PercentInstitutions',
        'PERatio', 'ForwardPE', 'MarketCapitalization', 'AnalystTargetPrice',
        'Industry', 'Sector'
    ]
    data_points_kmeans = data_points
    stock_returns = pd.DataFrame(columns=['ticker'] + data_points)
    if doEarnings:
        stock_returns = pd.DataFrame(columns=['ticker'] + data_points +
                                     earn_points)
        data_points_kmeans = data_points + earn_points
    runListA = b.stock_list
    runList = []
    allList = sqlcursor.cursor().execute(
        'SELECT name FROM sqlite_master WHERE type="table"').fetchall()
    for a in runListA:
        if [a[0]] not in runList:
            runList += [[a[0]]]
    for a in allList:
        #if len(runList)>1000:
        #    break
        if [a[0]] not in runList:
            runList += [[a[0]]]

    print('Running: ', len(runList))
    #for s in b.etfs:
    for s in runList:
        if s[0].count('^'):
            continue
        print(s[0])
Example #3
0
from ReadData import SQL_CURSOR
import sqlite3
s = SQL_CURSOR()
sc = s.cursor()

table_names = sc.execute(
    "SELECT name from sqlite_master WHERE type ='table' AND name NOT LIKE 'sqlite_%';"
).fetchall()
for tname in table_names:
    #print(tname[0])
    if tname[0].count('-'):
        continue
    try:
        #print(sc.execute('SELECT MIN(rowid) from SPY GROUP BY Date').fetchall())
        distin = sc.execute('SELECT COUNT(DISTINCT Date) from %s' %
                            tname[0]).fetchall()[0][0]
        allD = sc.execute('SELECT COUNT(Date) from  %s' %
                          tname[0]).fetchall()[0][0]
        if abs(allD - distin) > 0:
            print(distin, allD, tname[0])
            #print(sc.execute('SELECT Date from  %s' %tname[0]).fetchall())
            print(
                'DELETE FROM %s WHERE rowid NOT IN ( SELECT MIN(rowid) from  %s GROUP BY Date)'
                % (tname[0], tname[0]))
            #sc.execute('DELETE FROM %s WHERE rowid NOT IN ( SELECT MIN(rowid) from  %s GROUP BY Date)' %(tname[0],tname[0]))
            sc.execute('DROP TABLE %s' % (tname[0]))
            #print(sc.execute('SELECT COUNT( Date) from %s' %tname[0]).fetchall()[0][0])
    except sqlite3.OperationalError:
        print('Could not load!')
sc.close()
#DELETE FROM lipo