Skip to content

Commit

Permalink
#update tb/快期的采样方式
Browse files Browse the repository at this point in the history
  • Loading branch information
yutiansut committed Aug 13, 2019
1 parent 3fbe29f commit d1ee105
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions QUANTAXIS/QAData/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
QA_data_ctptick_resample, QA_data_day_resample,
QA_data_futuremin_resample_series,
QA_data_futuremin_resample, QA_data_tick_resample,
QA_data_futuremin_resample_tb_kq,
QA_data_tick_resample_1min)
from QUANTAXIS.QAData.dsmethods import (QDS_IndexDayWarpper,
QDS_IndexMinWarpper,
Expand Down
27 changes: 27 additions & 0 deletions QUANTAXIS/QAData/data_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,33 @@ def QA_data_futuremin_resample(min_data, type_='5min', exchange_id=EXCHANGE_ID.S
return pd.concat([part_1_res, part_2_res, part_3_res]).dropna().sort_index().reset_index().set_index(['datetime', 'code'])


def QA_data_futuremin_resample_tb_kq(min_data, type_='5min', exchange_id=EXCHANGE_ID.SHFE):
"""期货分钟线采样成大周期
此采样方法仅适用于tb/快期, 因此单独拿出来
分钟线采样成子级别的分钟线
"""
CONVERSION = {
'code': 'first',
'open': 'first',
'high': 'max',
'low': 'min',
'close': 'last',
'tradetime': 'last',
'position': 'last',
'volume': 'sum'}
min_data = min_data.loc[:, list(CONVERSION.keys())]
return min_data.resample(
type_,
base=0,
closed='right',
loffset=type_
).agg(CONVERSION).dropna().sort_index().reset_index().set_index(['datetime', 'code'])


def QA_data_futuremin_resample_today(min_data, type_='1D', exchange_id=EXCHANGE_ID.SHFE):
"""期货分钟线采样成大周期
Expand Down
1 change: 1 addition & 0 deletions QUANTAXIS/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
QA_data_tick_resample_1min,
QA_data_futuremin_resample_series,
QA_data_futuremin_resample,
QA_data_futuremin_resample_tb_kq,
QA_DataStruct_Day,
QA_DataStruct_Financial,
QA_DataStruct_Future_day,
Expand Down

0 comments on commit d1ee105

Please sign in to comment.