Пример #1
0
def main():
    var = ''  #just want update to repeat not entire thing

    while var != 'null':

        company_name = raw_input(
            "Enter the name of the company you're searching for "
        )  #THis asks for a company name

        var = get_companysymbol(
            company_name
        )  #this searchs the company list we have and returns null if not found
        var = company_name

        if var != 'null':  # ONLY PRECED IF WE HAVE A COMPANY

            timeBegin = int(
                input('Enter Start year ')
            ) - 2  #Gets the start date and pushes it back 2 years to show enough data to fit the screen nicely

            totalDataCurrent = Fetching.fetchDataToday(
                var, timeBegin
            )  # This gets all the data from the start year to 3 days ago (give or take a work day)

            googData = Fetching.fetchGoogData(
                var)  # Fetch Todays data from google finance

            Prediction_Data = Fetching.fetchDataSpec(
                var, (datetime.now() + timedelta(days=-45))
            )  # Get the data from just the past month for the prediciton part

            Prediction_Data_Length = len(
                Prediction_Data.High
            )  # Lenght of the predictin Data to save the recalc of it

            Coeffcients = LinearAlgebra.coeffcients_Generator(
                LinearAlgebra.makeXVals_Matrix(10, timeBegin,
                                               Prediction_Data_Length),
                LinearAlgebra.makeY_Matrix(Prediction_Data.High)
            )  #coeffcients for prediction fucntion a0-a10

            Prediction_Model = LinearAlgebra.makeOutY(
                Coeffcients, Prediction_Data_Length, timeBegin,
                totalDataCurrent.High, googData
            )  # Gets Prediciton Model or scatter of predicted points these points are also normalized

            pointY = LinearAlgebra.getPointY(
                Coeffcients, timeBegin, googData[0]['LastTradePrice'],
                totalDataCurrent.High[len(totalDataCurrent) - 1]
            )  #gets Predictiion Point for the next day independently so I can calculate individual days
            R = RSI.PredictRSI(totalDataCurrent.Close)
            Graphing.totalTogether(
                var, totalDataCurrent, googData, Prediction_Model, pointY,
                R)  #Print Final Graph with everything together

    pass
Пример #2
0
def getGraph():
	stockName = request.args.get('s')
	var=stockName
	old_stdout = sys.stdout
	sys.stdout = open(os.devnull, "w")
	if var != 'null':					# ONLY PRECEDE IF WE HAVE A COMPANY
	
			
			Coefficients = numpy.zeros(shape =(11,1))
			
			timeBegin=2010
			
			totalDataCurrent=Fetching.fetchDataToday(var,timeBegin) # This gets all the data from the start year to 3 days ago (give or take a work day)

			googData=Fetching.fetchGoogData(var) # Fetch Todays data from google finance
			
			Prediction_Data=Fetching.fetchDataSpec(var,(datetime.now()+timedelta(days=-45))) # Get the data from just the past month for the prediciton part
			
			Prediction_Data_Length=len(Prediction_Data.Close) # Lenght of the predictin Data to save the recalc of it

			
			#if Cache2.Search(var) ==0:
			
			Coefficients=LinearAlgebra.coefficients_Generator(LinearAlgebra.makeXVals_Matrix(10,timeBegin,Prediction_Data_Length),LinearAlgebra.makeY_Matrix(Prediction_Data.Low)) #coeffcients for prediction fucntion a0-a10		
			
			#Cache2.Cache_Predictions(var,Coefficients)		# after calculating store the data in cache
			
			#else:
			
				#Coefficients = Cache2.Fetch_Cache(var)		# fetch from cache if the company data is stored and it's recent ( less than 3 days from prediction)
			
			
			Prediction_Model=LinearAlgebra.makeOutY(Coefficients,Prediction_Data_Length,timeBegin,totalDataCurrent.High,googData) # Gets Prediciton Model or scatter of predicted points these points are also normalized
			
			pointY=LinearAlgebra.getPointY(Coefficients,timeBegin,googData[0]['LastTradePrice'],totalDataCurrent.High[len(totalDataCurrent)-1]) #gets Predictiion Point for the next day independently so I can calculate individual days
			
			R=RSI.PredictRSI(totalDataCurrent.Close)

			pointY=LinearAlgebra.getPointY(Coefficients,timeBegin,googData[0]['LastTradePrice'],totalDataCurrent.Low[len(totalDataCurrent)-1]) #gets Predictiion Point for the next day independently so I can calculate individual days
			
			url=Graphing.totalTogether(var,totalDataCurrent,googData,Prediction_Model,pointY,R) #Print Final Graph with everything together
			
			url = url + ".embed?width=640&height=480"
			ret = "<iframe width='640' height='480' frameborder='0' scrolling='no' src='" + url + "'> </iframe>"
			sys.stdout.close()
			sys.stdout = old_stdout
			return ret
	else:
		sys.stdout.close()
		sys.stdout = old_stdout
		return "false"