Add in db and time checks
This commit is contained in:
+2
-1
@@ -1,2 +1,3 @@
|
||||
stocks.parquet
|
||||
stocks_preview.csv
|
||||
stocks_preview.csv
|
||||
appdata.db
|
||||
@@ -1,7 +1,45 @@
|
||||
import tensorflow as tf
|
||||
import keras
|
||||
print( tf.__version__ )
|
||||
import sqlite3
|
||||
from datetime import date, datetime
|
||||
|
||||
# Initilize SqLite
|
||||
dbconn = sqlite3.connect("./data/appdata.db")
|
||||
dbcursor = dbconn.cursor()
|
||||
|
||||
# Create keystore table if it doesnt exist already
|
||||
dbcursor.execute('''
|
||||
CREATE TABLE IF NOT EXISTS keystore (
|
||||
key TEXT PRIMARY KEY,
|
||||
value TEXT
|
||||
)
|
||||
''')
|
||||
|
||||
def SetKey(Key, Value):
|
||||
dbcursor.execute('INSERT OR REPLACE INTO keystore (key, value) VALUES (?, ?)', (Key, Value))
|
||||
dbconn.commit()
|
||||
|
||||
def GetKey(Key):
|
||||
dbcursor.execute('SELECT value FROM keystore WHERE key = ?', (Key, ))
|
||||
result = dbcursor.fetchone()
|
||||
return result[0] if result else None
|
||||
|
||||
# Pull the last run data
|
||||
lastrundata = GetKey("LastRun")
|
||||
lastrun = None
|
||||
if lastrundata != None:
|
||||
lastrun = datetime.strptime( lastrundata, "%Y-%m-%d" )
|
||||
else:
|
||||
lastrun = datetime.strptime( "2000-01-01", "%Y-%m-%d" )
|
||||
|
||||
# If the strings dont match becuase were only checking day it has to be a new day so update the data
|
||||
if lastrun != str(date.today()):
|
||||
# This will update the data store in the data folder
|
||||
import datapuller
|
||||
# Update the last run to today
|
||||
SetKey("LastRun", str(date.today()))
|
||||
|
||||
# Load in the AI algorithm
|
||||
from keras.layers import Dense, Flatten, Conv2D
|
||||
from keras import Model
|
||||
|
||||
|
||||
Reference in New Issue
Block a user