<commit_before># !/usr/bin/env python
#title           :Time Series Wave Analyzer
#description     :Figures out the points of inflection in time series
#author          :<NAME>
#date            :20151224
#version         :0.1
#notes           :
#python_version  :2.7.3
#==============================================================================

import json
import sys
import os
import csv
import urllib2
import datetime
from random import randint
from stktrkr.Stock import Stock
from stktrkr.DataPoint import DataPoint

class StockTracker:
	def __init__(self, verbose=False):
		# Initialize the various SP lists
		self.initSP500()
		self.stockDict = []
		self.verbose = verbose
	
	def readFile(self, filename):
		if self.verbose:
			print 'Opening file',filename
			
		file = open(filename, 'r')
		stringValue = ''
		length = 0
		for line in file:
			stringValue = stringValue + line.rstrip() + ' '
			length += 1
		
		if self.verbose:
			print 'Read',length,'lines from file...'
		return stringValue.rstrip()
	
	
	def process(self, jsonString):
		jsonDict = json.loads(jsonString)
		stocks = jsonDict['stocks']
		sellDate = jsonDict['sell_date']
		
		for stock in stocks:
			name = stock['ticker'].upper()
			buyDate = stock['buy_date']
			if name == 'SP500-RANDOM':
				name = self.getRandomSP500()		

			# Printing verbose output stock name		
			if self.verbose:
				print 'Processing',name		
		
			buyLimit = stock['buy_limit']

			try:<commit_msg>Updating Stock Tracker<commit_after># !/usr/bin/env python
#title           :Time Series Wave Analyzer
#description     :Figures out the points of inflection in time series
#author          :<NAME>
#date            :20151224
#version         :0.1
#notes           :
#python_version  :2.7.3
#==============================================================================

import json
import sys
import os
import csv
import urllib2
import datetime
import re
from random import randint
from stktrkr.Stock import Stock
from stktrkr.DataPoint import DataPoint

class StockTracker:
	def __init__(self, verbose=False):
		# Initialize the various SP lists
		self.initSP500()
		self.stockDict = []
		self.verbose = verbose
	
	def readFile(self, filename):
		""" Read in the input JSON string specifying the funds and 
			stocks which are to be purchased. The function removes
			any comments an returns a list of strings, each element
			being a JSON object. 
		"""
		if self.verbose:
			print 'Opening file',filename
			
		file = open(filename, 'r')
		jsonStringList = []
		
		num = 0
		for line in file:
			if not re.match('^--', line):
				jsonStringList.append(line.rstrip())
				numJSON += 1
		
		if self.verbose:
			print 'Read',num,'JSON entities from file...'
		return jsonStringList
	
	
	def process(self, jsonStringList):
		""" This function takes as input the list of json
			strings, processing each in turn (as well as 
			doing some basic validation on each).
		"""		
		for jsonString in jsonStringList:
			try:
				jsonDict = json.loads(jsonString)
				if self.validateJSON(jsonDict):
				
				else:
					print 'ERROR in JSON...'
					print jsonString
			except ValueError:
				print 'Error decoding JSON...'
				print jsonString
	
	
	
		jsonDict = json.loads(jsonString)
		stocks = jsonDict['stocks']
		sellDate = jsonDict['sell_date']
		
		for stock in stocks:
			name = stock['ticker'].upper()
			buyDate = stock['buy_date']
			if name == 'SP500-RANDOM':
				name = self.getRandomSP500()		

			# Printing verbose output stock name		
			if self.verbose:
				print 'Processing',name		
		
			buyLimit = stock['buy_limit']

			try:
{'fraction_non_alphanumeric': 0.13637628722516004, 'fraction_numerical': 0.013915947676036738, 'mean_word_length': 3.213364595545135, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2324578', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1049, 'n_words': 346}