def opt(products): time_start = time.time() recs = [] model = MACD() for product in products: logger.info('Start analysis of %s', product.code) model.product = product recs += opt_single(model) time_end = time.time() recs = fromrecords(recs, names=['code', 'nfast', 'nslow', 'nmacd', 'revenue']) rec2csv(recs, join(CONFIG['out_p'], 'opt.csv')) pst = time_end - time_start logger.info(('Total %s para combinations computed, ' 'roughly %.3f seconds, %.3f ms per calc.'), len(recs), pst, pst / len(recs) * 1000) return recs
Test the moving average algo ''' import pandas as pd from strategies.macd import MACD __author__ = 'kongs' if __name__ == '__main__': ts=list(range(100)) + list(range(100,0,-1)) ts=ts*2 index=pd.date_range('2001-01-01', periods=len(ts)) ts=pd.Series(ts, index=index) ts.name='Close' product=pd.DataFrame(ts) product.code='TProduct' macd=MACD() macd.product=product macd.analyze() macd.summary()