def get_data_by_date_range(name, startMonth, startYear, endMonth, endYear): caseSensitiveName = DataManager.idToName[DataManager.nameToId[ name.lower()]] rtn = [] #iterate through month by month, year by year from the start to the #end and add any nonzero datapoints to the list of data currYear = startYear currMonth = startMonth while (currYear <= endYear): #if the current year is before the end year, then we just #iterate through all months if (currYear < endYear): while (currMonth <= 12): monthData = PriceReader.read_month_data( currMonth, currYear, caseSensitiveName) for day in range(1, len(monthData.data)): prices = monthData.get(day) #we only add nonzero prices becauase prices of 0 #means that there was no price data for that given date if (prices[0] != 0 and prices[1] != 0): rtn.append((currYear, currMonth, day, prices[0], prices[1])) currMonth = currMonth + 1 #have to reset the month back to 1 after we've gone through #all 12 months in the current year currMonth = 1 #if the current year is the end year, then we can only iterate #up to the end month elif (currYear == endYear): while (currMonth <= endMonth): monthData = PriceReader.read_month_data( currMonth, currYear, name) for day in range(1, len(monthData.data)): prices = monthData.get(day) if (prices[0] != 0 and prices[1] != 0): rtn.append((currYear, currMonth, day, prices[0], prices[1])) currMonth = currMonth + 1 #move on to the next year currYear = currYear + 1 return rtn
def get_data_by_date_range( name , startMonth , startYear , endMonth , endYear ): caseSensitiveName = DataManager.idToName[ DataManager.nameToId[ name.lower() ] ] rtn = [] #iterate through month by month, year by year from the start to the #end and add any nonzero datapoints to the list of data currYear = startYear currMonth = startMonth while( currYear <= endYear ): #if the current year is before the end year, then we just #iterate through all months if ( currYear < endYear ): while( currMonth <= 12 ): monthData = PriceReader.read_month_data( currMonth , currYear , caseSensitiveName ) for day in range( 1 , len( monthData.data ) ): prices = monthData.get( day ) #we only add nonzero prices becauase prices of 0 #means that there was no price data for that given date if ( prices[ 0 ] != 0 and prices[ 1 ] != 0 ): rtn.append( (currYear , currMonth , day , prices[ 0 ] , prices[ 1 ] ) ) currMonth = currMonth + 1 #have to reset the month back to 1 after we've gone through #all 12 months in the current year currMonth = 1 #if the current year is the end year, then we can only iterate #up to the end month elif ( currYear == endYear ): while( currMonth <= endMonth ): monthData = PriceReader.read_month_data( currMonth , currYear , name ) for day in range( 1 , len( monthData.data ) ): prices = monthData.get( day ) if ( prices[ 0 ] != 0 and prices[ 1 ] != 0 ): rtn.append( (currYear , currMonth , day , prices[ 0 ] , prices[ 1 ] ) ) currMonth = currMonth + 1 #move on to the next year currYear = currYear + 1 return rtn
def get_profitability_rankings( totalFunds , duration ): f = open( "price_data/item_ids" , 'r' ) rankings = [] for line in f.readlines(): commodityId = int(line.split( "," )[ 1 ]) data = PriceReader.get_price_data_from_csv( commodityId ) rankings.append( (data , ProfitabilityRanker.get_item_profitability( data , totalFunds , duration ) ) ) rankings.sort( key=lambda x: -1*x[1] ) return rankings
def get_profitability_rankings(totalFunds, duration): f = open("price_data/item_ids", 'r') rankings = [] for line in f.readlines(): commodityId = int(line.split(",")[1]) data = PriceReader.get_price_data_from_csv(commodityId) rankings.append((data, ProfitabilityRanker.get_item_profitability( data, totalFunds, duration))) rankings.sort(key=lambda x: -1 * x[1]) return rankings
def get_data_by_id(id): return PriceReader.get_price_data_from_csv(id)
def get_data_by_name(name): id = DataManager.nameToId[name.lower()] return PriceReader.get_price_data_from_csv(id)
def get_data_by_id( id ): return PriceReader.get_price_data_from_csv( id )
def get_data_by_name( name ): id = DataManager.nameToId[ name.lower() ] return PriceReader.get_price_data_from_csv( id )
def get_data_by_id( commodityId ): from price_data_io import PriceReader return PriceReader.get_price_data_from_csv( commodityId )
def get_data_by_id(commodityId): from price_data_io import PriceReader return PriceReader.get_price_data_from_csv(commodityId)