Skip to content

Commit

Permalink
Merge pull request #718 from yutiansut/master
Browse files Browse the repository at this point in the history
#增加盘中涨停分析的研究
  • Loading branch information
yutiansut authored Jul 15, 2018
2 parents 205906b + 171d296 commit f20a58f
Show file tree
Hide file tree
Showing 4 changed files with 5,060 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<!-- /TOC -->
## 1.0.66 (unreleased)

1. 修改series_struct 适配单个index的情景
2. 增加马科维茨有效前沿的研究/ 增加盘中涨停分析的研究 (research/)

## 1.0.65

Expand Down
27 changes: 23 additions & 4 deletions QUANTAXIS/QAData/QASeriesStruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@
class QA_DataStruct_Series():
def __init__(self, series):
self.series = series.sort_index()
self.index = series.index.remove_unused_levels()

if isinstance(series.index, pd.core.indexes.multi.MultiIndex):
self.if_multiindex=True
self.index = series.index.remove_unused_levels()
else:
self.if_multiindex=False
self.index = series.index

def __repr__(self):
return '< QA_DATASTRUCT_SEIRES >'
Expand All @@ -40,15 +46,28 @@ def __call__(self):

@property
def code(self):
return self.index.levels[1].tolist()
if self.if_multiindex:
return self.index.levels[1].tolist()
else:
return None

@property
def datetime(self):
return self.index.levels[0].tolist()
if self.if_multiindex:
return self.index.levels[0].tolist()
elif (self.index,pd.core.indexes.datetimes.DatetimeIndex):
return self.index
else:
return None

@property
def date(self):
return np.unique(self.index.levels[0].date).tolist()
if self.if_multiindex:
return np.unique(self.index.levels[0].date).tolist()
elif (self.index,pd.core.indexes.datetimes.DatetimeIndex):
return np.unique(self.index.date).tolist()
else:
return None

def new(self, series):
temp = deepcopy(self)
Expand Down
Loading

0 comments on commit f20a58f

Please sign in to comment.