# Market Estimate rawtrends = [ ["AA", -0.0127], ["AIG", 0.3046], ["AXP", 0.4952], ["BA", -0.3350], ["BAC", -0.2248], ["C", -0.4191], ["CAT", -0.3882], ["CVX", 0.1725], ["DD", 0.3213], ["DIS", 0.4269], ["GE", -0.4636], ["GM", 0.0186], ["HD", -0.4796], ["HPQ", -0.2585], ["IBM", 0.2315], ["INTC", -0.3587], ["JNJ", 0.0023], ["JPM", 0.1956], ["KO", -0.0152], ["MCD", -0.2444], ["MMM", -0.4833], ["MRK", 0.3685], ["MSFT", 0.3402], ["PFE", -0.1503], ["PG", -0.4201], ["T", 0.1011], ["UTX", -0.1350], ["VZ", -0.3281], ["WMT", 0.1554], ["XOM", 0.3617] ] class MarketEstimate: def __init__(self, f): # recommended adjustable multiplicative factor self.factor = 1.0 * f self.trends = {} for p in rawtrends: self.trends[ p[0] ] = self.factor * p[1] def show_market(self, f): f.write( "Market Estimate\n------------------\n") symb = self.trends.keys() symb.sort() for c in symb: f.write( "%5s = %f6.4\n" % ( c, self.trends[c]) ) f.write( "\nEstimate is percent change per month for each stock\n\n") if __name__ == '__main__': o = MarketEstimate(1.0) f = open("market_estimate.txt", "w") o.show_market(f) f.close() print "wrote market_estimate.txt"