MCPcopy
hub / github.com/microsoft/qlib / format_datetime

Method format_datetime

scripts/data_collector/cn_index/collector.py:103–122  ·  view source on GitHub ↗

formatting the datetime in an instrument Parameters ---------- inst_df: pd.DataFrame inst_df.columns = [self.SYMBOL_FIELD_NAME, self.START_DATE_FIELD, self.END_DATE_FIELD] Returns -------

(self, inst_df: pd.DataFrame)

Source from the content-addressed store, hash-verified

101 raise NotImplementedError("rewrite html_table_index")
102
103 def format_datetime(self, inst_df: pd.DataFrame) -> pd.DataFrame:
104 """formatting the datetime in an instrument
105
106 Parameters
107 ----------
108 inst_df: pd.DataFrame
109 inst_df.columns = [self.SYMBOL_FIELD_NAME, self.START_DATE_FIELD, self.END_DATE_FIELD]
110
111 Returns
112 -------
113
114 """
115 if self.freq != "day":
116 inst_df[self.START_DATE_FIELD] = inst_df[self.START_DATE_FIELD].apply(
117 lambda x: (pd.Timestamp(x) + pd.Timedelta(hours=9, minutes=30)).strftime("%Y-%m-%d %H:%M:%S")
118 )
119 inst_df[self.END_DATE_FIELD] = inst_df[self.END_DATE_FIELD].apply(
120 lambda x: (pd.Timestamp(x) + pd.Timedelta(hours=15, minutes=0)).strftime("%Y-%m-%d %H:%M:%S")
121 )
122 return inst_df
123
124 def get_changes(self) -> pd.DataFrame:
125 """get companies changes

Callers

nothing calls this directly

Calls 1

applyMethod · 0.45

Tested by

no test coverage detected