def calculateCorrelation(self, company, startDate, timeDelta): ## retreive stock dataset dataset = {'type' : 'stock_pull', 'symbol' : TICKER_SYMBOL_DICT[company], 'clientname' : 'graphanalysis_test'} message = json.dumps(dataset) socket = self.createSocket() socket.send(message) message = socket.recv() rcvd = json.loads(message) stk = g.graphanalysis(rcvd, 'stock') stk.interpolate(10) dataset = {'type' : 'avgSentiment_pull', 'symbol' : TICKER_SYMBOL_DICT[company], 'dateRange' : 'doesntmatter', 'clientname' : 'graphanalysis_test'} message = json.dumps(dataset) socket = self.createSocket() socket.send(message) message = socket.recv() rcvd = json.loads(message) twt = g.graphanalysis(rcvd, 'tweet') corrCoeff = stk.correlation(twt) print corrCoeff return corrCoeff[0][1]
def showCorrelationGraph(self, company, daterange): ## retreive stock dataset print daterange dataset = {'type' : 'stock_pull', 'symbol' : company.lower(), 'clientname' : 'graphanalysis_test'} message = json.dumps(dataset) socket = self.createSocket() socket.send(message) message = socket.recv() rcvd = json.loads(message) stk = g.graphanalysis(rcvd, 'stock') stk.interpolate(10) dataset = {'type' : 'avgSentiment_pull', 'symbol' : company.lower(), 'dateRange' : 'doesntmatter', 'clientname' : 'graphanalysis_test'} message = json.dumps(dataset) socket = self.createSocket() socket.send(message) message = socket.recv() rcvd = json.loads(message) twt = g.graphanalysis(rcvd, 'tweet') print twt.starts_within(stk) print stk.starts_within(twt) #dt = datetime(int(daterange[0:4]),int(daterange[5:7]),int(daterange[8-10])) dt = datetime(2013,4,4) stk.run_plot(8, stk.get_date_loc(dt)) return 0
def showGraph(self, company): ## retreive stock dataset dataset = {'type' : 'stock_pull', 'symbol' : TICKER_SYMBOL_DICT[company], 'clientname' : 'graphanalysis_test'} message = json.dumps(dataset) socket = self.createSocket() socket.send(message) message = socket.recv() rcvd = json.loads(message) stk = g.graphanalysis(rcvd, 'stock') stk.interpolate(10) stk.run_plot() ## retreive tweet dataset #dataset = {'type' : 'avgSentiment_pull', 'symbol' : TICKER_SYMBOL_DICT[company], 'dateRange' : 'doesntmatter', 'clientname' : 'graphanalysis_test'} #message = json.dumps(dataset) #socket.send(message) #message = socket.recv() #rcvd = json.loads(message) #twt = g.graphanalysis(rcvd, 'tweet') #twt.run_plot() #stk.run_plot(twt.length(), stk.starts_within(twt)) ## done return 0
def showTweetGraph(self, company, daterange): print daterange dataset = {'type' : 'avgSentiment_pull', 'symbol' : company.lower(), 'dateRange' : 'doesntmatter', 'clientname' : 'graphanalysis_test'} message = json.dumps(dataset) socket = self.createSocket() socket.send(message) message = socket.recv() rcvd = json.loads(message) twt = g.graphanalysis(rcvd, 'tweet') #dt = datetime(2013,4,4) twt.run_plot() return 0
def showTweetGraph(self, company, startDate, timeDelta): dataset = {'type' : 'avgSentiment_pull', 'symbol' : TICKER_SYMBOL_DICT[company], 'dateRange' : 'doesntmatter', 'clientname' : 'graphanalysis_test'} message = json.dumps(dataset) socket = self.createSocket() socket.send(message) message = socket.recv() rcvd = json.loads(message) twt = g.graphanalysis(rcvd, 'tweet') twt.interpolate(10) twt.run_plot(timeDelta, twt.get_date_loc(startDate)) #twt.run_plot() return 0
def showStockGraph(self, company, startDate, timeDelta): ## retreive stock dataset dataset = {'type' : 'stock_pull', 'symbol' : TICKER_SYMBOL_DICT[company], 'clientname' : 'graphanalysis_test'} message = json.dumps(dataset) socket = self.createSocket() socket.send(message) message = socket.recv() rcvd = json.loads(message) stk = g.graphanalysis(rcvd, 'stock') stk.interpolate(10) stk.run_plot(timeDelta, stk.get_date_loc(startDate)) return 0
def showStockGraph(self, company, daterange): ## retreive stock dataset print daterange dataset = {'type' : 'stock_pull', 'symbol' : TICKER_SYMBOL_DICT[company], 'clientname' : 'graphanalysis_test'} message = json.dumps(dataset) socket = self.createSocket() socket.send(message) message = socket.recv() rcvd = json.loads(message) stk = g.graphanalysis(rcvd, 'stock') stk.interpolate(10) #dt = datetime(2013,4,4) stk.run_plot() return 0