def run_daily_report(trade_date): d_stocks = datafile.load_stocks_rawdata(trade_date) volumes = [v.volume for v in d_stocks.values()] closes = [v.volume * v.close for v in d_stocks.values()] opens = [v.volume * v.open for v in d_stocks.values()] up_count = len([v for v in d_stocks.values() if v.close > v.open]) volume_avg = reduce(lambda x, y: x + y, volumes) / len(volumes) close_avg = reduce(lambda x, y: x + y, closes) / len(closes) / volume_avg open_avg = reduce(lambda x, y: x + y, opens) / len(opens) / volume_avg print trade_date, close_avg, volume_avg, float(up_count) / len( volumes), open_avg return web.storage(trade_date=trade_date, close=close_avg, volume=volume_avg, up_percent=float(up_count) / len(volumes), open=open_avg)
def run_daily_report(trade_date): d_stocks = datafile.load_stocks_rawdata(trade_date) volumes = [v.volume for v in d_stocks.values()] closes = [v.volume*v.close for v in d_stocks.values()] opens = [v.volume*v.open for v in d_stocks.values()] up_count = len([v for v in d_stocks.values() if v.close>v.open]) volume_avg = reduce(lambda x, y: x + y, volumes) / len(volumes) close_avg = reduce(lambda x, y: x + y, closes) / len(closes) / volume_avg open_avg = reduce(lambda x, y: x + y, opens) / len(opens) / volume_avg print trade_date,close_avg,volume_avg,float(up_count)/len(volumes),open_avg return web.storage(trade_date=trade_date,close=close_avg,volume=volume_avg,up_percent=float(up_count)/len(volumes),open=open_avg)
def run_draw_1(trade_date): stocks = datafile.load_stocks_rawdata(trade_date) local_dir = "%s/GaussianDistri/" % (const_root_local) filenames = os.listdir(local_dir) l=[] for f in filenames: print f f_segs = f.split('.') stock_no = '.'.join(f_segs[0:2]) try: close = 0 if f_segs[0] in stocks: close = stocks[ f_segs[0] ].close current_position = draw_1(stock_no,close) l.append((stock_no,current_position)) except Exception,e: print stock_no,e
def run_draw_1(trade_date): stocks = datafile.load_stocks_rawdata(trade_date) local_dir = "%s/GaussianDistri/" % (const_root_local) filenames = os.listdir(local_dir) l = [] for f in filenames: print f f_segs = f.split('.') stock_no = '.'.join(f_segs[0:2]) try: close = 0 if f_segs[0] in stocks: close = stocks[f_segs[0]].close current_position = draw_1(stock_no, close) l.append((stock_no, current_position)) except Exception, e: print stock_no, e