Module: playerD/market_estimate.py

# Market Estimate

rawtrends = [ 
 ["AA", -0.1757],
 ["AIG", -0.1746],
 ["AXP", 0.0978],
 ["BA", 0.2692],
 ["BAC", 0.1951],
 ["C", 0.2450],
 ["CAT", 0.1689],
 ["CVX", 0.1031],
 ["DD", -0.1359],
 ["DIS", -0.1932],
 ["GE", -0.2389],
 ["GM", 0.0917],
 ["HD", 0.2312],
 ["HPQ", 0.3827],
 ["IBM", 0.3587],
 ["INTC", -0.2342],
 ["JNJ", -0.4079],
 ["JPM", -0.3774],
 ["KO", 0.4464],
 ["MCD", -0.4480],
 ["MMM", -0.4999],
 ["MRK", -0.2301],
 ["MSFT", 0.3141],
 ["PFE", -0.3482],
 ["PG", 0.0372],
 ["T", -0.1180],
 ["UTX", -0.4928],
 ["VZ", 0.2563],
 ["WMT", -0.1052],
 ["XOM", 0.1689] ]


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"