@ST kong 获取历史买一卖一,只对银行这种低价股有效,根据前一分钟数据进行推断,代码如下:
```
#data 是按分钟回测handledata里的数据
def get_s1(data,code):
_h=data[code].high
_l=data[code].low
_c=data[code].close
#如果前一分钟最高最低价相等,则取前5分钟的
if _h==_l:
array = get_bars(code, 5, unit='1m',fields=['high','close','low'],include_now=False)
for _a in array[::-1]:
if _a['high']<>_a['low']: #这里是不等于,贴代码被自动转义了
_h=_a['high']
_l=_a['low']
break
#如果最高最低价还是相等,返回前1分钟收盘价+0.01
if _h==_l:
return _c+0.01
#如果最high等于close,则close即是s1,否则close+0.01是s1
if _h==_c:
return _c
else:
return _c+0.01
def get_b1(data,code):
_h=data[code].high
_l=data[code].low
_c=data[code].close
if _h==_l:
array = get_bars(code, 5, unit='1m',fields=['high','close','low'],include_now=False)
for _a in array[::-1]:
if _a['high']<>_a['low']: #这里是不等于,贴代码被自动转义了
_h=_a['high']
_l=_a['low']
break
if _h==_l:
return _c-0.01
if _l==_c:
return _c
else:
return _c-0.01
```
2018-02-23