"""沿用首轮已验证的绝对收益和交易时序。""" import numpy as np def outcome(a,i,j,hold=60): t=len(a['dates']);entry=i+1;due=entry+hold r={'entry_index':entry,'due_index':due,'calendar_matured':bool(due=t:return r r['entry_date']=str(a['dates'][entry]) if not a['can_buy'][entry,j]:return r r['entry_filled']=True;price=a['open'][entry,j] if due>=t:return r path=a['close'][entry:due,j]/price-1 r['path_complete']=bool(np.isfinite(path).all()) if r['path_complete']: hi=np.flatnonzero(path>=.15);lo=np.flatnonzero(path<=-.10) r.update(hit15=float(len(hi)>0),up_before_down=float(len(hi)>0 and (not len(lo) or hi[0]