diff --git a/.gitignore b/.gitignore index afd972df..731e1fda 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ stocks.parquet -stocks_preview.csv \ No newline at end of file +stocks_preview.csv +appdata.db \ No newline at end of file diff --git a/main.py b/main.py index d4371910..0dd85287 100644 --- a/main.py +++ b/main.py @@ -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