Ejemplo n.º 1
0
	def symbols_btw(self,startdate=None,enddate=None):
		if(startdate is None):
			startdate = str_to_dt('1970-01-01')
		if(enddate is None):
			enddate = datetime.datetime.now().date()
		# --
		uni = self.__membership
		uni = uni[inrange(uni.index,ge=startdate,le=enddate)]
		return uni.columns.to_numpy()
Ejemplo n.º 2
0
 def trade_dates_btw_(self, startdate=None, enddate=None):
     if (startdate is None):
         # startdate = __0_date_str__('1970-01-01')
         startdate = str_to_dt('1970-01-01')
     if (enddate is None):
         enddate = datetime.datetime.now().date()
     # --
     uni = self.__universe
     # uni = uni[__inrange__(uni.index,ge=startdate,le=enddate)]
     uni = uni[inrange(uni.index, ge=startdate, le=enddate)]
     return list(uni.index)
Ejemplo n.º 3
0
 def __load(self, *, symbol, loader_fn=None, date_range=None, **kv):
     bm_hist = ngu.load_ng_historical(symbol)
     bm_hist = pd.Series(data=bm_hist.index)
     if (date_range is not None):
         bm_hist = bm_hist[inrange(bm_hist,
                                   ge=date_range[0],
                                   lt=date_range[1])]
     if (loader_fn is None):
         self._d0 = self.__def_load_fn(bm_hist, **kv)
     elif (type(loader_fn) == "function"):
         self._d0 = loader_fn(bm_hist, **kv)
     elif (loader_fn == "ALGO_1"):
         self._d0 = self.__def_load_fn(bm_hist, **kv)
     elif (loader_fn == "ALGO_2"):
         self._d0 = bm_hist
     else:
         raise RuntimeError("unknown loader_fn:{}".format(loader_fn))
Ejemplo n.º 4
0
	def __load_d0(self,pp_opt):
		symbols = self.__membership.columns.to_numpy()
		df = ngu.load_history_for_symbols(symbols,pp_opt,startdate=self.__startdate,enddate=self.__enddate)
		df = df[inrange(df.index,ge=self.__startdate,le=self.__enddate)]
		return df
Ejemplo n.º 5
0
	def __load_membership(self):
		df = ngu.load_index_membership(self.__indexname)
		df = df[inrange(df.index,ge=self.__startdate,le=self.__enddate)]
		membership = df.dropna(axis=1,how='all')
		nominal_size = ngu.member_count_for(self.__indexname)
		return (membership,nominal_size)
Ejemplo n.º 6
0
 def __load_d0(self, pp_opt):
     df = ngu.load_history_for_symbols(self.__symbols, pp_opt)
     df = df[inrange(df.index, ge=self.__startdate, le=self.__enddate)]
     return df