def init_tick_key_list_for_retrospection(self, retrospective_ticks: int): offset_time_stamp = MyDate.get_offset_timestamp(days=-retrospective_ticks) self._tick_key_list_for_retrospection = [] while offset_time_stamp < MyDate.time_stamp_now(): offset_time_stamp += self._seconds_unit date_str = str(MyDate.get_date_from_epoch_seconds(offset_time_stamp)) self._tick_key_list_for_retrospection.append(date_str)
def get_grouped_by_for_wave_peak_plotting(self, wave_peak_date_type: str, aggregation=1, offset_date=''): if wave_peak_date_type in [WPDT.DAILY_DATE, WPDT.INTRADAY_DATE]: where_clause = "{}='{}'".format( DC.PERIOD, PRD.DAILY if wave_peak_date_type == WPDT.DAILY_DATE else PRD.INTRADAY) columns = [ DC.EQUITY_INDEX, DC.PERIOD, DC.PERIOD_AGGREGATION, DC.WAVE_TYPE, DC.WAVE_END_DATE, DC.TICKER_ID ] if offset_date != '': where_clause += " AND {}>'{}'".format(DC.WAVE_END_DATE, offset_date) else: # here we take only the intraday waves with the proper aggregation columns = [ DC.EQUITY_INDEX, DC.PERIOD, DC.PERIOD_AGGREGATION, DC.WAVE_TYPE, DC.WAVE_END_TS, DC.WAVE_END_DT, DC.TICKER_ID ] offset_ts = MyDate.get_offset_timestamp(days=-10) where_clause = "{}='{}' AND {}>{} AND {}={}".format( DC.PERIOD, PRD.INTRADAY, DC.WAVE_END_TS, offset_ts, DC.PERIOD_AGGREGATION, aggregation) df = self.get_all_as_data_frame(columns=columns, where_clause=where_clause) if df.empty: return df df = df.groupby(columns[:-1]).count() return df.reset_index(drop=False)