mirror of
https://gitee.com/fasiondog/hikyuu.git
synced 2024-12-01 19:38:20 +08:00
add df_to_ind 将 pandas.DataFrame 指定列转化为 Indicator
This commit is contained in:
parent
ec5c5c1dd8
commit
dba4586eea
@ -121,6 +121,22 @@ def concat_to_df(dates, ind_list, head_stock_code=True, head_ind_name=False):
|
||||
return df
|
||||
|
||||
|
||||
def df_to_ind(df, col_name, col_date=None):
|
||||
"""
|
||||
将 pandas.DataFrame 指定列转化为 Indicator
|
||||
|
||||
:param df: pandas.DataFrame
|
||||
:param col_name: 指定列名
|
||||
:param col_date: 指定日期列名 (为None时忽略, 否则该列为对应参考日期)
|
||||
:return: Indicator
|
||||
"""
|
||||
if col_date is not None:
|
||||
dates = df[col_date].to_list()
|
||||
dates = DatetimeList([Datetime(x) for x in dates])
|
||||
return PRICELIST(df[col_name].to_list(), align_dates=dates)
|
||||
return PRICELIST(df[col_name].to_list())
|
||||
|
||||
|
||||
# 避免 python 中公式原型必须加括号
|
||||
KDATA = C_KDATA()
|
||||
CLOSE = C_CLOSE()
|
||||
|
Loading…
Reference in New Issue
Block a user