def getConsecutiveDays(url): # set up constants positives = 0 negatives = 0 zeroes = 0 # set up bs4 r = requests.get(url) soup = BeautifulSoup(r.content, "html.parser") dayReturns = [] # manipulate data mm.appendData(6, 7, dayReturns, 'percent', url) # for x in xrange(0,int(len(dayReturns)-1)): # print (dayReturns[x] - dayReturns[x+1]) # # print("==========") for x in xrange(0,int(len(dayReturns)-1)): if (dayReturns[x] - dayReturns[x+1]) < 0: negatives+=1 if (dayReturns[x] - dayReturns[x+1]) > 0: positives+=1 elif (dayReturns[x] - dayReturns[x+1]) == 0: zeroes+=1 numerator = float(len(dayReturns) + positives - negatives) denominator = float((2 * len(dayReturns)) + zeroes) return (numerator / denominator) * 100
def getConsecutiveDays(url): # set up constants positives = 0 negatives = 0 zeroes = 0 # set up bs4 r = requests.get(url) soup = BeautifulSoup(r.content, "html.parser") dayReturns = [] # manipulate data mm.appendData(6, 7, dayReturns, 'percent', url) # for x in xrange(0,int(len(dayReturns)-1)): # print (dayReturns[x] - dayReturns[x+1]) # # print("==========") for x in xrange(0, int(len(dayReturns) - 1)): if (dayReturns[x] - dayReturns[x + 1]) < 0: negatives += 1 if (dayReturns[x] - dayReturns[x + 1]) > 0: positives += 1 elif (dayReturns[x] - dayReturns[x + 1]) == 0: zeroes += 1 numerator = float(len(dayReturns) + positives - negatives) denominator = float((2 * len(dayReturns)) + zeroes) return (numerator / denominator) * 100
def getTrans(inputUrl): transDict = {} symbols = [] orderdate = [] transdate = [] ordertype = [] orderamount = [] orderprice = [] # Find the person's name transDict['name'] = makeName(inputUrl) transDict['game'] = makeGameName(inputUrl) print("Finding transactions of " + transDict['name'] + "...") ## BEAUTIFULSOUP SETUP r = requests.get(inputUrl) soup = BeautifulSoup(r.content, "html.parser") # Ticker Symbols mm.appendData(0,1,symbols,'str', inputUrl) # Order Date and Time mm.appendData(1,2,orderdate,'str', inputUrl) # Transaction Date and Time mm.appendData(2,3,transdate,'str', inputUrl) # Order Type mm.appendData(3,4,ordertype,'orderType', inputUrl) # Order Amount (number of shares) mm.appendData(4,5,orderamount,'float', inputUrl) # Order Price mm.appendData(5,6,orderprice,'money', inputUrl) # package all of the data into a nice dictionary. transDict['symbols'] = symbols transDict['orderdate'] = orderdate transDict['transdate'] = transdate transDict['ordertype'] = ordertype transDict['orderamount'] = orderamount transDict['orderprice'] = orderprice return transDict