jaqs.util package¶
Submodules¶
jaqs.util.dtutil module¶
-
combine_date_time
(date, time)¶
-
convert_datetime_to_int
(dt)¶
-
convert_int_to_datetime
(dt)¶ Convert int date (%Y%m%d) to datetime.datetime object.
-
date_to_month
(ser)¶
-
date_to_year
(ser)¶
-
get_next_period_day
(current, period, n=1, extra_offset=0)¶ Get the n’th day in next period from current day.
参数: - current (int) – Current date in format “%Y%m%d”.
- period (str) – Interval between current and next. {‘day’, ‘week’, ‘month’}
- n (int) – n times period.
- extra_offset (int) – n’th business day after next period.
返回: nxt
返回类型: int
-
shift
(date, n_weeks=0)¶ Shift date backward or forward for n weeks.
参数: - date (int or datetime) – The date to be shifted.
- n_weeks (int, optional) – Positive for increasing date, negative for decreasing date. Default 0 (no shift).
返回: res
返回类型: int or datetime
-
split_date_time
(dt)¶
jaqs.util.fileio module¶
-
create_dir
(filename)¶ Create dir if directory of filename does not exist.
参数: filename (str) –
-
fig2base64
(fig, format='png')¶ 参数: - fig (matplotlib.fig.Figure) –
- format (str) – Eg. png, jpg
-
join_relative_path
(*paths)¶ Get absolute path using paths that are relative to project root.
-
load_pickle
(fp)¶ Read Pickle file. Return None if file not found.
参数: fp (str) – Path of the Pickle file. 返回: 返回类型: object or None
-
read_json
(fp)¶ Read JSON file to dict. Return None if file not found.
参数: fp (str) – Path of the JSON file. 返回: 返回类型: dict
-
save_json
(serializable, file_name)¶ Save an serializable object to JSON file.
参数: - serializable (object) –
- file_name (str) –
-
save_pickle
(obj, file_name)¶ Save an object to Pickle file.
参数: - obj (object) –
- file_name (str) –
jaqs.util.numeric module¶
-
is_numeric
(array)¶ Determine whether the argument has a numeric datatype, when converted to a NumPy array.
Booleans, unsigned integers, signed integers, floats and complex numbers are the kinds of numeric datatype.
参数: array (array-like) – The array to check. 返回: is_numeric – True if the array has a numeric datatype, False if not. 返回类型: bool
-
quantilize_without_nan
(mat, n_quantiles=5, axis=-1)¶
jaqs.util.pdutil module¶
-
fillinf
(df)¶
-
group_df_to_dict
(df, by)¶
-
rank_with_mask
(df, axis=1, mask=None, normalize=False, method='min')¶ 参数: - df (pd.DataFrame) –
- axis ({0, 1}) –
- mask (pd.DataFrame) –
- normalize (bool) –
- method ({'min', 'average', 'max', 'dense'}) –
返回: 返回类型: pd.DataFrame
Notes
If calculate rank, use ‘min’ method by default; If normalize, result will range in [0.0, 1.0]
-
to_quantile
(df, n_quantiles=5, axis=1)¶ Convert cross-section values to the quantile number they belong. Small values get small quantile numbers.
参数: - df (pd.DataFrame or pd.Series) – index date, column symbols
- n_quantiles (int) – The number of quantile to be divided to.
- axis (int) – Axis to apply quantilize.
返回: res – index date, column symbols
返回类型: DataFrame
jaqs.util.profile module¶
-
prof_print
()¶
-
prof_sample
(name, func)¶
-
prof_sample_begin
(name)¶
-
prof_sample_end
(data)¶