def main(args): lsym = getattr(yeod, "get_%s" % args.setname)() if args.start is None: args.start = base.last_trade_date() args.end = args.start cls = joblib.load(os.path.join(base.dir_model(), args.model)) ta = base.get_merged_with_na(args.taname, lsym) ta = ta[(ta['date'] >= args.start) & (ta['date'] <= args.end)] dfFeat = ta.loc[:, base.get_feat_names(ta)] dfFeat = dfFeat.replace([np.inf,-np.inf],np.nan)\ .dropna() npFeat = dfFeat.values npPred = cls.predict_proba(npFeat) #for i, npPred in enumerate(cls.staged_predict_proba(npFeat)): # if i == args.stage: # break ta["pred"] = npPred[:, 1] ta.sort("pred", inplace=True, ascending=False) freport, fcsv = base.file_pred(args) ta.to_csv(fcsv) #ta[["date", "sym", "pred", label]].to_csv(os.path.join(out_dir, 'pred.s.csv')) with open(freport, 'w') as fout: print >> fout, ta[["date", "sym", "pred"]].head(10)
def main(argv): yeod.main(["sp500", 5]) build.main(["sp500", 'call1s1', 5]) last_date = base.last_trade_date() pred.main([ 'call1s1_sp500_GBCv1n322md3lr001_l5_s1700e2009', 'call1s1_sp500', last_date, last_date, 'label5' ])
def main(argv): #shutil.rmtree(os.path.join(root, "data", "yeod_batch", "%s-%d" % (eod, batch)), ignore_errors=False) yeod.main(["index_dow", 1]) yeod_b.main([eod, batch, 10]) build_b.main([eod, batch ,ta,10]) paper_b.main([model, 600, "%s-%s" % (ta,eod), batch, "2010-06-01", "2016-06-31", 2, 400]) last_date = base.last_trade_date() pred_b.main([model, 600, "%s-%s-%d" % (ta, eod, batch), last_date, last_date, "label5"])
def transfer(): df_pred = pd.read_pickle(os.path.join(root, "data", "cross", "pred%s.pkl" % base.last_trade_date())) df_pred = df_pred[df_pred.date >= "2010-01-01"] index = df_pred[df_pred.sym == "MSFT"]["date"].unique(); index.sort() index = pd.to_datetime(index) columns = df_pred["sym"].unique(); columns.sort() df_price = pd.DataFrame(index = index, columns = columns) df_thred = pd.DataFrame(index = index, columns = columns) for i, each in df_pred.iterrows(): if each["date"] not in df_price.index: continue df_price.set_value(each["date"], each["sym"], each["close"]) df_thred.set_value(each["date"], each["sym"], each["pred"]) # assert assert_cotinue(df_price) assert_cotinue(df_thred) return (df_price, df_thred)