From 990481304869632cb8d7fc6b9d59d84bf71a02a8 Mon Sep 17 00:00:00 2001 From: yutiansut Date: Tue, 17 Jul 2018 03:17:15 +0800 Subject: [PATCH 1/4] # --- QUANTAXIS/QAData/data_fq.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/QUANTAXIS/QAData/data_fq.py b/QUANTAXIS/QAData/data_fq.py index c2ecf9130..73d733a22 100755 --- a/QUANTAXIS/QAData/data_fq.py +++ b/QUANTAXIS/QAData/data_fq.py @@ -50,19 +50,18 @@ def QA_data_get_hfq(code, start, end): def QA_data_make_qfq(bfq_data, xdxr_data): '使用数据库数据进行复权' - info = xdxr_data[xdxr_data['category'] == 1] + info = xdxr_data.query('category==1') bfq_data = bfq_data.assign(if_trade=1) if len(info) > 0: - data = pd.concat([bfq_data, info[['category']] - [bfq_data.index[0]:bfq_data.index[-1]]], axis=1) + data = pd.concat([bfq_data, info.loc[bfq_data.index[0]:bfq_data.index[-1],['category']]], axis=1) data['if_trade'].fillna(value=0, inplace=True) data = data.fillna(method='ffill') - data = pd.concat([data, info[['fenhong', 'peigu', 'peigujia', - 'songzhuangu']][bfq_data.index[0]:bfq_data.index[-1]]], axis=1) + data = pd.concat([data, info.loc[bfq_data.index[0]:bfq_data.index[-1],['fenhong', 'peigu', 'peigujia', + 'songzhuangu']]], axis=1) else: - data = pd.concat([bfq_data, info[['category', 'fenhong', 'peigu', 'peigujia', + data = pd.concat([bfq_data, info.loc[:,['category', 'fenhong', 'peigu', 'peigujia', 'songzhuangu']]], axis=1) data = data.fillna(0) data['preclose'] = (data['close'].shift(1) * 10 - data['fenhong'] + data['peigu'] @@ -136,10 +135,12 @@ def __QA_fetch_stock_xdxr(code, format_='pd', collections=DATABASE.stock_xdxr): 'fenshu', 'liquidity_after', 'liquidity_before', 'name', 'peigu', 'peigujia', 'shares_after', 'shares_before', 'songzhuangu', 'suogu', 'xingquanjia']) '股票 日线/分钟线 动态复权接口' + + code = __data.index.levels[1][0] if isinstance(__data.index, pd.core.indexes.multi.MultiIndex) else __data['code'][0] if type_ in ['01', 'qfq']: - return QA_data_make_qfq(__data, __QA_fetch_stock_xdxr(__data['code'][0])) + return QA_data_make_qfq(__data, __QA_fetch_stock_xdxr(code)) elif type_ in ['02', 'hfq']: - return QA_data_make_hfq(__data, __QA_fetch_stock_xdxr(__data['code'][0])) + return QA_data_make_hfq(__data, __QA_fetch_stock_xdxr(code)) else: QA_util_log_info('wrong fq type! Using qfq') - return QA_data_make_qfq(__data, __QA_fetch_stock_xdxr(__data['code'][0])) + return QA_data_make_qfq(__data, __QA_fetch_stock_xdxr(code)) From 1ba388999d55c90046bd1fc38213f25f54baea4e Mon Sep 17 00:00:00 2001 From: yutiansut Date: Tue, 17 Jul 2018 03:27:46 +0800 Subject: [PATCH 2/4] # --- QUANTAXIS/QAData/data_fq.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/QUANTAXIS/QAData/data_fq.py b/QUANTAXIS/QAData/data_fq.py index 73d733a22..b254602e7 100755 --- a/QUANTAXIS/QAData/data_fq.py +++ b/QUANTAXIS/QAData/data_fq.py @@ -86,20 +86,19 @@ def QA_data_make_qfq(bfq_data, xdxr_data): def QA_data_make_hfq(bfq_data, xdxr_data): '使用数据库数据进行复权' - info = xdxr_data[xdxr_data['category'] == 1] + info = xdxr_data.query('category==1') bfq_data = bfq_data.assign(if_trade=1) if len(info) > 0: - data = pd.concat([bfq_data, info[['category']] - [bfq_data.index[0]:bfq_data.index[-1]]], axis=1) + data = pd.concat([bfq_data, info.loc[bfq_data.index[0]:bfq_data.index[-1],['category']]], axis=1) data['if_trade'].fillna(value=0, inplace=True) data = data.fillna(method='ffill') - data = pd.concat([data, info[['fenhong', 'peigu', 'peigujia', - 'songzhuangu']][bfq_data.index[0]:bfq_data.index[-1]]], axis=1) + data = pd.concat([data, info.loc[bfq_data.index[0]:bfq_data.index[-1],['fenhong', 'peigu', 'peigujia', + 'songzhuangu']]], axis=1) else: - data = pd.concat([bfq_data, info[['category', 'fenhong', 'peigu', 'peigujia', + data = pd.concat([bfq_data, info.loc[:,['category', 'fenhong', 'peigu', 'peigujia', 'songzhuangu']]], axis=1) data = data.fillna(0) data['preclose'] = (data['close'].shift(1) * 10 - data['fenhong'] + data['peigu'] From d8be4c5ec27b2e5572380df66a686e464b02f8d1 Mon Sep 17 00:00:00 2001 From: yutiansut Date: Tue, 17 Jul 2018 03:28:50 +0800 Subject: [PATCH 3/4] #update fq --- QUANTAXIS/QAData/data_fq.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/QUANTAXIS/QAData/data_fq.py b/QUANTAXIS/QAData/data_fq.py index b254602e7..c3aaf8a96 100755 --- a/QUANTAXIS/QAData/data_fq.py +++ b/QUANTAXIS/QAData/data_fq.py @@ -29,7 +29,7 @@ import pandas as pd from QUANTAXIS.QAFetch import QA_fetch_get_stock_day, QA_fetch_get_stock_xdxr -from QUANTAXIS.QAUtil import QA_util_log_info, DATABASE +from QUANTAXIS.QAUtil import DATABASE, QA_util_log_info def QA_data_get_qfq(code, start, end): @@ -37,7 +37,7 @@ def QA_data_get_qfq(code, start, end): xdxr_data = QA_fetch_get_stock_xdxr('tdx', code) bfq_data = QA_fetch_get_stock_day( 'tdx', code, '1990-01-01', str(datetime.date.today())).dropna(axis=0) - return QA_data_make_qfq(bfq_data[start:end], xdxr_data) + return QA_data_make_qfq(bfq_data.loc[start:end], xdxr_data) def QA_data_get_hfq(code, start, end): @@ -45,7 +45,7 @@ def QA_data_get_hfq(code, start, end): xdxr_data = QA_fetch_get_stock_xdxr('tdx', code) bfq_data = QA_fetch_get_stock_day( 'tdx', code, '1990-01-01', str(datetime.date.today())).dropna(axis=0) - return QA_data_make_hfq(bfq_data[start:end], xdxr_data) + return QA_data_make_hfq(bfq_data.loc[start:end], xdxr_data) def QA_data_make_qfq(bfq_data, xdxr_data): @@ -55,14 +55,15 @@ def QA_data_make_qfq(bfq_data, xdxr_data): if len(info) > 0: - data = pd.concat([bfq_data, info.loc[bfq_data.index[0]:bfq_data.index[-1],['category']]], axis=1) + data = pd.concat([bfq_data, info.loc[bfq_data.index[0] + :bfq_data.index[-1], ['category']]], axis=1) data['if_trade'].fillna(value=0, inplace=True) data = data.fillna(method='ffill') - data = pd.concat([data, info.loc[bfq_data.index[0]:bfq_data.index[-1],['fenhong', 'peigu', 'peigujia', - 'songzhuangu']]], axis=1) + data = pd.concat([data, info.loc[bfq_data.index[0]:bfq_data.index[-1], ['fenhong', 'peigu', 'peigujia', + 'songzhuangu']]], axis=1) else: - data = pd.concat([bfq_data, info.loc[:,['category', 'fenhong', 'peigu', 'peigujia', - 'songzhuangu']]], axis=1) + data = pd.concat([bfq_data, info.loc[:, ['category', 'fenhong', 'peigu', 'peigujia', + 'songzhuangu']]], axis=1) data = data.fillna(0) data['preclose'] = (data['close'].shift(1) * 10 - data['fenhong'] + data['peigu'] * data['peigujia']) / (10 + data['peigu'] + data['songzhuangu']) @@ -90,16 +91,17 @@ def QA_data_make_hfq(bfq_data, xdxr_data): bfq_data = bfq_data.assign(if_trade=1) if len(info) > 0: - data = pd.concat([bfq_data, info.loc[bfq_data.index[0]:bfq_data.index[-1],['category']]], axis=1) + data = pd.concat([bfq_data, info.loc[bfq_data.index[0] + :bfq_data.index[-1], ['category']]], axis=1) data['if_trade'].fillna(value=0, inplace=True) data = data.fillna(method='ffill') - data = pd.concat([data, info.loc[bfq_data.index[0]:bfq_data.index[-1],['fenhong', 'peigu', 'peigujia', - 'songzhuangu']]], axis=1) + data = pd.concat([data, info.loc[bfq_data.index[0]:bfq_data.index[-1], ['fenhong', 'peigu', 'peigujia', + 'songzhuangu']]], axis=1) else: - data = pd.concat([bfq_data, info.loc[:,['category', 'fenhong', 'peigu', 'peigujia', - 'songzhuangu']]], axis=1) + data = pd.concat([bfq_data, info.loc[:, ['category', 'fenhong', 'peigu', 'peigujia', + 'songzhuangu']]], axis=1) data = data.fillna(0) data['preclose'] = (data['close'].shift(1) * 10 - data['fenhong'] + data['peigu'] * data['peigujia']) / (10 + data['peigu'] + data['songzhuangu']) @@ -135,7 +137,8 @@ def __QA_fetch_stock_xdxr(code, format_='pd', collections=DATABASE.stock_xdxr): 'shares_after', 'shares_before', 'songzhuangu', 'suogu', 'xingquanjia']) '股票 日线/分钟线 动态复权接口' - code = __data.index.levels[1][0] if isinstance(__data.index, pd.core.indexes.multi.MultiIndex) else __data['code'][0] + code = __data.index.levels[1][0] if isinstance( + __data.index, pd.core.indexes.multi.MultiIndex) else __data['code'][0] if type_ in ['01', 'qfq']: return QA_data_make_qfq(__data, __QA_fetch_stock_xdxr(code)) elif type_ in ['02', 'hfq']: From 3404c504f234fa7089989128c722acd6b02a8166 Mon Sep 17 00:00:00 2001 From: yutiansut Date: Tue, 17 Jul 2018 03:30:37 +0800 Subject: [PATCH 4/4] #update to 1.0.67 --- CHANGELOG.md | 8 ++++++-- QUANTAXIS/__init__.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2553ad950..714b3ff7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ - [QUANTAXIS 更新纪要](#quantaxis-更新纪要) - - [1.0.66 (unreleased)](#1066-unreleased) + - [1.0.67 (unreleased)](#1067-unreleased) + - [1.0.66](#1066) - [1.0.65](#1065) - [1.0.64](#1064) - [1.0.63](#1063) @@ -47,7 +48,9 @@ - [1.0.25](#1025) -## 1.0.66 (unreleased) +## 1.0.67 (unreleased) + +## 1.0.66 1. 修改series_struct 适配单个index的情景 2. 增加马科维茨有效前沿的研究/ 增加盘中涨停分析的研究 (research/) @@ -62,6 +65,7 @@ QA.concat([QA.QA_DataStruct_Stock_min(QA.QA_DataStruct_Stock_realtime(QA.QA_fetc 5. @逝去的亮光 增加了LINUX环境下的CTP撤单接口 6. 增加了日线数据的降采样 QA.QA_data_day_resample(data,'w') +released in : JULY 17, 2018 ## 1.0.65 diff --git a/QUANTAXIS/__init__.py b/QUANTAXIS/__init__.py index 12d4673c1..f17168232 100755 --- a/QUANTAXIS/__init__.py +++ b/QUANTAXIS/__init__.py @@ -32,7 +32,7 @@ 2017/4/8 """ -__version__ = '1.0.66' +__version__ = '1.0.67' __author__ = 'yutiansut' logo = ' \n \ ```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n \