diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d608cc0d..417cd231d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ - [QUANTAXIS 更新纪要](#quantaxis-更新纪要) - - [1.1.7 (unreleased)](#117-unreleased) + - [1.1.8(unreleased)](#118unreleased) + - [1.1.7](#117) - [1.1.6](#116) - [1.1.5](#115) - [1.1.4.dev1](#114dev1) @@ -63,11 +64,14 @@ - [1.0.25](#1025) -## 1.1.7 (unreleased) +## 1.1.8(unreleased) + +## 1.1.7 1. 优化 QA_DataStruct_future_day/min 2. 增加了QA_fetch_xxx_adv系列中的 QA_fetch_future_day_adv/QA_fetch_future_min_adv函数 - +3. 增加了QA_DataStruct的reindex方法, 方便从指标中提取部分行情 +4. 增加了商品期权的支持 to do: diff --git a/QUANTAXIS/QAData/base_datastruct.py b/QUANTAXIS/QAData/base_datastruct.py index 82dcb5ece..156998f98 100644 --- a/QUANTAXIS/QAData/base_datastruct.py +++ b/QUANTAXIS/QAData/base_datastruct.py @@ -731,6 +731,28 @@ def new(self, data=None, dtype=None, if_fq=None): def reverse(self): return self.new(self.data[::-1]) + def reindex(self, ind): + """reindex + + Arguments: + ind {[type]} -- [description] + + Raises: + RuntimeError -- [description] + RuntimeError -- [description] + + Returns: + [type] -- [description] + """ + + if isinstance(ind,pd.MultiIndex): + try: + return self.new(self.data.reindex(ind)) + except: + raise RuntimeError('QADATASTRUCT ERROR: CANNOT REINDEX') + else: + raise RuntimeError('QADATASTRUCT ERROR: ONLY ACCEPT MULTI-INDEX FORMAT') + def tail(self, lens): """返回最后Lens个值的DataStruct diff --git a/QUANTAXIS/QAEngine/QAAsyncioEngine.py b/QUANTAXIS/QAEngine/QAAsyncioEngine.py index d9f5626af..d5ecaf962 100644 --- a/QUANTAXIS/QAEngine/QAAsyncioEngine.py +++ b/QUANTAXIS/QAEngine/QAAsyncioEngine.py @@ -15,22 +15,25 @@ """ - class QAAsync(): def __init__(self): - self.event_loop = asyncio.get_event_loop() + self.event_loop = asyncio.new_event_loop() self.elthread = threading.Thread(target=self.event_loop.run_forever) # self.elthread.setDaemon(True) self.elthread.start() - def submit(self, func, callback, *args, **kwargs): - - # self.job=asyncio.run_coroutine_threadsafe(func(*args,**kwargs),self.event_loop) + def create_task(self, func, callback, *args, **kwargs): + # schedule a task + #task = self.event_loop.create_task(func(*args,**kwargs)) task = asyncio.ensure_future(func(*args, **kwargs)) task.add_done_callback(callback) - #print('get job async {}'.format(args)) + return task + + + def submit(self, coro): + return asyncio.run_coroutine_threadsafe(coro, self.event_loop) def callback(future): diff --git a/QUANTAXIS/__init__.py b/QUANTAXIS/__init__.py index f55c05981..a78bfd596 100755 --- a/QUANTAXIS/__init__.py +++ b/QUANTAXIS/__init__.py @@ -32,7 +32,7 @@ 2017/4/8 """ -__version__ = '1.1.7.dev3' +__version__ = '1.1.7' __author__ = 'yutiansut' logo = ' \n \ ```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n \