def __init__(self, **kwargs): super().__init__(**kwargs) self.cols = 2 self.add_widget(Label(text="Company Name:", font_size=30)) self.Ticker = TextInput(multiline=False, font_size=30) self.add_widget(self.Ticker) self.add_widget(Label(text="Start Refrence (yyyy-mm-dd):", font_size=30)) self.Start = TextInput(multiline=False, font_size=30) self.add_widget(self.Start) self.add_widget(Label(text="Stop Refrence(yyyy-mm-dd):", font_size=30)) self.Stop = TextInput(multiline=False, font_size=30) self.add_widget(self.Stop) self.Predict = Button(text="Predict", font_size=30) self.Predict.bind(on_release=self.PredictButton) self.add_widget(self.Predict) self.Updates = Button(text="Version Information", font_size=30) self.Updates.bind(on_press=self.InfoPopup) self.add_widget(self.Updates) self.OutputPrediction = Label(text="Decision", font_size=30) self.add_widget(self.OutputPrediction) self.Probability = Label(text="Probability", font_size=30) self.add_widget(self.Probability) try: self.DH = DataHandler.BuySellHandler() self.Predictor = Model.StockPredictingModel((window_size,7)) self.Predictor.Load() except: raise AssertionError("Load Failed")
def __init__(self, window_size): super().__init__() self.window_size = window_size self.UI = tk.Tk() self.UI.minsize(150, 200) self.DH = DataHandler.BuySellHandler() self.BuildUIElements() self.Predictor = Model.StockPredictingModel((self.window_size, 7)) self.Predictor.Load() self.UI.mainloop()
# All user editable variables will go here # Part of SMP500:['QCOM','NVDA','AMAT','PYPL','XLNX','TXN','WDC','STX','ADBE','MCHP','SWKS','FTNT','AVGO','ADSK','FISV','ADP','LRCX','CTSH','KLAC','ADI','AKAM','CDNS','PAYX','CTXS','QRVO','VRSN','FLIR','INTU','SNPS','ANSS','IPGP','V','HPE','ORCL','IBM','DXC','HPQ','MA'] tickers = ['QCOM','NVDA','TXN','ADP','IBM','INTC','AMD',"IBM","MSFT","ORCL"] start_date = '2014-01-01' end_date = '2020-4-10' window_size = 64 step_size = 16 CrossValSplits = 5 Epochs = 32 Batch_size = 32 # In[] # Prepare the Stock Data from the datahandler to be used in the NN DataProcessor = DataHandler.BuySellHandler() Unbatched_Data = DataProcessor.BuySell(tickers,start_date,end_date) # Now lets convert the data into rolling window batches BatchedX = DataProcessor.MultiMakeBatches(Unbatched_Data[0],window_size,step_size)[:-1] # Labels|'Adj Close', 'Close', 'High', 'Low', 'Open', 'Volume','Trends'| Stats = norm() BatchedY = Stats.cdf(DataProcessor.MultiMakeBatches(Unbatched_Data[1],window_size,step_size)[1:,-1,1].reshape(BatchedX.shape[0],1)) # In[] #Load the ML model Predictor = Model.StockPredictingModel(BatchedX[0].shape) Predictor.CVTrain(BatchedX,BatchedY,CrossValSplits,Epochs,Batch_size) # In[] #Test to see if it works on dataset print(Predictor.model.evaluate(BatchedX,BatchedY)) # In[] #Save The trained network
if Return_Values[0][0]>.5: br = "Buy" bkg = (0,1,0,1) else: br = "Sell" bkg = (1,0,0,1) print(br) pb = Return_Values except: br = "Error" bkg = (0,0,1,1) pb = "Check Inputs" self.OutputPrediction.text = br self.OutputPrediction.color = bkg self.Probability.text = str(pb[0][0]) class PredictorApp(App): def build(self): return PredictorPage() cs = PredictorApp().run() else: DH = DataHandler.BuySellHandler() Predictor = Model.StockPredictingModel((window_size,7)) Predictor.Load() stocks = sys.argv[1].split(",") print("Sotcks Entered:"+str(stocks)) Data = DH.BuySell(stocks,sys.argv[2],sys.argv[3]) for i in range(0,len(stocks)): Model_throughput_X = Data[i][-1][-window_size:].reshape(1,window_size,7) print(Predictor.Predict(Model_throughput_X))