Skip to content

Commit

Permalink
Merge pull request #834 from yutiansut/master
Browse files Browse the repository at this point in the history
update asyncio
  • Loading branch information
yutiansut authored Oct 4, 2018
2 parents fc19649 + 1657aa5 commit 5fe9208
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
<!-- TOC -->

- [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)
Expand Down Expand Up @@ -63,11 +64,14 @@
- [1.0.25](#1025)

<!-- /TOC -->
## 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:

Expand Down
22 changes: 22 additions & 0 deletions QUANTAXIS/QAData/base_datastruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions QUANTAXIS/QAEngine/QAAsyncioEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion QUANTAXIS/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
2017/4/8
"""

__version__ = '1.1.7.dev3'
__version__ = '1.1.7'
__author__ = 'yutiansut'
logo = ' \n \
```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````` \n \
Expand Down

0 comments on commit 5fe9208

Please sign in to comment.